blob: 15adb01a924c2a859006ab5f5d9307f9fdd8234b [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>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055
Amar Singhal7c1e8982016-05-19 15:08:09 -070056#define MAX_PWR_FCC_CHAN_12 8
57#define MAX_PWR_FCC_CHAN_13 2
58
Sandeep Puligilla80038de2017-05-10 10:43:29 -070059#define CSR_NUM_IBSS_START_CHAN_50 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060#define CSR_NUM_IBSS_START_CHANNELS_24 3
Naveen Rawatd7734142017-10-27 10:02:40 -070061/* 70 seconds, for WPA, WPA2, CCKM */
62#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD \
63 (SIR_INSTALL_KEY_TIMEOUT_SEC * QDF_MC_TIMER_TO_SEC_UNIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064/* 120 seconds, for WPS */
Anurag Chouhan210db072016-02-22 18:42:15 +053065#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD (120 * QDF_MC_TIMER_TO_SEC_UNIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053067/* OBIWAN recommends [8 10]% : pick 9% */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053069/* OBIWAN recommends -85dBm */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070#define CSR_VCC_RSSI_THRESHOLD 80
71#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 /* ms */
72#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 /* ms */
73#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 /* ms */
74/* Flag to send/do not send disassoc frame over the air */
75#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
76#define RSSI_HACK_BMPS (-40)
77#define MAX_CB_VALUE_IN_INI (2)
78
79#define MAX_SOCIAL_CHANNELS 3
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053080
81/* packet dump timer duration of 60 secs */
82#define PKT_DUMP_TIMER_DURATION 60
83
Jeff Johnson698eacd2018-05-12 17:00:03 -070084/* Choose the largest possible value that can be accommodated in 8 bit signed */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085/* variable. */
86#define SNR_HACK_BMPS (127)
87
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070088/*
89 * ROAMING_OFFLOAD_TIMER_START - Indicates the action to start the timer
90 * ROAMING_OFFLOAD_TIMER_STOP - Indicates the action to stop the timer
91 * CSR_ROAMING_OFFLOAD_TIMEOUT_PERIOD - Timeout value for roaming offload timer
92 */
93#define ROAMING_OFFLOAD_TIMER_START 1
94#define ROAMING_OFFLOAD_TIMER_STOP 2
95#define CSR_ROAMING_OFFLOAD_TIMEOUT_PERIOD (5 * QDF_MC_TIMER_TO_SEC_UNIT)
96
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -070097/*
98 * MAWC_ROAM_TRAFFIC_THRESHOLD_DEFAULT - Indicates the traffic thresold in kBps
99 * MAWC_ROAM_AP_RSSI_THRESHOLD_DEFAULT - indicates the AP RSSI threshold
100 * MAWC_ROAM_RSSI_HIGH_ADJUST_DEFAULT - Adjustable high value to suppress scan
101 * MAWC_ROAM_RSSI_LOW_ADJUST_DEFAULT - Adjustable low value to suppress scan
102 */
103#define MAWC_ROAM_TRAFFIC_THRESHOLD_DEFAULT 300
104#define MAWC_ROAM_AP_RSSI_THRESHOLD_DEFAULT (-66)
105#define MAWC_ROAM_RSSI_HIGH_ADJUST_DEFAULT 5
106#define MAWC_ROAM_RSSI_LOW_ADJUST_DEFAULT 5
107
Vignesh Viswanathanfb9d0752018-02-06 16:19:00 +0530108/*
109 * Neighbor report offload needs to send 0xFFFFFFFF if a particular
110 * parameter is disabled from the ini
111 */
112#define NEIGHBOR_REPORT_PARAM_INVALID (0xFFFFFFFFU)
113
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530114/* Static Type declarations */
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530115static struct csr_roam_session csr_roam_roam_session[CSR_ROAM_SESSION_MAX];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800116
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +0530117#ifdef WLAN_FEATURE_SAE
118/**
119 * csr_sae_callback - Update SAE info to CSR roam session
120 * @mac_ctx: MAC context
121 * @msg_ptr: pointer to SAE message
122 *
123 * API to update SAE info to roam csr session
124 *
125 * Return: QDF_STATUS
126 */
127static QDF_STATUS csr_sae_callback(tpAniSirGlobal mac_ctx,
128 tSirSmeRsp *msg_ptr)
129{
130 struct csr_roam_info *roam_info;
131 uint32_t session_id;
132 struct sir_sae_info *sae_info;
133
134 sae_info = (struct sir_sae_info *) msg_ptr;
135 if (!sae_info) {
136 sme_err("SAE info is NULL");
137 return QDF_STATUS_E_FAILURE;
138 }
139
140 sme_debug("vdev_id %d "MAC_ADDRESS_STR"",
141 sae_info->vdev_id,
142 MAC_ADDR_ARRAY(sae_info->peer_mac_addr.bytes));
143
144 session_id = sae_info->vdev_id;
145 if (session_id == CSR_SESSION_ID_INVALID)
146 return QDF_STATUS_E_INVAL;
147
148 roam_info = qdf_mem_malloc(sizeof(*roam_info));
149 if (!roam_info) {
150 sme_err("qdf_mem_malloc failed for SAE");
151 return QDF_STATUS_E_FAILURE;
152 }
153
154 roam_info->sae_info = sae_info;
155
156 csr_roam_call_callback(mac_ctx, session_id, roam_info,
157 0, eCSR_ROAM_SAE_COMPUTE,
158 eCSR_ROAM_RESULT_NONE);
159 qdf_mem_free(roam_info);
160
161 return QDF_STATUS_SUCCESS;
162}
163#else
164static inline QDF_STATUS csr_sae_callback(tpAniSirGlobal mac_ctx,
165 tSirSmeRsp *msg_ptr)
166{
167 return QDF_STATUS_SUCCESS;
168}
169#endif
170
171
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Krunal Soni4b6c9462018-03-09 15:56:56 -0800173enum mgmt_auth_type diag_auth_type_from_csr_type(eCsrAuthType authtype)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174{
175 int n = AUTH_OPEN;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530176
Krunal Soni4b6c9462018-03-09 15:56:56 -0800177 switch (authtype) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 case eCSR_AUTH_TYPE_SHARED_KEY:
179 n = AUTH_SHARED;
180 break;
181 case eCSR_AUTH_TYPE_WPA:
182 n = AUTH_WPA_EAP;
183 break;
184 case eCSR_AUTH_TYPE_WPA_PSK:
185 n = AUTH_WPA_PSK;
186 break;
187 case eCSR_AUTH_TYPE_RSN:
188#ifdef WLAN_FEATURE_11W
189 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
190#endif
191 n = AUTH_WPA2_EAP;
192 break;
193 case eCSR_AUTH_TYPE_RSN_PSK:
194#ifdef WLAN_FEATURE_11W
195 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
196#endif
197 n = AUTH_WPA2_PSK;
198 break;
199#ifdef FEATURE_WLAN_WAPI
200 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
201 n = AUTH_WAPI_CERT;
202 break;
203 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
204 n = AUTH_WAPI_PSK;
205 break;
206#endif /* FEATURE_WLAN_WAPI */
207 default:
208 break;
209 }
210 return n;
211}
212
Krunal Soni4b6c9462018-03-09 15:56:56 -0800213enum mgmt_encrypt_type diag_enc_type_from_csr_type(eCsrEncryptionType enctype)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800214{
215 int n = ENC_MODE_OPEN;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530216
Krunal Soni4b6c9462018-03-09 15:56:56 -0800217 switch (enctype) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800218 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
219 case eCSR_ENCRYPT_TYPE_WEP40:
220 n = ENC_MODE_WEP40;
221 break;
222 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
223 case eCSR_ENCRYPT_TYPE_WEP104:
224 n = ENC_MODE_WEP104;
225 break;
226 case eCSR_ENCRYPT_TYPE_TKIP:
227 n = ENC_MODE_TKIP;
228 break;
229 case eCSR_ENCRYPT_TYPE_AES:
230 n = ENC_MODE_AES;
231 break;
Mukul Sharma05504ac2017-06-08 12:35:53 +0530232 case eCSR_ENCRYPT_TYPE_AES_GCMP:
233 n = ENC_MODE_AES_GCMP;
234 break;
235 case eCSR_ENCRYPT_TYPE_AES_GCMP_256:
236 n = ENC_MODE_AES_GCMP_256;
237 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238#ifdef FEATURE_WLAN_WAPI
239 case eCSR_ENCRYPT_TYPE_WPI:
240 n = ENC_MODE_SMS4;
241 break;
242#endif /* FEATURE_WLAN_WAPI */
243 default:
244 break;
245 }
246 return n;
247}
Krunal Soni4b6c9462018-03-09 15:56:56 -0800248
249enum mgmt_dot11_mode
250diag_dot11_mode_from_csr_type(enum csr_cfgdot11mode dot11mode)
251{
252 switch (dot11mode) {
253 case eCSR_CFG_DOT11_MODE_ABG:
254 return DOT11_MODE_ABG;
255 case eCSR_CFG_DOT11_MODE_11A:
256 return DOT11_MODE_11A;
257 case eCSR_CFG_DOT11_MODE_11B:
258 return DOT11_MODE_11B;
259 case eCSR_CFG_DOT11_MODE_11G:
260 return DOT11_MODE_11G;
261 case eCSR_CFG_DOT11_MODE_11N:
262 return DOT11_MODE_11N;
263 case eCSR_CFG_DOT11_MODE_11AC:
264 return DOT11_MODE_11AC;
265 case eCSR_CFG_DOT11_MODE_11G_ONLY:
266 return DOT11_MODE_11G_ONLY;
267 case eCSR_CFG_DOT11_MODE_11N_ONLY:
268 return DOT11_MODE_11N_ONLY;
269 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
270 return DOT11_MODE_11AC_ONLY;
271 case eCSR_CFG_DOT11_MODE_AUTO:
272 return DOT11_MODE_AUTO;
273 case eCSR_CFG_DOT11_MODE_11AX:
274 return DOT11_MODE_11AX;
275 case eCSR_CFG_DOT11_MODE_11AX_ONLY:
276 return DOT11_MODE_11AX_ONLY;
277 default:
278 return DOT11_MODE_MAX;
279 }
280}
281
282enum mgmt_ch_width diag_ch_width_from_csr_type(enum phy_ch_width ch_width)
283{
284 switch (ch_width) {
285 case CH_WIDTH_20MHZ:
286 return BW_20MHZ;
287 case CH_WIDTH_40MHZ:
288 return BW_40MHZ;
289 case CH_WIDTH_80MHZ:
290 return BW_80MHZ;
291 case CH_WIDTH_160MHZ:
292 return BW_160MHZ;
293 case CH_WIDTH_80P80MHZ:
294 return BW_80P80MHZ;
295 case CH_WIDTH_5MHZ:
296 return BW_5MHZ;
297 case CH_WIDTH_10MHZ:
298 return BW_10MHZ;
299 default:
300 return BW_MAX;
301 }
302}
303
304enum mgmt_bss_type diag_persona_from_csr_type(enum QDF_OPMODE persona)
305{
306 switch (persona) {
307 case QDF_STA_MODE:
308 return STA_PERSONA;
309 case QDF_SAP_MODE:
310 return SAP_PERSONA;
311 case QDF_P2P_CLIENT_MODE:
312 return P2P_CLIENT_PERSONA;
313 case QDF_P2P_GO_MODE:
314 return P2P_GO_PERSONA;
315 case QDF_FTM_MODE:
316 return FTM_PERSONA;
317 case QDF_IBSS_MODE:
318 return IBSS_PERSONA;
319 case QDF_MONITOR_MODE:
320 return MONITOR_PERSONA;
321 case QDF_P2P_DEVICE_MODE:
322 return P2P_DEVICE_PERSONA;
323 case QDF_OCB_MODE:
324 return OCB_PERSONA;
325 case QDF_EPPING_MODE:
326 return EPPING_PERSONA;
327 case QDF_QVIT_MODE:
328 return QVIT_PERSONA;
329 case QDF_NDI_MODE:
330 return NDI_PERSONA;
331 case QDF_WDS_MODE:
332 return WDS_PERSONA;
333 case QDF_BTAMP_MODE:
334 return BTAMP_PERSONA;
335 case QDF_AHDEMO_MODE:
336 return AHDEMO_PERSONA;
337 default:
338 return MAX_PERSONA;
339 }
340}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341#endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */
Krunal Soni4b6c9462018-03-09 15:56:56 -0800342
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343static const uint8_t
Sandeep Puligilla80038de2017-05-10 10:43:29 -0700344csr_start_ibss_channels50[CSR_NUM_IBSS_START_CHAN_50] = { 36, 44, 52, 56, 140 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345static const uint8_t
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530346csr_start_ibss_channels24[CSR_NUM_IBSS_START_CHANNELS_24] = { 1, 6, 11 };
Ganesh Kondabattinib1960e72017-09-01 09:09:50 +0530347
348static const uint8_t
349social_channel[MAX_SOCIAL_CHANNELS] = { 1, 6, 11 };
350
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800351static void init_config_param(tpAniSirGlobal pMac);
352static bool csr_roam_process_results(tpAniSirGlobal pMac, tSmeCmd *pCommand,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +0530353 enum csr_roamcomplete_result Result,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354 void *Context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530355static QDF_STATUS csr_roam_start_ibss(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -0700356 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357 bool *pfSameIbss);
358static void csr_roam_update_connected_profile_from_new_bss(tpAniSirGlobal pMac,
359 uint32_t sessionId,
360 tSirSmeNewBssInfo *
361 pNewBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362static ePhyChanBondState csr_get_cb_mode_from_ies(tpAniSirGlobal pMac,
363 uint8_t primaryChn,
364 tDot11fBeaconIEs *pIes);
365
366static void csr_roaming_state_config_cnf_processor(tpAniSirGlobal pMac,
Krunal Sonia8270f52017-02-23 19:51:25 -0800367 tSmeCmd *pCommand, uint32_t result, uint8_t session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530368static QDF_STATUS csr_roam_open(tpAniSirGlobal pMac);
369static QDF_STATUS csr_roam_close(tpAniSirGlobal pMac);
370static bool csr_roam_is_same_profile_keys(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371 tCsrRoamConnectedProfile *pConnProfile,
Jeff Johnson66ee8a92018-03-17 15:24:26 -0700372 struct csr_roam_profile *pProfile2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800373
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530374static QDF_STATUS csr_roam_start_roaming_timer(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800375 uint32_t sessionId,
376 uint32_t interval);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530377static QDF_STATUS csr_roam_stop_roaming_timer(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378 uint32_t sessionId);
379static void csr_roam_roaming_timer_handler(void *pv);
Yingying Tang87f01392017-03-22 17:29:54 +0800380#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -0700381static void csr_roam_roaming_offload_timer_action(tpAniSirGlobal mac_ctx,
382 uint32_t interval, uint8_t session_id, uint8_t action);
Yingying Tang87f01392017-03-22 17:29:54 +0800383#endif
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -0700384static void csr_roam_roaming_offload_timeout_handler(void *timer_data);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530385static QDF_STATUS csr_roam_start_wait_for_key_timer(tpAniSirGlobal pMac,
386 uint32_t interval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387static void csr_roam_wait_for_key_time_out_handler(void *pv);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530388static QDF_STATUS csr_init11d_info(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
389static QDF_STATUS csr_init_channel_power_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390 tCsr11dinfo *ps11dinfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530391static QDF_STATUS csr_roam_free_connected_info(tpAniSirGlobal pMac,
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530392 struct csr_roam_connectedinfo *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800393 pConnectedInfo);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530394static QDF_STATUS csr_send_mb_set_context_req_msg(tpAniSirGlobal pMac,
395 uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530396 struct qdf_mac_addr peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -0800397 uint8_t numKeys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 tAniEdType edType, bool fUnicast,
399 tAniKeyDirection aniKeyDirection,
400 uint8_t keyId, uint8_t keyLength,
401 uint8_t *pKey, uint8_t paeRole,
402 uint8_t *pKeyRsc);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530403static void csr_roam_link_up(tpAniSirGlobal pMac, struct qdf_mac_addr bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800404static void csr_roam_link_down(tpAniSirGlobal pMac, uint32_t sessionId);
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700405#ifndef QCA_SUPPORT_CP_STATS
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530406static QDF_STATUS csr_send_mb_stats_req_msg(tpAniSirGlobal pMac,
407 uint32_t statsMask, uint8_t staId,
408 uint8_t sessionId);
409/* pStaEntry is no longer invalid upon the return of this function. */
410static void csr_roam_remove_stat_list_entry(tpAniSirGlobal pMac,
411 tListElem *pEntry);
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530412struct csr_statsclient_reqinfo *csr_roam_insert_entry_into_list(
413 tpAniSirGlobal pMac, tDblLinkList *pStaList,
414 struct csr_statsclient_reqinfo *
415 pStaEntry);
416static void csr_roam_report_statistics(tpAniSirGlobal pMac,
417 uint32_t statsMask, tCsrStatsCallback callback, uint8_t staId,
418 void *pContext);
419tListElem *csr_roam_check_client_req_list(
420 tpAniSirGlobal pMac, uint32_t statsMask);
421static void csr_roam_remove_entry_from_pe_stats_req_list(
422 tpAniSirGlobal pMac, struct csr_pestats_reqinfo *pPeStaEntry);
423tListElem *csr_roam_find_in_pe_stats_req_list(
424 tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530425 uint32_t statsMask);
426static QDF_STATUS csr_roam_dereg_statistics_req(tpAniSirGlobal pMac);
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700427#else
428static QDF_STATUS csr_roam_dereg_statistics_req(tpAniSirGlobal pMac)
429{
430 return QDF_STATUS_SUCCESS;
431}
432#endif
433static enum csr_cfgdot11mode
434csr_roam_get_phy_mode_band_for_bss(tpAniSirGlobal pMac,
435 struct csr_roam_profile *pProfile,
436 uint8_t operationChn,
437 enum band_info *pBand);
438static QDF_STATUS csr_roam_get_qos_info_from_bss(
439tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440static uint32_t csr_find_ibss_session(tpAniSirGlobal pMac);
Peng Xuf5d60c82015-10-02 17:17:03 -0700441static uint32_t csr_find_session_by_type(tpAniSirGlobal,
Jeff Johnsonc1e62782017-11-09 09:50:17 -0800442 enum QDF_OPMODE);
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530443static bool csr_is_conn_allow_2g_band(tpAniSirGlobal pMac,
444 uint32_t chnl);
445static bool csr_is_conn_allow_5g_band(tpAniSirGlobal pMac,
446 uint32_t chnl);
447static QDF_STATUS csr_roam_start_wds(tpAniSirGlobal pMac,
448 uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -0700449 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450 tSirBssDescription *pBssDesc);
451static void csr_init_session(tpAniSirGlobal pMac, uint32_t sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530452static QDF_STATUS csr_roam_issue_set_key_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800453 uint32_t sessionId,
454 tCsrRoamSetKey *pSetKey,
455 uint32_t roamId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530456static QDF_STATUS csr_roam_get_qos_info_from_bss(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457 tSirBssDescription *pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458static void csr_ser_des_unpack_diassoc_rsp(uint8_t *pBuf,
459 tSirSmeDisassocRsp *pRsp);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530460static void csr_init_operating_classes(tHalHandle hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461
Ganesh Kondabattinib1960e72017-09-01 09:09:50 +0530462static void csr_add_len_of_social_channels(tpAniSirGlobal mac,
463 uint8_t *num_chan);
464static void csr_add_social_channels(tpAniSirGlobal mac,
465 tSirUpdateChanList *chan_list, struct csr_scanstruct *pScan,
466 uint8_t *num_chan);
467
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800468/* Initialize global variables */
469static void csr_roam_init_globals(tpAniSirGlobal pMac)
470{
471 if (pMac) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530472 qdf_mem_zero(&csr_roam_roam_session,
473 sizeof(csr_roam_roam_session));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800474 pMac->roam.roamSession = csr_roam_roam_session;
475 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800476}
477
478static void csr_roam_de_init_globals(tpAniSirGlobal pMac)
479{
Naveen Rawat20969542017-01-27 18:01:17 -0800480 uint8_t i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482 if (pMac) {
Naveen Rawat20969542017-01-27 18:01:17 -0800483 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
484 if (pMac->roam.roamSession[i].pCurRoamProfile)
485 csr_release_profile(pMac,
486 pMac->roam.roamSession[i].
487 pCurRoamProfile);
488 csr_release_profile(pMac,
489 &pMac->roam.roamSession[i].
490 stored_roam_profile.profile);
491 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800492 pMac->roam.roamSession = NULL;
493 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494}
495
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700496#ifdef QCA_SUPPORT_CP_STATS
497static QDF_STATUS csr_open_stats_ll(struct sAniSirGlobal *mac_ctx)
498{
499 return QDF_STATUS_SUCCESS;
500}
501
502static void csr_close_stats_ll(struct sAniSirGlobal *mac_ctx) {}
503#else
504static QDF_STATUS csr_open_stats_ll(struct sAniSirGlobal *mac_ctx)
505{
506 QDF_STATUS status;
507
508 status = csr_ll_open(mac_ctx->hHdd, &mac_ctx->roam.statsClientReqList);
509 if (QDF_IS_STATUS_ERROR(status))
510 return status;
511
512 return csr_ll_open(mac_ctx->hHdd, &mac_ctx->roam.peStatsReqList);
513}
514
515static void csr_close_stats_ll(struct sAniSirGlobal *mac_ctx)
516{
517 csr_ll_close(&mac_ctx->roam.statsClientReqList);
518 csr_ll_close(&mac_ctx->roam.peStatsReqList);
519}
520#endif
521
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530522QDF_STATUS csr_open(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530524 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800525 uint32_t i;
526
527 do {
528 /* Initialize CSR Roam Globals */
529 csr_roam_init_globals(pMac);
530 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
531 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_STOP, i);
532
533 init_config_param(pMac);
534 status = csr_scan_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530535 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800536 break;
537 status = csr_roam_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530538 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800539 break;
540 pMac->roam.nextRoamId = 1; /* Must not be 0 */
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700541 status = csr_open_stats_ll(pMac);
542 if (QDF_IS_STATUS_ERROR(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800543 break;
Abhishek Singhf3756fc2017-06-28 16:04:06 +0530544 qdf_list_create(&pMac->roam.rssi_disallow_bssid,
545 MAX_RSSI_AVOID_BSSID_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800546 } while (0);
547
548 return status;
549}
550
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530551QDF_STATUS csr_init_chan_list(tpAniSirGlobal mac, uint8_t *alpha2)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800552{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530553 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800554
555 mac->scan.countryCodeDefault[0] = alpha2[0];
556 mac->scan.countryCodeDefault[1] = alpha2[1];
557 mac->scan.countryCodeDefault[2] = alpha2[2];
558
Srinivas Girigowda81aef902017-03-17 09:34:19 -0700559 sme_debug("init time country code %.2s", mac->scan.countryCodeDefault);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800560
Amar Singhale4f28ee2015-10-21 14:36:56 -0700561 mac->scan.domainIdDefault = 0;
562 mac->scan.domainIdCurrent = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800563
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530564 qdf_mem_copy(mac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565 mac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530566 qdf_mem_copy(mac->scan.countryCodeElected,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800567 mac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
568 status = csr_get_channel_and_power_list(mac);
569 csr_clear_votes_for_country_info(mac);
570 return status;
571}
572
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530573QDF_STATUS csr_set_channels(tHalHandle hHal, tCsrConfigParam *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530575 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800576 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
577 uint8_t index = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530578
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530579 qdf_mem_copy(pParam->Csr11dinfo.countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800580 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
581 for (index = 0; index < pMac->scan.base_channels.numChannels;
582 index++) {
583 pParam->Csr11dinfo.Channels.channelList[index] =
584 pMac->scan.base_channels.channelList[index];
585 pParam->Csr11dinfo.ChnPower[index].firstChannel =
586 pMac->scan.base_channels.channelList[index];
587 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
588 pParam->Csr11dinfo.ChnPower[index].maxtxPower =
Amar Singhal5cccafe2017-02-15 12:42:58 -0800589 pMac->scan.defaultPowerTable[index].tx_power;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800590 }
591 pParam->Csr11dinfo.Channels.numChannels =
592 pMac->scan.base_channels.numChannels;
593
594 return status;
595}
596
Abhishek Singhf3756fc2017-06-28 16:04:06 +0530597/**
598 * csr_assoc_rej_free_rssi_disallow_list() - Free the rssi diallowed
599 * BSSID entries and destroy the list
600 * @list: rssi based disallowed list entry
601 *
602 * Return: void
603 */
604static void csr_assoc_rej_free_rssi_disallow_list(qdf_list_t *list)
605{
606 QDF_STATUS status;
607 struct sir_rssi_disallow_lst *cur_node;
608 qdf_list_node_t *cur_lst = NULL, *next_lst = NULL;
609
610 qdf_list_peek_front(list, &cur_lst);
611 while (cur_lst) {
612 qdf_list_peek_next(list, cur_lst, &next_lst);
613 cur_node = qdf_container_of(cur_lst,
614 struct sir_rssi_disallow_lst, node);
615 status = qdf_list_remove_node(list, cur_lst);
616 if (QDF_IS_STATUS_SUCCESS(status))
617 qdf_mem_free(cur_node);
618 cur_lst = next_lst;
619 next_lst = NULL;
620 }
621 qdf_list_destroy(list);
622}
623
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530624QDF_STATUS csr_close(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530626 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800627
628 csr_roam_close(pMac);
Abhishek Singhf3756fc2017-06-28 16:04:06 +0530629 csr_assoc_rej_free_rssi_disallow_list(
630 &pMac->roam.rssi_disallow_bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 csr_scan_close(pMac);
Naveen Rawatfa2a1002018-05-17 16:06:37 -0700632 csr_close_stats_ll(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800633 /* DeInit Globals */
634 csr_roam_de_init_globals(pMac);
635 return status;
636}
637
Amar Singhala297bfa2015-10-15 15:07:29 -0700638static int8_t csr_find_channel_pwr(struct channel_power *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639 pdefaultPowerTable,
640 uint8_t ChannelNum)
641{
642 uint8_t i;
643 /* TODO: if defaultPowerTable is guaranteed to be in ascending */
644 /* order of channel numbers, we can employ binary search */
645 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -0700646 if (pdefaultPowerTable[i].chan_num == ChannelNum)
Amar Singhal5cccafe2017-02-15 12:42:58 -0800647 return pdefaultPowerTable[i].tx_power;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800648 }
649 /* could not find the channel list in default list */
Jeff Johnson11d7c9d2018-05-06 15:44:09 -0700650 /* this should not have occurred */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530651 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800652 return 0;
653}
Naveen Rawat16b82872015-12-14 17:59:16 -0800654
655/**
656 * csr_roam_arrange_ch_list() - Updates the channel list modified with greedy
657 * order for 5 Ghz preference and DFS channels.
658 * @mac_ctx: pointer to mac context.
659 * @chan_list: channel list updated with greedy channel order.
660 * @num_channel: Number of channels in list
661 *
662 * To allow Early Stop Roaming Scan feature to co-exist with 5G preference,
663 * this function moves 5G channels ahead of 2G channels. This function can
664 * also move 2G channels, ahead of DFS channel or vice versa. Order is
665 * maintained among same category channels
666 *
667 * Return: None
668 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -0700669static void csr_roam_arrange_ch_list(tpAniSirGlobal mac_ctx,
Naveen Rawat16b82872015-12-14 17:59:16 -0800670 tSirUpdateChanParam *chan_list, uint8_t num_channel)
671{
672 bool prefer_5g = CSR_IS_ROAM_PREFER_5GHZ(mac_ctx);
673 bool prefer_dfs = CSR_IS_DFS_CH_ROAM_ALLOWED(mac_ctx);
674 int i, j = 0;
675 tSirUpdateChanParam *tmp_list = NULL;
676
677 if (!prefer_5g)
678 return;
679
680 tmp_list = (tSirUpdateChanParam *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530681 qdf_mem_malloc(sizeof(tSirUpdateChanParam) * num_channel);
Naveen Rawat16b82872015-12-14 17:59:16 -0800682 if (tmp_list == NULL) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -0700683 sme_err("Memory allocation failed");
Naveen Rawat16b82872015-12-14 17:59:16 -0800684 return;
685 }
686
687 /* Fist copy Non-DFS 5g channels */
688 for (i = 0; i < num_channel; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700689 if (WLAN_REG_IS_5GHZ_CH(chan_list[i].chanId) &&
690 !wlan_reg_is_dfs_ch(mac_ctx->pdev,
691 chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530692 qdf_mem_copy(&tmp_list[j++],
Naveen Rawat16b82872015-12-14 17:59:16 -0800693 &chan_list[i], sizeof(tSirUpdateChanParam));
694 chan_list[i].chanId = INVALID_CHANNEL_ID;
695 }
696 }
697 if (prefer_dfs) {
698 /* next copy DFS channels (remaining channels in 5G) */
699 for (i = 0; i < num_channel; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700700 if (WLAN_REG_IS_5GHZ_CH(chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530701 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800702 sizeof(tSirUpdateChanParam));
703 chan_list[i].chanId = INVALID_CHANNEL_ID;
704 }
705 }
706 } else {
707 /* next copy 2G channels */
708 for (i = 0; i < num_channel; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700709 if (WLAN_REG_IS_24GHZ_CH(chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530710 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800711 sizeof(tSirUpdateChanParam));
712 chan_list[i].chanId = INVALID_CHANNEL_ID;
713 }
714 }
715 }
716 /* copy rest of the channels in same order to tmp list */
717 for (i = 0; i < num_channel; i++) {
718 if (chan_list[i].chanId != INVALID_CHANNEL_ID) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530719 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800720 sizeof(tSirUpdateChanParam));
721 chan_list[i].chanId = INVALID_CHANNEL_ID;
722 }
723 }
724 /* copy tmp list to original channel list buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530725 qdf_mem_copy(chan_list, tmp_list,
Naveen Rawat16b82872015-12-14 17:59:16 -0800726 sizeof(tSirUpdateChanParam) * num_channel);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530727 qdf_mem_free(tmp_list);
Naveen Rawat16b82872015-12-14 17:59:16 -0800728}
729
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700730/**
731 * csr_roam_sort_channel_for_early_stop() - Sort the channels
Naveen Rawat16b82872015-12-14 17:59:16 -0800732 * @mac_ctx: mac global context
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700733 * @chan_list: Original channel list from the upper layers
734 * @num_channel: Number of original channels
735 *
736 * For Early stop scan feature, the channel list should be in an order,
737 * where-in there is a maximum chance to detect an AP in the initial
738 * channels in the list so that the scanning can be stopped early as the
739 * feature demands.
740 * Below fixed greedy channel list has been provided
741 * based on most of the enterprise wifi installations across the globe.
742 *
743 * Identify all the greedy channels within the channel list from user space.
744 * Identify all the non-greedy channels in the user space channel list.
745 * Merge greedy channels followed by non-greedy channels back into the
746 * chan_list.
747 *
748 * Return: None
749 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -0700750static void csr_roam_sort_channel_for_early_stop(tpAniSirGlobal mac_ctx,
Naveen Rawat16b82872015-12-14 17:59:16 -0800751 tSirUpdateChanList *chan_list, uint8_t num_channel)
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700752{
753 tSirUpdateChanList *chan_list_greedy, *chan_list_non_greedy;
754 uint8_t i, j;
755 static const uint8_t fixed_greedy_chan_list[] = {1, 6, 11, 36, 48, 40,
756 44, 10, 2, 9, 149, 157, 161, 3, 4, 8, 153, 165, 7, 5, 136, 140,
757 52, 116, 56, 104, 64, 60, 100, 120, 13, 14, 112, 132, 151, 155};
758 uint8_t num_fixed_greedy_chan;
759 uint8_t num_greedy_chan = 0;
760 uint8_t num_non_greedy_chan = 0;
761 uint8_t match_found = false;
762 uint32_t buf_size;
763
764 buf_size = sizeof(tSirUpdateChanList) +
765 (sizeof(tSirUpdateChanParam) * num_channel);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530766 chan_list_greedy = qdf_mem_malloc(buf_size);
767 chan_list_non_greedy = qdf_mem_malloc(buf_size);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700768 if (!chan_list_greedy || !chan_list_non_greedy) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530769 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700770 "Failed to allocate memory for tSirUpdateChanList");
771 return;
772 }
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700773 /*
774 * fixed_greedy_chan_list is an evaluated channel list based on most of
775 * the enterprise wifi deployments and the order of the channels
776 * determines the highest possibility of finding an AP.
777 * chan_list is the channel list provided by upper layers based on the
778 * regulatory domain.
779 */
780 num_fixed_greedy_chan = sizeof(fixed_greedy_chan_list)/sizeof(uint8_t);
781 /*
782 * Browse through the chan_list and put all the non-greedy channels
Jeff Johnsonfa7d9602018-05-06 11:25:31 -0700783 * into a separate list by name chan_list_non_greedy
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700784 */
785 for (i = 0; i < num_channel; i++) {
786 for (j = 0; j < num_fixed_greedy_chan; j++) {
787 if (chan_list->chanParam[i].chanId ==
788 fixed_greedy_chan_list[j]) {
789 match_found = true;
790 break;
791 }
792 }
793 if (!match_found) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530794 qdf_mem_copy(
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700795 &chan_list_non_greedy->chanParam[num_non_greedy_chan],
796 &chan_list->chanParam[i],
797 sizeof(tSirUpdateChanParam));
798 num_non_greedy_chan++;
799 } else {
800 match_found = false;
801 }
802 }
803 /*
804 * Browse through the fixed_greedy_chan_list and put all the greedy
Jeff Johnsonfa7d9602018-05-06 11:25:31 -0700805 * channels in the chan_list into a separate list by name
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700806 * chan_list_greedy
807 */
808 for (i = 0; i < num_fixed_greedy_chan; i++) {
809 for (j = 0; j < num_channel; j++) {
810 if (fixed_greedy_chan_list[i] ==
811 chan_list->chanParam[j].chanId) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530812 qdf_mem_copy(
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700813 &chan_list_greedy->chanParam[num_greedy_chan],
814 &chan_list->chanParam[j],
815 sizeof(tSirUpdateChanParam));
816 num_greedy_chan++;
817 break;
818 }
819 }
820 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530821 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700822 "greedy=%d, non-greedy=%d, tot=%d",
823 num_greedy_chan, num_non_greedy_chan, num_channel);
824 if ((num_greedy_chan + num_non_greedy_chan) != num_channel) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530825 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700826 "incorrect sorting of channels");
827 goto scan_list_sort_error;
828 }
829 /* Copy the Greedy channels first */
830 i = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530831 qdf_mem_copy(&chan_list->chanParam[i],
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700832 &chan_list_greedy->chanParam[i],
833 num_greedy_chan * sizeof(tSirUpdateChanParam));
834 /* Copy the remaining Non Greedy channels */
835 i = num_greedy_chan;
836 j = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530837 qdf_mem_copy(&chan_list->chanParam[i],
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700838 &chan_list_non_greedy->chanParam[j],
839 num_non_greedy_chan * sizeof(tSirUpdateChanParam));
Naveen Rawat16b82872015-12-14 17:59:16 -0800840
841 /* Update channel list for 5g preference and allow DFS roam */
842 csr_roam_arrange_ch_list(mac_ctx, chan_list->chanParam, num_channel);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700843scan_list_sort_error:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530844 qdf_mem_free(chan_list_greedy);
845 qdf_mem_free(chan_list_non_greedy);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700846}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -0700848/**
849 * csr_emu_chan_req() - update the required channel list for emulation
850 * @channel: channel number to check
851 *
852 * To reduce scan time during emulation platforms, this function
853 * restricts the scanning to be done on selected channels
854 *
855 * Return: QDF_STATUS enumeration
856 */
857#ifdef QCA_WIFI_NAPIER_EMULATION
Krishna Kumaar Natarajan585f0302017-08-07 18:01:27 -0700858#define SCAN_CHAN_LIST_5G_LEN 6
859#define SCAN_CHAN_LIST_2G_LEN 3
860static const uint8_t
861csr_scan_chan_list_5g[SCAN_CHAN_LIST_5G_LEN] = { 36, 44, 52, 56, 140, 149 };
862static const uint8_t
863csr_scan_chan_list_2g[SCAN_CHAN_LIST_2G_LEN] = { 1, 6, 11 };
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -0700864static QDF_STATUS csr_emu_chan_req(uint32_t channel)
865{
866 int i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700867
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700868 if (WLAN_REG_IS_24GHZ_CH(channel)) {
Krishna Kumaar Natarajan585f0302017-08-07 18:01:27 -0700869 for (i = 0; i < QDF_ARRAY_SIZE(csr_scan_chan_list_2g); i++) {
870 if (csr_scan_chan_list_2g[i] == channel)
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -0700871 return QDF_STATUS_SUCCESS;
872 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700873 } else if (WLAN_REG_IS_5GHZ_CH(channel)) {
Krishna Kumaar Natarajan585f0302017-08-07 18:01:27 -0700874 for (i = 0; i < QDF_ARRAY_SIZE(csr_scan_chan_list_5g); i++) {
875 if (csr_scan_chan_list_5g[i] == channel)
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -0700876 return QDF_STATUS_SUCCESS;
877 }
878 }
879 return QDF_STATUS_E_FAILURE;
880}
881#else
882static QDF_STATUS csr_emu_chan_req(uint32_t channel_num)
883{
884 return QDF_STATUS_SUCCESS;
885}
886#endif
887
Ganesh Kondabattinib1960e72017-09-01 09:09:50 +0530888#ifdef WLAN_ENABLE_SOCIAL_CHANNELS_5G_ONLY
889static void csr_add_len_of_social_channels(tpAniSirGlobal mac,
890 uint8_t *num_chan)
891{
892 uint8_t i;
893 uint8_t no_chan = *num_chan;
894
895 sme_debug("add len of social channels, before adding - num_chan:%hu",
896 *num_chan);
897 if (CSR_IS_5G_BAND_ONLY(mac)) {
898 for (i = 0; i < MAX_SOCIAL_CHANNELS; i++) {
899 if (wlan_reg_get_channel_state(
900 mac->pdev, social_channel[i]) ==
901 CHANNEL_STATE_ENABLE)
902 no_chan++;
903 }
904 }
905 *num_chan = no_chan;
906 sme_debug("after adding - num_chan:%hu", *num_chan);
907}
908
909static void csr_add_social_channels(tpAniSirGlobal mac,
910 tSirUpdateChanList *chan_list, struct csr_scanstruct *pScan,
911 uint8_t *num_chan)
912{
913 uint8_t i;
914 uint8_t no_chan = *num_chan;
915
916 sme_debug("add social channels chan_list %pK, num_chan %hu", chan_list,
917 *num_chan);
918 if (CSR_IS_5G_BAND_ONLY(mac)) {
919 for (i = 0; i < MAX_SOCIAL_CHANNELS; i++) {
920 if (wlan_reg_get_channel_state(mac->pdev,
921 social_channel[i]) != CHANNEL_STATE_ENABLE)
922 continue;
923 chan_list->chanParam[no_chan].chanId =
924 social_channel[i];
925 chan_list->chanParam[no_chan].pwr =
926 csr_find_channel_pwr(pScan->defaultPowerTable,
927 social_channel[i]);
928 chan_list->chanParam[no_chan].dfsSet = false;
929 if (cds_is_5_mhz_enabled())
930 chan_list->chanParam[no_chan].quarter_rate
931 = 1;
932 else if (cds_is_10_mhz_enabled())
933 chan_list->chanParam[no_chan].half_rate = 1;
934 no_chan++;
935 }
936 sme_debug("after adding -num_chan %hu", no_chan);
937 }
938 *num_chan = no_chan;
939}
940#else
941static void csr_add_len_of_social_channels(tpAniSirGlobal mac,
942 uint8_t *num_chan)
943{
944 sme_debug("skip adding len of social channels");
945}
946static void csr_add_social_channels(tpAniSirGlobal mac,
947 tSirUpdateChanList *chan_list, struct csr_scanstruct *pScan,
948 uint8_t *num_chan)
949{
950 sme_debug("skip social channels");
951}
952#endif
953
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530954QDF_STATUS csr_update_channel_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955{
956 tSirUpdateChanList *pChanList;
gaurank kathpalia14e2f912017-08-31 14:51:45 +0530957 struct csr_scanstruct *pScan = &pMac->scan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958 uint8_t numChan = pScan->base_channels.numChannels;
959 uint8_t num_channel = 0;
960 uint32_t bufLen;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700961 struct scheduler_msg msg = {0};
Ganesh Kondabattinib1960e72017-09-01 09:09:50 +0530962 uint8_t i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 uint8_t channel_state;
Agrawal Ashish21ba2572016-09-03 16:40:10 +0530964 uint16_t unsafe_chan[NUM_CHANNELS];
965 uint16_t unsafe_chan_cnt = 0;
966 uint16_t cnt = 0;
967 uint8_t channel;
968 bool is_unsafe_chan;
969 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
970
971 if (!qdf_ctx) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -0700972 sme_err("qdf_ctx is NULL");
Agrawal Ashish21ba2572016-09-03 16:40:10 +0530973 return QDF_STATUS_E_FAILURE;
974 }
975
976 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
977 &unsafe_chan_cnt,
978 sizeof(unsafe_chan));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979
Ganesh Kondabattinib1960e72017-09-01 09:09:50 +0530980 csr_add_len_of_social_channels(pMac, &numChan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981
982 bufLen = sizeof(tSirUpdateChanList) +
983 (sizeof(tSirUpdateChanParam) * (numChan));
984
985 csr_init_operating_classes((tHalHandle) pMac);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530986 pChanList = (tSirUpdateChanList *) qdf_mem_malloc(bufLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 if (!pChanList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530988 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 "Failed to allocate memory for tSirUpdateChanList");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530990 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992
993 for (i = 0; i < pScan->base_channels.numChannels; i++) {
Agrawal, Ashish9f84c402016-11-30 16:19:44 +0530994 struct csr_sta_roam_policy_params *roam_policy =
995 &pMac->roam.configParam.sta_roam_policy;
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -0700996 if (QDF_STATUS_SUCCESS !=
997 csr_emu_chan_req(pScan->base_channels.channelList[i]))
998 continue;
999
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000 /* Scan is not performed on DSRC channels*/
Amar Singhal5cccafe2017-02-15 12:42:58 -08001001 if (pScan->base_channels.channelList[i] >=
1002 WLAN_REG_MIN_11P_CH_NUM)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003 continue;
Amar Singhal5cccafe2017-02-15 12:42:58 -08001004
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301005 channel = pScan->base_channels.channelList[i];
Amar Singhal7c1e8982016-05-19 15:08:09 -07001006
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001007 channel_state = wlan_reg_get_channel_state(pMac->pdev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 pScan->base_channels.channelList[i]);
1009 if ((CHANNEL_STATE_ENABLE == channel_state) ||
1010 pMac->scan.fEnableDFSChnlScan) {
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301011 if ((pMac->roam.configParam.sta_roam_policy.dfs_mode ==
1012 CSR_STA_ROAM_POLICY_DFS_DISABLED) &&
1013 (channel_state == CHANNEL_STATE_DFS)) {
1014 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh245182f2017-08-10 17:41:09 +05301015 QDF_TRACE_LEVEL_DEBUG,
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301016 FL("skip dfs channel %d"),
1017 channel);
1018 continue;
1019 }
1020 if (pMac->roam.configParam.sta_roam_policy.
1021 skip_unsafe_channels &&
1022 unsafe_chan_cnt) {
1023 is_unsafe_chan = false;
1024 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
1025 if (unsafe_chan[cnt] == channel) {
1026 is_unsafe_chan = true;
1027 break;
1028 }
1029 }
Agrawal, Ashish9f84c402016-11-30 16:19:44 +05301030 if ((is_unsafe_chan) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001031 ((WLAN_REG_IS_24GHZ_CH(channel) &&
Agrawal, Ashish9f84c402016-11-30 16:19:44 +05301032 roam_policy->sap_operating_band ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001033 BAND_2G) ||
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001034 (WLAN_REG_IS_5GHZ_CH(channel) &&
Agrawal, Ashish9f84c402016-11-30 16:19:44 +05301035 roam_policy->sap_operating_band ==
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001036 BAND_5G))) {
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301037 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh245182f2017-08-10 17:41:09 +05301038 QDF_TRACE_LEVEL_DEBUG,
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301039 FL("ignoring unsafe channel %d"),
1040 channel);
1041 continue;
1042 }
1043 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 pChanList->chanParam[num_channel].chanId =
1045 pScan->base_channels.channelList[i];
1046 pChanList->chanParam[num_channel].pwr =
1047 csr_find_channel_pwr(pScan->defaultPowerTable,
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301048 pChanList->chanParam[num_channel].chanId);
Amar Singhal7c1e8982016-05-19 15:08:09 -07001049
1050 if (pScan->fcc_constraint) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301051 if (12 == pChanList->chanParam[num_channel].
1052 chanId) {
Amar Singhal7c1e8982016-05-19 15:08:09 -07001053 pChanList->chanParam[num_channel].pwr =
1054 MAX_PWR_FCC_CHAN_12;
1055 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh245182f2017-08-10 17:41:09 +05301056 QDF_TRACE_LEVEL_DEBUG,
Amar Singhal83a047a2016-05-19 15:56:11 -07001057 "txpow for channel 12 is %d",
1058 MAX_PWR_FCC_CHAN_12);
Amar Singhal7c1e8982016-05-19 15:08:09 -07001059 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301060 if (13 == pChanList->chanParam[num_channel].
1061 chanId) {
Amar Singhal7c1e8982016-05-19 15:08:09 -07001062 pChanList->chanParam[num_channel].pwr =
1063 MAX_PWR_FCC_CHAN_13;
1064 QDF_TRACE(QDF_MODULE_ID_SME,
Abhishek Singh245182f2017-08-10 17:41:09 +05301065 QDF_TRACE_LEVEL_DEBUG,
Amar Singhal83a047a2016-05-19 15:56:11 -07001066 "txpow for channel 13 is %d",
1067 MAX_PWR_FCC_CHAN_13);
Amar Singhal7c1e8982016-05-19 15:08:09 -07001068 }
1069 }
1070
1071
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072 if (CHANNEL_STATE_ENABLE == channel_state)
1073 pChanList->chanParam[num_channel].dfsSet =
1074 false;
1075 else
1076 pChanList->chanParam[num_channel].dfsSet =
1077 true;
Naveen Rawat64e477e2016-05-20 10:34:56 -07001078 if (cds_is_5_mhz_enabled())
1079 pChanList->chanParam[num_channel].quarter_rate
1080 = 1;
1081 else if (cds_is_10_mhz_enabled())
1082 pChanList->chanParam[num_channel].half_rate = 1;
Abhishek Singh245182f2017-08-10 17:41:09 +05301083 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singh562aad62017-01-05 16:24:23 +05301084 "channel:%d, pwr=%d, DFS=%d qrate %d hrate %d ",
1085 pChanList->chanParam[num_channel].chanId,
1086 pChanList->chanParam[num_channel].pwr,
1087 pChanList->chanParam[num_channel].dfsSet,
1088 pChanList->chanParam[num_channel].quarter_rate,
1089 pChanList->chanParam[num_channel].half_rate);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090 num_channel++;
1091 }
1092 }
1093
Ganesh Kondabattinib1960e72017-09-01 09:09:50 +05301094 csr_add_social_channels(pMac, pChanList, pScan, &num_channel);
1095
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07001096 if (pMac->roam.configParam.early_stop_scan_enable)
Naveen Rawat16b82872015-12-14 17:59:16 -08001097 csr_roam_sort_channel_for_early_stop(pMac, pChanList,
1098 num_channel);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07001099 else
Abhishek Singh245182f2017-08-10 17:41:09 +05301100 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07001101 FL("Early Stop Scan Feature not supported"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001103 if ((pMac->roam.configParam.uCfgDot11Mode ==
1104 eCSR_CFG_DOT11_MODE_AUTO) ||
1105 (pMac->roam.configParam.uCfgDot11Mode ==
1106 eCSR_CFG_DOT11_MODE_11AC) ||
1107 (pMac->roam.configParam.uCfgDot11Mode ==
1108 eCSR_CFG_DOT11_MODE_11AC_ONLY)) {
1109 pChanList->vht_en = true;
1110 if (pMac->roam.configParam.enableVhtFor24GHz)
1111 pChanList->vht_24_en = true;
1112 }
1113 if ((pMac->roam.configParam.uCfgDot11Mode ==
1114 eCSR_CFG_DOT11_MODE_AUTO) ||
1115 (pMac->roam.configParam.uCfgDot11Mode ==
1116 eCSR_CFG_DOT11_MODE_11N) ||
1117 (pMac->roam.configParam.uCfgDot11Mode ==
1118 eCSR_CFG_DOT11_MODE_11N_ONLY)) {
1119 pChanList->ht_en = true;
1120 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121 msg.type = WMA_UPDATE_CHAN_LIST_REQ;
1122 msg.reserved = 0;
1123 msg.bodyptr = pChanList;
1124 pChanList->numChan = num_channel;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +05301125 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
1126 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08001127 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08001128 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301129 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001130 "%s: Failed to post msg to WMA", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301131 qdf_mem_free(pChanList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301132 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001133 }
1134
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301135 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136}
1137
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001138#ifdef QCA_SUPPORT_CP_STATS
1139static void csr_init_tl_stats(struct sAniSirGlobal *mac_ctx) {}
1140#else
1141static void csr_init_tl_stats(struct sAniSirGlobal *mac_ctx)
1142{
1143 mac_ctx->roam.tlStatsReqInfo.numClient = 0;
1144}
1145#endif /* QCA_SUPPORT_CP_STATS */
1146
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301147QDF_STATUS csr_start(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001148{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301149 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 uint32_t i;
1151
1152 do {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
1154 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_IDLE, i);
1155
1156 status = csr_roam_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301157 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158 break;
1159
1160 pMac->roam.sPendingCommands = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001161 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
1162 status = csr_neighbor_roam_init(pMac, i);
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001163 csr_init_tl_stats(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164 /* init the link quality indication also */
1165 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301166 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001167 sme_warn("csr_start: Couldn't Init HO control blk ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001168 break;
1169 }
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -08001170 /* Register with scan component */
1171 pMac->scan.requester_id = ucfg_scan_register_requester(
1172 pMac->psoc,
1173 "CSR", csr_scan_callback, pMac);
wadesongd5477662018-04-25 17:00:47 +08001174 ucfg_scan_set_enable(pMac->psoc, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001175 } while (0);
1176 return status;
1177}
1178
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301179QDF_STATUS csr_stop(tpAniSirGlobal pMac, tHalStopType stopType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180{
1181 uint32_t sessionId;
1182
wadesongd5477662018-04-25 17:00:47 +08001183 ucfg_scan_set_enable(pMac->psoc, false);
1184 ucfg_scan_unregister_requester(pMac->psoc, pMac->scan.requester_id);
1185
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301186 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
Krunal Soni8d184fa2017-11-20 21:52:05 -08001187 csr_roam_close_session(pMac, sessionId, true);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301188
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001189 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
1190 csr_neighbor_roam_close(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001191 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
1192 if (CSR_IS_SESSION_VALID(pMac, sessionId))
1193 csr_scan_flush_result(pMac);
1194
1195 /* Reset the domain back to the deault */
1196 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
1197
1198 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++) {
1199 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_STOP, sessionId);
Padma, Santhosh Kumar510f60c2017-12-07 16:58:41 +05301200 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
1201 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001202 }
1203
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301204 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205}
1206
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301207QDF_STATUS csr_ready(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301209 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210 /* If the gScanAgingTime is set to '0' then scan results aging timeout
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301211 * based on timer feature is not enabled
1212 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001213 status = csr_apply_channel_and_power_list(pMac);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301214 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001215 sme_err("csr_apply_channel_and_power_list failed during csr_ready with status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 status);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301217
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218 return status;
1219}
1220
1221void csr_set_default_dot11_mode(tpAniSirGlobal pMac)
1222{
1223 uint32_t wniDot11mode = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301224
1225 wniDot11mode = csr_translate_to_wni_cfg_dot11_mode(pMac,
1226 pMac->roam.configParam.uCfgDot11Mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 cfg_set_int(pMac, WNI_CFG_DOT11_MODE, wniDot11mode);
1228}
1229
1230void csr_set_global_cfgs(tpAniSirGlobal pMac)
1231{
1232
1233 cfg_set_int(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD,
1234 csr_get_frag_thresh(pMac));
1235 cfg_set_int(pMac, WNI_CFG_RTS_THRESHOLD, csr_get_rts_thresh(pMac));
1236 cfg_set_int(pMac, WNI_CFG_11D_ENABLED,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301237 ((pMac->roam.configParam.Is11hSupportEnabled) ?
1238 pMac->roam.configParam.Is11dSupportEnabled :
1239 pMac->roam.configParam.Is11dSupportEnabled));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 cfg_set_int(pMac, WNI_CFG_11H_ENABLED,
1241 pMac->roam.configParam.Is11hSupportEnabled);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301242 /* For now we will just use the 5GHz CB mode ini parameter to decide
1243 * whether CB supported or not in Probes when there is no session
1244 * Once session is established we will use the session related params
1245 * stored in PE session for CB mode
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246 */
1247 cfg_set_int(pMac, WNI_CFG_CHANNEL_BONDING_MODE,
1248 !!(pMac->roam.configParam.channelBondingMode5GHz));
1249 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
1250 pMac->roam.configParam.HeartbeatThresh24);
1251
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301252 /* Update the operating mode to configured value during
1253 * initialization, So that client can advertise full
1254 * capabilities in Probe request frame.
1255 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 csr_set_default_dot11_mode(pMac);
1257}
1258
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301259/**
1260 * csr_packetdump_timer_handler() - packet dump timer
1261 * handler
1262 * @pv: user data
1263 *
1264 * This function is used to handle packet dump timer
1265 *
1266 * Return: None
1267 *
1268 */
1269static void csr_packetdump_timer_handler(void *pv)
1270{
Abhishek Singh245182f2017-08-10 17:41:09 +05301271 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301272 "%s Invoking packetdump deregistration API", __func__);
1273 wlan_deregister_txrx_packetdump();
1274}
1275
1276/**
1277 * csr_packetdump_timer_stop() - stops packet dump timer
1278 *
1279 * This function is used to stop packet dump timer
1280 *
1281 * Return: None
1282 *
1283 */
1284void csr_packetdump_timer_stop(void)
1285{
1286 QDF_STATUS status;
1287 tHalHandle hal;
1288 tpAniSirGlobal mac;
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301289
1290 hal = cds_get_context(QDF_MODULE_ID_SME);
1291 if (hal == NULL) {
1292 QDF_ASSERT(0);
1293 return;
1294 }
1295
1296 mac = PMAC_STRUCT(hal);
1297 status = qdf_mc_timer_stop(&mac->roam.packetdump_timer);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301298 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001299 sme_err("cannot stop packetdump timer");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301300}
1301
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301302static QDF_STATUS csr_roam_open(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301304 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305 uint32_t i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301306 struct csr_roam_session *pSession;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301307
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 do {
1309 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
1310 pSession = CSR_GET_SESSION(pMac, i);
1311 pSession->roamingTimerInfo.pMac = pMac;
1312 pSession->roamingTimerInfo.sessionId =
1313 CSR_SESSION_ID_INVALID;
1314 }
1315 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
1316 pMac->roam.WaitForKeyTimerInfo.sessionId =
1317 CSR_SESSION_ID_INVALID;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301318 status = qdf_mc_timer_init(&pMac->roam.hTimerWaitForKey,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301319 QDF_TIMER_TYPE_SW,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301320 csr_roam_wait_for_key_time_out_handler,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 &pMac->roam.WaitForKeyTimerInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301322 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001323 sme_err("cannot allocate memory for WaitForKey time out timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 break;
1325 }
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301326 status = qdf_mc_timer_init(&pMac->roam.packetdump_timer,
1327 QDF_TIMER_TYPE_SW, csr_packetdump_timer_handler,
1328 pMac);
1329 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001330 sme_err("cannot allocate memory for packetdump timer");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301331 break;
1332 }
Padma, Santhosh Kumar510f60c2017-12-07 16:58:41 +05301333 spin_lock_init(&pMac->roam.roam_state_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 } while (0);
1335 return status;
1336}
1337
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301338static QDF_STATUS csr_roam_close(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339{
1340 uint32_t sessionId;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301341
1342 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
Krunal Soni8d184fa2017-11-20 21:52:05 -08001343 csr_roam_close_session(pMac, sessionId, true);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301344
Anurag Chouhan210db072016-02-22 18:42:15 +05301345 qdf_mc_timer_stop(&pMac->roam.hTimerWaitForKey);
1346 qdf_mc_timer_destroy(&pMac->roam.hTimerWaitForKey);
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301347 qdf_mc_timer_stop(&pMac->roam.packetdump_timer);
1348 qdf_mc_timer_destroy(&pMac->roam.packetdump_timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301349 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001350}
1351
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301352QDF_STATUS csr_roam_start(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353{
1354 (void)pMac;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301355 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356}
1357
1358void csr_roam_stop(tpAniSirGlobal pMac, uint32_t sessionId)
1359{
1360 csr_roam_stop_roaming_timer(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301361 /* deregister the clients requesting stats from PE/TL & also stop
1362 * the corresponding timers
1363 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001364 csr_roam_dereg_statistics_req(pMac);
1365}
1366
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301367QDF_STATUS csr_roam_get_connect_state(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 eCsrConnectState *pState)
1369{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301370 QDF_STATUS status = QDF_STATUS_E_INVAL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301371
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372 if (CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301373 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374 *pState = pMac->roam.roamSession[sessionId].connectState;
1375 }
1376 return status;
1377}
1378
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301379QDF_STATUS csr_roam_copy_connect_profile(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 uint32_t sessionId, tCsrRoamConnectedProfile *pProfile)
1381{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301382 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001383 uint32_t size = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301384 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385 tCsrRoamConnectedProfile *connected_prof;
1386
1387 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001388 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301389 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001390 }
1391 if (!pProfile) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001392 sme_err("profile not found");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301393 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394 }
1395
1396 if (pSession->pConnectBssDesc) {
1397 size = pSession->pConnectBssDesc->length +
1398 sizeof(pSession->pConnectBssDesc->length);
1399 if (size) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301400 pProfile->pBssDesc = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 if (NULL != pProfile->pBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301402 qdf_mem_copy(pProfile->pBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403 pSession->pConnectBssDesc,
1404 size);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301405 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301407 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408 }
1409 } else {
1410 pProfile->pBssDesc = NULL;
1411 }
1412 connected_prof = &(pSession->connectedProfile);
1413 pProfile->AuthType = connected_prof->AuthType;
1414 pProfile->EncryptionType = connected_prof->EncryptionType;
1415 pProfile->mcEncryptionType = connected_prof->mcEncryptionType;
1416 pProfile->BSSType = connected_prof->BSSType;
1417 pProfile->operationChannel = connected_prof->operationChannel;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301418 qdf_mem_copy(&pProfile->bssid, &connected_prof->bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301419 sizeof(struct qdf_mac_addr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301420 qdf_mem_copy(&pProfile->SSID, &connected_prof->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421 sizeof(tSirMacSSid));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 if (connected_prof->MDID.mdiePresent) {
1423 pProfile->MDID.mdiePresent = 1;
1424 pProfile->MDID.mobilityDomain =
1425 connected_prof->MDID.mobilityDomain;
1426 } else {
1427 pProfile->MDID.mdiePresent = 0;
1428 pProfile->MDID.mobilityDomain = 0;
1429 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430#ifdef FEATURE_WLAN_ESE
1431 pProfile->isESEAssoc = connected_prof->isESEAssoc;
1432 if (csr_is_auth_type_ese(connected_prof->AuthType)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301433 qdf_mem_copy(pProfile->eseCckmInfo.krk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 connected_prof->eseCckmInfo.krk,
1435 SIR_KRK_KEY_LEN);
1436#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301437 qdf_mem_copy(pProfile->eseCckmInfo.btk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438 connected_prof->eseCckmInfo.btk,
1439 SIR_BTK_KEY_LEN);
1440#endif
1441 pProfile->eseCckmInfo.reassoc_req_num =
1442 connected_prof->eseCckmInfo.reassoc_req_num;
1443 pProfile->eseCckmInfo.krk_plumbed =
1444 connected_prof->eseCckmInfo.krk_plumbed;
1445 }
1446#endif
Krunal Sonib2f13042015-11-02 18:41:08 -08001447#ifdef WLAN_FEATURE_11W
1448 pProfile->MFPEnabled = connected_prof->MFPEnabled;
1449 pProfile->MFPRequired = connected_prof->MFPRequired;
1450 pProfile->MFPCapable = connected_prof->MFPCapable;
1451#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452 }
1453 return status;
1454}
1455
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301456QDF_STATUS csr_roam_get_connect_profile(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457 tCsrRoamConnectedProfile *pProfile)
1458{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301459 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460
1461 if ((csr_is_conn_state_connected(pMac, sessionId)) ||
1462 (csr_is_conn_state_ibss(pMac, sessionId))) {
1463 if (pProfile) {
1464 status =
1465 csr_roam_copy_connect_profile(pMac, sessionId,
1466 pProfile);
1467 }
1468 }
1469 return status;
1470}
1471
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001472void csr_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473{
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001474 if (profile->pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301475 qdf_mem_free(profile->pBssDesc);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001476 if (profile->pAddIEAssoc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301477 qdf_mem_free(profile->pAddIEAssoc);
1478 qdf_mem_set(profile, sizeof(tCsrRoamConnectedProfile), 0);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001479 profile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480}
1481
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301482static QDF_STATUS csr_roam_free_connected_info(tpAniSirGlobal pMac,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301483 struct csr_roam_connectedinfo *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001484 pConnectedInfo)
1485{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301486 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301487
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488 if (pConnectedInfo->pbFrames) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301489 qdf_mem_free(pConnectedInfo->pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001490 pConnectedInfo->pbFrames = NULL;
1491 }
1492 pConnectedInfo->nBeaconLength = 0;
1493 pConnectedInfo->nAssocReqLength = 0;
1494 pConnectedInfo->nAssocRspLength = 0;
1495 pConnectedInfo->staId = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496 pConnectedInfo->nRICRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001497#ifdef FEATURE_WLAN_ESE
1498 pConnectedInfo->nTspecIeLength = 0;
1499#endif
1500 return status;
1501}
1502
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503void csr_release_command_roam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1504{
1505 csr_reinit_roam_cmd(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506}
1507
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301508void csr_release_command_wm_status_change(tpAniSirGlobal pMac,
1509 tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001510{
1511 csr_reinit_wm_status_change_cmd(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001512}
1513
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301514void csr_roam_substate_change(tpAniSirGlobal pMac,
1515 enum csr_roam_substate NewSubstate, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516{
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001517 sme_debug("CSR RoamSubstate: [ %s <== %s ]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 mac_trace_getcsr_roam_sub_state(NewSubstate),
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301519 mac_trace_getcsr_roam_sub_state(pMac->roam.
1520 curSubState[sessionId]));
1521 if (pMac->roam.curSubState[sessionId] == NewSubstate)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522 return;
Padma, Santhosh Kumar510f60c2017-12-07 16:58:41 +05301523 spin_lock(&pMac->roam.roam_state_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524 pMac->roam.curSubState[sessionId] = NewSubstate;
Padma, Santhosh Kumar510f60c2017-12-07 16:58:41 +05301525 spin_unlock(&pMac->roam.roam_state_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526}
1527
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301528enum csr_roam_state csr_roam_state_change(tpAniSirGlobal pMac,
1529 enum csr_roam_state NewRoamState,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301530 uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301532 enum csr_roam_state PreviousState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001534 sme_debug("CSR RoamState[%hu]: [ %s <== %s ]", sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 mac_trace_getcsr_roam_state(NewRoamState),
1536 mac_trace_getcsr_roam_state(pMac->roam.curState[sessionId]));
1537 PreviousState = pMac->roam.curState[sessionId];
1538
1539 if (NewRoamState != pMac->roam.curState[sessionId]) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301540 /* Whenever we transition OUT of the Roaming state,
1541 * clear the Roaming substate.
1542 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543 if (CSR_IS_ROAM_JOINING(pMac, sessionId)) {
1544 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
1545 sessionId);
1546 }
1547
1548 pMac->roam.curState[sessionId] = NewRoamState;
1549 }
1550 return PreviousState;
1551}
1552
1553void csr_assign_rssi_for_category(tpAniSirGlobal pMac, int8_t bestApRssi,
1554 uint8_t catOffset)
1555{
1556 int i;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001557
1558 sme_debug("best AP RSSI: %d cat offset: %d", bestApRssi, catOffset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559 if (catOffset) {
1560 pMac->roam.configParam.bCatRssiOffset = catOffset;
1561 for (i = 0; i < CSR_NUM_RSSI_CAT; i++) {
1562 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i -
1563 1] =
1564 (int)bestApRssi -
1565 pMac->roam.configParam.nSelect5GHzMargin -
1566 (int)(i * catOffset);
1567 }
1568 }
1569}
1570
1571static void init_config_param(tpAniSirGlobal pMac)
1572{
1573 int i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301574
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
1576 pMac->roam.configParam.channelBondingMode24GHz =
1577 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1578 pMac->roam.configParam.channelBondingMode5GHz =
1579 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
1580
1581 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_AUTO;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001582 pMac->roam.configParam.eBand = BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
1584 pMac->roam.configParam.FragmentationThreshold =
1585 eCSR_DOT11_FRAG_THRESH_DEFAULT;
1586 pMac->roam.configParam.HeartbeatThresh24 = 40;
1587 pMac->roam.configParam.HeartbeatThresh50 = 40;
1588 pMac->roam.configParam.Is11dSupportEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001589 pMac->roam.configParam.Is11eSupportEnabled = true;
1590 pMac->roam.configParam.Is11hSupportEnabled = true;
1591 pMac->roam.configParam.RTSThreshold = 2346;
1592 pMac->roam.configParam.shortSlotTime = true;
1593 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1594 pMac->roam.configParam.ProprietaryRatesEnabled = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301595 for (i = 0; i < CSR_NUM_RSSI_CAT; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 pMac->roam.configParam.BssPreferValue[i] = i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 csr_assign_rssi_for_category(pMac, CSR_BEST_RSSI_VALUE,
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08001598 CSR_DEFAULT_RSSI_DB_GAP);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = false;
1600 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1601 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1602 pMac->roam.configParam.nPassiveMaxChnTime =
1603 CSR_PASSIVE_MAX_CHANNEL_TIME;
1604 pMac->roam.configParam.nPassiveMinChnTime =
1605 CSR_PASSIVE_MIN_CHANNEL_TIME;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606 pMac->roam.configParam.nActiveMaxChnTimeConc =
1607 CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1608 pMac->roam.configParam.nActiveMinChnTimeConc =
1609 CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1610 pMac->roam.configParam.nPassiveMaxChnTimeConc =
1611 CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1612 pMac->roam.configParam.nPassiveMinChnTimeConc =
1613 CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1614 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301615 pMac->roam.configParam.min_rest_time_conc = CSR_MIN_REST_TIME_CONC;
1616 pMac->roam.configParam.idle_time_conc = CSR_IDLE_TIME_CONC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301618 pMac->roam.configParam.allow_tpc_from_ap = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619 pMac->roam.configParam.statsReqPeriodicity =
1620 CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1621 pMac->roam.configParam.statsReqPeriodicityInPS =
1622 CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1624 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold =
1625 120;
Varun Reddy Yeturu168134f2017-06-26 13:46:05 -07001626 pMac->roam.configParam.neighborRoamConfig.rssi_thresh_offset_5g = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001627 pMac->roam.configParam.neighborRoamConfig.nOpportunisticThresholdDiff =
1628 30;
1629 pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff = 5;
1630 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1631 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1632 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod =
1633 200;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05301634 pMac->roam.configParam.neighborRoamConfig.
1635 neighbor_scan_min_timer_period = 200;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1637 numChannels = 3;
1638 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1639 channelList[0] = 1;
1640 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1641 channelList[1] = 6;
1642 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1643 channelList[2] = 11;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301644 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod
1645 = 20000; /* 20 seconds */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
1647 pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt = 10;
1648 pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt = 10;
1649 pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight = 14;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 pMac->roam.configParam.nVhtChannelWidth =
1651 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652
1653 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1654 pMac->roam.configParam.fScanTwice = false;
1655
1656 /* Remove this code once SLM_Sessionization is supported */
1657 /* BMPS_WORKAROUND_NOT_NEEDED */
1658 pMac->roam.configParam.doBMPSWorkaround = 0;
1659
1660 pMac->roam.configParam.nInitialDwellTime = 0;
1661 pMac->roam.configParam.initial_scan_no_dfs_chnl = 0;
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07001662 pMac->roam.configParam.csr_mawc_config.mawc_enabled = true;
1663 pMac->roam.configParam.csr_mawc_config.mawc_roam_enabled = true;
1664 pMac->roam.configParam.csr_mawc_config.mawc_roam_traffic_threshold =
1665 MAWC_ROAM_TRAFFIC_THRESHOLD_DEFAULT;
1666 pMac->roam.configParam.csr_mawc_config.mawc_roam_ap_rssi_threshold =
1667 MAWC_ROAM_AP_RSSI_THRESHOLD_DEFAULT;
1668 pMac->roam.configParam.csr_mawc_config.mawc_roam_rssi_high_adjust =
1669 MAWC_ROAM_RSSI_HIGH_ADJUST_DEFAULT;
1670 pMac->roam.configParam.csr_mawc_config.mawc_roam_rssi_low_adjust =
1671 MAWC_ROAM_RSSI_LOW_ADJUST_DEFAULT;
Himanshu Agarwal8bcec572017-09-28 11:54:37 +05301672
1673 qdf_mem_zero(&pMac->roam.configParam.bss_score_params,
1674 sizeof(struct sir_score_config));
1675 pMac->roam.configParam.bss_score_params.weight_cfg.rssi_weightage =
1676 RSSI_WEIGHTAGE;
1677 pMac->roam.configParam.bss_score_params.weight_cfg.ht_caps_weightage =
1678 HT_CAPABILITY_WEIGHTAGE;
1679 pMac->roam.configParam.bss_score_params.weight_cfg.vht_caps_weightage =
1680 VHT_CAP_WEIGHTAGE;
1681 pMac->roam.configParam.bss_score_params.
1682 weight_cfg.chan_width_weightage = CHAN_WIDTH_WEIGHTAGE;
1683 pMac->roam.configParam.bss_score_params.
1684 weight_cfg.chan_band_weightage = CHAN_BAND_WEIGHTAGE;
1685 pMac->roam.configParam.bss_score_params.weight_cfg.nss_weightage =
1686 NSS_WEIGHTAGE;
1687 pMac->roam.configParam.bss_score_params.weight_cfg.
1688 beamforming_cap_weightage = BEAMFORMING_CAP_WEIGHTAGE;
1689 pMac->roam.configParam.bss_score_params.weight_cfg.pcl_weightage =
1690 PCL_WEIGHT;
1691 pMac->roam.configParam.bss_score_params.weight_cfg.
1692 channel_congestion_weightage = CHANNEL_CONGESTION_WEIGHTAGE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693}
1694
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001695enum band_info csr_get_current_band(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696{
1697 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 return pMac->roam.configParam.bandCapability;
1700}
1701
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301702/* This function flushes the roam scan cache */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301703QDF_STATUS csr_flush_cfg_bg_scan_roam_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 uint8_t sessionId)
1705{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301706 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301707
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
1709 &pMac->roam.neighborRoamInfo[sessionId];
1710
1711 /* Free up the memory first (if required) */
1712 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301713 qdf_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 ChannelList);
1715 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
1716 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1717 }
1718 return status;
1719}
1720
1721/*
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301722 * This function flushes the roam scan cache and creates fresh cache
1723 * based on the input channel list
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301725QDF_STATUS csr_create_bg_scan_roam_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001726 uint8_t sessionId,
1727 const uint8_t *pChannelList,
1728 const uint8_t numChannels)
1729{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301730 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
1732 &pMac->roam.neighborRoamInfo[sessionId];
1733
1734 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1735
1736 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301737 qdf_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 numOfChannels);
1739
1740 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001741 sme_err("Memory Allocation for CFG Channel List failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001742 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301743 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001744 }
1745
1746 /* Update the roam global structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301747 qdf_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 pChannelList,
1749 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1750 return status;
1751}
1752
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001754#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001755/**
1756 * csr_create_roam_scan_channel_list() - create roam scan channel list
1757 * @pMac: Global mac pointer
1758 * @sessionId: session id
1759 * @pChannelList: pointer to channel list
1760 * @numChannels: number of channels
1761 * @eBand: band enumeration
1762 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001763 * This function modifies the roam scan channel list as per AP neighbor
1764 * report; AP neighbor report may be empty or may include only other AP
1765 * channels; in any case, we merge the channel list with the learned occupied
1766 * channels list.
1767 * if the band is 2.4G, then make sure channel list contains only 2.4G
1768 * valid channels if the band is 5G, then make sure channel list contains
1769 * only 5G valid channels
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001770 *
1771 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301773QDF_STATUS csr_create_roam_scan_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 uint8_t sessionId,
1775 uint8_t *pChannelList,
1776 uint8_t numChannels,
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001777 const enum band_info eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301779 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301780
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 tpCsrNeighborRoamControlInfo pNeighborRoamInfo
1782 = &pMac->roam.neighborRoamInfo[sessionId];
1783 uint8_t outNumChannels = 0;
1784 uint8_t inNumChannels = numChannels;
1785 uint8_t *inPtr = pChannelList;
1786 uint8_t i = 0;
1787 uint8_t ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
1788 uint8_t tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
1789 uint8_t mergedOutputNumOfChannels = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301790
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791 tpCsrChannelInfo currChannelListInfo
1792 = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1793 /*
1794 * Create a Union of occupied channel list learnt by the DUT along
1795 * with the Neighbor report Channels. This increases the chances of
1796 * the DUT to get a candidate AP while roaming even if the Neighbor
1797 * Report is not able to provide sufficient information.
1798 */
1799 if (pMac->scan.occupiedChannels[sessionId].numChannels) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301800 csr_neighbor_roam_merge_channel_lists(pMac, &pMac->scan.
1801 occupiedChannels[sessionId].
1802 channelList[0], pMac->scan.
1803 occupiedChannels[sessionId].
1804 numChannels, inPtr,
1805 inNumChannels,
1806 &mergedOutputNumOfChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 inNumChannels = mergedOutputNumOfChannels;
1808 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001809 if (BAND_2G == eBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 for (i = 0; i < inNumChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001811 if (WLAN_REG_IS_24GHZ_CH(inPtr[i])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812 && csr_roam_is_channel_valid(pMac, inPtr[i])) {
1813 ChannelList[outNumChannels++] = inPtr[i];
1814 }
1815 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001816 } else if (BAND_5G == eBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 for (i = 0; i < inNumChannels; i++) {
1818 /* Add 5G Non-DFS channel */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001819 if (WLAN_REG_IS_5GHZ_CH(inPtr[i]) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820 csr_roam_is_channel_valid(pMac, inPtr[i]) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001821 !wlan_reg_is_dfs_ch(pMac->pdev, inPtr[i])) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822 ChannelList[outNumChannels++] = inPtr[i];
1823 }
1824 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001825 } else if (BAND_ALL == eBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 for (i = 0; i < inNumChannels; i++) {
1827 if (csr_roam_is_channel_valid(pMac, inPtr[i]) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001828 !wlan_reg_is_dfs_ch(pMac->pdev, inPtr[i])) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 ChannelList[outNumChannels++] = inPtr[i];
1830 }
1831 }
1832 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301833 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 "Invalid band, No operation carried out (Band %d)",
1835 eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301836 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 }
1838 /*
1839 * if roaming within band is enabled, then select only the
1840 * in band channels .
1841 * This is required only if the band capability is set to ALL,
1842 * E.g., if band capability is only 2.4G then all the channels in the
1843 * list are already filtered for 2.4G channels, hence ignore this check
1844 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001845 if ((BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846 csr_neighbor_roam_channels_filter_by_current_band(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301847 sessionId,
1848 ChannelList,
1849 outNumChannels,
1850 tmpChannelList,
1851 &outNumChannels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301852 qdf_mem_copy(ChannelList, tmpChannelList, outNumChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 }
1854 /* Prepare final roam scan channel list */
1855 if (outNumChannels) {
1856 /* Clear the channel list first */
1857 if (NULL != currChannelListInfo->ChannelList) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301858 qdf_mem_free(currChannelListInfo->ChannelList);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 currChannelListInfo->ChannelList = NULL;
1860 currChannelListInfo->numOfChannels = 0;
1861 }
1862 currChannelListInfo->ChannelList
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301863 = qdf_mem_malloc(outNumChannels * sizeof(uint8_t));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 if (NULL == currChannelListInfo->ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301865 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866 "Failed to allocate memory for roam scan channel list");
1867 currChannelListInfo->numOfChannels = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301868 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001869 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301870 qdf_mem_copy(currChannelListInfo->ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871 ChannelList, outNumChannels);
1872 }
1873 return status;
1874}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001875
1876/**
1877 * csr_roam_is_ese_assoc() - is this ese association
1878 * @mac_ctx: Global MAC context
1879 * @session_id: session identifier
1880 *
1881 * Returns whether the current association is a ESE assoc or not.
1882 *
1883 * Return: true if ese association; false otherwise
1884 */
Selvaraj, Sridharbc950df2016-07-05 15:35:47 +05301885bool csr_roam_is_ese_assoc(tpAniSirGlobal mac_ctx, uint32_t session_id)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001886{
Srinivas Girigowda18dcf3d2015-12-16 18:11:48 -08001887 return mac_ctx->roam.neighborRoamInfo[session_id].isESEAssoc;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001888}
1889
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001890
1891/**
1892 * csr_roam_is_ese_ini_feature_enabled() - is ese feature enabled
1893 * @mac_ctx: Global MAC context
1894 *
1895 * Return: true if ese feature is enabled; false otherwise
1896 */
1897bool csr_roam_is_ese_ini_feature_enabled(tpAniSirGlobal pMac)
1898{
1899 return pMac->roam.configParam.isEseIniFeatureEnabled;
1900}
1901
1902/**
1903 * csr_tsm_stats_rsp_processor() - tsm stats response processor
1904 * @pMac: Global MAC context
1905 * @pMsg: Message pointer
1906 *
1907 * Return: None
1908 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -07001909static void csr_tsm_stats_rsp_processor(tpAniSirGlobal pMac, void *pMsg)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001910{
1911 tAniGetTsmStatsRsp *pTsmStatsRsp = (tAniGetTsmStatsRsp *) pMsg;
1912
1913 if (NULL != pTsmStatsRsp) {
1914 /*
1915 * Get roam Rssi request is backed up and passed back
1916 * to the response, Extract the request message
1917 * to fetch callback.
1918 */
1919 tpAniGetTsmStatsReq reqBkp
1920 = (tAniGetTsmStatsReq *) pTsmStatsRsp->tsmStatsReq;
1921
1922 if (NULL != reqBkp) {
1923 if (NULL != reqBkp->tsmStatsCallback) {
1924 ((tCsrTsmStatsCallback)
1925 (reqBkp->tsmStatsCallback))(pTsmStatsRsp->
1926 tsmMetrics,
1927 pTsmStatsRsp->
1928 staId,
1929 reqBkp->
1930 pDevContext);
1931 reqBkp->tsmStatsCallback = NULL;
1932 }
1933 qdf_mem_free(reqBkp);
1934 pTsmStatsRsp->tsmStatsReq = NULL;
1935 } else {
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001936 if (NULL != reqBkp) {
1937 qdf_mem_free(reqBkp);
1938 pTsmStatsRsp->tsmStatsReq = NULL;
1939 }
1940 }
1941 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001942 sme_err("pTsmStatsRsp is NULL");
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001943 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001944}
1945
1946/**
1947 * csr_send_ese_adjacent_ap_rep_ind() - ese send adjacent ap report
1948 * @pMac: Global MAC context
1949 * @pSession: Session pointer
1950 *
1951 * Return: None
1952 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -07001953static void csr_send_ese_adjacent_ap_rep_ind(tpAniSirGlobal pMac,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05301954 struct csr_roam_session *pSession)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001955{
1956 uint32_t roamTS2 = 0;
Jeff Johnson172237b2017-11-07 15:32:59 -08001957 struct csr_roam_info roamInfo;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001958 tpPESession pSessionEntry = NULL;
1959 uint8_t sessionId = CSR_SESSION_ID_INVALID;
1960
1961 if (NULL == pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001962 sme_err("pSession is NULL");
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001963 return;
1964 }
1965
1966 roamTS2 = qdf_mc_timer_get_system_time();
1967 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001968 sme_debug("Bssid(" MAC_ADDRESS_STR ") Roaming Delay(%u ms)",
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001969 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid.bytes),
1970 roamInfo.tsmRoamDelay);
1971
1972 pSessionEntry = pe_find_session_by_bssid(pMac,
1973 pSession->connectedProfile.bssid.bytes,
1974 &sessionId);
1975 if (NULL == pSessionEntry) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001976 sme_err("session %d not found", sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001977 return;
1978 }
1979
1980 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly
1981 = roamInfo.tsmRoamDelay;
1982
1983 csr_roam_call_callback(pMac, pSession->sessionId, &roamInfo,
1984 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
1985}
1986
1987/**
1988 * csr_get_tsm_stats() - get tsm stats
1989 * @pMac: Global MAC context
1990 * @callback: TSM stats callback
1991 * @staId: Station id
1992 * @bssId: bssid
1993 * @pContext: pointer to context
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001994 * @tid: traffic id
1995 *
1996 * Return: QDF_STATUS enumeration
1997 */
1998QDF_STATUS csr_get_tsm_stats(tpAniSirGlobal pMac,
1999 tCsrTsmStatsCallback callback,
2000 uint8_t staId,
2001 struct qdf_mac_addr bssId,
Jeff Johnson30f84552017-09-13 14:55:25 -07002002 void *pContext, uint8_t tid)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002003{
2004 QDF_STATUS status = QDF_STATUS_SUCCESS;
2005 tAniGetTsmStatsReq *pMsg = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302006
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002007 pMsg = qdf_mem_malloc(sizeof(tAniGetTsmStatsReq));
2008 if (!pMsg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002009 sme_err(
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002010 "csr_get_tsm_stats: failed to allocate mem for req");
2011 return QDF_STATUS_E_NOMEM;
2012 }
2013 /* need to initiate a stats request to PE */
2014 pMsg->msgType = eWNI_SME_GET_TSM_STATS_REQ;
2015 pMsg->msgLen = (uint16_t) sizeof(tAniGetTsmStatsReq);
2016 pMsg->staId = staId;
2017 pMsg->tid = tid;
2018 qdf_copy_macaddr(&pMsg->bssId, &bssId);
2019 pMsg->tsmStatsCallback = callback;
2020 pMsg->pDevContext = pContext;
Rajeev Kumard138ac52017-01-30 18:38:37 -08002021 status = umac_send_mb_message_to_mac(pMsg);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002022 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002023 sme_debug("csr_get_tsm_stats: failed to send down the rssi req");
2024 /* pMsg is freed by cds_send_mb_message_to_mac */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002025 status = QDF_STATUS_E_FAILURE;
2026 }
2027 return status;
2028}
2029
Paul Zhangc3fc0a82018-01-09 16:38:20 +08002030
2031#if defined(WLAN_FEATURE_HOST_ROAM) || defined(WLAN_FEATURE_ROAM_OFFLOAD)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002032/**
2033 * csr_fetch_ch_lst_from_received_list() - fetch channel list from received list
2034 * and update req msg
Jeff Johnson60ed45a2018-05-06 15:28:49 -07002035 * parameters
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002036 * @mac_ctx: global mac ctx
2037 * @roam_info: roam info struct
2038 * @curr_ch_lst_info: current channel list info
2039 * @req_buf: out param, roam offload scan request packet
2040 *
2041 * Return: void
2042 */
2043static void
2044csr_fetch_ch_lst_from_received_list(tpAniSirGlobal mac_ctx,
2045 tpCsrNeighborRoamControlInfo roam_info,
2046 tpCsrChannelInfo curr_ch_lst_info,
2047 tSirRoamOffloadScanReq *req_buf)
2048{
2049 uint8_t i = 0;
2050 uint8_t num_channels = 0;
2051 uint8_t *ch_lst = NULL;
Agrawal Ashish21ba2572016-09-03 16:40:10 +05302052 uint16_t unsafe_chan[NUM_CHANNELS];
2053 uint16_t unsafe_chan_cnt = 0;
2054 uint16_t cnt = 0;
2055 bool is_unsafe_chan;
2056 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
2057
2058 if (!qdf_ctx) {
2059 cds_err("qdf_ctx is NULL");
2060 return;
2061 }
2062 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
2063 &unsafe_chan_cnt,
2064 sizeof(unsafe_chan));
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002065
2066 if (curr_ch_lst_info->numOfChannels == 0)
2067 return;
2068
2069 ch_lst = curr_ch_lst_info->ChannelList;
2070 for (i = 0; i < curr_ch_lst_info->numOfChannels; i++) {
Agrawal Ashish21ba2572016-09-03 16:40:10 +05302071 if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
2072 (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
2073 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002074 (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002075 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
2076 ("ignoring dfs channel %d"), *ch_lst);
Agrawal Ashish21ba2572016-09-03 16:40:10 +05302077 ch_lst++;
2078 continue;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002079 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +05302080
2081 if (mac_ctx->roam.configParam.sta_roam_policy.
2082 skip_unsafe_channels &&
2083 unsafe_chan_cnt) {
2084 is_unsafe_chan = false;
2085 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
2086 if (unsafe_chan[cnt] == *ch_lst) {
2087 is_unsafe_chan = true;
2088 break;
2089 }
2090 }
2091 if (is_unsafe_chan) {
2092 QDF_TRACE(QDF_MODULE_ID_SME,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002093 QDF_TRACE_LEVEL_DEBUG,
2094 ("ignoring unsafe channel %d"),
Agrawal Ashish21ba2572016-09-03 16:40:10 +05302095 *ch_lst);
2096 ch_lst++;
2097 continue;
2098 }
2099 }
2100 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
2101 *ch_lst;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002102 ch_lst++;
2103 }
2104 req_buf->ConnectedNetwork.ChannelCount = num_channels;
2105 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
2106}
Paul Zhangc3fc0a82018-01-09 16:38:20 +08002107#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002108
2109/**
2110 * csr_set_cckm_ie() - set CCKM IE
2111 * @pMac: Global MAC context
2112 * @sessionId: session identifier
2113 * @pCckmIe: Pointer to input CCKM IE data
2114 * @ccKmIeLen: Length of @pCckmIe
2115 *
2116 * This function stores the CCKM IE passed by the supplicant
2117 * in a place holder data structure and this IE will be packed inside
2118 * reassociation request
2119 *
2120 * Return: QDF_STATUS enumeration
2121 */
2122QDF_STATUS csr_set_cckm_ie(tpAniSirGlobal pMac, const uint8_t sessionId,
2123 const uint8_t *pCckmIe, const uint8_t ccKmIeLen)
2124{
2125 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05302126 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302127
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002128 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002129 sme_err("session %d not found", sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002130 return QDF_STATUS_E_FAILURE;
2131 }
2132 qdf_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
2133 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
2134 return status;
2135}
2136
2137/**
2138 * csr_roam_read_tsf() - read TSF
2139 * @pMac: Global MAC context
2140 * @sessionId: session identifier
2141 * @pTimestamp: output TSF timestamp
2142 *
2143 * This function reads the TSF; and also add the time elapsed since
2144 * last beacon or probe response reception from the hand off AP to arrive at
2145 * the latest TSF value.
2146 *
2147 * Return: QDF_STATUS enumeration
2148 */
2149QDF_STATUS csr_roam_read_tsf(tpAniSirGlobal pMac, uint8_t *pTimestamp,
2150 uint8_t sessionId)
2151{
2152 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridhar258594c2016-07-31 15:17:45 +05302153 tCsrNeighborRoamBSSInfo handoffNode = {{0} };
Arun Khandavalli8a711cb2017-01-03 20:23:56 +05302154 uint64_t timer_diff = 0;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002155 uint32_t timeStamp[2];
2156 tpSirBssDescription pBssDescription = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302157
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002158 csr_neighbor_roam_get_handoff_ap_info(pMac, &handoffNode, sessionId);
2159 pBssDescription = handoffNode.pBssDescription;
Arun Khandavalli8a711cb2017-01-03 20:23:56 +05302160 /* Get the time diff in nano seconds */
2161 timer_diff = (qdf_get_monotonic_boottime_ns() -
2162 pBssDescription->scansystimensec);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002163 /* Convert msec to micro sec timer */
Sarada Prasanna Garnayakf21c2962017-03-08 20:42:38 +05302164 timer_diff = do_div(timer_diff, SYSTEM_TIME_NSEC_TO_USEC);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002165 timeStamp[0] = pBssDescription->timeStamp[0];
2166 timeStamp[1] = pBssDescription->timeStamp[1];
2167 update_cckmtsf(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
2168 qdf_mem_copy(pTimestamp, (void *)&timeStamp[0], sizeof(uint32_t) * 2);
2169 return status;
2170}
2171
2172#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002173
Mahesh Kumar Kalikot Veetil40575112016-09-09 16:57:08 -07002174/**
2175 * csr_roam_is_roam_offload_scan_enabled() - is roam offload enabled
2176 * @mac_ctx: Global MAC context
2177 *
2178 * Returns whether firmware based background scan is currently enabled or not.
2179 *
2180 * Return: true if roam offload scan enabled; false otherwise
2181 */
2182bool csr_roam_is_roam_offload_scan_enabled(tpAniSirGlobal mac_ctx)
2183{
2184 return mac_ctx->roam.configParam.isRoamOffloadScanEnabled;
2185}
2186
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002187QDF_STATUS csr_set_band(tHalHandle hHal, uint8_t sessionId,
2188 enum band_info eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002189{
2190 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302191 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302192
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002193 if (CSR_IS_PHY_MODE_A_ONLY(pMac) && (eBand == BAND_2G)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 /* DOT11 mode configured to 11a only and received
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302195 * request to change the band to 2.4 GHz
2196 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302197 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 "failed to set band cfg80211 = %u, band = %u",
2199 pMac->roam.configParam.uCfgDot11Mode, eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302200 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201 }
2202 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08002203 CSR_IS_PHY_MODE_G_ONLY(pMac)) && (eBand == BAND_5G)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002204 /* DOT11 mode configured to 11b/11g only and received
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302205 * request to change the band to 5 GHz
2206 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302207 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208 "failed to set band dot11mode = %u, band = %u",
2209 pMac->roam.configParam.uCfgDot11Mode, eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302210 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 }
Abhishek Singh245182f2017-08-10 17:41:09 +05302212 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
2214 pMac->roam.configParam.eBand = eBand;
2215 pMac->roam.configParam.bandCapability = eBand;
2216
2217 status = csr_get_channel_and_power_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302218 if (QDF_STATUS_SUCCESS == status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002219 csr_apply_channel_and_power_list(pMac);
2220 return status;
2221}
2222
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302223/* The funcns csr_convert_cb_ini_value_to_phy_cb_state and
2224 * csr_convert_phy_cb_state_to_ini_value have been introduced
2225 * to convert the ini value to the ENUM used in csr and MAC for CB state
2226 * Ideally we should have kept the ini value and enum value same and
2227 * representing the same cb values as in 11n standard i.e.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 * Set to 1 (SCA) if the secondary channel is above the primary channel
2229 * Set to 3 (SCB) if the secondary channel is below the primary channel
2230 * Set to 0 (SCN) if no secondary channel is present
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302231 * However, since our driver is already distributed we will keep the ini
2232 * definition as it is which is:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 * 0 - secondary none
2234 * 1 - secondary LOW
2235 * 2 - secondary HIGH
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302236 * and convert to enum value used within the driver in
2237 * csr_change_default_config_param using this funcn
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238 * The enum values are as follows:
2239 * PHY_SINGLE_CHANNEL_CENTERED = 0
2240 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
2241 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
2242 */
2243ePhyChanBondState csr_convert_cb_ini_value_to_phy_cb_state(uint32_t cbIniValue)
2244{
2245
2246 ePhyChanBondState phyCbState;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302247
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002248 switch (cbIniValue) {
2249 /* secondary none */
2250 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
2251 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
2252 break;
2253 /* secondary LOW */
2254 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
2255 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
2256 break;
2257 /* secondary HIGH */
2258 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
2259 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
2260 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002261 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
2262 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
2263 break;
2264 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
2265 phyCbState =
2266 PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
2267 break;
2268 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
2269 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
2270 break;
2271 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
2272 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
2273 break;
2274 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
2275 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
2276 break;
2277 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
2278 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
2279 break;
2280 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
2281 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
2282 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283 default:
2284 /* If an invalid value is passed, disable CHANNEL BONDING */
2285 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
2286 break;
2287 }
2288 return phyCbState;
2289}
2290
Jeff Johnson29e2ca12016-10-14 12:50:38 -07002291static
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292uint32_t csr_convert_phy_cb_state_to_ini_value(ePhyChanBondState phyCbState)
2293{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294 uint32_t cbIniValue;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302295
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296 switch (phyCbState) {
2297 /* secondary none */
2298 case PHY_SINGLE_CHANNEL_CENTERED:
2299 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
2300 break;
2301 /* secondary LOW */
2302 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
2303 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
2304 break;
2305 /* secondary HIGH */
2306 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
2307 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
2308 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
2310 cbIniValue =
2311 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
2312 break;
2313 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
2314 cbIniValue =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302315 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002316 break;
2317 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
2318 cbIniValue =
2319 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
2320 break;
2321 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
2322 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
2323 break;
2324 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
2325 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
2326 break;
2327 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
2328 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
2329 break;
2330 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
2331 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
2332 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002333 default:
2334 /* return some invalid value */
2335 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
2336 break;
2337 }
2338 return cbIniValue;
2339}
2340
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08002341#ifdef WLAN_FEATURE_11AX
2342/**
2343 * csr_update_he_config_param() - Update MAC context with HE config param
2344 * @mac_ctx: pointer to MAC context
2345 * @param: pointer to CSR config params
2346 *
2347 * Return: None
2348 */
2349static void csr_update_he_config_param(tpAniSirGlobal mac_ctx,
2350 tCsrConfigParam *param)
2351{
2352 mac_ctx->roam.configParam.enable_ul_ofdma = param->enable_ul_ofdma;
2353 mac_ctx->roam.configParam.enable_ul_mimo = param->enable_ul_mimo;
2354}
2355
2356/**
2357 * csr_get_he_config_param() - Get HE config param from MAC context
2358 * @param: pointer to CSR config params
2359 * @mac_ctx: pointer to MAC context
2360 *
2361 * Return: None
2362 */
2363static void csr_get_he_config_param(tCsrConfigParam *param,
2364 tpAniSirGlobal mac_ctx)
2365{
2366 param->enable_ul_ofdma = mac_ctx->roam.configParam.enable_ul_ofdma;
2367 param->enable_ul_mimo = mac_ctx->roam.configParam.enable_ul_mimo;
2368}
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002369
2370
2371/**
2372 * csr_join_req_copy_he_cap() - Copy HE cap into CSR Join Req
2373 * @csr_join_req: pointer to CSR Join Req
2374 * @session: pointer to CSR session
2375 *
2376 * Return: None
2377 */
2378static void csr_join_req_copy_he_cap(tSirSmeJoinReq *csr_join_req,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05302379 struct csr_roam_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002380{
2381 qdf_mem_copy(&csr_join_req->he_config, &session->he_config,
2382 sizeof(session->he_config));
2383}
2384
2385/**
2386 * csr_start_bss_copy_he_cap() - Copy HE cap into CSR Join Req
2387 * @req: pointer to START BSS Req
2388 * @session: pointer to CSR session
2389 *
2390 * Return: None
2391 */
2392static void csr_start_bss_copy_he_cap(tSirSmeStartBssReq *req,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05302393 struct csr_roam_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002394{
2395 qdf_mem_copy(&req->he_config, &session->he_config,
2396 sizeof(session->he_config));
2397}
2398
Kiran Kumar Lokere44a29432018-01-24 16:10:30 -08002399void csr_update_session_he_cap(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05302400 struct csr_roam_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002401{
2402 uint32_t value = 0;
Naveen Rawatd8feac12017-09-08 15:08:39 -07002403 tDot11fIEhe_cap *he_cap = &session->he_config;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002404
2405 he_cap->present = true;
2406
2407 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_CONTROL, &value);
2408 he_cap->htc_he = value;
2409 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TWT_REQUESTOR, &value);
2410 he_cap->twt_request = value;
2411 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TWT_RESPONDER, &value);
2412 he_cap->twt_responder = value;
2413 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_FRAGMENTATION, &value);
2414 he_cap->fragmentation = value;
2415 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MAX_FRAG_MSDU, &value);
2416 he_cap->max_num_frag_msdu = value;
2417 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MIN_FRAG_SIZE, &value);
2418 he_cap->min_frag_size = value;
2419 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TRIG_PAD, &value);
2420 he_cap->trigger_frm_mac_pad = value;
2421 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MTID_AGGR, &value);
2422 he_cap->multi_tid_aggr = value;
2423 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_LINK_ADAPTATION, &value);
2424 he_cap->he_link_adaptation = value;
2425 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_ALL_ACK, &value);
2426 he_cap->all_ack = value;
2427 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_UL_MU_RSP_SCHEDULING, &value);
2428 he_cap->ul_mu_rsp_sched = value;
2429 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_BUFFER_STATUS_RPT, &value);
2430 he_cap->a_bsr = value;
2431 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_BCAST_TWT, &value);
2432 he_cap->broadcast_twt = value;
2433 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_BA_32BIT, &value);
2434 he_cap->ba_32bit_bitmap = value;
2435 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MU_CASCADING, &value);
2436 he_cap->mu_cascade = value;
2437 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MULTI_TID, &value);
2438 he_cap->ack_enabled_multitid = value;
2439 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_DL_MU_BA, &value);
2440 he_cap->dl_mu_ba = value;
2441 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_OMI, &value);
2442 he_cap->omi_a_ctrl = value;
2443 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_OFDMA_RA, &value);
2444 he_cap->ofdma_ra = value;
2445 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MAX_AMPDU_LEN, &value);
2446 he_cap->max_ampdu_len = value;
2447 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_AMSDU_FRAG, &value);
2448 he_cap->amsdu_frag = value;
2449 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_FLEX_TWT_SCHED, &value);
2450 he_cap->flex_twt_sched = value;
2451 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_RX_CTRL, &value);
2452 he_cap->rx_ctrl_frame = value;
2453 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_BSRP_AMPDU_AGGR, &value);
2454 he_cap->bsrp_ampdu_aggr = value;
2455 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_QTP, &value);
2456 he_cap->qtp = value;
2457 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_A_BQR, &value);
2458 he_cap->a_bqr = value;
Naveen Rawat4051b022017-09-08 16:17:54 -07002459 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_SR_RESPONDER, &value);
2460 he_cap->sr_responder = value;
2461 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_NDP_FEEDBACK_SUPP, &value);
2462 he_cap->ndp_feedback_supp = value;
2463 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_OPS_SUPP, &value);
2464 he_cap->ops_supp = value;
Naveen Rawatfc530312017-10-23 14:34:12 -07002465 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_AMSDU_IN_AMPDU, &value);
2466 he_cap->amsdu_in_ampdu = value;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002467
2468 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_DUAL_BAND, &value);
2469 he_cap->dual_band = value;
2470 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_CHAN_WIDTH, &value);
Naveen Rawataeca1b92017-10-16 16:55:31 -07002471 he_cap->chan_width_0 = HE_CH_WIDTH_GET_BIT(value, 0);
2472 he_cap->chan_width_1 = HE_CH_WIDTH_GET_BIT(value, 1);
2473 he_cap->chan_width_2 = HE_CH_WIDTH_GET_BIT(value, 2);
2474 he_cap->chan_width_3 = HE_CH_WIDTH_GET_BIT(value, 3);
2475 he_cap->chan_width_4 = HE_CH_WIDTH_GET_BIT(value, 4);
2476 he_cap->chan_width_5 = HE_CH_WIDTH_GET_BIT(value, 5);
2477 he_cap->chan_width_6 = HE_CH_WIDTH_GET_BIT(value, 6);
2478
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002479 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_RX_PREAM_PUNC, &value);
2480 he_cap->rx_pream_puncturing = value;
2481 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_CLASS_OF_DEVICE, &value);
2482 he_cap->device_class = value;
2483 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_LDPC, &value);
2484 he_cap->ldpc_coding = value;
2485 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_LTF_PPDU, &value);
Naveen Rawat4051b022017-09-08 16:17:54 -07002486 he_cap->he_1x_ltf_800_gi_ppdu = value;
Naveen Rawatfc530312017-10-23 14:34:12 -07002487 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MIDAMBLE_RX_MAX_NSTS, &value);
2488 he_cap->midamble_rx_max_nsts = value;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002489 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_LTF_NDP, &value);
Naveen Rawat4051b022017-09-08 16:17:54 -07002490 he_cap->he_4x_ltf_3200_gi_ndp = value;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08002491 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TX_STBC_LT80, &value);
2492 he_cap->tx_stbc_lt_80mhz = value;
2493 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_RX_STBC_LT80, &value);
2494 he_cap->rx_stbc_lt_80mhz = value;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002495 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_DOPPLER, &value);
2496 he_cap->doppler = value;
2497 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_UL_MUMIMO, &value);
2498 he_cap->ul_mu = value;
2499 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_DCM_TX, &value);
2500 he_cap->dcm_enc_tx = value;
2501 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_DCM_RX, &value);
2502 he_cap->dcm_enc_rx = value;
2503 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MU_PPDU, &value);
2504 he_cap->ul_he_mu = value;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002505 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_SU_BEAMFORMEE, &value);
2506 he_cap->su_beamformee = value;
Kiran Kumar Lokere6c7f3fa2018-05-14 18:12:27 -07002507 if (he_cap->su_beamformee) {
2508 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_BFEE_STS_LT80, &value);
2509 he_cap->bfee_sts_lt_80 = value;
2510 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_BFEE_STS_GT80, &value);
2511 he_cap->bfee_sts_gt_80 = value;
2512 } else {
2513 he_cap->bfee_sts_lt_80 = 0;
2514 he_cap->bfee_sts_gt_80 = 0;
2515 }
2516 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_SU_BEAMFORMER, &value);
2517 he_cap->su_beamformer = value;
2518 if (he_cap->su_beamformer) {
2519 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MU_BEAMFORMER, &value);
2520 he_cap->mu_beamformer = value;
2521 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_NUM_SOUND_LT80, &value);
2522 he_cap->num_sounding_lt_80 = value;
2523 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_NUM_SOUND_GT80, &value);
2524 he_cap->num_sounding_gt_80 = value;
2525 } else {
2526 he_cap->mu_beamformer = 0;
2527 he_cap->num_sounding_lt_80 = 0;
2528 he_cap->num_sounding_gt_80 = 0;
2529 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002530 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_SU_FEED_TONE16, &value);
2531 he_cap->su_feedback_tone16 = value;
2532 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MU_FEED_TONE16, &value);
2533 he_cap->mu_feedback_tone16 = value;
2534 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_CODEBOOK_SU, &value);
2535 he_cap->codebook_su = value;
2536 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_CODEBOOK_MU, &value);
2537 he_cap->codebook_mu = value;
2538 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_BFRM_FEED, &value);
2539 he_cap->beamforming_feedback = value;
2540 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_ER_SU_PPDU, &value);
2541 he_cap->he_er_su_ppdu = value;
2542 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_DL_PART_BW, &value);
2543 he_cap->dl_mu_mimo_part_bw = value;
2544 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_PPET_PRESENT, &value);
2545 he_cap->ppet_present = value;
2546 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_SRP, &value);
2547 he_cap->srp = value;
2548 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_POWER_BOOST, &value);
2549 he_cap->power_boost = value;
2550 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_4x_LTF_GI, &value);
Naveen Rawat4051b022017-09-08 16:17:54 -07002551 he_cap->he_ltf_800_gi_4x = value;
2552 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MAX_NC, &value);
2553 he_cap->max_nc = value;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08002554 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TX_STBC_GT80, &value);
2555 he_cap->tx_stbc_gt_80mhz = value;
2556 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_RX_STBC_GT80, &value);
2557 he_cap->rx_stbc_gt_80mhz = value;
Naveen Rawat4051b022017-09-08 16:17:54 -07002558 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_ER_4x_LTF_GI, &value);
2559 he_cap->er_he_ltf_800_gi_4x = value;
Naveen Rawatfc530312017-10-23 14:34:12 -07002560 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_PPDU_20_IN_40MHZ_2G, &value);
2561 he_cap->he_ppdu_20_in_40Mhz_2G = value;
2562 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_PPDU_20_IN_160_80P80MHZ, &value);
2563 he_cap->he_ppdu_20_in_160_80p80Mhz = value;
2564 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_PPDU_80_IN_160_80P80MHZ, &value);
2565 he_cap->he_ppdu_80_in_160_80p80Mhz = value;
2566 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_ER_1X_HE_LTF_GI, &value);
2567 he_cap->er_1x_he_ltf_gi = value;
2568 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MIDAMBLE_RX_1X_HE_LTF, &value);
2569 he_cap->midamble_rx_1x_he_ltf = value;
Naveen Rawataeca1b92017-10-16 16:55:31 -07002570 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_RX_MCS_MAP_LT_80, &value);
2571 he_cap->rx_he_mcs_map_lt_80 = value;
2572 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TX_MCS_MAP_LT_80, &value);
2573 he_cap->tx_he_mcs_map_lt_80 = value;
2574 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_RX_MCS_MAP_160, &value);
2575 *((uint16_t *)he_cap->rx_he_mcs_map_160) = value;
2576 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TX_MCS_MAP_160, &value);
2577 *((uint16_t *)he_cap->tx_he_mcs_map_160) = value;
2578 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_RX_MCS_MAP_80_80, &value);
2579 *((uint16_t *)he_cap->rx_he_mcs_map_80_80) = value;
2580 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TX_MCS_MAP_80_80, &value);
2581 *((uint16_t *)he_cap->tx_he_mcs_map_80_80) = value;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002582
Krishna Kumaar Natarajanbc594592017-04-12 19:02:39 -07002583 if (he_cap->ppet_present) {
2584 value = WNI_CFG_HE_PPET_LEN;
Naveen Rawat01213762018-01-04 17:25:31 -08002585 /* till now operating channel is not decided yet, use 5g cap */
2586 sme_cfg_get_str(mac_ctx, WNI_CFG_HE_PPET_5G,
Naveen Rawat819158d2018-01-16 10:56:45 -08002587 he_cap->ppet.ppe_threshold.ppe_th, &value);
2588 he_cap->ppet.ppe_threshold.num_ppe_th =
2589 lim_truncate_ppet(he_cap->ppet.ppe_threshold.ppe_th,
2590 value);
Krishna Kumaar Natarajanbc594592017-04-12 19:02:39 -07002591 } else {
Naveen Rawat819158d2018-01-16 10:56:45 -08002592 he_cap->ppet.ppe_threshold.num_ppe_th = 0;
Krishna Kumaar Natarajanbc594592017-04-12 19:02:39 -07002593 }
Manikandan Mohan39accff2017-05-02 16:09:00 -07002594 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_STA_OBSSPD, &value);
2595 session->he_sta_obsspd = value;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002596}
2597
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08002598#else
2599static inline void csr_update_he_config_param(tpAniSirGlobal mac_ctx,
2600 tCsrConfigParam *param)
2601{
2602}
2603
2604static inline void csr_get_he_config_param(tCsrConfigParam *param,
2605 tpAniSirGlobal mac_ctx)
2606{
2607}
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002608
2609static inline void csr_join_req_copy_he_cap(tSirSmeJoinReq *csr_join_req,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05302610 struct csr_roam_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002611{
2612}
2613
2614static inline void csr_start_bss_copy_he_cap(tSirSmeStartBssReq *req,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05302615 struct csr_roam_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002616{
2617}
2618
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08002619#endif
2620
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05302621/**
2622 * csr_set_11k_offload_config_param() - Update 11k neighbor report config
2623 *
2624 * @csr_config: pointer to csr_config in MAC context
2625 * @pParam: pointer to config params from HDD
2626 *
2627 * Return: none
2628 */
2629static
2630void csr_set_11k_offload_config_param(struct csr_config *csr_config,
2631 tCsrConfigParam *param)
2632{
2633 csr_config->offload_11k_enable_bitmask =
2634 param->offload_11k_enable_bitmask;
2635 csr_config->neighbor_report_offload.params_bitmask =
2636 param->neighbor_report_offload.params_bitmask;
2637 csr_config->neighbor_report_offload.time_offset =
2638 param->neighbor_report_offload.time_offset;
2639 csr_config->neighbor_report_offload.low_rssi_offset =
2640 param->neighbor_report_offload.low_rssi_offset;
2641 csr_config->neighbor_report_offload.bmiss_count_trigger =
2642 param->neighbor_report_offload.bmiss_count_trigger;
2643 csr_config->neighbor_report_offload.per_threshold_offset =
2644 param->neighbor_report_offload.per_threshold_offset;
2645 csr_config->neighbor_report_offload.
2646 neighbor_report_cache_timeout =
2647 param->neighbor_report_offload.
2648 neighbor_report_cache_timeout;
2649 csr_config->neighbor_report_offload.
2650 max_neighbor_report_req_cap =
2651 param->neighbor_report_offload.
2652 max_neighbor_report_req_cap;
2653}
2654
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302655QDF_STATUS csr_change_default_config_param(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 tCsrConfigParam *pParam)
2657{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302658 QDF_STATUS status = QDF_STATUS_SUCCESS;
Paul Zhang99fe8842017-12-08 14:43:46 +08002659 int i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660
2661 if (pParam) {
Naveen Rawat2b6e3c92017-03-20 13:59:07 -07002662 pMac->roam.configParam.pkt_err_disconn_th =
2663 pParam->pkt_err_disconn_th;
Naveen Rawatb2fc4132017-05-10 20:42:05 -07002664 pMac->roam.configParam.is_force_1x1 =
2665 pParam->is_force_1x1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
2667 cfg_set_int(pMac, WNI_CFG_WME_ENABLED,
2668 (pParam->WMMSupportMode == eCsrRoamWmmNoQos) ? 0 : 1);
2669 pMac->roam.configParam.Is11eSupportEnabled =
2670 pParam->Is11eSupportEnabled;
2671 pMac->roam.configParam.FragmentationThreshold =
2672 pParam->FragmentationThreshold;
2673 pMac->roam.configParam.Is11dSupportEnabled =
2674 pParam->Is11dSupportEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 pMac->roam.configParam.Is11hSupportEnabled =
2676 pParam->Is11hSupportEnabled;
2677
2678 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
2679 pMac->roam.configParam.mcc_rts_cts_prot_enable =
2680 pParam->mcc_rts_cts_prot_enable;
2681 pMac->roam.configParam.mcc_bcast_prob_resp_enable =
2682 pParam->mcc_bcast_prob_resp_enable;
2683 pMac->roam.configParam.fAllowMCCGODiffBI =
2684 pParam->fAllowMCCGODiffBI;
2685
2686 /* channelBondingMode5GHz plays a dual role right now
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302687 * INFRA STA will use this non zero value as CB enabled
2688 * and SOFTAP will use this non-zero value to determine
2689 * the secondary channel offset. This is how
2690 * channelBondingMode5GHz works now and this is kept intact
2691 * to avoid any cfg.ini change.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002692 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302693 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
2694 sme_warn("Invalid CB value from ini in 2.4GHz band %d, CB DISABLED",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695 pParam->channelBondingMode24GHz);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 pMac->roam.configParam.channelBondingMode24GHz =
2697 csr_convert_cb_ini_value_to_phy_cb_state(pParam->
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302698 channelBondingMode24GHz);
2699 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
2700 sme_warn("Invalid CB value from ini in 5GHz band %d, CB DISABLED",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701 pParam->channelBondingMode5GHz);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002702 pMac->roam.configParam.channelBondingMode5GHz =
2703 csr_convert_cb_ini_value_to_phy_cb_state(pParam->
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302704 channelBondingMode5GHz);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
2706 pMac->roam.configParam.phyMode = pParam->phyMode;
2707 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
2708 pMac->roam.configParam.HeartbeatThresh24 =
2709 pParam->HeartbeatThresh24;
2710 pMac->roam.configParam.HeartbeatThresh50 =
2711 pParam->HeartbeatThresh50;
2712 pMac->roam.configParam.ProprietaryRatesEnabled =
2713 pParam->ProprietaryRatesEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
2715 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
2716 pMac->roam.configParam.bandCapability = pParam->bandCapability;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08002717 pMac->roam.configParam.wep_tkip_in_he = pParam->wep_tkip_in_he;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718 pMac->roam.configParam.neighborRoamConfig.
2719 delay_before_vdev_stop =
2720 pParam->neighborRoamConfig.delay_before_vdev_stop;
2721
2722 /* if HDD passed down non zero values then only update, */
2723 /* otherwise keep using the defaults */
2724 if (pParam->initial_scan_no_dfs_chnl) {
2725 pMac->roam.configParam.initial_scan_no_dfs_chnl =
2726 pParam->initial_scan_no_dfs_chnl;
2727 }
2728 if (pParam->nInitialDwellTime) {
2729 pMac->roam.configParam.nInitialDwellTime =
2730 pParam->nInitialDwellTime;
2731 }
2732 if (pParam->nActiveMaxChnTime) {
2733 pMac->roam.configParam.nActiveMaxChnTime =
2734 pParam->nActiveMaxChnTime;
2735 cfg_set_int(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
2736 pParam->nActiveMaxChnTime);
2737 }
2738 if (pParam->nActiveMinChnTime) {
2739 pMac->roam.configParam.nActiveMinChnTime =
2740 pParam->nActiveMinChnTime;
2741 cfg_set_int(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
2742 pParam->nActiveMinChnTime);
2743 }
2744 if (pParam->nPassiveMaxChnTime) {
2745 pMac->roam.configParam.nPassiveMaxChnTime =
2746 pParam->nPassiveMaxChnTime;
2747 cfg_set_int(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
2748 pParam->nPassiveMaxChnTime);
2749 }
2750 if (pParam->nPassiveMinChnTime) {
2751 pMac->roam.configParam.nPassiveMinChnTime =
2752 pParam->nPassiveMinChnTime;
2753 cfg_set_int(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
2754 pParam->nPassiveMinChnTime);
2755 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 if (pParam->nActiveMaxChnTimeConc) {
2757 pMac->roam.configParam.nActiveMaxChnTimeConc =
2758 pParam->nActiveMaxChnTimeConc;
2759 }
2760 if (pParam->nActiveMinChnTimeConc) {
2761 pMac->roam.configParam.nActiveMinChnTimeConc =
2762 pParam->nActiveMinChnTimeConc;
2763 }
2764 if (pParam->nPassiveMaxChnTimeConc) {
2765 pMac->roam.configParam.nPassiveMaxChnTimeConc =
2766 pParam->nPassiveMaxChnTimeConc;
2767 }
2768 if (pParam->nPassiveMinChnTimeConc) {
2769 pMac->roam.configParam.nPassiveMinChnTimeConc =
2770 pParam->nPassiveMinChnTimeConc;
2771 }
Agrawal Ashish17bb3902016-05-05 13:29:40 +05302772 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
2773 pMac->roam.configParam.min_rest_time_conc =
2774 pParam->min_rest_time_conc;
2775 pMac->roam.configParam.idle_time_conc = pParam->idle_time_conc;
2776
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002777 pMac->roam.configParam.eBand = pParam->eBand;
2778 pMac->roam.configParam.uCfgDot11Mode =
2779 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302780 pMac->roam.configParam.
2781 phyMode,
2782 pMac->roam.configParam.
2783 ProprietaryRatesEnabled);
2784 /* if HDD passed down non zero values for age params,
2785 * then only update, otherwise keep using the defaults
2786 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002787 if (pParam->nScanResultAgeCount) {
2788 pMac->roam.configParam.agingCount =
2789 pParam->nScanResultAgeCount;
2790 }
Sandeep Puligillae0875662016-02-12 16:09:21 -08002791 if (pParam->obss_width_interval) {
2792 pMac->roam.configParam.obss_width_interval =
2793 pParam->obss_width_interval;
2794 cfg_set_int(pMac,
2795 WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
2796 pParam->obss_width_interval);
2797 }
2798 if (pParam->obss_active_dwelltime) {
2799 pMac->roam.configParam.obss_active_dwelltime =
2800 pParam->obss_active_dwelltime;
2801 cfg_set_int(pMac,
2802 WNI_CFG_OBSS_HT40_SCAN_ACTIVE_DWELL_TIME,
2803 pParam->obss_active_dwelltime);
2804 }
2805 if (pParam->obss_passive_dwelltime) {
2806 pMac->roam.configParam.obss_passive_dwelltime =
2807 pParam->obss_passive_dwelltime;
2808 cfg_set_int(pMac,
2809 WNI_CFG_OBSS_HT40_SCAN_PASSIVE_DWELL_TIME,
2810 pParam->obss_passive_dwelltime);
2811 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08002813 pMac->first_scan_bucket_threshold =
2814 pParam->first_scan_bucket_threshold;
2815 csr_assign_rssi_for_category(pMac,
2816 pMac->first_scan_bucket_threshold,
2817 pParam->bCatRssiOffset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002818 pMac->roam.configParam.fSupplicantCountryCodeHasPriority =
2819 pParam->fSupplicantCountryCodeHasPriority;
2820 pMac->roam.configParam.vccRssiThreshold =
2821 pParam->vccRssiThreshold;
2822 pMac->roam.configParam.vccUlMacLossThreshold =
2823 pParam->vccUlMacLossThreshold;
2824 pMac->roam.configParam.statsReqPeriodicity =
2825 pParam->statsReqPeriodicity;
2826 pMac->roam.configParam.statsReqPeriodicityInPS =
2827 pParam->statsReqPeriodicityInPS;
2828 /* Assign this before calling csr_init11d_info */
2829 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05302830 pMac->roam.configParam.allow_tpc_from_ap =
2831 pParam->allow_tpc_from_ap;
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07002832 if (wlan_reg_11d_enabled_on_host(pMac->psoc))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002833 status = csr_init11d_info(pMac, &pParam->Csr11dinfo);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302834 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002835 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002836
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302837 /* Initialize the power + channel information if 11h is
2838 * enabled. If 11d is enabled this information has already
2839 * been initialized
2840 */
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07002841 if (csr_is11h_supported(pMac) &&
2842 !wlan_reg_11d_enabled_on_host(pMac->psoc))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002843 csr_init_channel_power_list(pMac, &pParam->Csr11dinfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845 pMac->roam.configParam.isFastTransitionEnabled =
2846 pParam->isFastTransitionEnabled;
2847 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Abhishek Singh34c0e632017-09-28 14:39:29 +05302848 pMac->roam.configParam.rssi_abs_thresh =
2849 pParam->rssi_abs_thresh;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850 pMac->roam.configParam.nRoamPrefer5GHz =
2851 pParam->nRoamPrefer5GHz;
2852 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
2853 pMac->roam.configParam.isWESModeEnabled =
2854 pParam->isWESModeEnabled;
2855 pMac->roam.configParam.nProbes = pParam->nProbes;
2856 pMac->roam.configParam.nRoamScanHomeAwayTime =
2857 pParam->nRoamScanHomeAwayTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002858 pMac->roam.configParam.isRoamOffloadScanEnabled =
2859 pParam->isRoamOffloadScanEnabled;
2860 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
2861 pParam->bFastRoamInConIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
2863 pParam->isFastRoamIniFeatureEnabled;
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07002864 qdf_mem_copy(&pMac->roam.configParam.csr_mawc_config,
2865 &pParam->csr_mawc_config,
2866 sizeof(pParam->csr_mawc_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867#ifdef FEATURE_WLAN_ESE
2868 pMac->roam.configParam.isEseIniFeatureEnabled =
2869 pParam->isEseIniFeatureEnabled;
2870#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302871 qdf_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 &pParam->neighborRoamConfig,
2873 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002874 sme_debug("nNeighborScanTimerPerioid: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 pMac->roam.configParam.neighborRoamConfig.
2876 nNeighborScanTimerPeriod);
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05302877 sme_debug("neighbor_scan_min_timer_period: %d",
2878 pMac->roam.configParam.neighborRoamConfig.
2879 neighbor_scan_min_timer_period);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002880 sme_debug("nNeighborLookupRssiThreshold: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881 pMac->roam.configParam.neighborRoamConfig.
2882 nNeighborLookupRssiThreshold);
Varun Reddy Yeturu168134f2017-06-26 13:46:05 -07002883 sme_debug("rssi_thresh_offset_5g: %d",
2884 pMac->roam.configParam.neighborRoamConfig.rssi_thresh_offset_5g);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002885 sme_debug("nOpportunisticThresholdDiff: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002886 pMac->roam.configParam.neighborRoamConfig.
2887 nOpportunisticThresholdDiff);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002888 sme_debug("nRoamRescanRssiDiff: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889 pMac->roam.configParam.neighborRoamConfig.
2890 nRoamRescanRssiDiff);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002891 sme_debug("nNeighborScanMinChanTime: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002892 pMac->roam.configParam.neighborRoamConfig.
2893 nNeighborScanMinChanTime);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002894 sme_debug("nNeighborScanMaxChanTime: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002895 pMac->roam.configParam.neighborRoamConfig.
2896 nNeighborScanMaxChanTime);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002897 sme_debug("nMaxNeighborRetries: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 pMac->roam.configParam.neighborRoamConfig.
2899 nMaxNeighborRetries);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002900 sme_debug("nNeighborResultsRefreshPeriod: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002901 pMac->roam.configParam.neighborRoamConfig.
2902 nNeighborResultsRefreshPeriod);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002903 sme_debug("nEmptyScanRefreshPeriod: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904 pMac->roam.configParam.neighborRoamConfig.
2905 nEmptyScanRefreshPeriod);
2906 {
2907 int i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302908
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002909 sme_debug("Num of Channels in CFG Channel List: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002910 pMac->roam.configParam.neighborRoamConfig.
2911 neighborScanChanList.numChannels);
2912 for (i = 0;
2913 i <
2914 pMac->roam.configParam.neighborRoamConfig.
2915 neighborScanChanList.numChannels; i++) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002916 sme_debug("%d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917 pMac->roam.configParam.
2918 neighborRoamConfig.neighborScanChanList.
2919 channelList[i]);
2920 }
2921 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002922 sme_debug("nRoamBmissFirstBcnt: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923 pMac->roam.configParam.neighborRoamConfig.
2924 nRoamBmissFirstBcnt);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002925 sme_debug("nRoamBmissFinalBcnt: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002926 pMac->roam.configParam.neighborRoamConfig.
2927 nRoamBmissFinalBcnt);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002928 sme_debug("nRoamBeaconRssiWeight: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 pMac->roam.configParam.neighborRoamConfig.
2930 nRoamBeaconRssiWeight);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931 pMac->roam.configParam.addTSWhenACMIsOff =
2932 pParam->addTSWhenACMIsOff;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
2934 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
2935 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
2936 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
2937 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
2938 pMac->scan.max_scan_count = pParam->max_scan_count;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302939 /* This parameter is not available in cfg and not passed from
Jeff Johnson810596a2018-05-06 17:01:22 -07002940 * upper layers. Instead it is initialized here This parametere
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302941 * is used in concurrency to determine if there are concurrent
2942 * active sessions. Is used as a temporary fix to disconnect
2943 * all active sessions when BMPS enabled so the active session
2944 * if Infra STA will automatically connect back and resume BMPS
2945 * since resume BMPS is not working when moving from concurrent
2946 * to single session
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947 */
2948 /* Remove this code once SLM_Sessionization is supported */
2949 /* BMPS_WORKAROUND_NOT_NEEDED */
2950 pMac->roam.configParam.doBMPSWorkaround = 0;
2951
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952 pMac->roam.configParam.nVhtChannelWidth =
2953 pParam->nVhtChannelWidth;
Abhishek Singh68844282018-01-25 16:48:41 +05302954 pMac->roam.configParam.enable_subfee_vendor_vhtie =
2955 pParam->enable_subfee_vendor_vhtie;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08002956 pMac->roam.configParam.enable_txbf_sap_mode =
2957 pParam->enable_txbf_sap_mode;
Kiran Kumar Lokere0e255172018-03-30 18:54:25 -07002958 pMac->roam.configParam.enable_vht20_mcs9 =
2959 pParam->enable_vht20_mcs9;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 pMac->roam.configParam.enable2x2 = pParam->enable2x2;
2961 pMac->roam.configParam.enableVhtFor24GHz =
2962 pParam->enableVhtFor24GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963 pMac->roam.configParam.enableVhtpAid = pParam->enableVhtpAid;
2964 pMac->roam.configParam.enableVhtGid = pParam->enableVhtGid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965 pMac->roam.configParam.enableAmpduPs = pParam->enableAmpduPs;
2966 pMac->roam.configParam.enableHtSmps = pParam->enableHtSmps;
2967 pMac->roam.configParam.htSmps = pParam->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002968 pMac->roam.configParam.send_smps_action =
2969 pParam->send_smps_action;
Krunal Sonia2c0e412017-05-04 14:12:41 +05302970 pMac->roam.configParam.tx_ldpc_enable = pParam->enable_tx_ldpc;
2971 pMac->roam.configParam.rx_ldpc_enable = pParam->enable_rx_ldpc;
Krunal Soni158bfe62017-08-02 12:33:08 -07002972 pMac->roam.configParam.disable_high_ht_mcs_2x2 =
2973 pParam->disable_high_ht_mcs_2x2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002974 pMac->roam.configParam.ignore_peer_erp_info =
2975 pParam->ignore_peer_erp_info;
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07002976 pMac->roam.configParam.max_amsdu_num =
2977 pParam->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002978 pMac->roam.configParam.nSelect5GHzMargin =
2979 pParam->nSelect5GHzMargin;
Abhinav Kumara083f212018-04-05 18:49:45 +05302980 pMac->roam.configParam.ho_delay_for_rx =
2981 pParam->ho_delay_for_rx;
Abhinav Kumara95af7c2018-04-06 17:08:00 +05302982 pMac->roam.configParam.min_delay_btw_roam_scans =
2983 pParam->min_delay_btw_roam_scans;
2984 pMac->roam.configParam.roam_trigger_reason_bitmask =
2985 pParam->roam_trigger_reason_bitmask;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986 pMac->roam.configParam.isCoalesingInIBSSAllowed =
2987 pParam->isCoalesingInIBSSAllowed;
2988#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
2989 pMac->roam.configParam.cc_switch_mode = pParam->cc_switch_mode;
2990#endif
2991 pMac->roam.configParam.allowDFSChannelRoam =
2992 pParam->allowDFSChannelRoam;
2993#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2994 pMac->roam.configParam.isRoamOffloadEnabled =
2995 pParam->isRoamOffloadEnabled;
2996#endif
2997 pMac->roam.configParam.obssEnabled = pParam->obssEnabled;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302998 pMac->roam.configParam.vendor_vht_sap =
2999 pParam->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003000 pMac->roam.configParam.conc_custom_rule1 =
3001 pParam->conc_custom_rule1;
3002 pMac->roam.configParam.conc_custom_rule2 =
3003 pParam->conc_custom_rule2;
3004 pMac->roam.configParam.is_sta_connection_in_5gz_enabled =
3005 pParam->is_sta_connection_in_5gz_enabled;
Jeff Johnson1ad3fbd2017-11-03 08:00:02 -07003006 pMac->roam.configParam.send_deauth_before_con =
3007 pParam->send_deauth_before_con;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008
3009 pMac->enable_dot11p = pParam->enable_dot11p;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07003010 pMac->roam.configParam.early_stop_scan_enable =
3011 pParam->early_stop_scan_enable;
3012 pMac->roam.configParam.early_stop_scan_min_threshold =
3013 pParam->early_stop_scan_min_threshold;
3014 pMac->roam.configParam.early_stop_scan_max_threshold =
3015 pParam->early_stop_scan_max_threshold;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003016 pMac->isCoalesingInIBSSAllowed =
3017 pParam->isCoalesingInIBSSAllowed;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07003018
Gupta, Kapilc68ad462016-02-01 19:17:23 +05303019 pMac->roam.configParam.roam_params.dense_rssi_thresh_offset =
3020 pParam->roam_dense_rssi_thresh_offset;
3021 pMac->roam.configParam.roam_params.dense_min_aps_cnt =
3022 pParam->roam_dense_min_aps;
3023 pMac->roam.configParam.roam_params.traffic_threshold =
3024 pParam->roam_dense_traffic_thresh;
3025
Varun Reddy Yeturufaad37e2017-07-26 10:54:13 -07003026 pMac->roam.configParam.roam_params.bg_scan_bad_rssi_thresh =
3027 pParam->roam_bg_scan_bad_rssi_thresh;
3028 pMac->roam.configParam.roam_params.bg_scan_client_bitmap =
3029 pParam->roam_bg_scan_client_bitmap;
Vignesh Viswanathanc018e982017-09-07 18:49:19 +05303030 pMac->roam.configParam.roam_params.
3031 roam_bad_rssi_thresh_offset_2g =
3032 pParam->roam_bad_rssi_thresh_offset_2g;
Varun Reddy Yeturufaad37e2017-07-26 10:54:13 -07003033
Abhinav Kumar271f0632018-03-29 16:01:30 +05303034 pMac->roam.configParam.enable_ftopen =
3035 pParam->enable_ftopen;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05303036 pMac->roam.configParam.scan_adaptive_dwell_mode =
3037 pParam->scan_adaptive_dwell_mode;
Paul Zhang72697bd2017-12-20 09:24:25 +08003038 pMac->roam.configParam.scan_adaptive_dwell_mode_nc =
3039 pParam->scan_adaptive_dwell_mode_nc;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05303040 pMac->roam.configParam.roamscan_adaptive_dwell_mode =
3041 pParam->roamscan_adaptive_dwell_mode;
3042
Kapil Gupta5cda2252016-12-29 18:44:26 +05303043 pMac->roam.configParam.per_roam_config.enable =
3044 pParam->per_roam_config.enable;
3045 pMac->roam.configParam.per_roam_config.tx_high_rate_thresh =
3046 pParam->per_roam_config.tx_high_rate_thresh;
3047 pMac->roam.configParam.per_roam_config.rx_high_rate_thresh =
3048 pParam->per_roam_config.rx_high_rate_thresh;
3049 pMac->roam.configParam.per_roam_config.tx_low_rate_thresh =
3050 pParam->per_roam_config.tx_low_rate_thresh;
3051 pMac->roam.configParam.per_roam_config.rx_low_rate_thresh =
3052 pParam->per_roam_config.rx_low_rate_thresh;
3053 pMac->roam.configParam.per_roam_config.tx_rate_thresh_percnt =
3054 pParam->per_roam_config.tx_rate_thresh_percnt;
3055 pMac->roam.configParam.per_roam_config.rx_rate_thresh_percnt =
3056 pParam->per_roam_config.rx_rate_thresh_percnt;
3057 pMac->roam.configParam.per_roam_config.per_rest_time =
3058 pParam->per_roam_config.per_rest_time;
Kapil Gupta957827b2017-02-13 15:47:04 +05303059 pMac->roam.configParam.per_roam_config.tx_per_mon_time =
3060 pParam->per_roam_config.tx_per_mon_time;
3061 pMac->roam.configParam.per_roam_config.rx_per_mon_time =
3062 pParam->per_roam_config.rx_per_mon_time;
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +05303063 pMac->roam.configParam.per_roam_config.min_candidate_rssi =
3064 pParam->per_roam_config.min_candidate_rssi;
Kapil Gupta5cda2252016-12-29 18:44:26 +05303065
Krunal Soni1878d3a2016-01-14 13:00:44 -08003066 pMac->fEnableDebugLog = pParam->fEnableDebugLog;
3067
3068 /* update interface configuration */
3069 pMac->sme.max_intf_count = pParam->max_intf_count;
3070
3071 pMac->enable5gEBT = pParam->enable5gEBT;
3072 pMac->sme.enableSelfRecovery = pParam->enableSelfRecovery;
3073
3074 pMac->f_sta_miracast_mcc_rest_time_val =
3075 pParam->f_sta_miracast_mcc_rest_time_val;
3076#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
3077 pMac->sap.sap_channel_avoidance =
3078 pParam->sap_channel_avoidance;
3079#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
gaoleze5108942017-03-31 16:56:42 +08003080 pMac->sap.acs_with_more_param =
3081 pParam->acs_with_more_param;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003082
3083 pMac->f_prefer_non_dfs_on_radar =
3084 pParam->f_prefer_non_dfs_on_radar;
3085
3086 pMac->sme.ps_global_info.ps_enabled =
3087 pParam->is_ps_enabled;
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08003088 pMac->sme.ps_global_info.auto_bmps_timer_val =
3089 pParam->auto_bmps_timer_val;
Abhishek Singh165bc602016-03-21 12:43:00 +05303090 pMac->roam.configParam.ignore_peer_ht_opmode =
3091 pParam->ignore_peer_ht_opmode;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003092 pMac->dual_mac_feature_disable =
3093 pParam->dual_mac_feature_disable;
Ganesh Kondabattini930304c2017-10-10 15:25:36 +05303094 pMac->sta_sap_scc_on_dfs_chan =
3095 pParam->sta_sap_scc_on_dfs_chan;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003096 pMac->roam.configParam.early_stop_scan_enable =
3097 pParam->early_stop_scan_enable;
3098 pMac->roam.configParam.early_stop_scan_min_threshold =
3099 pParam->early_stop_scan_min_threshold;
3100 pMac->roam.configParam.early_stop_scan_max_threshold =
3101 pParam->early_stop_scan_max_threshold;
Abhishek Singh10ecf582016-05-04 17:48:59 +05303102 pMac->roam.configParam.enable_edca_params =
3103 pParam->enable_edca_params;
3104 pMac->roam.configParam.edca_vo_cwmin = pParam->edca_vo_cwmin;
3105 pMac->roam.configParam.edca_vi_cwmin = pParam->edca_vi_cwmin;
3106 pMac->roam.configParam.edca_bk_cwmin = pParam->edca_bk_cwmin;
3107 pMac->roam.configParam.edca_be_cwmin = pParam->edca_be_cwmin;
3108
3109 pMac->roam.configParam.edca_vo_cwmax = pParam->edca_vo_cwmax;
3110 pMac->roam.configParam.edca_vi_cwmax = pParam->edca_vi_cwmax;
3111 pMac->roam.configParam.edca_bk_cwmax = pParam->edca_bk_cwmax;
3112 pMac->roam.configParam.edca_be_cwmax = pParam->edca_be_cwmax;
3113
3114 pMac->roam.configParam.edca_vo_aifs = pParam->edca_vo_aifs;
3115 pMac->roam.configParam.edca_vi_aifs = pParam->edca_vi_aifs;
3116 pMac->roam.configParam.edca_bk_aifs = pParam->edca_bk_aifs;
3117 pMac->roam.configParam.edca_be_aifs = pParam->edca_be_aifs;
3118
Abhishek Singh5ea86532016-04-27 14:10:53 +05303119 pMac->roam.configParam.enable_fatal_event =
3120 pParam->enable_fatal_event;
Agrawal Ashish21ba2572016-09-03 16:40:10 +05303121 pMac->roam.configParam.sta_roam_policy.dfs_mode =
3122 pParam->sta_roam_policy_params.dfs_mode;
3123 pMac->roam.configParam.sta_roam_policy.skip_unsafe_channels =
3124 pParam->sta_roam_policy_params.skip_unsafe_channels;
Zhang Qian65e2e8d2017-07-11 11:56:43 +08003125 pMac->roam.configParam.sta_roam_policy.sap_operating_band =
3126 pParam->sta_roam_policy_params.sap_operating_band;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +05303128 pMac->roam.configParam.tx_aggregation_size =
3129 pParam->tx_aggregation_size;
Paul Zhangee09f8e2018-04-23 16:11:32 +08003130 pMac->roam.configParam.tx_aggregation_size_be =
3131 pParam->tx_aggregation_size_be;
3132 pMac->roam.configParam.tx_aggregation_size_bk =
3133 pParam->tx_aggregation_size_bk;
3134 pMac->roam.configParam.tx_aggregation_size_vi =
3135 pParam->tx_aggregation_size_vi;
3136 pMac->roam.configParam.tx_aggregation_size_vo =
3137 pParam->tx_aggregation_size_vo;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +05303138 pMac->roam.configParam.rx_aggregation_size =
3139 pParam->rx_aggregation_size;
Paul Zhang33fae272018-04-23 16:19:00 +08003140 pMac->roam.configParam.tx_aggr_sw_retry_threshold_be =
3141 pParam->tx_aggr_sw_retry_threshold_be;
3142 pMac->roam.configParam.tx_aggr_sw_retry_threshold_bk =
3143 pParam->tx_aggr_sw_retry_threshold_bk;
3144 pMac->roam.configParam.tx_aggr_sw_retry_threshold_vi =
3145 pParam->tx_aggr_sw_retry_threshold_vi;
3146 pMac->roam.configParam.tx_aggr_sw_retry_threshold_vo =
3147 pParam->tx_aggr_sw_retry_threshold_vo;
Selvaraj, Sridhar4f684bb2017-01-19 15:59:23 +05303148 pMac->roam.configParam.enable_bcast_probe_rsp =
3149 pParam->enable_bcast_probe_rsp;
Vignesh Viswanathan32761e42017-09-25 17:10:54 +05303150 pMac->roam.configParam.is_fils_enabled =
3151 pParam->is_fils_enabled;
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05303152 pMac->roam.configParam.qcn_ie_support =
3153 pParam->qcn_ie_support;
Selvaraj, Sridhar97ce6582017-01-20 17:06:34 +05303154 pMac->roam.configParam.fils_max_chan_guard_time =
3155 pParam->fils_max_chan_guard_time;
Selvaraj, Sridhar57ce4df2017-05-29 18:30:49 +05303156 pMac->roam.configParam.disallow_duration =
3157 pParam->disallow_duration;
3158 pMac->roam.configParam.rssi_channel_penalization =
3159 pParam->rssi_channel_penalization;
3160 pMac->roam.configParam.num_disallowed_aps =
3161 pParam->num_disallowed_aps;
Paul Zhang99fe8842017-12-08 14:43:46 +08003162 pMac->roam.configParam.wlm_latency_enable =
3163 pParam->wlm_latency_enable;
3164 pMac->roam.configParam.wlm_latency_level =
3165 pParam->wlm_latency_level;
3166 for (i = 0; i < CSR_NUM_WLM_LATENCY_LEVEL; i++) {
3167 pMac->roam.configParam.wlm_latency_flags[i] =
3168 pParam->wlm_latency_flags[i];
3169 }
Yeshwanth Sriram Guntuka2ba6fe92017-10-04 14:40:45 +05303170 pMac->roam.configParam.oce_feature_bitmap =
3171 pParam->oce_feature_bitmap;
Abhinav Kumaredd1d372018-05-11 15:33:35 +05303172 pMac->roam.configParam.roam_force_rssi_trigger =
3173 pParam->roam_force_rssi_trigger;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +05303174
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +05303175 pMac->roam.configParam.mbo_thresholds.
3176 mbo_candidate_rssi_thres =
3177 pParam->mbo_thresholds.mbo_candidate_rssi_thres;
3178 pMac->roam.configParam.mbo_thresholds.
3179 mbo_current_rssi_thres =
3180 pParam->mbo_thresholds.mbo_current_rssi_thres;
3181 pMac->roam.configParam.mbo_thresholds.
3182 mbo_current_rssi_mcc_thres =
3183 pParam->mbo_thresholds.mbo_current_rssi_mcc_thres;
3184 pMac->roam.configParam.mbo_thresholds.
3185 mbo_candidate_rssi_btc_thres =
3186 pParam->mbo_thresholds.mbo_candidate_rssi_btc_thres;
3187
Himanshu Agarwal8bcec572017-09-28 11:54:37 +05303188 qdf_mem_copy(&pMac->roam.configParam.bss_score_params,
3189 &pParam->bss_score_params,
3190 sizeof(struct sir_score_config));
yeshwanth sriram guntuka41f936c2017-09-01 17:53:49 +05303191 pMac->roam.configParam.btm_offload_config =
3192 pParam->btm_offload_config;
Jiachao Wu84bb2ea2018-01-08 16:17:33 +08003193 pMac->roam.configParam.btm_solicited_timeout =
3194 pParam->btm_solicited_timeout;
3195 pMac->roam.configParam.btm_max_attempt_cnt =
3196 pParam->btm_max_attempt_cnt;
3197 pMac->roam.configParam.btm_sticky_time =
3198 pParam->btm_sticky_time;
Himanshu Agarwal8bcec572017-09-28 11:54:37 +05303199
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08003200 csr_update_he_config_param(pMac, pParam);
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05303201 csr_set_11k_offload_config_param(&pMac->roam.configParam,
3202 pParam);
Gupta, Kapilc68ad462016-02-01 19:17:23 +05303203 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204 return status;
3205}
3206
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05303207/**
3208 * csr_get_11k_offload_config_param() - Get 11k neighbor report config
3209 *
3210 * @csr_config: pointer to csr_config in MAC context
3211 * @pParam: pointer to config params from HDD
3212 *
3213 * Return: none
3214 */
3215static
3216void csr_get_11k_offload_config_param(struct csr_config *csr_config,
3217 tCsrConfigParam *param)
3218{
3219 param->offload_11k_enable_bitmask =
3220 csr_config->offload_11k_enable_bitmask;
3221 param->neighbor_report_offload.params_bitmask =
3222 csr_config->neighbor_report_offload.params_bitmask;
3223 param->neighbor_report_offload.time_offset =
3224 csr_config->neighbor_report_offload.time_offset;
3225 param->neighbor_report_offload.low_rssi_offset =
3226 csr_config->neighbor_report_offload.low_rssi_offset;
3227 param->neighbor_report_offload.bmiss_count_trigger =
3228 csr_config->neighbor_report_offload.bmiss_count_trigger;
3229 param->neighbor_report_offload.per_threshold_offset =
3230 csr_config->neighbor_report_offload.per_threshold_offset;
3231 param->neighbor_report_offload.neighbor_report_cache_timeout =
3232 csr_config->neighbor_report_offload.
3233 neighbor_report_cache_timeout;
3234 param->neighbor_report_offload.max_neighbor_report_req_cap =
3235 csr_config->neighbor_report_offload.
3236 max_neighbor_report_req_cap;
3237}
3238
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303239QDF_STATUS csr_get_config_param(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240{
3241 int i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303242 struct csr_config *cfg_params = &pMac->roam.configParam;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243
3244 if (!pParam)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303245 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003246
Naveen Rawat2b6e3c92017-03-20 13:59:07 -07003247 pParam->pkt_err_disconn_th = cfg_params->pkt_err_disconn_th;
Naveen Rawatb2fc4132017-05-10 20:42:05 -07003248 pParam->is_force_1x1 = cfg_params->is_force_1x1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 pParam->WMMSupportMode = cfg_params->WMMSupportMode;
3250 pParam->Is11eSupportEnabled = cfg_params->Is11eSupportEnabled;
3251 pParam->FragmentationThreshold = cfg_params->FragmentationThreshold;
3252 pParam->Is11dSupportEnabled = cfg_params->Is11dSupportEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 pParam->Is11hSupportEnabled = cfg_params->Is11hSupportEnabled;
3254 pParam->channelBondingMode24GHz = csr_convert_phy_cb_state_to_ini_value(
3255 cfg_params->channelBondingMode24GHz);
3256 pParam->channelBondingMode5GHz = csr_convert_phy_cb_state_to_ini_value(
3257 cfg_params->channelBondingMode5GHz);
3258 pParam->RTSThreshold = cfg_params->RTSThreshold;
3259 pParam->phyMode = cfg_params->phyMode;
3260 pParam->shortSlotTime = cfg_params->shortSlotTime;
3261 pParam->HeartbeatThresh24 = cfg_params->HeartbeatThresh24;
3262 pParam->HeartbeatThresh50 = cfg_params->HeartbeatThresh50;
3263 pParam->ProprietaryRatesEnabled = cfg_params->ProprietaryRatesEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003264 pParam->AdHocChannel24 = cfg_params->AdHocChannel24;
3265 pParam->AdHocChannel5G = cfg_params->AdHocChannel5G;
3266 pParam->bandCapability = cfg_params->bandCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003267 pParam->nActiveMaxChnTime = cfg_params->nActiveMaxChnTime;
3268 pParam->nActiveMinChnTime = cfg_params->nActiveMinChnTime;
3269 pParam->nPassiveMaxChnTime = cfg_params->nPassiveMaxChnTime;
3270 pParam->nPassiveMinChnTime = cfg_params->nPassiveMinChnTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271 pParam->nActiveMaxChnTimeConc = cfg_params->nActiveMaxChnTimeConc;
3272 pParam->nActiveMinChnTimeConc = cfg_params->nActiveMinChnTimeConc;
3273 pParam->nPassiveMaxChnTimeConc = cfg_params->nPassiveMaxChnTimeConc;
3274 pParam->nPassiveMinChnTimeConc = cfg_params->nPassiveMinChnTimeConc;
3275 pParam->nRestTimeConc = cfg_params->nRestTimeConc;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05303276 pParam->min_rest_time_conc = cfg_params->min_rest_time_conc;
3277 pParam->idle_time_conc = cfg_params->idle_time_conc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 pParam->eBand = cfg_params->eBand;
3279 pParam->nScanResultAgeCount = cfg_params->agingCount;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280 pParam->bCatRssiOffset = cfg_params->bCatRssiOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281 pParam->fSupplicantCountryCodeHasPriority =
3282 cfg_params->fSupplicantCountryCodeHasPriority;
3283 pParam->vccRssiThreshold = cfg_params->vccRssiThreshold;
3284 pParam->vccUlMacLossThreshold = cfg_params->vccUlMacLossThreshold;
3285 pParam->nTxPowerCap = cfg_params->nTxPowerCap;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05303286 pParam->allow_tpc_from_ap = cfg_params->allow_tpc_from_ap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 pParam->statsReqPeriodicity = cfg_params->statsReqPeriodicity;
3288 pParam->statsReqPeriodicityInPS = cfg_params->statsReqPeriodicityInPS;
3289 pParam->addTSWhenACMIsOff = cfg_params->addTSWhenACMIsOff;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
3291 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
3292 pParam->fScanTwice = cfg_params->fScanTwice;
3293 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
3294 pParam->fEnableMCCMode = cfg_params->fenableMCCMode;
3295 pParam->fAllowMCCGODiffBI = cfg_params->fAllowMCCGODiffBI;
3296 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303297 qdf_mem_copy(&pParam->neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298 &cfg_params->neighborRoamConfig,
3299 sizeof(tCsrNeighborRoamConfigParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003300 pParam->nVhtChannelWidth = cfg_params->nVhtChannelWidth;
Abhishek Singh68844282018-01-25 16:48:41 +05303301 pParam->enable_subfee_vendor_vhtie =
3302 cfg_params->enable_subfee_vendor_vhtie;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08003303 pParam->enable_txbf_sap_mode =
3304 cfg_params->enable_txbf_sap_mode;
Kiran Kumar Lokere0e255172018-03-30 18:54:25 -07003305 pParam->enable_vht20_mcs9 = cfg_params->enable_vht20_mcs9;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306 pParam->enableVhtFor24GHz = cfg_params->enableVhtFor24GHz;
3307 pParam->ignore_peer_erp_info = cfg_params->ignore_peer_erp_info;
3308 pParam->enable2x2 = cfg_params->enable2x2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 pParam->isFastTransitionEnabled = cfg_params->isFastTransitionEnabled;
3310 pParam->RoamRssiDiff = cfg_params->RoamRssiDiff;
Abhishek Singh34c0e632017-09-28 14:39:29 +05303311 pParam->rssi_abs_thresh = cfg_params->rssi_abs_thresh;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312 pParam->nRoamPrefer5GHz = cfg_params->nRoamPrefer5GHz;
3313 pParam->nRoamIntraBand = cfg_params->nRoamIntraBand;
3314 pParam->isWESModeEnabled = cfg_params->isWESModeEnabled;
3315 pParam->nProbes = cfg_params->nProbes;
3316 pParam->nRoamScanHomeAwayTime = cfg_params->nRoamScanHomeAwayTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317 pParam->isRoamOffloadScanEnabled = cfg_params->isRoamOffloadScanEnabled;
3318 pParam->bFastRoamInConIniFeatureEnabled =
3319 cfg_params->bFastRoamInConIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 pParam->isFastRoamIniFeatureEnabled =
3321 cfg_params->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322#ifdef FEATURE_WLAN_ESE
3323 pParam->isEseIniFeatureEnabled = cfg_params->isEseIniFeatureEnabled;
3324#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303325 qdf_mem_copy(&pParam->neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 &cfg_params->neighborRoamConfig,
3327 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003328 sme_debug("Num of Channels in CFG Channel List: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 cfg_params->neighborRoamConfig.
3330 neighborScanChanList.numChannels);
3331 for (i = 0; i < cfg_params->neighborRoamConfig.
3332 neighborScanChanList.numChannels; i++) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003333 sme_debug("%d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 cfg_params->neighborRoamConfig.
3335 neighborScanChanList.channelList[i]);
3336 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337
3338#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
3339 pParam->cc_switch_mode = cfg_params->cc_switch_mode;
3340#endif
Krunal Sonia2c0e412017-05-04 14:12:41 +05303341 pParam->enable_tx_ldpc = cfg_params->tx_ldpc_enable;
3342 pParam->enable_rx_ldpc = cfg_params->rx_ldpc_enable;
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -08003343 pParam->wep_tkip_in_he = cfg_params->wep_tkip_in_he;
Krunal Soni158bfe62017-08-02 12:33:08 -07003344 pParam->disable_high_ht_mcs_2x2 = cfg_params->disable_high_ht_mcs_2x2;
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07003345 pParam->max_amsdu_num = cfg_params->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003346 pParam->nSelect5GHzMargin = cfg_params->nSelect5GHzMargin;
Abhinav Kumara083f212018-04-05 18:49:45 +05303347 pParam->ho_delay_for_rx = cfg_params->ho_delay_for_rx;
Abhinav Kumara95af7c2018-04-06 17:08:00 +05303348 pParam->min_delay_btw_roam_scans = cfg_params->min_delay_btw_roam_scans;
3349 pParam->roam_trigger_reason_bitmask =
3350 cfg_params->roam_trigger_reason_bitmask;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351 pParam->isCoalesingInIBSSAllowed = cfg_params->isCoalesingInIBSSAllowed;
3352 pParam->allowDFSChannelRoam = cfg_params->allowDFSChannelRoam;
3353 pParam->nInitialDwellTime = cfg_params->nInitialDwellTime;
3354 pParam->initial_scan_no_dfs_chnl = cfg_params->initial_scan_no_dfs_chnl;
3355#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3356 pParam->isRoamOffloadEnabled = cfg_params->isRoamOffloadEnabled;
3357#endif
3358 pParam->enable_dot11p = pMac->enable_dot11p;
3359 csr_set_channels(pMac, pParam);
3360 pParam->obssEnabled = cfg_params->obssEnabled;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303361 pParam->vendor_vht_sap =
3362 pMac->roam.configParam.vendor_vht_sap;
Gupta, Kapilc68ad462016-02-01 19:17:23 +05303363 pParam->roam_dense_rssi_thresh_offset =
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05303364 cfg_params->roam_params.dense_rssi_thresh_offset;
Gupta, Kapilc68ad462016-02-01 19:17:23 +05303365 pParam->roam_dense_min_aps =
3366 cfg_params->roam_params.dense_min_aps_cnt;
3367 pParam->roam_dense_traffic_thresh =
3368 cfg_params->roam_params.traffic_threshold;
3369
Varun Reddy Yeturufaad37e2017-07-26 10:54:13 -07003370 pParam->roam_bg_scan_bad_rssi_thresh =
3371 cfg_params->roam_params.bg_scan_bad_rssi_thresh;
3372 pParam->roam_bg_scan_client_bitmap =
3373 cfg_params->roam_params.bg_scan_client_bitmap;
Vignesh Viswanathanc018e982017-09-07 18:49:19 +05303374 pParam->roam_bad_rssi_thresh_offset_2g =
3375 cfg_params->roam_params.roam_bad_rssi_thresh_offset_2g;
Varun Reddy Yeturufaad37e2017-07-26 10:54:13 -07003376
Abhinav Kumar271f0632018-03-29 16:01:30 +05303377 pParam->enable_ftopen = cfg_params->enable_ftopen;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05303378 pParam->scan_adaptive_dwell_mode =
3379 cfg_params->scan_adaptive_dwell_mode;
Paul Zhang72697bd2017-12-20 09:24:25 +08003380 pParam->scan_adaptive_dwell_mode_nc =
3381 cfg_params->scan_adaptive_dwell_mode_nc;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05303382 pParam->roamscan_adaptive_dwell_mode =
3383 cfg_params->roamscan_adaptive_dwell_mode;
Kapil Gupta5cda2252016-12-29 18:44:26 +05303384
3385 pParam->per_roam_config.enable = cfg_params->per_roam_config.enable;
3386 pParam->per_roam_config.tx_high_rate_thresh =
3387 cfg_params->per_roam_config.tx_high_rate_thresh;
3388 pParam->per_roam_config.rx_high_rate_thresh =
3389 cfg_params->per_roam_config.rx_high_rate_thresh;
3390 pParam->per_roam_config.tx_low_rate_thresh =
3391 cfg_params->per_roam_config.tx_low_rate_thresh;
3392 pParam->per_roam_config.rx_low_rate_thresh =
3393 cfg_params->per_roam_config.rx_low_rate_thresh;
3394 pParam->per_roam_config.tx_rate_thresh_percnt =
3395 cfg_params->per_roam_config.tx_rate_thresh_percnt;
3396 pParam->per_roam_config.rx_rate_thresh_percnt =
3397 cfg_params->per_roam_config.rx_rate_thresh_percnt;
3398 pParam->per_roam_config.per_rest_time =
3399 cfg_params->per_roam_config.per_rest_time;
Kapil Gupta957827b2017-02-13 15:47:04 +05303400 pParam->per_roam_config.tx_per_mon_time =
3401 cfg_params->per_roam_config.tx_per_mon_time;
3402 pParam->per_roam_config.rx_per_mon_time =
3403 cfg_params->per_roam_config.rx_per_mon_time;
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +05303404 pParam->per_roam_config.min_candidate_rssi =
3405 cfg_params->per_roam_config.min_candidate_rssi;
Kapil Gupta5cda2252016-12-29 18:44:26 +05303406
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 pParam->conc_custom_rule1 = cfg_params->conc_custom_rule1;
3408 pParam->conc_custom_rule2 = cfg_params->conc_custom_rule2;
3409 pParam->is_sta_connection_in_5gz_enabled =
3410 cfg_params->is_sta_connection_in_5gz_enabled;
Jeff Johnson1ad3fbd2017-11-03 08:00:02 -07003411 pParam->send_deauth_before_con =
3412 cfg_params->send_deauth_before_con;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413 pParam->max_scan_count = pMac->scan.max_scan_count;
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08003414 pParam->first_scan_bucket_threshold =
3415 pMac->first_scan_bucket_threshold;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003416#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
3417 pParam->sap_channel_avoidance = pMac->sap.sap_channel_avoidance;
3418#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
gaoleze5108942017-03-31 16:56:42 +08003419 pParam->acs_with_more_param = pMac->sap.acs_with_more_param;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003420 pParam->max_intf_count = pMac->sme.max_intf_count;
3421 pParam->enableSelfRecovery = pMac->sme.enableSelfRecovery;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003422 pParam->f_prefer_non_dfs_on_radar =
3423 pMac->f_prefer_non_dfs_on_radar;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003424 pParam->dual_mac_feature_disable =
3425 pMac->dual_mac_feature_disable;
Ganesh Kondabattini930304c2017-10-10 15:25:36 +05303426 pParam->sta_sap_scc_on_dfs_chan =
3427 pMac->sta_sap_scc_on_dfs_chan;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003428 pParam->is_ps_enabled = pMac->sme.ps_global_info.ps_enabled;
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08003429 pParam->auto_bmps_timer_val =
3430 pMac->sme.ps_global_info.auto_bmps_timer_val;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003431 pParam->fEnableDebugLog = pMac->fEnableDebugLog;
3432 pParam->enable5gEBT = pMac->enable5gEBT;
3433 pParam->f_sta_miracast_mcc_rest_time_val =
3434 pMac->f_sta_miracast_mcc_rest_time_val;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003435 pParam->early_stop_scan_enable =
3436 pMac->roam.configParam.early_stop_scan_enable;
3437 pParam->early_stop_scan_min_threshold =
3438 pMac->roam.configParam.early_stop_scan_min_threshold;
3439 pParam->early_stop_scan_max_threshold =
3440 pMac->roam.configParam.early_stop_scan_max_threshold;
Sandeep Puligillae0875662016-02-12 16:09:21 -08003441 pParam->obss_width_interval =
3442 pMac->roam.configParam.obss_width_interval;
3443 pParam->obss_active_dwelltime =
3444 pMac->roam.configParam.obss_active_dwelltime;
3445 pParam->obss_passive_dwelltime =
3446 pMac->roam.configParam.obss_passive_dwelltime;
Abhishek Singh165bc602016-03-21 12:43:00 +05303447 pParam->ignore_peer_ht_opmode =
3448 pMac->roam.configParam.ignore_peer_ht_opmode;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08003449 pParam->enableHtSmps = pMac->roam.configParam.enableHtSmps;
3450 pParam->htSmps = pMac->roam.configParam.htSmps;
3451 pParam->send_smps_action = pMac->roam.configParam.send_smps_action;
Abhishek Singh10ecf582016-05-04 17:48:59 +05303452
3453 pParam->enable_edca_params =
3454 pMac->roam.configParam.enable_edca_params;
3455 pParam->edca_vo_cwmin = pMac->roam.configParam.edca_vo_cwmin;
3456 pParam->edca_vi_cwmin = pMac->roam.configParam.edca_vi_cwmin;
3457 pParam->edca_bk_cwmin = pMac->roam.configParam.edca_bk_cwmin;
3458 pParam->edca_be_cwmin = pMac->roam.configParam.edca_be_cwmin;
3459
3460 pParam->edca_vo_cwmax = pMac->roam.configParam.edca_vo_cwmax;
3461 pParam->edca_vi_cwmax = pMac->roam.configParam.edca_vi_cwmax;
3462 pParam->edca_bk_cwmax = pMac->roam.configParam.edca_bk_cwmax;
3463 pParam->edca_be_cwmax = pMac->roam.configParam.edca_be_cwmax;
3464
3465 pParam->edca_vo_aifs = pMac->roam.configParam.edca_vo_aifs;
3466 pParam->edca_vi_aifs = pMac->roam.configParam.edca_vi_aifs;
3467 pParam->edca_bk_aifs = pMac->roam.configParam.edca_bk_aifs;
3468 pParam->edca_be_aifs = pMac->roam.configParam.edca_be_aifs;
Abhishek Singh5ea86532016-04-27 14:10:53 +05303469 pParam->enable_fatal_event =
3470 pMac->roam.configParam.enable_fatal_event;
Agrawal Ashish21ba2572016-09-03 16:40:10 +05303471 pParam->sta_roam_policy_params.dfs_mode =
3472 pMac->roam.configParam.sta_roam_policy.dfs_mode;
3473 pParam->sta_roam_policy_params.skip_unsafe_channels =
3474 pMac->roam.configParam.sta_roam_policy.skip_unsafe_channels;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +05303475 pParam->tx_aggregation_size =
3476 pMac->roam.configParam.tx_aggregation_size;
Paul Zhangee09f8e2018-04-23 16:11:32 +08003477 pParam->tx_aggregation_size_be =
3478 pMac->roam.configParam.tx_aggregation_size_be;
3479 pParam->tx_aggregation_size_bk =
3480 pMac->roam.configParam.tx_aggregation_size_bk;
3481 pParam->tx_aggregation_size_vi =
3482 pMac->roam.configParam.tx_aggregation_size_vi;
3483 pParam->tx_aggregation_size_vo =
3484 pMac->roam.configParam.tx_aggregation_size_vo;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +05303485 pParam->rx_aggregation_size =
3486 pMac->roam.configParam.rx_aggregation_size;
Selvaraj, Sridhar4f684bb2017-01-19 15:59:23 +05303487 pParam->enable_bcast_probe_rsp =
3488 pMac->roam.configParam.enable_bcast_probe_rsp;
Vignesh Viswanathan32761e42017-09-25 17:10:54 +05303489 pParam->is_fils_enabled =
3490 pMac->roam.configParam.is_fils_enabled;
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05303491 pParam->qcn_ie_support =
3492 pMac->roam.configParam.qcn_ie_support;
Selvaraj, Sridhar97ce6582017-01-20 17:06:34 +05303493 pParam->fils_max_chan_guard_time =
3494 pMac->roam.configParam.fils_max_chan_guard_time;
Selvaraj, Sridhar57ce4df2017-05-29 18:30:49 +05303495 pParam->disallow_duration =
3496 pMac->roam.configParam.disallow_duration;
3497 pParam->rssi_channel_penalization =
3498 pMac->roam.configParam.rssi_channel_penalization;
3499 pParam->num_disallowed_aps =
3500 pMac->roam.configParam.num_disallowed_aps;
Yeshwanth Sriram Guntuka2ba6fe92017-10-04 14:40:45 +05303501 pParam->oce_feature_bitmap =
3502 pMac->roam.configParam.oce_feature_bitmap;
Abhinav Kumaredd1d372018-05-11 15:33:35 +05303503 pParam->roam_force_rssi_trigger = cfg_params->roam_force_rssi_trigger;
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -07003504 qdf_mem_copy(&pParam->csr_mawc_config,
3505 &pMac->roam.configParam.csr_mawc_config,
3506 sizeof(pParam->csr_mawc_config));
Sandeep Puligillae0875662016-02-12 16:09:21 -08003507
Himanshu Agarwal8bcec572017-09-28 11:54:37 +05303508 qdf_mem_copy(&pParam->bss_score_params,
3509 &pMac->roam.configParam.bss_score_params,
3510 sizeof(struct sir_score_config));
yeshwanth sriram guntuka41f936c2017-09-01 17:53:49 +05303511 pParam->btm_offload_config = pMac->roam.configParam.btm_offload_config;
Jiachao Wu84bb2ea2018-01-08 16:17:33 +08003512 pParam->btm_solicited_timeout =
3513 pMac->roam.configParam.btm_solicited_timeout;
3514 pParam->btm_max_attempt_cnt =
3515 pMac->roam.configParam.btm_max_attempt_cnt;
3516 pParam->btm_sticky_time = pMac->roam.configParam.btm_sticky_time;
Himanshu Agarwal8bcec572017-09-28 11:54:37 +05303517
Vignesh Viswanathan9dd88d32017-11-22 14:22:03 +05303518 pParam->mbo_thresholds.mbo_candidate_rssi_thres =
3519 pMac->roam.configParam.mbo_thresholds.
3520 mbo_candidate_rssi_thres;
3521 pParam->mbo_thresholds.mbo_current_rssi_thres =
3522 pMac->roam.configParam.mbo_thresholds.
3523 mbo_current_rssi_thres;
3524 pParam->mbo_thresholds.mbo_current_rssi_mcc_thres =
3525 pMac->roam.configParam.mbo_thresholds.
3526 mbo_current_rssi_mcc_thres;
3527 pParam->mbo_thresholds.mbo_candidate_rssi_btc_thres =
3528 pMac->roam.configParam.mbo_thresholds.
3529 mbo_candidate_rssi_btc_thres;
3530
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08003531 csr_get_he_config_param(pParam, pMac);
3532
Vignesh Viswanathan694e28e2018-01-18 20:53:57 +05303533 csr_get_11k_offload_config_param(&pMac->roam.configParam, pParam);
3534
Liangwei Dong81935512018-04-12 23:35:01 -04003535 pParam->wlm_latency_enable = pMac->roam.configParam.wlm_latency_enable;
3536 pParam->wlm_latency_level = pMac->roam.configParam.wlm_latency_level;
3537 for (i = 0; i < CSR_NUM_WLM_LATENCY_LEVEL; i++) {
3538 pParam->wlm_latency_flags[i] =
3539 pMac->roam.configParam.wlm_latency_flags[i];
3540 }
3541
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303542 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543}
3544
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003545QDF_STATUS csr_set_phy_mode(tHalHandle hHal, uint32_t phyMode,
3546 enum band_info eBand, bool *pfRestartNeeded)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003547{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303548 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3550 bool fRestartNeeded = false;
3551 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303552
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003553 if (BAND_2G == eBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554 if (CSR_IS_RADIO_A_ONLY(pMac))
3555 goto end;
3556 if (eCSR_DOT11_MODE_11a & phyMode)
3557 goto end;
3558 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003559 if (BAND_5G == eBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003560 if (CSR_IS_RADIO_BG_ONLY(pMac))
3561 goto end;
3562 if ((eCSR_DOT11_MODE_11b & phyMode)
3563 || (eCSR_DOT11_MODE_11b_ONLY & phyMode)
3564 || (eCSR_DOT11_MODE_11g & phyMode)
3565 || (eCSR_DOT11_MODE_11g_ONLY & phyMode))
3566 goto end;
3567 }
3568 if (eCSR_DOT11_MODE_AUTO & phyMode)
3569 newPhyMode = eCSR_DOT11_MODE_AUTO;
3570 else {
3571 /* Check for dual band and higher capability first */
3572 if (eCSR_DOT11_MODE_11n_ONLY & phyMode) {
3573 if (eCSR_DOT11_MODE_11n_ONLY != phyMode)
3574 goto end;
3575 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
3576 } else if (eCSR_DOT11_MODE_11g_ONLY & phyMode) {
3577 if (eCSR_DOT11_MODE_11g_ONLY != phyMode)
3578 goto end;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003579 if (BAND_5G == eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 goto end;
3581 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003582 eBand = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583 } else if (eCSR_DOT11_MODE_11b_ONLY & phyMode) {
3584 if (eCSR_DOT11_MODE_11b_ONLY != phyMode)
3585 goto end;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003586 if (BAND_5G == eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003587 goto end;
3588 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003589 eBand = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003590 } else if (eCSR_DOT11_MODE_11n & phyMode) {
3591 newPhyMode = eCSR_DOT11_MODE_11n;
3592 } else if (eCSR_DOT11_MODE_abg & phyMode) {
3593 newPhyMode = eCSR_DOT11_MODE_abg;
3594 } else if (eCSR_DOT11_MODE_11a & phyMode) {
3595 if ((eCSR_DOT11_MODE_11g & phyMode)
3596 || (eCSR_DOT11_MODE_11b & phyMode)) {
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003597 if (BAND_ALL == eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 newPhyMode = eCSR_DOT11_MODE_abg;
3599 else
3600 goto end;
3601 } else {
3602 newPhyMode = eCSR_DOT11_MODE_11a;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003603 eBand = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604 }
3605 } else if (eCSR_DOT11_MODE_11g & phyMode) {
3606 newPhyMode = eCSR_DOT11_MODE_11g;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003607 eBand = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003608 } else if (eCSR_DOT11_MODE_11b & phyMode) {
3609 newPhyMode = eCSR_DOT11_MODE_11b;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08003610 eBand = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003611 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003612 sme_err("can't recognize phymode 0x%08X", phyMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003613 newPhyMode = eCSR_DOT11_MODE_AUTO;
3614 }
3615 }
3616 /* Done validating */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303617 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 /* Now we need to check whether a restart is needed. */
3619 if (eBand != pMac->roam.configParam.eBand) {
3620 fRestartNeeded = true;
3621 goto end;
3622 }
3623 if (newPhyMode != pMac->roam.configParam.phyMode) {
3624 fRestartNeeded = true;
3625 goto end;
3626 }
3627end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303628 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 pMac->roam.configParam.eBand = eBand;
3630 pMac->roam.configParam.phyMode = newPhyMode;
3631 if (pfRestartNeeded)
3632 *pfRestartNeeded = fRestartNeeded;
3633 }
3634 return status;
3635}
3636
3637/**
3638 * csr_prune_ch_list() - prunes the channel list to keep only a type of channels
3639 * @ch_lst: existing channel list
3640 * @is_24_GHz: indicates if 2.5 GHz or 5 GHz channels are required
3641 *
3642 * Return: void
3643 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303644static void csr_prune_ch_list(struct csr_channel *ch_lst, bool is_24_GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645{
3646 uint8_t idx = 0, num_channels = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303647
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648 for ( ; idx < ch_lst->numChannels; idx++) {
3649 if (is_24_GHz) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07003650 if (WLAN_REG_IS_24GHZ_CH(ch_lst->channelList[idx])) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 ch_lst->channelList[num_channels] =
3652 ch_lst->channelList[idx];
3653 num_channels++;
3654 }
3655 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07003656 if (WLAN_REG_IS_5GHZ_CH(ch_lst->channelList[idx])) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003657 ch_lst->channelList[num_channels] =
3658 ch_lst->channelList[idx];
3659 num_channels++;
3660 }
3661 }
3662 }
3663 /*
3664 * Cleanup the rest of channels. Note we only need to clean up the
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303665 * channels if we had to trim the list. Calling qdf_mem_set() with a 0
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 * size is going to throw asserts on the debug builds so let's be a bit
3667 * smarter about that. Zero out the reset of the channels only if we
3668 * need to. The amount of memory to clear is the number of channesl that
3669 * we trimmed (ch_lst->numChannels - num_channels) times the size of a
3670 * channel in the structure.
3671 */
3672 if (ch_lst->numChannels > num_channels) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303673 qdf_mem_set(&ch_lst->channelList[num_channels],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003674 sizeof(ch_lst->channelList[0]) *
3675 (ch_lst->numChannels - num_channels), 0);
3676 }
3677 ch_lst->numChannels = num_channels;
3678}
3679
3680/**
3681 * csr_prune_channel_list_for_mode() - prunes the channel list
3682 * @mac_ctx: global mac context
3683 * @ch_lst: existing channel list
3684 *
3685 * Prunes the channel list according to band stored in mac_ctx
3686 *
3687 * Return: void
3688 */
3689void csr_prune_channel_list_for_mode(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303690 struct csr_channel *ch_lst)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691{
3692 /* for dual band NICs, don't need to trim the channel list.... */
3693 if (CSR_IS_OPEARTING_DUAL_BAND(mac_ctx))
3694 return;
3695 /*
3696 * 2.4 GHz band operation requires the channel list to be trimmed to
3697 * the 2.4 GHz channels only
3698 */
3699 if (CSR_IS_24_BAND_ONLY(mac_ctx))
3700 csr_prune_ch_list(ch_lst, true);
3701 else if (CSR_IS_5G_BAND_ONLY(mac_ctx))
3702 csr_prune_ch_list(ch_lst, false);
3703}
3704
3705#define INFRA_AP_DEFAULT_CHANNEL 6
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303706QDF_STATUS csr_is_valid_channel(tpAniSirGlobal pMac, uint8_t chnNum)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003707{
3708 uint8_t index = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303709 QDF_STATUS status = QDF_STATUS_E_NOSUPPORT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710
3711 /* regulatory check */
3712 for (index = 0; index < pMac->scan.base_channels.numChannels;
3713 index++) {
3714 if (pMac->scan.base_channels.channelList[index] == chnNum) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303715 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003716 break;
3717 }
3718 }
3719
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303720 if (status == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003721 /* dfs nol */
3722 for (index = 0;
3723 index <
3724 pMac->sap.SapDfsInfo.numCurrentRegDomainDfsChannels;
3725 index++) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303726 tSapDfsNolInfo *dfsChan = &pMac->sap.SapDfsInfo.
3727 sapDfsChannelNolList[index];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728 if ((dfsChan->dfs_channel_number == chnNum)
3729 && (dfsChan->radar_status_flag ==
3730 eSAP_DFS_CHANNEL_UNAVAILABLE)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303731 QDF_TRACE(QDF_MODULE_ID_SME,
3732 QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003733 FL("channel %d is in dfs nol"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734 chnNum);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303735 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003736 break;
3737 }
3738 }
3739 }
3740
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303741 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303742 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003743 FL("channel %d is not available"), chnNum);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003744 }
3745
3746 return status;
3747}
3748
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303749QDF_STATUS csr_get_channel_and_power_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003750{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303751 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003752 uint8_t num20MHzChannelsFound = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303753 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003754 uint8_t Index = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003755
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07003756 qdf_status = wlan_reg_get_channel_list_with_power(pMac->pdev,
3757 pMac->scan.defaultPowerTable,
3758 &num20MHzChannelsFound);
Amar Singhal7ccdc4f2015-10-30 15:10:05 -07003759
3760 if ((QDF_STATUS_SUCCESS != qdf_status) ||
3761 (num20MHzChannelsFound == 0)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003762 sme_err("failed to get channels");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303763 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003764 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303765 if (num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003766 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003767 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
3768 /* Move the channel list to the global data */
3769 /* structure -- this will be used as the scan list */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303770 for (Index = 0; Index < num20MHzChannelsFound; Index++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771 pMac->scan.base_channels.channelList[Index] =
Amar Singhala297bfa2015-10-15 15:07:29 -07003772 pMac->scan.defaultPowerTable[Index].chan_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003773 pMac->scan.base_channels.numChannels =
3774 num20MHzChannelsFound;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003775 }
3776 return status;
3777}
3778
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303779QDF_STATUS csr_apply_channel_and_power_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003780{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303781 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782
3783 csr_prune_channel_list_for_mode(pMac, &pMac->scan.base_channels);
3784 csr_save_channel_power_for_band(pMac, false);
3785 csr_save_channel_power_for_band(pMac, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786 csr_apply_channel_power_info_to_fw(pMac,
3787 &pMac->scan.base_channels,
3788 pMac->scan.countryCodeCurrent);
3789
3790 csr_init_operating_classes((tHalHandle) pMac);
3791 return status;
3792}
3793
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303794static QDF_STATUS csr_init11d_info(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303796 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797 uint8_t index;
3798 uint32_t count = 0;
3799 tSirMacChanInfo *pChanInfo;
3800 tSirMacChanInfo *pChanInfoStart;
3801 bool applyConfig = true;
3802
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303803 if (!ps11dinfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003804 return status;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303805
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806 if (ps11dinfo->Channels.numChannels
3807 && (WNI_CFG_VALID_CHANNEL_LIST_LEN >=
3808 ps11dinfo->Channels.numChannels)) {
3809 pMac->scan.base_channels.numChannels =
3810 ps11dinfo->Channels.numChannels;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303811 qdf_mem_copy(pMac->scan.base_channels.channelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812 ps11dinfo->Channels.channelList,
3813 ps11dinfo->Channels.numChannels);
3814 } else {
3815 /* No change */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303816 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817 }
3818 /* legacy maintenance */
3819
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303820 qdf_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003821 WNI_CFG_COUNTRY_CODE_LEN);
3822
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303823 /* Tush: at csropen get this initialized with default,
3824 * during csr reset if this already set with some value
3825 * no need initilaize with default again
3826 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827 if (0 == pMac->scan.countryCodeCurrent[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303828 qdf_mem_copy(pMac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003829 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
3830 }
3831 /* need to add the max power channel list */
3832 pChanInfo =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303833 qdf_mem_malloc(sizeof(tSirMacChanInfo) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003834 WNI_CFG_VALID_CHANNEL_LIST_LEN);
3835 if (pChanInfo != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003836 pChanInfoStart = pChanInfo;
3837 for (index = 0; index < ps11dinfo->Channels.numChannels;
3838 index++) {
3839 pChanInfo->firstChanNum =
3840 ps11dinfo->ChnPower[index].firstChannel;
3841 pChanInfo->numChannels =
3842 ps11dinfo->ChnPower[index].numChannels;
3843 pChanInfo->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303844 QDF_MIN(ps11dinfo->ChnPower[index].maxtxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845 pMac->roam.configParam.nTxPowerCap);
3846 pChanInfo++;
3847 count++;
3848 }
3849 if (count) {
Ravi Kumar Bokkac20393f2017-07-27 12:49:52 +05303850 status = csr_save_to_channel_power2_g_5_g(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003851 count *
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303852 sizeof(tSirMacChanInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003853 pChanInfoStart);
3854 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303855 qdf_mem_free(pChanInfoStart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303857 /* Only apply them to CFG when not in STOP state.
3858 * Otherwise they will be applied later
3859 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303860 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003861 for (index = 0; index < CSR_ROAM_SESSION_MAX; index++) {
3862 if ((CSR_IS_SESSION_VALID(pMac, index))
3863 && CSR_IS_ROAM_STOP(pMac, index)) {
3864 applyConfig = false;
3865 }
3866 }
3867
3868 if (true == applyConfig) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303869 /* Apply the base channel list, power info,
3870 * and set the Country code.
3871 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003872 csr_apply_channel_power_info_to_fw(pMac,
3873 &pMac->scan.
3874 base_channels,
3875 pMac->scan.
3876 countryCodeCurrent);
3877 }
3878 }
3879 return status;
3880}
3881
3882/* Initialize the Channel + Power List in the local cache and in the CFG */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303883QDF_STATUS csr_init_channel_power_list(tpAniSirGlobal pMac,
3884 tCsr11dinfo *ps11dinfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885{
3886 uint8_t index;
3887 uint32_t count = 0;
3888 tSirMacChanInfo *pChanInfo;
3889 tSirMacChanInfo *pChanInfoStart;
3890
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303891 if (!ps11dinfo || !pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303892 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003893
3894 pChanInfo =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303895 qdf_mem_malloc(sizeof(tSirMacChanInfo) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896 WNI_CFG_VALID_CHANNEL_LIST_LEN);
3897 if (pChanInfo != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003898 pChanInfoStart = pChanInfo;
3899
3900 for (index = 0; index < ps11dinfo->Channels.numChannels;
3901 index++) {
3902 pChanInfo->firstChanNum =
3903 ps11dinfo->ChnPower[index].firstChannel;
3904 pChanInfo->numChannels =
3905 ps11dinfo->ChnPower[index].numChannels;
3906 pChanInfo->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303907 QDF_MIN(ps11dinfo->ChnPower[index].maxtxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 pMac->roam.configParam.nTxPowerCap);
3909 pChanInfo++;
3910 count++;
3911 }
3912 if (count) {
3913 csr_save_to_channel_power2_g_5_g(pMac,
3914 count *
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303915 sizeof(tSirMacChanInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003916 pChanInfoStart);
3917 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303918 qdf_mem_free(pChanInfoStart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 }
3920
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303921 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003922}
3923
Abhishek Singhd86d9832015-12-30 17:18:13 +05303924/**
3925 * csr_roam_remove_duplicate_cmd_from_list()- Remove duplicate roam cmd from
3926 * list
3927 *
3928 * @mac_ctx: pointer to global mac
3929 * @session_id: session id for the cmd
3930 * @list: pending list from which cmd needs to be removed
3931 * @command: cmd to be removed, can be NULL
3932 * @roam_reason: cmd with reason to be removed
3933 *
3934 * Remove duplicate command from the pending list.
3935 *
3936 * Return: void
3937 */
Krunal Soni72dba662017-02-15 20:13:17 -08003938static void csr_roam_remove_duplicate_pending_cmd_from_list(
3939 tpAniSirGlobal mac_ctx,
3940 uint32_t session_id,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05303941 tSmeCmd *command, enum csr_roam_reason roam_reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003942{
Abhishek Singhd86d9832015-12-30 17:18:13 +05303943 tListElem *entry, *next_entry;
3944 tSmeCmd *dup_cmd;
3945 tDblLinkList local_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003946
Abhishek Singhd86d9832015-12-30 17:18:13 +05303947 qdf_mem_zero(&local_list, sizeof(tDblLinkList));
3948 if (!QDF_IS_STATUS_SUCCESS(csr_ll_open(mac_ctx->hHdd, &local_list))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003949 sme_err("failed to open list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003950 return;
3951 }
Krunal Soni72dba662017-02-15 20:13:17 -08003952 csr_nonscan_pending_ll_lock(mac_ctx);
Krunal Sonia8270f52017-02-23 19:51:25 -08003953 entry = csr_nonscan_pending_ll_peek_head(mac_ctx, LL_ACCESS_NOLOCK);
Abhishek Singhd86d9832015-12-30 17:18:13 +05303954 while (entry) {
Krunal Soni72dba662017-02-15 20:13:17 -08003955 next_entry = csr_nonscan_pending_ll_next(mac_ctx, entry,
3956 LL_ACCESS_NOLOCK);
Abhishek Singhd86d9832015-12-30 17:18:13 +05303957 dup_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
3958 /*
Abhinav Kumar74948192018-05-09 17:17:50 +05303959 * If command is not NULL remove the similar duplicate cmd for
3960 * same reason as command. If command is NULL then check if
3961 * roam_reason is eCsrForcedDisassoc (disconnect) and remove
3962 * all roam command for the sessionId, else if roam_reason is
3963 * eCsrHddIssued (connect) remove all connect (non disconenct)
3964 * commands.
Abhishek Singhd86d9832015-12-30 17:18:13 +05303965 */
3966 if ((command && (command->sessionId == dup_cmd->sessionId) &&
3967 ((command->command == dup_cmd->command) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968 /*
Jeff Johnson265d6a72018-05-12 09:46:20 -07003969 * This peermac check is required for Softap/GO
Abhishek Singhd86d9832015-12-30 17:18:13 +05303970 * scenarios. for STA scenario below OR check will
3971 * suffice as command will always be NULL for
3972 * STA scenarios
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003973 */
Abhishek Singhd86d9832015-12-30 17:18:13 +05303974 (!qdf_mem_cmp(dup_cmd->u.roamCmd.peerMac,
3975 command->u.roamCmd.peerMac,
3976 sizeof(QDF_MAC_ADDR_SIZE))) &&
3977 ((command->u.roamCmd.roamReason ==
3978 dup_cmd->u.roamCmd.roamReason) ||
3979 (eCsrForcedDisassoc ==
3980 command->u.roamCmd.roamReason) ||
3981 (eCsrHddIssued ==
3982 command->u.roamCmd.roamReason)))) ||
3983 /* OR if pCommand is NULL */
3984 ((session_id == dup_cmd->sessionId) &&
3985 (eSmeCommandRoam == dup_cmd->command) &&
3986 ((eCsrForcedDisassoc == roam_reason) ||
Abhinav Kumar74948192018-05-09 17:17:50 +05303987 (eCsrHddIssued == roam_reason &&
3988 !CSR_IS_DISCONNECT_COMMAND(dup_cmd))))) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303989 sme_debug("RoamReason: %d",
3990 dup_cmd->u.roamCmd.roamReason);
Abhishek Singhd86d9832015-12-30 17:18:13 +05303991 /* Remove the roam command from the pending list */
Krunal Soni72dba662017-02-15 20:13:17 -08003992 if (csr_nonscan_pending_ll_remove_entry(mac_ctx,
3993 entry, LL_ACCESS_NOLOCK))
Abhishek Singhd86d9832015-12-30 17:18:13 +05303994 csr_ll_insert_tail(&local_list, entry,
3995 LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003996 }
Abhishek Singhd86d9832015-12-30 17:18:13 +05303997 entry = next_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003998 }
Krunal Soni72dba662017-02-15 20:13:17 -08003999 csr_nonscan_pending_ll_unlock(mac_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004000
Abhishek Singhd86d9832015-12-30 17:18:13 +05304001 while ((entry = csr_ll_remove_head(&local_list, LL_ACCESS_NOLOCK))) {
4002 dup_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003 /* Tell caller that the command is cancelled */
Abhishek Singhd86d9832015-12-30 17:18:13 +05304004 csr_roam_call_callback(mac_ctx, dup_cmd->sessionId, NULL,
4005 dup_cmd->u.roamCmd.roamId,
4006 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
Krunal Sonidea45952017-02-15 11:58:15 -08004007 csr_release_command(mac_ctx, dup_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008 }
Abhishek Singhd86d9832015-12-30 17:18:13 +05304009 csr_ll_close(&local_list);
4010}
4011
4012/**
4013 * csr_roam_remove_duplicate_command()- Remove duplicate roam cmd
4014 * from pending lists.
4015 *
4016 * @mac_ctx: pointer to global mac
4017 * @session_id: session id for the cmd
4018 * @command: cmd to be removed, can be null
4019 * @roam_reason: cmd with reason to be removed
4020 *
4021 * Remove duplicate command from the sme and roam pending list.
4022 *
4023 * Return: void
4024 */
4025void csr_roam_remove_duplicate_command(tpAniSirGlobal mac_ctx,
4026 uint32_t session_id, tSmeCmd *command,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304027 enum csr_roam_reason roam_reason)
Abhishek Singhd86d9832015-12-30 17:18:13 +05304028{
4029 /* Always lock active list before locking pending lists */
Krunal Soni20126cb2017-02-15 16:26:57 -08004030 csr_nonscan_active_ll_lock(mac_ctx);
Krunal Soni72dba662017-02-15 20:13:17 -08004031 csr_roam_remove_duplicate_pending_cmd_from_list(mac_ctx,
4032 session_id, command, roam_reason);
Krunal Soni20126cb2017-02-15 16:26:57 -08004033 csr_nonscan_active_ll_unlock(mac_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034}
4035
4036/**
4037 * csr_roam_populate_channels() - Helper function to populate channels
4038 * @beacon_ies: pointer to beacon ie
4039 * @roam_info: Roaming related information
4040 * @chan1: center freq 1
4041 * @chan2: center freq2
4042 *
4043 * This function will issue populate chan1 and chan2 based on beacon ie
4044 *
4045 * Return: none.
4046 */
4047static void csr_roam_populate_channels(tDot11fBeaconIEs *beacon_ies,
Jeff Johnson172237b2017-11-07 15:32:59 -08004048 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004049 uint8_t *chan1, uint8_t *chan2)
4050{
4051 ePhyChanBondState phy_state;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304052
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004053 if (beacon_ies->VHTOperation.present) {
4054 *chan1 = beacon_ies->VHTOperation.chanCenterFreqSeg1;
4055 *chan2 = beacon_ies->VHTOperation.chanCenterFreqSeg2;
4056 roam_info->chan_info.info = MODE_11AC_VHT80;
4057 } else if (beacon_ies->HTInfo.present) {
4058 if (beacon_ies->HTInfo.recommendedTxWidthSet ==
4059 eHT_CHANNEL_WIDTH_40MHZ) {
4060 phy_state = beacon_ies->HTInfo.secondaryChannelOffset;
4061 if (phy_state == PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
4062 *chan1 = beacon_ies->HTInfo.primaryChannel +
4063 CSR_CB_CENTER_CHANNEL_OFFSET;
4064 else if (phy_state == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
4065 *chan1 = beacon_ies->HTInfo.primaryChannel -
4066 CSR_CB_CENTER_CHANNEL_OFFSET;
4067 else
4068 *chan1 = beacon_ies->HTInfo.primaryChannel;
4069
4070 roam_info->chan_info.info = MODE_11NA_HT40;
4071 } else {
4072 *chan1 = beacon_ies->HTInfo.primaryChannel;
4073 roam_info->chan_info.info = MODE_11NA_HT20;
4074 }
4075 *chan2 = 0;
4076 } else {
4077 *chan1 = 0;
4078 *chan2 = 0;
4079 roam_info->chan_info.info = MODE_11A;
4080 }
4081}
4082
Krunal Soni4b6c9462018-03-09 15:56:56 -08004083#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4084static const char *csr_get_ch_width_str(uint8_t ch_width)
4085{
4086 switch (ch_width) {
4087 CASE_RETURN_STRING(BW_20MHZ);
4088 CASE_RETURN_STRING(BW_40MHZ);
4089 CASE_RETURN_STRING(BW_80MHZ);
4090 CASE_RETURN_STRING(BW_160MHZ);
4091 CASE_RETURN_STRING(BW_80P80MHZ);
4092 CASE_RETURN_STRING(BW_5MHZ);
4093 CASE_RETURN_STRING(BW_10MHZ);
4094 default:
4095 return "Unknown";
4096 }
4097}
4098
4099static const char *csr_get_dot11_mode_str(enum csr_cfgdot11mode dot11mode)
4100{
4101 switch (dot11mode) {
4102 CASE_RETURN_STRING(DOT11_MODE_AUTO);
4103 CASE_RETURN_STRING(DOT11_MODE_ABG);
4104 CASE_RETURN_STRING(DOT11_MODE_11A);
4105 CASE_RETURN_STRING(DOT11_MODE_11B);
4106 CASE_RETURN_STRING(DOT11_MODE_11G);
4107 CASE_RETURN_STRING(DOT11_MODE_11N);
4108 CASE_RETURN_STRING(DOT11_MODE_11AC);
4109 CASE_RETURN_STRING(DOT11_MODE_11G_ONLY);
4110 CASE_RETURN_STRING(DOT11_MODE_11N_ONLY);
4111 CASE_RETURN_STRING(DOT11_MODE_11AC_ONLY);
4112 CASE_RETURN_STRING(DOT11_MODE_11AX);
4113 CASE_RETURN_STRING(DOT11_MODE_11AX_ONLY);
4114 default:
4115 return "Unknown";
4116 }
4117}
4118
4119static const char *csr_get_auth_type_str(uint8_t auth_type)
4120{
4121 switch (auth_type) {
4122 CASE_RETURN_STRING(AUTH_OPEN);
4123 CASE_RETURN_STRING(AUTH_SHARED);
4124 CASE_RETURN_STRING(AUTH_WPA_EAP);
4125 CASE_RETURN_STRING(AUTH_WPA_PSK);
4126 CASE_RETURN_STRING(AUTH_WPA2_EAP);
4127 CASE_RETURN_STRING(AUTH_WPA2_PSK);
4128 CASE_RETURN_STRING(AUTH_WAPI_CERT);
4129 CASE_RETURN_STRING(AUTH_WAPI_PSK);
4130 default:
4131 return "Unknown";
4132 }
4133}
4134
4135static const char *csr_get_encr_type_str(uint8_t encr_type)
4136{
4137 switch (encr_type) {
4138 CASE_RETURN_STRING(ENC_MODE_OPEN);
4139 CASE_RETURN_STRING(ENC_MODE_WEP40);
4140 CASE_RETURN_STRING(ENC_MODE_WEP104);
4141 CASE_RETURN_STRING(ENC_MODE_TKIP);
4142 CASE_RETURN_STRING(ENC_MODE_AES);
4143 CASE_RETURN_STRING(ENC_MODE_AES_GCMP);
4144 CASE_RETURN_STRING(ENC_MODE_AES_GCMP_256);
4145 CASE_RETURN_STRING(ENC_MODE_SMS4);
4146 default:
4147 return "Unknown";
4148 }
4149}
4150
4151static void csr_dump_connection_stats(tpAniSirGlobal mac_ctx,
4152 struct csr_roam_session *session,
4153 struct csr_roam_info *roam_info,
4154 eRoamCmdStatus u1, eCsrRoamResult u2)
4155{
4156 struct tagCsrRoamConnectedProfile *conn_profile;
4157 struct csr_roam_profile *profile;
4158 WLAN_HOST_DIAG_EVENT_DEF(conn_stats,
4159 struct host_event_wlan_connection_stats);
4160
4161 if (!session || !session->pCurRoamProfile || !roam_info)
4162 return;
4163
4164 conn_profile = roam_info->u.pConnectedProfile;
4165 if (!conn_profile)
4166 return;
4167 profile = session->pCurRoamProfile;
4168 qdf_mem_set(&conn_stats,
4169 sizeof(struct host_event_wlan_connection_stats), 0);
4170 qdf_mem_copy(conn_stats.bssid, conn_profile->bssid.bytes,
4171 QDF_MAC_ADDR_SIZE);
4172 conn_stats.ssid_len = conn_profile->SSID.length;
4173 if (conn_stats.ssid_len > SIR_MAC_MAX_SSID_LENGTH)
4174 conn_stats.ssid_len = SIR_MAC_MAX_SSID_LENGTH;
4175 qdf_mem_copy(conn_stats.ssid, conn_profile->SSID.ssId,
4176 conn_stats.ssid_len);
4177 sme_get_rssi_snr_by_bssid(mac_ctx, session->pCurRoamProfile,
4178 &conn_stats.bssid[0],
4179 &conn_stats.rssi, NULL);
4180 conn_stats.est_link_speed = 0;
4181 conn_stats.chnl_bw =
4182 diag_ch_width_from_csr_type(conn_profile->vht_channel_width);
4183 conn_stats.dot11mode =
4184 diag_dot11_mode_from_csr_type(conn_profile->dot11Mode);
4185 conn_stats.bss_type =
4186 diag_persona_from_csr_type(session->pCurRoamProfile->csrPersona);
4187 conn_stats.operating_channel = conn_profile->operationChannel;
4188 conn_stats.qos_capability = conn_profile->qosConnection;
4189 conn_stats.auth_type =
4190 diag_auth_type_from_csr_type(conn_profile->AuthType);
4191 conn_stats.encryption_type =
4192 diag_enc_type_from_csr_type(conn_profile->EncryptionType);
4193 conn_stats.result_code = (u2 == eCSR_ROAM_RESULT_ASSOCIATED) ? 1 : 0;
4194 conn_stats.reason_code = 0;
4195 sme_debug("+---------CONNECTION INFO START------------+");
4196 sme_debug("connection stats for session-id: %d", session->sessionId);
4197 sme_debug("ssid: %.*s", conn_stats.ssid_len, conn_stats.ssid);
4198 sme_debug("bssid: %pM", conn_stats.bssid);
4199 sme_debug("rssi: %d dBm", conn_stats.rssi);
4200 sme_debug("channel: %d", conn_stats.operating_channel);
4201 sme_debug("dot11Mode: %s",
4202 csr_get_dot11_mode_str(conn_stats.dot11mode));
4203 sme_debug("channel bw: %s",
4204 csr_get_ch_width_str(conn_stats.chnl_bw));
4205 sme_debug("Qos enable: %d", conn_stats.qos_capability);
4206 sme_debug("Auth-type: %s",
4207 csr_get_auth_type_str(conn_stats.auth_type));
4208 sme_debug("Encry-type: %s",
4209 csr_get_encr_type_str(conn_stats.encryption_type));
4210 sme_debug("is associated?: %s",
4211 (conn_stats.result_code ? "yes" : "no"));
4212 sme_debug("+---------CONNECTION INFO END------------+");
4213
4214 WLAN_HOST_DIAG_EVENT_REPORT(&conn_stats, EVENT_WLAN_CONN_STATS_V2);
4215}
4216#else
4217static void csr_dump_connection_stats(tpAniSirGlobal mac_ctx,
4218 struct csr_roam_session *session,
4219 struct csr_roam_info *roam_info,
4220 eRoamCmdStatus u1, eCsrRoamResult u2)
4221{}
4222
4223#endif
4224
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304225QDF_STATUS csr_roam_call_callback(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson172237b2017-11-07 15:32:59 -08004226 struct csr_roam_info *roam_info,
4227 uint32_t roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004228 eRoamCmdStatus u1, eCsrRoamResult u2)
4229{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304230 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
4232 uint32_t rssi = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304233
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004234 WLAN_HOST_DIAG_EVENT_DEF(connectionStatus,
4235 host_event_wlan_status_payload_type);
4236#endif
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304237 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004238 tDot11fBeaconIEs *beacon_ies = NULL;
4239 uint8_t chan1, chan2;
4240
4241 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004242 sme_err("Session ID: %d is not valid", sessionId);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304243 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304244 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004245 }
4246 pSession = CSR_GET_SESSION(pMac, sessionId);
4247
4248 if (false == pSession->sessionActive) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004249 sme_debug("Session is not Active");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304250 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 }
4252
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004253 if (eCSR_ROAM_ASSOCIATION_COMPLETION == u1 &&
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004254 eCSR_ROAM_RESULT_ASSOCIATED == u2 && roam_info) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004255 sme_info("Assoc complete result: %d status: %d reason: %d",
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004256 u2, roam_info->statusCode, roam_info->reasonCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304257 beacon_ies = qdf_mem_malloc(sizeof(tDot11fBeaconIEs));
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004258 if ((NULL != beacon_ies) && (NULL != roam_info->pBssDesc)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259 status = csr_parse_bss_description_ies(
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004260 (tHalHandle) pMac, roam_info->pBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004261 beacon_ies);
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004262 csr_roam_populate_channels(beacon_ies, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004263 &chan1, &chan2);
4264 if (0 != chan1)
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004265 roam_info->chan_info.band_center_freq1 =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004266 cds_chan_to_freq(chan1);
4267 else
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004268 roam_info->chan_info.band_center_freq1 = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004269 if (0 != chan2)
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004270 roam_info->chan_info.band_center_freq2 =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004271 cds_chan_to_freq(chan2);
4272 else
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004273 roam_info->chan_info.band_center_freq2 = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274 } else {
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004275 roam_info->chan_info.band_center_freq1 = 0;
4276 roam_info->chan_info.band_center_freq2 = 0;
4277 roam_info->chan_info.info = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004278 }
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004279 roam_info->chan_info.chan_id =
4280 roam_info->u.pConnectedProfile->operationChannel;
4281 roam_info->chan_info.mhz =
4282 cds_chan_to_freq(roam_info->chan_info.chan_id);
4283 roam_info->chan_info.reg_info_1 =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284 (csr_get_cfg_max_tx_power(pMac,
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004285 roam_info->chan_info.chan_id) << 16);
4286 roam_info->chan_info.reg_info_2 =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287 (csr_get_cfg_max_tx_power(pMac,
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004288 roam_info->chan_info.chan_id) << 8);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304289 qdf_mem_free(beacon_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004290 } else if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED)
4291 && (pSession->bRefAssocStartCnt)) {
4292 /*
4293 * Decrement bRefAssocStartCnt for FT reassoc failure.
4294 * Reason: For FT reassoc failures, we first call
4295 * csr_roam_call_callback before notifying a failed roam
4296 * completion through csr_roam_complete. The latter in
4297 * turn calls csr_roam_process_results which tries to
4298 * once again call csr_roam_call_callback if bRefAssocStartCnt
4299 * is non-zero. Since this is redundant for FT reassoc
4300 * failure, decrement bRefAssocStartCnt.
4301 */
4302 pSession->bRefAssocStartCnt--;
Naveen Rawatc3411bb2018-04-30 14:28:52 -07004303 } else if (roam_info && (u1 == eCSR_ROAM_SET_CHANNEL_RSP)
4304 && (u2 == eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004305 pSession->connectedProfile.operationChannel =
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004306 roam_info->channelChangeRespEvent->newChannelNumber;
Krunal Soni8d184fa2017-11-20 21:52:05 -08004307 } else if ((u1 == eCSR_ROAM_SESSION_OPENED) &&
4308 (u2 == eCSR_ROAM_RESULT_NONE)) {
4309 if (pSession->session_open_cb)
4310 pSession->session_open_cb(sessionId);
4311 else
4312 sme_err("session_open_cb is not registered");
4313 }
Krunal Soni4b6c9462018-03-09 15:56:56 -08004314 if (eCSR_ROAM_ASSOCIATION_COMPLETION == u1)
4315 csr_dump_connection_stats(pMac, pSession, roam_info, u1, u2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004316
4317 if (NULL != pSession->callback) {
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004318 if (roam_info) {
4319 roam_info->sessionId = (uint8_t) sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320 /*
4321 * the reasonCode will be passed to supplicant by
4322 * cfg80211_disconnected. Based on the document,
4323 * the reason code passed to supplicant needs to set
Jeff Johnsonbbca3d52018-05-10 14:59:38 -07004324 * to 0 if unknown. eSIR_BEACON_MISSED reason code is
4325 * not recognizable so that we set to 0 instead.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004326 */
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004327 roam_info->reasonCode =
4328 (roam_info->reasonCode == eSIR_BEACON_MISSED) ?
4329 0 : roam_info->reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004330 }
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004331 status = pSession->callback(pSession->pContext, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004332 roamId, u1, u2);
4333 }
4334 /*
Abhishek Singh7a995582016-04-27 13:53:36 +05304335 * EVENT_WLAN_STATUS_V2: eCSR_ROAM_ASSOCIATION_COMPLETION,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336 * eCSR_ROAM_LOSTLINK,
4337 * eCSR_ROAM_DISASSOCIATED,
4338 */
4339#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304340 qdf_mem_set(&connectionStatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004341 sizeof(host_event_wlan_status_payload_type), 0);
4342
4343 if ((eCSR_ROAM_ASSOCIATION_COMPLETION == u1)
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004344 && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && roam_info) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004345 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
4346 connectionStatus.bssType =
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004347 roam_info->u.pConnectedProfile->BSSType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004348
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004349 if (NULL != roam_info->pBssDesc) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004350 connectionStatus.rssi =
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004351 roam_info->pBssDesc->rssi * (-1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004352 connectionStatus.channel =
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004353 roam_info->pBssDesc->channelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004354 }
4355 if (cfg_set_int(pMac, WNI_CFG_CURRENT_RSSI,
4356 connectionStatus.rssi) == eSIR_FAILURE)
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004357 sme_err("Can't pass WNI_CFG_CURRENT_RSSI to cfg");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004358
4359 connectionStatus.qosCapability =
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004360 roam_info->u.pConnectedProfile->qosConnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004361 connectionStatus.authType =
4362 (uint8_t) diag_auth_type_from_csr_type(
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004363 roam_info->u.pConnectedProfile->AuthType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364 connectionStatus.encryptionType =
4365 (uint8_t) diag_enc_type_from_csr_type(
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004366 roam_info->u.pConnectedProfile->EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304367 qdf_mem_copy(connectionStatus.ssid,
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004368 roam_info->u.pConnectedProfile->SSID.ssId,
4369 roam_info->u.pConnectedProfile->SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004370
4371 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304372 qdf_mem_copy(&pMac->sme.eventPayload, &connectionStatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004373 sizeof(host_event_wlan_status_payload_type));
4374 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05304375 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004376 }
4377 if ((eCSR_ROAM_MIC_ERROR_IND == u1)
4378 || (eCSR_ROAM_RESULT_MIC_FAILURE == u2)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304379 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 sizeof(host_event_wlan_status_payload_type));
4381 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
4382 WNI_CFG_CURRENT_RSSI, &rssi)))
4383 connectionStatus.rssi = rssi;
4384
4385 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
4386 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
4387 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05304388 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004389 }
4390 if (eCSR_ROAM_RESULT_FORCED == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304391 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004392 sizeof(host_event_wlan_status_payload_type));
4393 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
4394 WNI_CFG_CURRENT_RSSI, &rssi)))
4395 connectionStatus.rssi = rssi;
4396
4397 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
4398 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
4399 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05304400 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 }
4402 if (eCSR_ROAM_RESULT_DISASSOC_IND == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304403 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004404 sizeof(host_event_wlan_status_payload_type));
4405 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
4406 WNI_CFG_CURRENT_RSSI, &rssi)))
4407 connectionStatus.rssi = rssi;
4408
4409 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
4410 connectionStatus.reason = eCSR_REASON_DISASSOC;
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004411 if (roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 connectionStatus.reasonDisconnect =
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004413 roam_info->reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414
4415 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05304416 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417 }
4418 if (eCSR_ROAM_RESULT_DEAUTH_IND == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304419 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420 sizeof(host_event_wlan_status_payload_type));
4421 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
4422 WNI_CFG_CURRENT_RSSI, &rssi)))
4423 connectionStatus.rssi = rssi;
4424
4425 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
4426 connectionStatus.reason = eCSR_REASON_DEAUTH;
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004427 if (roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428 connectionStatus.reasonDisconnect =
Jeff Johnsoneddf5442017-10-04 10:55:53 -07004429 roam_info->reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004430 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05304431 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004432 }
4433#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05304434
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435 return status;
4436}
4437
4438/* Returns whether handoff is currently in progress or not */
Jeff Johnson29e2ca12016-10-14 12:50:38 -07004439static
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004440bool csr_roam_is_handoff_in_progress(tpAniSirGlobal pMac, uint8_t sessionId)
4441{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004442 return csr_neighbor_roam_is_handoff_in_progress(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004443}
4444
Jeff Johnson29e2ca12016-10-14 12:50:38 -07004445static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304446QDF_STATUS csr_roam_issue_disassociate(tpAniSirGlobal pMac, uint32_t sessionId,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304447 enum csr_roam_substate NewSubstate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004448 bool fMICFailure)
4449{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304450 QDF_STATUS status = QDF_STATUS_SUCCESS;
Dustin Brownce5b3d32018-01-17 15:07:38 -08004451 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BCAST_INIT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452 uint16_t reasonCode;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304453 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004454
4455 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004456 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304457 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 }
4459
4460 if (fMICFailure) {
4461 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
4462 } else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF) {
4463 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
4464 } else if (eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT == NewSubstate) {
4465 reasonCode = eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
4466 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004467 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304468 "set to reason code eSIR_MAC_DISASSOC_LEAVING_BSS_REASON and set back NewSubstate");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004469 } else {
4470 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
4471 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004472 if ((csr_roam_is_handoff_in_progress(pMac, sessionId)) &&
4473 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)) {
4474 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
4475 &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanc5548422016-02-24 18:33:27 +05304476 qdf_copy_macaddr(&bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.
4478 bssid);
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -08004479 } else if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304480 qdf_mem_copy(&bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304481 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004482 }
4483
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004484 sme_debug("CSR Attempting to Disassociate Bssid=" MAC_ADDRESS_STR
4485 " subState: %s reason: %d", MAC_ADDR_ARRAY(bssId.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486 mac_trace_getcsr_roam_sub_state(NewSubstate), reasonCode);
4487
4488 csr_roam_substate_change(pMac, NewSubstate, sessionId);
4489
4490 status = csr_send_mb_disassoc_req_msg(pMac, sessionId, bssId.bytes,
4491 reasonCode);
4492
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304493 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494 csr_roam_link_down(pMac, sessionId);
4495#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304496 /* no need to tell QoS that we are disassociating, it will be
4497 * taken care off in assoc req for HO
4498 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 if (eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate) {
4500 /* notify QoS module that disassoc happening */
4501 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
4502 SME_QOS_CSR_DISCONNECT_REQ, NULL);
4503 }
4504#endif
4505 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004506 sme_warn("csr_send_mb_disassoc_req_msg failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004507 status);
4508 }
4509
4510 return status;
4511}
4512
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05304513/**
4514 * csr_roam_issue_disassociate_sta_cmd() - disassociate a associated station
4515 * @sessionId: Session Id for Soft AP
4516 * @p_del_sta_params: Pointer to parameters of the station to disassoc
4517 *
4518 * CSR function that HDD calls to delete a associated station
4519 *
4520 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS_* on error
4521 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304522QDF_STATUS csr_roam_issue_disassociate_sta_cmd(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523 uint32_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08004524 struct csr_del_sta_params
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05304525 *p_del_sta_params)
4526
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304528 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529 tSmeCmd *pCommand;
4530
4531 do {
4532 pCommand = csr_get_command_buffer(pMac);
4533 if (!pCommand) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004534 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304535 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004536 break;
4537 }
4538 pCommand->command = eSmeCommandRoam;
4539 pCommand->sessionId = (uint8_t) sessionId;
4540 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05304541 qdf_mem_copy(pCommand->u.roamCmd.peerMac,
4542 p_del_sta_params->peerMacAddr.bytes,
4543 sizeof(pCommand->u.roamCmd.peerMac));
4544 pCommand->u.roamCmd.reason =
4545 (tSirMacReasonCodes)p_del_sta_params->reason_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004546 status = csr_queue_sme_command(pMac, pCommand, false);
Krunal Soniaa179db2017-10-13 19:28:17 -07004547 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004548 sme_err("fail to send message status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549 } while (0);
4550
4551 return status;
4552}
4553
4554/**
4555 * csr_roam_issue_deauthSta() - delete a associated station
4556 * @sessionId: Session Id for Soft AP
4557 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
4558 *
4559 * CSR function that HDD calls to delete a associated station
4560 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304561 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304563QDF_STATUS csr_roam_issue_deauth_sta_cmd(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004564 uint32_t sessionId,
Jeff Johnsone6bf7192017-11-07 15:16:09 -08004565 struct csr_del_sta_params *pDelStaParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304567 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568 tSmeCmd *pCommand;
4569
4570 do {
4571 pCommand = csr_get_command_buffer(pMac);
4572 if (!pCommand) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004573 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304574 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004575 break;
4576 }
4577 pCommand->command = eSmeCommandRoam;
4578 pCommand->sessionId = (uint8_t) sessionId;
4579 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304580 qdf_mem_copy(pCommand->u.roamCmd.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581 pDelStaParams->peerMacAddr.bytes,
4582 sizeof(tSirMacAddr));
4583 pCommand->u.roamCmd.reason =
4584 (tSirMacReasonCodes)pDelStaParams->reason_code;
4585 status = csr_queue_sme_command(pMac, pCommand, false);
Krunal Soniaa179db2017-10-13 19:28:17 -07004586 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004587 sme_err("fail to send message status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004588 } while (0);
4589
4590 return status;
4591}
4592
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304593QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594csr_roam_get_associated_stas(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304595 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004596 void *pfnSapEventCallback, uint8_t *pAssocStasBuf)
4597{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304598 QDF_STATUS status = QDF_STATUS_SUCCESS;
Dustin Brownce5b3d32018-01-17 15:07:38 -08004599 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BCAST_INIT;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304600 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304601
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304603 sme_err("csr_roam_get_associated_stas:CSR Session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004604 return status;
4605 }
4606 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304607 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304608 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304610 sme_err("csr_roam_get_associated_stas:Connected BSS Description in CSR Session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611 return status;
4612 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304613 sme_debug("CSR getting associated stations for Bssid: " MAC_ADDRESS_STR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004614 MAC_ADDR_ARRAY(bssId.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004615 status =
4616 csr_send_mb_get_associated_stas_req_msg(pMac, sessionId, modId,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08004617 bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618 pUsrContext,
4619 pfnSapEventCallback,
4620 pAssocStasBuf);
4621 return status;
4622}
4623
Jeff Johnson29e2ca12016-10-14 12:50:38 -07004624static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304625QDF_STATUS csr_roam_issue_deauth(tpAniSirGlobal pMac, uint32_t sessionId,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304626 enum csr_roam_substate NewSubstate)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304628 QDF_STATUS status = QDF_STATUS_SUCCESS;
Dustin Brownce5b3d32018-01-17 15:07:38 -08004629 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BCAST_INIT;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304630 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631
4632 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004633 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304634 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 }
4636
4637 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304638 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304639 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004641 sme_debug("CSR Attempting to Deauth Bssid= " MAC_ADDRESS_STR,
4642 MAC_ADDR_ARRAY(bssId.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643 csr_roam_substate_change(pMac, NewSubstate, sessionId);
4644
4645 status =
4646 csr_send_mb_deauth_req_msg(pMac, sessionId, bssId.bytes,
4647 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304648 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649 csr_roam_link_down(pMac, sessionId);
4650 else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004651 sme_err("csr_send_mb_deauth_req_msg failed with status %d Session ID: %d"
4652 MAC_ADDRESS_STR, status, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 MAC_ADDR_ARRAY(bssId.bytes));
4654 }
4655
4656 return status;
4657}
4658
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304659QDF_STATUS csr_roam_save_connected_bss_desc(tpAniSirGlobal pMac,
4660 uint32_t sessionId,
4661 tSirBssDescription *pBssDesc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004662{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304663 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304664 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 uint32_t size;
4666
4667 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004668 sme_err(" session %d not found ", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304669 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004670 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304671 /* If no BSS description was found in this connection
4672 * (happens with start IBSS), then nix the BSS description
4673 * that we keep around for the connected BSS) and get out.
4674 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004675 if (NULL == pBssDesc) {
4676 csr_free_connect_bss_desc(pMac, sessionId);
4677 } else {
4678 size = pBssDesc->length + sizeof(pBssDesc->length);
4679 if (NULL != pSession->pConnectBssDesc) {
4680 if (((pSession->pConnectBssDesc->length) +
4681 sizeof(pSession->pConnectBssDesc->length)) <
4682 size) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304683 /* not enough room for the new BSS,
4684 * pMac->roam.pConnectBssDesc is freed inside
4685 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004686 csr_free_connect_bss_desc(pMac, sessionId);
4687 }
4688 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304689 if (NULL == pSession->pConnectBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304690 pSession->pConnectBssDesc = qdf_mem_malloc(size);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304691
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004692 if (NULL == pSession->pConnectBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304693 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694 else
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304695 qdf_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004696 }
4697 return status;
4698}
4699
Jeff Johnson29e2ca12016-10-14 12:50:38 -07004700static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304701QDF_STATUS csr_roam_prepare_bss_config(tpAniSirGlobal pMac,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07004702 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703 tSirBssDescription *pBssDesc,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304704 struct bss_config_param *pBssConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004705 tDot11fBeaconIEs *pIes)
4706{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304707 enum csr_cfgdot11mode cfgDot11Mode;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304708
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304709 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004710 if (pIes == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304711 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304713 qdf_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714 sizeof(tSirMacCapabilityInfo));
4715 /* get qos */
4716 pBssConfig->qosType = csr_get_qo_s_from_bss_desc(pMac, pBssDesc, pIes);
Padma, Santhosh Kumar7eecb5a2018-02-28 19:37:20 +05304717 /* Take SSID always from profile */
4718 qdf_mem_copy(&pBssConfig->SSID.ssId,
4719 pProfile->SSIDs.SSIDList->SSID.ssId,
4720 pProfile->SSIDs.SSIDList->SSID.length);
4721 pBssConfig->SSID.length = pProfile->SSIDs.SSIDList->SSID.length;
4722
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004723 if (csr_is_nullssid(pBssConfig->SSID.ssId, pBssConfig->SSID.length)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004724 sme_warn("BSS desc SSID is a wild card");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004725 /* Return failed if profile doesn't have an SSID either. */
4726 if (pProfile->SSIDs.numOfSSIDs == 0) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004727 sme_warn("BSS desc and profile doesn't have SSID");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304728 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729 }
4730 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07004731 if (WLAN_REG_IS_5GHZ_CH(pBssDesc->channelId))
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004732 pBssConfig->eBand = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004733 else
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004734 pBssConfig->eBand = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004735 /* phymode */
4736 if (csr_is_phy_mode_match(pMac, pProfile->phyMode, pBssDesc,
4737 pProfile, &cfgDot11Mode, pIes)) {
4738 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
4739 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004740 sme_warn("Can not find match phy mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004741 /* force it */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004742 if (BAND_2G == pBssConfig->eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004743 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
4744 else
4745 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
4746 }
Padma, Santhosh Kumar19f57652017-05-26 18:03:45 +05304747
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05304748 sme_debug("phyMode=%d, uCfgDot11Mode=%d negotiatedAuthType %d",
4749 pProfile->phyMode, pBssConfig->uCfgDot11Mode,
4750 pProfile->negotiatedAuthType);
Padma, Santhosh Kumar19f57652017-05-26 18:03:45 +05304751
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004752 /* Qos */
4753 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
4754 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos)) {
4755 /*
4756 * Joining BSS is not 11n capable and WMM is disabled on client.
4757 * Disable QoS and WMM
4758 */
4759 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
4760 }
4761
4762 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N)
4763 || (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC))
4764 && ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP)
4765 || (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF)
4766 || (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF))) {
4767 /* Joining BSS is 11n capable and WMM is disabled on AP. */
4768 /* Assume all HT AP's are QOS AP's and enable WMM */
4769 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
4770 }
4771 /* auth type */
4772 switch (pProfile->negotiatedAuthType) {
4773 default:
4774 case eCSR_AUTH_TYPE_WPA:
4775 case eCSR_AUTH_TYPE_WPA_PSK:
4776 case eCSR_AUTH_TYPE_WPA_NONE:
4777 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4778 pBssConfig->authType = eSIR_OPEN_SYSTEM;
4779 break;
4780 case eCSR_AUTH_TYPE_SHARED_KEY:
4781 pBssConfig->authType = eSIR_SHARED_KEY;
4782 break;
4783 case eCSR_AUTH_TYPE_AUTOSWITCH:
4784 pBssConfig->authType = eSIR_AUTO_SWITCH;
4785 break;
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05304786 case eCSR_AUTH_TYPE_SAE:
4787 pBssConfig->authType = eSIR_AUTH_TYPE_SAE;
4788 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004789 }
4790 /* short slot time */
4791 if (eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode)
4792 pBssConfig->uShortSlotTime =
4793 pMac->roam.configParam.shortSlotTime;
4794 else
4795 pBssConfig->uShortSlotTime = 0;
4796
4797 if (pBssConfig->BssCap.ibss)
4798 /* We don't support 11h on IBSS */
4799 pBssConfig->f11hSupport = false;
4800 else
4801 pBssConfig->f11hSupport =
4802 pMac->roam.configParam.Is11hSupportEnabled;
4803 /* power constraint */
4804 pBssConfig->uPowerLimit =
4805 csr_get11h_power_constraint(pMac, &pIes->PowerConstraints);
4806 /* heartbeat */
4807 if (CSR_IS_11A_BSS(pBssDesc))
4808 pBssConfig->uHeartBeatThresh =
4809 pMac->roam.configParam.HeartbeatThresh50;
4810 else
4811 pBssConfig->uHeartBeatThresh =
4812 pMac->roam.configParam.HeartbeatThresh24;
4813
4814 /*
4815 * Join timeout: if we find a BeaconInterval in the BssDescription,
4816 * then set the Join Timeout to be 10 x the BeaconInterval.
4817 */
Naveen Rawate1fbbe02017-09-05 12:01:56 -07004818 if (pBssDesc->beaconInterval) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004819 /* Make sure it is bigger than the minimal */
4820 pBssConfig->uJoinTimeOut =
Anurag Chouhan6d760662016-02-20 16:05:43 +05304821 QDF_MAX(10 * pBssDesc->beaconInterval,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822 CSR_JOIN_FAILURE_TIMEOUT_MIN);
yeshwanth sriram guntuka6d261f82017-08-24 15:56:47 +05304823 if (pBssConfig->uJoinTimeOut > CSR_JOIN_FAILURE_TIMEOUT_DEFAULT)
4824 pBssConfig->uJoinTimeOut =
4825 CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Naveen Rawate1fbbe02017-09-05 12:01:56 -07004826 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827 pBssConfig->uJoinTimeOut =
4828 CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Naveen Rawate1fbbe02017-09-05 12:01:56 -07004829 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004830 /* validate CB */
Krishna Kumaar Natarajanf86c6ed2017-03-27 11:36:29 -07004831 if ((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
4832 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N_ONLY) ||
4833 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC) ||
4834 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC_ONLY) ||
4835 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AX) ||
4836 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AX_ONLY))
Kiran Kumar Lokere35fb5242017-03-10 20:16:44 -08004837 pBssConfig->cbMode = csr_get_cb_mode_from_ies(pMac,
4838 pBssDesc->channelId, pIes);
4839 else
4840 pBssConfig->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004841
Abhishek Singhb59f8d42017-07-31 14:42:47 +05304842 if (WLAN_REG_IS_24GHZ_CH(pBssDesc->channelId) &&
4843 pProfile->force_24ghz_in_ht20) {
4844 pBssConfig->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
4845 sme_debug("force_24ghz_in_ht20 is set so set cbmode to 0");
4846 }
4847
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304848 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004849}
4850
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304851QDF_STATUS csr_roam_prepare_bss_config_from_profile(
Jeff Johnson66ee8a92018-03-17 15:24:26 -07004852 tpAniSirGlobal pMac, struct csr_roam_profile *pProfile,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05304853 struct bss_config_param *pBssConfig,
4854 tSirBssDescription *pBssDesc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004855{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304856 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004857 uint8_t operationChannel = 0;
4858 uint8_t qAPisEnabled = false;
4859 /* SSID */
4860 pBssConfig->SSID.length = 0;
4861 if (pProfile->SSIDs.numOfSSIDs) {
4862 /* only use the first one */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304863 qdf_mem_copy(&pBssConfig->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864 &pProfile->SSIDs.SSIDList[0].SSID,
4865 sizeof(tSirMacSSid));
4866 } else {
4867 /* SSID must present */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304868 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004869 }
4870 /* Settomg up the capabilities */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304871 if (csr_is_bss_type_ibss(pProfile->BSSType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004872 pBssConfig->BssCap.ibss = 1;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304873 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004874 pBssConfig->BssCap.ess = 1;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304875
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004876 if (eCSR_ENCRYPT_TYPE_NONE !=
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304877 pProfile->EncryptionType.encryptionType[0])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004878 pBssConfig->BssCap.privacy = 1;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304879
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004880 pBssConfig->eBand = pMac->roam.configParam.eBand;
4881 /* phymode */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304882 if (pProfile->ChannelInfo.ChannelList)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004883 operationChannel = pProfile->ChannelInfo.ChannelList[0];
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304884 pBssConfig->uCfgDot11Mode = csr_roam_get_phy_mode_band_for_bss(pMac,
4885 pProfile, operationChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004886 &pBssConfig->eBand);
4887 /* QOS */
4888 /* Is this correct to always set to this // *** */
4889 if (pBssConfig->BssCap.ess == 1) {
4890 /*For Softap case enable WMM */
4891 if (CSR_IS_INFRA_AP(pProfile)
4892 && (eCsrRoamWmmNoQos !=
4893 pMac->roam.configParam.WMMSupportMode)) {
4894 qAPisEnabled = true;
4895 } else
4896 if (csr_roam_get_qos_info_from_bss(pMac, pBssDesc) ==
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304897 QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004898 qAPisEnabled = true;
4899 } else {
4900 qAPisEnabled = false;
4901 }
4902 } else {
4903 qAPisEnabled = true;
4904 }
4905 if ((eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode &&
4906 qAPisEnabled) ||
4907 ((eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode &&
4908 qAPisEnabled))) {
4909 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
4910 } else {
4911 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
4912 }
4913
4914 /* auth type */
4915 /* Take the preferred Auth type. */
4916 switch (pProfile->AuthType.authType[0]) {
4917 default:
4918 case eCSR_AUTH_TYPE_WPA:
4919 case eCSR_AUTH_TYPE_WPA_PSK:
4920 case eCSR_AUTH_TYPE_WPA_NONE:
4921 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4922 pBssConfig->authType = eSIR_OPEN_SYSTEM;
4923 break;
4924 case eCSR_AUTH_TYPE_SHARED_KEY:
4925 pBssConfig->authType = eSIR_SHARED_KEY;
4926 break;
4927 case eCSR_AUTH_TYPE_AUTOSWITCH:
4928 pBssConfig->authType = eSIR_AUTO_SWITCH;
4929 break;
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05304930 case eCSR_AUTH_TYPE_SAE:
4931 pBssConfig->authType = eSIR_AUTH_TYPE_SAE;
4932 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933 }
4934 /* short slot time */
4935 if (WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode) {
4936 pBssConfig->uShortSlotTime =
4937 pMac->roam.configParam.shortSlotTime;
4938 } else {
4939 pBssConfig->uShortSlotTime = 0;
4940 }
4941 /* power constraint. We don't support 11h on IBSS */
4942 pBssConfig->f11hSupport = false;
4943 pBssConfig->uPowerLimit = 0;
4944 /* heartbeat */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08004945 if (BAND_5G == pBssConfig->eBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004946 pBssConfig->uHeartBeatThresh =
4947 pMac->roam.configParam.HeartbeatThresh50;
4948 } else {
4949 pBssConfig->uHeartBeatThresh =
4950 pMac->roam.configParam.HeartbeatThresh24;
4951 }
4952 /* Join timeout */
4953 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
4954
4955 return status;
4956}
4957
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304958static QDF_STATUS csr_roam_get_qos_info_from_bss(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004959 tSirBssDescription *pBssDesc)
4960{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304961 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004962 tDot11fBeaconIEs *pIes = NULL;
4963
4964 do {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304965 if (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004966 csr_get_parsed_bss_description_ies(
4967 pMac, pBssDesc, &pIes))) {
4968 /* err msg */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304969 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004970 "csr_roam_get_qos_info_from_bss() failed");
4971 break;
4972 }
4973 /* check if the AP is QAP & it supports APSD */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304974 if (CSR_IS_QOS_BSS(pIes))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304975 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976 } while (0);
4977
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304978 if (NULL != pIes)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304979 qdf_mem_free(pIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004980
4981 return status;
4982}
4983
Jeff Johnson66ee8a92018-03-17 15:24:26 -07004984void csr_set_cfg_privacy(tpAniSirGlobal pMac, struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004985 bool fPrivacy)
4986{
4987 /*
4988 * the only difference between this function and
4989 * the csr_set_cfg_privacyFromProfile() is the setting of the privacy
4990 * CFG based on the advertised privacy setting from the AP for WPA
4991 * associations. See note below in this function...
4992 */
4993 uint32_t PrivacyEnabled = 0, RsnEnabled = 0, WepDefaultKeyId = 0;
4994 uint32_t WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
4995 uint32_t Key0Length = 0, Key1Length = 0, Key2Length = 0, Key3Length = 0;
4996
4997 /* Reserve for the biggest key */
4998 uint8_t Key0[WNI_CFG_WEP_DEFAULT_KEY_1_LEN];
4999 uint8_t Key1[WNI_CFG_WEP_DEFAULT_KEY_2_LEN];
5000 uint8_t Key2[WNI_CFG_WEP_DEFAULT_KEY_3_LEN];
5001 uint8_t Key3[WNI_CFG_WEP_DEFAULT_KEY_4_LEN];
5002
5003 switch (pProfile->negotiatedUCEncryptionType) {
5004 case eCSR_ENCRYPT_TYPE_NONE:
5005 /* for NO encryption, turn off Privacy and Rsn. */
5006 PrivacyEnabled = 0;
5007 RsnEnabled = 0;
5008 /* clear out the WEP keys that may be hanging around. */
5009 Key0Length = 0;
5010 Key1Length = 0;
5011 Key2Length = 0;
5012 Key3Length = 0;
5013 break;
5014
5015 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5016 case eCSR_ENCRYPT_TYPE_WEP40:
5017
5018 /* Privacy is ON. NO RSN for Wep40 static key. */
5019 PrivacyEnabled = 1;
5020 RsnEnabled = 0;
5021 /* Set the Wep default key ID. */
5022 WepDefaultKeyId = pProfile->Keys.defaultIndex;
5023 /* Wep key size if 5 bytes (40 bits). */
5024 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
5025 /*
5026 * set encryption keys in the CFG database or
5027 * clear those that are not present in this profile.
5028 */
5029 if (pProfile->Keys.KeyLength[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305030 qdf_mem_copy(Key0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005031 pProfile->Keys.KeyMaterial[0],
5032 WNI_CFG_WEP_KEY_LENGTH_5);
5033 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
5034 } else {
5035 Key0Length = 0;
5036 }
5037
5038 if (pProfile->Keys.KeyLength[1]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305039 qdf_mem_copy(Key1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005040 pProfile->Keys.KeyMaterial[1],
5041 WNI_CFG_WEP_KEY_LENGTH_5);
5042 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
5043 } else {
5044 Key1Length = 0;
5045 }
5046
5047 if (pProfile->Keys.KeyLength[2]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305048 qdf_mem_copy(Key2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005049 pProfile->Keys.KeyMaterial[2],
5050 WNI_CFG_WEP_KEY_LENGTH_5);
5051 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
5052 } else {
5053 Key2Length = 0;
5054 }
5055
5056 if (pProfile->Keys.KeyLength[3]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305057 qdf_mem_copy(Key3,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005058 pProfile->Keys.KeyMaterial[3],
5059 WNI_CFG_WEP_KEY_LENGTH_5);
5060 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
5061 } else {
5062 Key3Length = 0;
5063 }
5064 break;
5065
5066 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5067 case eCSR_ENCRYPT_TYPE_WEP104:
5068
5069 /* Privacy is ON. NO RSN for Wep40 static key. */
5070 PrivacyEnabled = 1;
5071 RsnEnabled = 0;
5072 /* Set the Wep default key ID. */
5073 WepDefaultKeyId = pProfile->Keys.defaultIndex;
5074 /* Wep key size if 13 bytes (104 bits). */
5075 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
5076 /*
5077 * set encryption keys in the CFG database or clear
5078 * those that are not present in this profile.
5079 */
5080 if (pProfile->Keys.KeyLength[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305081 qdf_mem_copy(Key0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005082 pProfile->Keys.KeyMaterial[0],
5083 WNI_CFG_WEP_KEY_LENGTH_13);
5084 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
5085 } else {
5086 Key0Length = 0;
5087 }
5088
5089 if (pProfile->Keys.KeyLength[1]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305090 qdf_mem_copy(Key1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091 pProfile->Keys.KeyMaterial[1],
5092 WNI_CFG_WEP_KEY_LENGTH_13);
5093 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
5094 } else {
5095 Key1Length = 0;
5096 }
5097
5098 if (pProfile->Keys.KeyLength[2]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305099 qdf_mem_copy(Key2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005100 pProfile->Keys.KeyMaterial[2],
5101 WNI_CFG_WEP_KEY_LENGTH_13);
5102 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
5103 } else {
5104 Key2Length = 0;
5105 }
5106
5107 if (pProfile->Keys.KeyLength[3]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305108 qdf_mem_copy(Key3,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109 pProfile->Keys.KeyMaterial[3],
5110 WNI_CFG_WEP_KEY_LENGTH_13);
5111 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
5112 } else {
5113 Key3Length = 0;
5114 }
5115 break;
5116
5117 case eCSR_ENCRYPT_TYPE_TKIP:
5118 case eCSR_ENCRYPT_TYPE_AES:
Mukul Sharma05504ac2017-06-08 12:35:53 +05305119 case eCSR_ENCRYPT_TYPE_AES_GCMP:
5120 case eCSR_ENCRYPT_TYPE_AES_GCMP_256:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121#ifdef FEATURE_WLAN_WAPI
5122 case eCSR_ENCRYPT_TYPE_WPI:
5123#endif /* FEATURE_WLAN_WAPI */
5124 /*
5125 * this is the only difference between this function and
5126 * the csr_set_cfg_privacyFromProfile().
5127 * (setting of the privacy CFG based on the advertised
5128 * privacy setting from AP for WPA/WAPI associations).
5129 */
5130 PrivacyEnabled = (0 != fPrivacy);
5131 /* turn on RSN enabled for WPA associations */
5132 RsnEnabled = 1;
5133 /* clear static WEP keys that may be hanging around. */
5134 Key0Length = 0;
5135 Key1Length = 0;
5136 Key2Length = 0;
5137 Key3Length = 0;
5138 break;
5139 default:
5140 PrivacyEnabled = 0;
5141 RsnEnabled = 0;
5142 break;
5143 }
5144
5145 cfg_set_int(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled);
5146 cfg_set_int(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled);
5147 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length);
5148 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length);
5149 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length);
5150 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 cfg_set_int(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId);
5152}
5153
5154static void csr_set_cfg_ssid(tpAniSirGlobal pMac, tSirMacSSid *pSSID)
5155{
5156 uint32_t len = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305157
5158 if (pSSID->length <= WNI_CFG_SSID_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005159 len = pSSID->length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160 cfg_set_str(pMac, WNI_CFG_SSID, (uint8_t *) pSSID->ssId, len);
5161}
5162
Jeff Johnson29e2ca12016-10-14 12:50:38 -07005163static QDF_STATUS csr_set_qos_to_cfg(tpAniSirGlobal pMac, uint32_t sessionId,
5164 eCsrMediaAccessType qosType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005165{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305166 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005167 uint32_t QoSEnabled;
5168 uint32_t WmeEnabled;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305169 /* set the CFG enable/disable variables based on the
5170 * qosType being configured.
5171 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005172 switch (qosType) {
5173 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
5174 QoSEnabled = false;
5175 WmeEnabled = true;
5176 break;
5177 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
5178 QoSEnabled = false;
5179 WmeEnabled = true;
5180 break;
5181 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
5182 QoSEnabled = false;
5183 WmeEnabled = true;
5184 break;
5185 case eCSR_MEDIUM_ACCESS_11e_eDCF:
5186 QoSEnabled = true;
5187 WmeEnabled = false;
5188 break;
5189 case eCSR_MEDIUM_ACCESS_11e_HCF:
5190 QoSEnabled = true;
5191 WmeEnabled = false;
5192 break;
5193 default:
5194 case eCSR_MEDIUM_ACCESS_DCF:
5195 QoSEnabled = false;
5196 WmeEnabled = false;
5197 break;
5198 }
5199 /* save the WMM setting for later use */
5200 pMac->roam.roamSession[sessionId].fWMMConnection = (bool) WmeEnabled;
5201 pMac->roam.roamSession[sessionId].fQOSConnection = (bool) QoSEnabled;
5202 return status;
5203}
5204
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305205static QDF_STATUS csr_get_rate_set(tpAniSirGlobal pMac,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005206 struct csr_roam_profile *pProfile,
5207 eCsrPhyMode phyMode,
5208 tSirBssDescription *pBssDesc,
5209 tDot11fBeaconIEs *pIes,
5210 tSirMacRateSet *pOpRateSet,
5211 tSirMacRateSet *pExRateSet)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005212{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305213 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005214 int i;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305215 enum csr_cfgdot11mode cfgDot11Mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005216 uint8_t *pDstRate;
5217 uint16_t rateBitmap = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305218
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305219 qdf_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
5220 qdf_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305221 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005222
5223 if (NULL == pIes) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005224 sme_err("failed to parse BssDesc");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005225 return status;
5226 }
5227
5228 csr_is_phy_mode_match(pMac, phyMode, pBssDesc, pProfile,
5229 &cfgDot11Mode, pIes);
5230 /*
5231 * Originally, we thought that for 11a networks, the 11a rates
5232 * are always in the Operational Rate set & for 11b and 11g
5233 * networks, the 11b rates appear in the Operational Rate set.
5234 * Consequently, in either case, we would blindly put the rates
5235 * we support into our Operational Rate set.
5236 * (including the basic rates, which we've already verified are
5237 * supported earlier in the roaming decision).
5238 * However, it turns out that this is not always the case.
5239 * Some AP's (e.g. D-Link DI-784) ram 11g rates into the
5240 * Operational Rate set too. Now, we're a little more careful.
5241 */
5242 pDstRate = pOpRateSet->rate;
5243 if (pIes->SuppRates.present) {
5244 for (i = 0; i < pIes->SuppRates.num_rates; i++) {
5245 if (csr_rates_is_dot11_rate_supported(pMac,
5246 pIes->SuppRates.rates[i]) &&
5247 !csr_check_rate_bitmap(
5248 pIes->SuppRates.rates[i],
5249 rateBitmap)) {
5250 csr_add_rate_bitmap(pIes->SuppRates.
5251 rates[i], &rateBitmap);
5252 *pDstRate++ = pIes->SuppRates.rates[i];
5253 pOpRateSet->numRates++;
5254 }
5255 }
5256 }
Abhishek Singh10112382015-12-03 16:06:59 +05305257 /*
5258 * If there are Extended Rates in the beacon, we will reflect the
5259 * extended rates that we support in our Extended Operational Rate
5260 * set.
5261 */
5262 if (pIes->ExtSuppRates.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005263 pDstRate = pExRateSet->rate;
5264 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++) {
5265 if (csr_rates_is_dot11_rate_supported(pMac,
5266 pIes->ExtSuppRates.rates[i]) &&
5267 !csr_check_rate_bitmap(
5268 pIes->ExtSuppRates.rates[i],
5269 rateBitmap)) {
5270 *pDstRate++ = pIes->ExtSuppRates.rates[i];
5271 pExRateSet->numRates++;
5272 }
5273 }
5274 }
5275 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305276 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005277 return status;
5278}
5279
5280static void csr_set_cfg_rate_set(tpAniSirGlobal pMac, eCsrPhyMode phyMode,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005281 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005282 tSirBssDescription *pBssDesc,
5283 tDot11fBeaconIEs *pIes)
5284{
5285 int i;
5286 uint8_t *pDstRate;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305287 enum csr_cfgdot11mode cfgDot11Mode;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305288 /* leave enough room for the max number of rates */
5289 uint8_t OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290 uint32_t OperationalRatesLength = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305291 /* leave enough room for the max number of rates */
5292 uint8_t ExtendedOperationalRates
5293 [CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005294 uint32_t ExtendedOperationalRatesLength = 0;
5295 uint8_t MCSRateIdxSet[SIZE_OF_SUPPORTED_MCS_SET];
5296 uint32_t MCSRateLength = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305297
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305298 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 if (NULL != pIes) {
5300 csr_is_phy_mode_match(pMac, phyMode, pBssDesc, pProfile,
5301 &cfgDot11Mode, pIes);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305302 /* Originally, we thought that for 11a networks, the 11a rates
5303 * are always in the Operational Rate set & for 11b and 11g
5304 * networks, the 11b rates appear in the Operational Rate set.
5305 * Consequently, in either case, we would blindly put the rates
5306 * we support into our Operational Rate set (including the basic
5307 * rates, which we have already verified are supported earlier
5308 * in the roaming decision). However, it turns out that this is
5309 * not always the case. Some AP's (e.g. D-Link DI-784) ram 11g
5310 * rates into the Operational Rate set, too. Now, we're a
5311 * little more careful:
5312 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005313 pDstRate = OperationalRates;
5314 if (pIes->SuppRates.present) {
5315 for (i = 0; i < pIes->SuppRates.num_rates; i++) {
5316 if (csr_rates_is_dot11_rate_supported
5317 (pMac, pIes->SuppRates.rates[i])
5318 && (OperationalRatesLength <
5319 CSR_DOT11_SUPPORTED_RATES_MAX)) {
5320 *pDstRate++ = pIes->SuppRates.rates[i];
5321 OperationalRatesLength++;
5322 }
5323 }
5324 }
5325 if (eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
5326 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
5327 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305328 /* If there are Extended Rates in the beacon, we will
5329 * reflect those extended rates that we support in out
5330 * Extended Operational Rate set:
5331 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005332 pDstRate = ExtendedOperationalRates;
5333 if (pIes->ExtSuppRates.present) {
5334 for (i = 0; i < pIes->ExtSuppRates.num_rates;
5335 i++) {
5336 if (csr_rates_is_dot11_rate_supported
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305337 (pMac, pIes->ExtSuppRates.
5338 rates[i])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005339 && (ExtendedOperationalRatesLength <
5340 CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX)) {
5341 *pDstRate++ =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305342 pIes->ExtSuppRates.
5343 rates[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005344 ExtendedOperationalRatesLength++;
5345 }
5346 }
5347 }
5348 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305349 /* Enable proprietary MAC features if peer node is Airgo node
5350 * and STA user wants to use them For ANI network companions,
5351 * we need to populate the proprietary rate set with any
5352 * proprietary rates we found in the beacon, only if user allows
5353 * them.
5354 */
5355 /* No proprietary modes... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005356 /* Get MCS Rate */
5357 pDstRate = MCSRateIdxSet;
5358 if (pIes->HTCaps.present) {
5359 for (i = 0; i < VALID_MAX_MCS_INDEX; i++) {
5360 if ((unsigned int)pIes->HTCaps.
5361 supportedMCSSet[0] & (1 << i)) {
5362 MCSRateLength++;
5363 *pDstRate++ = i;
5364 }
5365 }
5366 }
5367 /* Set the operational rate set CFG variables... */
5368 cfg_set_str(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
5369 OperationalRates, OperationalRatesLength);
5370 cfg_set_str(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
5371 ExtendedOperationalRates,
5372 ExtendedOperationalRatesLength);
5373 cfg_set_str(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
5374 MCSRateLength);
5375 } /* Parsing BSSDesc */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305376 else
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005377 sme_err("failed to parse BssDesc");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005378}
5379
5380static void csr_set_cfg_rate_set_from_profile(tpAniSirGlobal pMac,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005381 struct csr_roam_profile *pProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005382{
5383 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
5384 {8,
5385 {SIR_MAC_RATE_6,
5386 SIR_MAC_RATE_9,
5387 SIR_MAC_RATE_12,
5388 SIR_MAC_RATE_18,
5389 SIR_MAC_RATE_24,
5390 SIR_MAC_RATE_36,
5391 SIR_MAC_RATE_48,
5392 SIR_MAC_RATE_54} } };
5393 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
5394 {4,
5395 {SIR_MAC_RATE_1,
5396 SIR_MAC_RATE_2,
5397 SIR_MAC_RATE_5_5,
5398 SIR_MAC_RATE_11} } };
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305399 enum csr_cfgdot11mode cfgDot11Mode;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005400 enum band_info eBand;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005401 /* leave enough room for the max number of rates */
5402 uint8_t OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
5403 uint32_t OperationalRatesLength = 0;
5404 /* leave enough room for the max number of rates */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305405 uint8_t ExtendedOperationalRates
5406 [CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005407 uint32_t ExtendedOperationalRatesLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005408 uint8_t operationChannel = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305409
5410 if (pProfile->ChannelInfo.ChannelList)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005411 operationChannel = pProfile->ChannelInfo.ChannelList[0];
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305412 cfgDot11Mode = csr_roam_get_phy_mode_band_for_bss(pMac, pProfile,
5413 operationChannel,
5414 &eBand);
5415 /* For 11a networks, the 11a rates go into the Operational Rate set.
5416 * For 11b and 11g networks, the 11b rates appear in the Operational
5417 * Rate set. In either case, we can blindly put the rates we support
5418 * into our Operational Rate set (including the basic rates, which we
5419 * have already verified are supported earlier in the roaming decision).
5420 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08005421 if (BAND_5G == eBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005422 /* 11a rates into the Operational Rate Set. */
5423 OperationalRatesLength =
5424 DefaultSupportedRates11a.supportedRateSet.numRates *
5425 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305426 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005427 DefaultSupportedRates11a.supportedRateSet.rate,
5428 OperationalRatesLength);
5429
5430 /* Nothing in the Extended rate set. */
5431 ExtendedOperationalRatesLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005432 } else if (eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode) {
5433 /* 11b rates into the Operational Rate Set. */
5434 OperationalRatesLength =
5435 DefaultSupportedRates11b.supportedRateSet.numRates *
5436 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305437 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438 DefaultSupportedRates11b.supportedRateSet.rate,
5439 OperationalRatesLength);
5440 /* Nothing in the Extended rate set. */
5441 ExtendedOperationalRatesLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005442 } else {
5443 /* 11G */
5444
5445 /* 11b rates into the Operational Rate Set. */
5446 OperationalRatesLength =
5447 DefaultSupportedRates11b.supportedRateSet.numRates *
5448 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305449 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005450 DefaultSupportedRates11b.supportedRateSet.rate,
5451 OperationalRatesLength);
5452
5453 /* 11a rates go in the Extended rate set. */
5454 ExtendedOperationalRatesLength =
5455 DefaultSupportedRates11a.supportedRateSet.numRates *
5456 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305457 qdf_mem_copy(ExtendedOperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005458 DefaultSupportedRates11a.supportedRateSet.rate,
5459 ExtendedOperationalRatesLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005460 }
5461
5462 /* Set the operational rate set CFG variables... */
5463 cfg_set_str(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
5464 OperationalRatesLength);
5465 cfg_set_str(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305466 ExtendedOperationalRates,
5467 ExtendedOperationalRatesLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005468}
5469
Krunal Sonif3583022017-02-10 17:18:10 -08005470void csr_roam_ccm_cfg_set_callback(tpAniSirGlobal pMac, int32_t result,
5471 uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005472{
5473 tListElem *pEntry =
Krunal Sonia8270f52017-02-23 19:51:25 -08005474 csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005475 uint32_t sessionId;
5476 tSmeCmd *pCommand = NULL;
5477#ifdef WLAN_FEATURE_ROAM_OFFLOAD
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305478 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005479#endif
5480 if (NULL == pEntry) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005481 sme_err("CFG_CNF with active list empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005482 return;
5483 }
5484 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
5485 sessionId = pCommand->sessionId;
5486#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5487 pSession = &pMac->roam.roamSession[sessionId];
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08005488 if (pSession->roam_synch_in_progress) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305489 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005490 "LFR3:csr_roam_cfg_set_callback");
5491 }
5492#endif
5493
5494 if (CSR_IS_ROAM_JOINING(pMac, sessionId)
5495 && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId)) {
Krunal Sonia8270f52017-02-23 19:51:25 -08005496 csr_roaming_state_config_cnf_processor(pMac, pCommand,
5497 (uint32_t) result, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005498 }
5499}
5500
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005501/* pIes may be NULL */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305502QDF_STATUS csr_roam_set_bss_config_cfg(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005503 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005504 tSirBssDescription *pBssDesc,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305505 struct bss_config_param *pBssConfig,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05305506 struct sDot11fBeaconIEs *pIes,
5507 bool resetCountry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005508{
5509 tSirRetStatus status;
5510 uint32_t cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5511 uint8_t channel = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305512 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08005513
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305514 /* Make sure we have the domain info for the BSS we try to connect to.
5515 * Do we need to worry about sequence for OSs that are not Windows??
5516 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517 if (pBssDesc) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305518 if ((QDF_SAP_MODE !=
Peng Xuf5d60c82015-10-02 17:17:03 -07005519 csr_get_session_persona(pMac, sessionId)) &&
5520 csr_learn_11dcountry_information(
5521 pMac, pBssDesc, pIes, true)) {
5522 csr_apply_country_information(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005523 }
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07005524 if ((wlan_reg_11d_enabled_on_host(pMac->psoc)) && pIes) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305525 if (!pIes->Country.present)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005526 csr_apply_channel_power_info_wrapper(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005527 }
5528 }
5529 /* Qos */
5530 csr_set_qos_to_cfg(pMac, sessionId, pBssConfig->qosType);
5531 /* SSID */
5532 csr_set_cfg_ssid(pMac, &pBssConfig->SSID);
5533
5534 /* Auth type */
5535 cfg_set_int(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType);
5536 /* encryption type */
5537 csr_set_cfg_privacy(pMac, pProfile, (bool) pBssConfig->BssCap.privacy);
5538 /* short slot time */
5539 cfg_set_int(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED,
5540 pBssConfig->uShortSlotTime);
5541 /* 11d */
5542 cfg_set_int(pMac, WNI_CFG_11D_ENABLED,
5543 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport :
5544 pProfile->ieee80211d));
5545 cfg_set_int(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT,
5546 pBssConfig->uPowerLimit);
5547 /* CB */
5548
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305549 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_IBSS(pProfile))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005550 channel = pProfile->operationChannel;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305551 else if (pBssDesc)
5552 channel = pBssDesc->channelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005553 if (0 != channel) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005554 /* for now if we are on 2.4 Ghz, CB will be always disabled */
5555 if (WLAN_REG_IS_24GHZ_CH(channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005557 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005558 cfgCb = pBssConfig->cbMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559 }
5560 /* Rate */
5561 /* Fixed Rate */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305562 if (pBssDesc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005563 csr_set_cfg_rate_set(pMac, (eCsrPhyMode) pProfile->phyMode,
5564 pProfile, pBssDesc, pIes);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305565 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005566 csr_set_cfg_rate_set_from_profile(pMac, pProfile);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08005567 status = cfg_set_int(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT,
5568 pBssConfig->uJoinTimeOut);
5569 /* Any roaming related changes should be above this line */
Arif Hussain557920f2016-09-07 16:03:46 -07005570 if (pSession && pSession->roam_synch_in_progress) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005571 sme_debug("Roam synch is in progress Session_id: %d",
5572 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305573 return QDF_STATUS_SUCCESS;
Arif Hussain557920f2016-09-07 16:03:46 -07005574 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305575 /* Make this the last CFG to set. The callback will trigger a
5576 * join_req Join time out
5577 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId);
5579
Krunal Sonif3583022017-02-10 17:18:10 -08005580 csr_roam_ccm_cfg_set_callback(pMac, status, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305581 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582}
5583
Jeff Johnson29e2ca12016-10-14 12:50:38 -07005584static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305585QDF_STATUS csr_roam_stop_network(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005586 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005587 tSirBssDescription *pBssDesc,
5588 tDot11fBeaconIEs *pIes)
5589{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305590 QDF_STATUS status;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305591 struct bss_config_param *pBssConfig;
5592 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005593
5594 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005595 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305596 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005597 }
5598
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305599 pBssConfig = qdf_mem_malloc(sizeof(struct bss_config_param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005600 if (NULL == pBssConfig)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305601 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005603 sme_debug("session id: %d", sessionId);
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +05305604
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005605 status = csr_roam_prepare_bss_config(pMac, pProfile, pBssDesc,
5606 pBssConfig, pIes);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305607 if (QDF_IS_STATUS_SUCCESS(status)) {
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305608 enum csr_roam_substate substate;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305609
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005610 substate = eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING;
5611 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
5612 /* This will allow to pass cbMode during join req */
5613 pSession->bssParams.cbMode = pBssConfig->cbMode;
5614 /* For IBSS, we need to prepare some more information */
5615 if (csr_is_bss_type_ibss(pProfile->BSSType) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005616 CSR_IS_INFRA_AP(pProfile))
5617 csr_roam_prepare_bss_params(pMac, sessionId, pProfile,
5618 pBssDesc, pBssConfig, pIes);
5619
5620 /*
5621 * If we are in an IBSS, then stop the IBSS...
5622 * Not worry about WDS connection for now
5623 */
5624 if (csr_is_conn_state_ibss(pMac, sessionId)) {
5625 status = csr_roam_issue_stop_bss(pMac, sessionId,
5626 substate);
5627 } else if (csr_is_conn_state_infra(pMac, sessionId)) {
5628 /*
5629 * the new Bss is an Ibss OR we are roaming from
5630 * Infra to Infra across SSIDs
5631 * (roaming to a new SSID)...
5632 * Not worry about WDS connection for now
5633 */
5634 if (pBssDesc && (csr_is_ibss_bss_desc(pBssDesc) ||
5635 !csr_is_ssid_equal(pMac,
5636 pSession->pConnectBssDesc,
5637 pBssDesc, pIes)))
5638 status = csr_roam_issue_disassociate(pMac,
5639 sessionId, substate, false);
5640 else if (pBssDesc)
5641 /*
5642 * In an infra & going to an infra network with
5643 * the same SSID. This calls for a reassoc seq.
5644 * So issue the CFG sets for this new AP. Set
5645 * parameters for this Bss.
5646 */
5647 status = csr_roam_set_bss_config_cfg(pMac,
5648 sessionId, pProfile, pBssDesc,
5649 pBssConfig, pIes, false);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07005650 } else if (pBssDesc ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005651 CSR_IS_INFRA_AP(pProfile)) {
5652 /*
5653 * Neither in IBSS nor in Infra. We can go ahead and set
5654 * the cfg for tne new network... nothing to stop.
5655 */
5656 bool is11rRoamingFlag = false;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305657
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005658 is11rRoamingFlag = csr_roam_is11r_assoc(pMac,
5659 sessionId);
5660 /* Set parameters for this Bss. */
5661 status = csr_roam_set_bss_config_cfg(pMac, sessionId,
5662 pProfile, pBssDesc, pBssConfig, pIes,
5663 is11rRoamingFlag);
5664 }
5665 } /* Success getting BSS config info */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305666 qdf_mem_free(pBssConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667 return status;
5668}
5669
5670/**
5671 * csr_roam_state_for_same_profile() - Determine roam state for same profile
5672 * @mac_ctx: pointer to mac context
5673 * @profile: Roam profile
5674 * @session: Roam session
5675 * @session_id: session id
5676 * @ies_local: local ies
5677 * @bss_descr: bss description
5678 *
5679 * This function will determine the roam state for same profile
5680 *
5681 * Return: Roaming state.
5682 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305683static enum csr_join_state csr_roam_state_for_same_profile(
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005684 tpAniSirGlobal mac_ctx, struct csr_roam_profile *profile,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305685 struct csr_roam_session *session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005686 uint32_t session_id, tDot11fBeaconIEs *ies_local,
5687 tSirBssDescription *bss_descr)
5688{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305689 QDF_STATUS status;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305690 struct bss_config_param bssConfig;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305691
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692 if (csr_roam_is_same_profile_keys(mac_ctx, &session->connectedProfile,
5693 profile))
5694 return eCsrReassocToSelfNoCapChange;
5695 /* The key changes */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305696 qdf_mem_set(&bssConfig, sizeof(bssConfig), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005697 status = csr_roam_prepare_bss_config(mac_ctx, profile, bss_descr,
5698 &bssConfig, ies_local);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305699 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005700 session->bssParams.uCfgDot11Mode =
5701 bssConfig.uCfgDot11Mode;
5702 session->bssParams.cbMode =
5703 bssConfig.cbMode;
5704 /* reapply the cfg including keys so reassoc happens. */
5705 status = csr_roam_set_bss_config_cfg(mac_ctx, session_id,
5706 profile, bss_descr, &bssConfig,
5707 ies_local, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305708 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005709 return eCsrContinueRoaming;
5710 }
5711
5712 return eCsrStopRoaming;
5713
5714}
5715
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305716static enum csr_join_state csr_roam_join(tpAniSirGlobal pMac,
5717 uint32_t sessionId, tCsrScanResultInfo *pScanResult,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005718 struct csr_roam_profile *pProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005719{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305720 enum csr_join_state eRoamState = eCsrContinueRoaming;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005721 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
5722 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *) (pScanResult->pvIes);
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305723 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005724
5725 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005726 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005727 return eCsrStopRoaming;
5728 }
5729
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005730 if (!pIesLocal &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305731 !QDF_IS_STATUS_SUCCESS(csr_get_parsed_bss_description_ies(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005732 pBssDesc, &pIesLocal))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005733 sme_err("fail to parse IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005734 return eCsrStopRoaming;
5735 }
5736 if (csr_is_infra_bss_desc(pBssDesc)) {
5737 /*
5738 * If we are connected in infra mode and the join bss descr is
5739 * for the same BssID, then we are attempting to join the AP we
5740 * are already connected with. In that case, see if the Bss or
5741 * sta capabilities have changed and handle the changes
5742 * without disturbing the current association
5743 */
5744
5745 if (csr_is_conn_state_connected_infra(pMac, sessionId) &&
5746 csr_is_bss_id_equal(pMac,
5747 pBssDesc, pSession->pConnectBssDesc) &&
5748 csr_is_ssid_equal(pMac, pSession->pConnectBssDesc,
5749 pBssDesc, pIesLocal)) {
5750 /*
5751 * Check to see if the Auth type has changed in the
5752 * profile. If so, we don't want to reassociate with
5753 * authenticating first. To force this, stop the
5754 * current association (Disassociate) and then re 'Join'
5755 * the AP, wihch will force an Authentication (with the
5756 * new Auth type) followed by a new Association.
5757 */
5758 if (csr_is_same_profile(pMac,
5759 &pSession->connectedProfile, pProfile)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005760 sme_warn("detect same profile");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005761 eRoamState =
5762 csr_roam_state_for_same_profile(pMac,
5763 pProfile, pSession, sessionId,
5764 pIesLocal, pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305765 } else if (!QDF_IS_STATUS_SUCCESS(
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305766 csr_roam_issue_disassociate(
5767 pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768 sessionId,
5769 eCSR_ROAM_SUBSTATE_DISASSOC_REQ,
5770 false))) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305771 sme_err("fail disassoc session %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005772 sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305773 eRoamState = eCsrStopRoaming;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005774 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305775 } else if (!QDF_IS_STATUS_SUCCESS(csr_roam_stop_network(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305776 sessionId, pProfile, pBssDesc, pIesLocal)))
5777 /* we used to pre-auth here with open auth
5778 * networks but that wasn't working so well.
5779 * stop the existing network before attempting
5780 * to join the new network.
5781 */
5782 eRoamState = eCsrStopRoaming;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305783 } else if (!QDF_IS_STATUS_SUCCESS(csr_roam_stop_network(pMac, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005784 pProfile, pBssDesc,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305785 pIesLocal)))
5786 eRoamState = eCsrStopRoaming;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005787
5788 if (pIesLocal && !pScanResult->pvIes)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305789 qdf_mem_free(pIesLocal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005790 return eRoamState;
5791}
5792
Jeff Johnson29e2ca12016-10-14 12:50:38 -07005793static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305794QDF_STATUS csr_roam_should_roam(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005795 tSirBssDescription *pBssDesc, uint32_t roamId)
5796{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305797 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08005798 struct csr_roam_info roamInfo;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305799
Jeff Johnson172237b2017-11-07 15:32:59 -08005800 qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005801 roamInfo.pBssDesc = pBssDesc;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305802 status = csr_roam_call_callback(pMac, sessionId, &roamInfo, roamId,
5803 eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005804 return status;
5805}
5806
5807/* In case no matching BSS is found, use whatever default we can find */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305808static void csr_roam_assign_default_param(tpAniSirGlobal pMac,
5809 tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005810{
5811 /* Need to get all negotiated types in place first */
5812 /* auth type */
5813 /* Take the preferred Auth type. */
5814 switch (pCommand->u.roamCmd.roamProfile.AuthType.authType[0]) {
5815 default:
5816 case eCSR_AUTH_TYPE_WPA:
5817 case eCSR_AUTH_TYPE_WPA_PSK:
5818 case eCSR_AUTH_TYPE_WPA_NONE:
5819 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5820 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
5821 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5822 break;
5823
5824 case eCSR_AUTH_TYPE_SHARED_KEY:
5825 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
5826 eCSR_AUTH_TYPE_SHARED_KEY;
5827 break;
5828
5829 case eCSR_AUTH_TYPE_AUTOSWITCH:
5830 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
5831 eCSR_AUTH_TYPE_AUTOSWITCH;
5832 break;
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305833
5834 case eCSR_AUTH_TYPE_SAE:
5835 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
5836 eCSR_AUTH_TYPE_SAE;
5837 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005838 }
5839 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305840 pCommand->u.roamCmd.roamProfile.EncryptionType.
5841 encryptionType[0];
5842 /* In this case, the multicast encryption needs to follow the
5843 * uncast ones.
5844 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005845 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305846 pCommand->u.roamCmd.roamProfile.EncryptionType.
5847 encryptionType[0];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005848}
5849
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305850static void csr_set_abort_roaming_command(tpAniSirGlobal pMac,
5851 tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005852{
5853 switch (pCommand->u.roamCmd.roamReason) {
5854 case eCsrLostLink1:
Krunal Sonid8e8e3d2017-02-23 19:52:28 -08005855 pCommand->u.roamCmd.roamReason = eCsrLostLink1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005856 break;
5857 case eCsrLostLink2:
Krunal Sonid8e8e3d2017-02-23 19:52:28 -08005858 pCommand->u.roamCmd.roamReason = eCsrLostLink2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005859 break;
5860 case eCsrLostLink3:
Krunal Sonid8e8e3d2017-02-23 19:52:28 -08005861 pCommand->u.roamCmd.roamReason = eCsrLostLink3;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005862 break;
5863 default:
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005864 sme_err("aborting roaming reason %d not recognized",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005865 pCommand->u.roamCmd.roamReason);
5866 break;
5867 }
5868}
5869
5870/**
5871 * csr_roam_select_bss() - Handle join scenario based on profile
5872 * @mac_ctx: Global MAC Context
5873 * @roam_bss_entry: The next BSS to join
5874 * @csr_result_info: Result of join
5875 * @csr_scan_result: Global scan result
5876 * @session_id: SME Session ID
5877 * @roam_id: Roaming ID
5878 * @roam_state: Current roaming state
5879 * @bss_list: BSS List
5880 *
5881 * Return: true if the entire BSS list is done, false otherwise.
5882 */
5883static bool csr_roam_select_bss(tpAniSirGlobal mac_ctx,
5884 tListElem *roam_bss_entry, tCsrScanResultInfo **csr_result_info,
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07005885 struct tag_csrscan_result **csr_scan_result,
5886 uint32_t session_id, uint32_t roam_id,
5887 enum csr_join_state *roam_state,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05305888 struct scan_result_list *bss_list)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005889{
5890 uint8_t conc_channel = 0;
5891 bool status = false;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05305892 struct tag_csrscan_result *scan_result = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005893 tCsrScanResultInfo *result = NULL;
5894
5895 while (roam_bss_entry) {
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05305896 scan_result = GET_BASE_ADDR(roam_bss_entry, struct
5897 tag_csrscan_result, Link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005898 /*
5899 * If concurrency enabled take the
5900 * concurrent connected channel first.
5901 * Valid multichannel concurrent
5902 * sessions exempted
5903 */
5904 result = &scan_result->Result;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005905 if (policy_mgr_concurrent_open_sessions_running(mac_ctx->psoc)
5906 && !csr_is_valid_mc_concurrent_session(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005907 session_id, &result->BssDescriptor)) {
5908 conc_channel = csr_get_concurrent_operation_channel(
5909 mac_ctx);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005910 sme_debug("csr Conc Channel: %d", conc_channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005911 if ((conc_channel) && (conc_channel ==
5912 result->BssDescriptor.channelId)) {
5913 /*
5914 * make this 0 because we do not want the below
5915 * check to pass as we don't want to connect on
5916 * other channel
5917 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005918 sme_debug("Conc chnl match: %d", conc_channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005919 conc_channel = 0;
5920 }
5921 }
5922
5923 /* Ok to roam this */
5924 if (!conc_channel &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305925 QDF_IS_STATUS_SUCCESS(csr_roam_should_roam(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005926 session_id, &result->BssDescriptor, roam_id))) {
5927 status = false;
5928 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005929 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305930 *roam_state = eCsrStopRoamingDueToConcurrency;
5931 status = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005932 roam_bss_entry = csr_ll_next(&bss_list->List, roam_bss_entry,
5933 LL_ACCESS_LOCK);
5934 }
5935 *csr_result_info = result;
5936 *csr_scan_result = scan_result;
5937 return status;
5938}
5939
5940/**
5941 * csr_roam_join_handle_profile() - Handle join scenario based on profile
5942 * @mac_ctx: Global MAC Context
5943 * @session_id: SME Session ID
5944 * @cmd: Command
5945 * @roam_info_ptr: Pointed to the roaming info for join
5946 * @roam_state: Current roaming state
5947 * @result: Result of join
5948 * @scan_result: Global scan result
5949 *
5950 * Return: None
5951 */
5952static void csr_roam_join_handle_profile(tpAniSirGlobal mac_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -08005953 uint32_t session_id, tSmeCmd *cmd,
5954 struct csr_roam_info *roam_info_ptr,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305955 enum csr_join_state *roam_state, tCsrScanResultInfo *result,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05305956 struct tag_csrscan_result *scan_result)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005957{
5958#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5959 uint8_t acm_mask = 0;
5960#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305961 QDF_STATUS status;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05305962 struct csr_roam_session *session;
Jeff Johnson66ee8a92018-03-17 15:24:26 -07005963 struct csr_roam_profile *profile = &cmd->u.roamCmd.roamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005964 tDot11fBeaconIEs *ies_local = NULL;
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07005965
5966 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005967 sme_err("Invalid session id %d", session_id);
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07005968 return;
5969 }
5970 session = CSR_GET_SESSION(mac_ctx, session_id);
5971
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005972 /*
5973 * We have something to roam, tell HDD when it is infra.
5974 * For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005975 */
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07005976 if (CSR_IS_INFRASTRUCTURE(profile) && roam_info_ptr) {
5977 if (session->bRefAssocStartCnt) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005978 session->bRefAssocStartCnt--;
5979 roam_info_ptr->pProfile = profile;
5980 /*
5981 * Complete the last assoc attempt as a
5982 * new one is about to be tried
5983 */
5984 csr_roam_call_callback(mac_ctx, session_id,
5985 roam_info_ptr, cmd->u.roamCmd.roamId,
5986 eCSR_ROAM_ASSOCIATION_COMPLETION,
5987 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
5988 }
5989 /* If roaming has stopped, don't continue the roaming command */
5990 if (!CSR_IS_ROAMING(session) && CSR_IS_ROAMING_COMMAND(cmd)) {
5991 /* No need to complete roaming as it already complete */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005992 sme_debug("Roam cmd(reason %d)aborted as roam complete",
5993 cmd->u.roamCmd.roamReason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005994 *roam_state = eCsrStopRoaming;
5995 csr_set_abort_roaming_command(mac_ctx, cmd);
5996 return;
5997 }
Jeff Johnson172237b2017-11-07 15:32:59 -08005998 qdf_mem_set(roam_info_ptr, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005999 if (!scan_result)
6000 cmd->u.roamCmd.roamProfile.uapsd_mask = 0;
6001 else
6002 ies_local = scan_result->Result.pvIes;
6003
Naveen Rawat48f51d02016-07-22 10:15:08 -07006004 if (!result) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006005 sme_err(" cannot parse IEs");
Naveen Rawat48f51d02016-07-22 10:15:08 -07006006 *roam_state = eCsrStopRoaming;
6007 return;
6008 } else if (scan_result && !ies_local &&
6009 (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006010 csr_get_parsed_bss_description_ies(
Naveen Rawat48f51d02016-07-22 10:15:08 -07006011 mac_ctx, &result->BssDescriptor,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006012 &ies_local)))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006013 sme_err(" cannot parse IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006014 *roam_state = eCsrStopRoaming;
6015 return;
6016 }
Naveen Rawat48f51d02016-07-22 10:15:08 -07006017 roam_info_ptr->pBssDesc = &result->BssDescriptor;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006018 cmd->u.roamCmd.pLastRoamBss = roam_info_ptr->pBssDesc;
6019 /* dont put uapsd_mask if BSS doesn't support uAPSD */
6020 if (scan_result && cmd->u.roamCmd.roamProfile.uapsd_mask
6021 && CSR_IS_QOS_BSS(ies_local)
6022 && CSR_IS_UAPSD_BSS(ies_local)) {
6023#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Naveen Rawat48f51d02016-07-22 10:15:08 -07006024 acm_mask = sme_qos_get_acm_mask(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006025 &result->BssDescriptor, ies_local);
6026#endif /* WLAN_MDM_CODE_REDUCTION_OPT */
6027 } else {
6028 cmd->u.roamCmd.roamProfile.uapsd_mask = 0;
6029 }
Arif Hussainfdb25e22017-02-05 17:38:16 -08006030 if (ies_local && !scan_result->Result.pvIes)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306031 qdf_mem_free(ies_local);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006032 roam_info_ptr->pProfile = profile;
6033 session->bRefAssocStartCnt++;
6034 csr_roam_call_callback(mac_ctx, session_id, roam_info_ptr,
6035 cmd->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_START,
6036 eCSR_ROAM_RESULT_NONE);
6037 }
6038 if (NULL != cmd->u.roamCmd.pRoamBssEntry) {
6039 /*
6040 * We have BSS
6041 * Need to assign these value because
6042 * they are used in csr_is_same_profile
6043 */
6044 scan_result = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05306045 struct tag_csrscan_result, Link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006046 /*
6047 * The OSEN IE doesn't provide the cipher suite.Therefore set
6048 * to constant value of AES
6049 */
6050 if (cmd->u.roamCmd.roamProfile.bOSENAssociation) {
6051 cmd->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
6052 eCSR_ENCRYPT_TYPE_AES;
6053 cmd->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
6054 eCSR_ENCRYPT_TYPE_AES;
6055 } else {
6056 /* Negotiated while building scan result. */
6057 cmd->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
6058 scan_result->ucEncryptionType;
6059 cmd->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
6060 scan_result->mcEncryptionType;
6061 }
6062 cmd->u.roamCmd.roamProfile.negotiatedAuthType =
6063 scan_result->authType;
6064 if (CSR_IS_START_IBSS(&cmd->u.roamCmd.roamProfile)) {
6065 if (csr_is_same_profile(mac_ctx,
6066 &session->connectedProfile, profile)) {
6067 *roam_state = eCsrStartIbssSameIbss;
6068 return;
6069 }
6070 }
6071 if (cmd->u.roamCmd.fReassocToSelfNoCapChange) {
6072 /* trying to connect to the one already connected */
6073 cmd->u.roamCmd.fReassocToSelfNoCapChange = false;
6074 *roam_state = eCsrReassocToSelfNoCapChange;
6075 return;
6076 }
6077 /* Attempt to Join this Bss... */
6078 *roam_state = csr_roam_join(mac_ctx, session_id,
6079 &scan_result->Result, profile);
6080 return;
6081 }
6082
6083 /* For an IBSS profile, then we need to start the IBSS. */
6084 if (CSR_IS_START_IBSS(profile)) {
6085 bool same_ibss = false;
6086 /* Attempt to start this IBSS... */
6087 csr_roam_assign_default_param(mac_ctx, cmd);
6088 status = csr_roam_start_ibss(mac_ctx, session_id,
6089 profile, &same_ibss);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306090 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006091 if (same_ibss)
6092 *roam_state = eCsrStartIbssSameIbss;
6093 else
6094 *roam_state = eCsrContinueRoaming;
6095 } else {
6096 /* it somehow fail need to stop */
6097 *roam_state = eCsrStopRoaming;
6098 }
6099 return;
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006100 } else if (CSR_IS_INFRA_AP(profile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006101 /* Attempt to start this WDS... */
6102 csr_roam_assign_default_param(mac_ctx, cmd);
6103 /* For AP WDS, we dont have any BSSDescription */
6104 status = csr_roam_start_wds(mac_ctx, session_id, profile, NULL);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306105 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006106 *roam_state = eCsrContinueRoaming;
6107 else
6108 *roam_state = eCsrStopRoaming;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07006109 } else if (CSR_IS_NDI(profile)) {
6110 csr_roam_assign_default_param(mac_ctx, cmd);
6111 status = csr_roam_start_ndi(mac_ctx, session_id, profile);
6112 if (QDF_IS_STATUS_SUCCESS(status))
6113 *roam_state = eCsrContinueRoaming;
6114 else
6115 *roam_state = eCsrStopRoaming;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006116 } else {
6117 /* Nothing we can do */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006118 sme_warn("cannot continue without BSS list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006119 *roam_state = eCsrStopRoaming;
6120 return;
6121 }
6122
6123}
6124/**
6125 * csr_roam_join_next_bss() - Pick the next BSS for join
6126 * @mac_ctx: Global MAC Context
6127 * @cmd: Command
6128 * @use_same_bss: Use Same BSS to Join
6129 *
6130 * Return: The Join State
6131 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306132static enum csr_join_state csr_roam_join_next_bss(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006133 tSmeCmd *cmd, bool use_same_bss)
6134{
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05306135 struct tag_csrscan_result *scan_result = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306136 enum csr_join_state roam_state = eCsrStopRoaming;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05306137 struct scan_result_list *bss_list =
6138 (struct scan_result_list *) cmd->u.roamCmd.hBSSList;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006139 bool done = false;
Jeff Johnson172237b2017-11-07 15:32:59 -08006140 struct csr_roam_info *roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006141 uint32_t session_id = cmd->sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306142 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006143 struct csr_roam_profile *profile = &cmd->u.roamCmd.roamProfile;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306144 struct csr_roam_joinstatus *join_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006145 tCsrScanResultInfo *result = NULL;
6146
6147 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006148 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006149 return eCsrStopRoaming;
6150 }
6151
Srinivas Girigowdaea4d8062017-10-14 12:40:48 -07006152 roam_info = qdf_mem_malloc(sizeof(*roam_info));
Kapil Guptaffa26022017-08-16 12:20:09 +05306153 if (!roam_info) {
6154 sme_err("failed to allocate memory");
6155 return eCsrStopRoaming;
6156 }
6157 qdf_mem_copy(&roam_info->bssid, &session->joinFailStatusCode.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006158 sizeof(tSirMacAddr));
6159 /*
6160 * When handling AP's capability change, continue to associate
6161 * to same BSS and make sure pRoamBssEntry is not Null.
6162 */
6163 if ((NULL != bss_list) &&
6164 ((false == use_same_bss) ||
6165 (cmd->u.roamCmd.pRoamBssEntry == NULL))) {
6166 if (cmd->u.roamCmd.pRoamBssEntry == NULL) {
6167 /* Try the first BSS */
6168 cmd->u.roamCmd.pLastRoamBss = NULL;
6169 cmd->u.roamCmd.pRoamBssEntry =
6170 csr_ll_peek_head(&bss_list->List,
6171 LL_ACCESS_LOCK);
6172 } else {
6173 cmd->u.roamCmd.pRoamBssEntry =
6174 csr_ll_next(&bss_list->List,
6175 cmd->u.roamCmd.pRoamBssEntry,
6176 LL_ACCESS_LOCK);
6177 /*
6178 * Done with all the BSSs.
6179 * In this case, will tell HDD the
6180 * completion
6181 */
6182 if (NULL == cmd->u.roamCmd.pRoamBssEntry)
6183 goto end;
6184 /*
6185 * We need to indicate to HDD that we
6186 * are done with this one.
6187 */
Kapil Guptaffa26022017-08-16 12:20:09 +05306188 roam_info->pBssDesc = cmd->u.roamCmd.pLastRoamBss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006189 join_status = &session->joinFailStatusCode;
Kapil Guptaffa26022017-08-16 12:20:09 +05306190 roam_info->statusCode = join_status->statusCode;
6191 roam_info->reasonCode = join_status->reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006192 }
6193 done = csr_roam_select_bss(mac_ctx,
6194 cmd->u.roamCmd.pRoamBssEntry, &result,
6195 &scan_result, session_id, cmd->u.roamCmd.roamId,
6196 &roam_state, bss_list);
6197 if (done)
6198 goto end;
6199 }
Kapil Guptaffa26022017-08-16 12:20:09 +05306200 roam_info->u.pConnectedProfile = &session->connectedProfile;
Naveen Rawata395d252016-06-15 11:07:24 -07006201
Kapil Guptaffa26022017-08-16 12:20:09 +05306202 csr_roam_join_handle_profile(mac_ctx, session_id, cmd, roam_info,
Naveen Rawat696a9302016-06-15 11:07:24 -07006203 &roam_state, result, scan_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006204end:
6205 if ((eCsrStopRoaming == roam_state) && CSR_IS_INFRASTRUCTURE(profile) &&
6206 (session->bRefAssocStartCnt > 0)) {
6207 /*
6208 * Need to indicate association_completion if association_start
6209 * has been done
6210 */
6211 session->bRefAssocStartCnt--;
6212 /*
6213 * Complete the last assoc attempte as a
6214 * new one is about to be tried
6215 */
Kapil Guptaffa26022017-08-16 12:20:09 +05306216 roam_info->pProfile = profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006217 csr_roam_call_callback(mac_ctx, session_id,
Kapil Guptaffa26022017-08-16 12:20:09 +05306218 roam_info, cmd->u.roamCmd.roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006219 eCSR_ROAM_ASSOCIATION_COMPLETION,
6220 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
6221 }
Kapil Guptaffa26022017-08-16 12:20:09 +05306222 qdf_mem_free(roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006223
6224 return roam_state;
6225}
6226
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306227static QDF_STATUS csr_roam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006228{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306229 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306230 enum csr_join_state RoamState;
6231 enum csr_roam_substate substate;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006232 uint32_t sessionId = pCommand->sessionId;
6233
6234 /* Attept to join a Bss... */
6235 RoamState = csr_roam_join_next_bss(pMac, pCommand, false);
6236
6237 /* if nothing to join.. */
6238 if ((eCsrStopRoaming == RoamState) ||
6239 (eCsrStopRoamingDueToConcurrency == RoamState)) {
6240 bool fComplete = false;
6241 /* and if connected in Infrastructure mode... */
6242 if (csr_is_conn_state_infra(pMac, sessionId)) {
6243 /* ... then we need to issue a disassociation */
6244 substate = eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN;
6245 status = csr_roam_issue_disassociate(pMac, sessionId,
6246 substate, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306247 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006248 sme_warn("fail issuing disassoc status = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006249 status);
6250 /*
6251 * roam command is completed by caller in the
6252 * failed case
6253 */
6254 fComplete = true;
6255 }
6256 } else if (csr_is_conn_state_ibss(pMac, sessionId)) {
6257 status = csr_roam_issue_stop_bss(pMac, sessionId,
6258 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306259 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006260 sme_warn("fail issuing stop bss status = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006261 status);
6262 /*
6263 * roam command is completed by caller in the
6264 * failed case
6265 */
6266 fComplete = true;
6267 }
6268 } else if (csr_is_conn_state_connected_infra_ap(pMac,
6269 sessionId)) {
6270 substate = eCSR_ROAM_SUBSTATE_STOP_BSS_REQ;
6271 status = csr_roam_issue_stop_bss(pMac, sessionId,
6272 substate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306273 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006274 sme_warn("fail issuing stop bss status = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006275 status);
6276 /*
6277 * roam command is completed by caller in the
6278 * failed case
6279 */
6280 fComplete = true;
6281 }
6282 } else {
6283 fComplete = true;
6284 }
6285
6286 if (fComplete) {
6287 /* otherwise, we can complete the Roam command here. */
6288 if (eCsrStopRoamingDueToConcurrency == RoamState)
6289 csr_roam_complete(pMac,
Krunal Sonif3583022017-02-10 17:18:10 -08006290 eCsrJoinFailureDueToConcurrency, NULL,
6291 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006292 else
6293 csr_roam_complete(pMac,
Krunal Sonif3583022017-02-10 17:18:10 -08006294 eCsrNothingToJoin, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006295 }
6296 } else if (eCsrReassocToSelfNoCapChange == RoamState) {
6297 csr_roam_complete(pMac, eCsrSilentlyStopRoamingSaveState,
Krunal Sonif3583022017-02-10 17:18:10 -08006298 NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006299 } else if (eCsrStartIbssSameIbss == RoamState) {
Krunal Sonif3583022017-02-10 17:18:10 -08006300 csr_roam_complete(pMac, eCsrSilentlyStopRoaming, NULL,
6301 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006302 }
6303
6304 return status;
6305}
6306
Jeff Johnson29e2ca12016-10-14 12:50:38 -07006307static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306308QDF_STATUS csr_process_ft_reassoc_roam_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006309 tSmeCmd *pCommand)
6310{
6311 uint32_t sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306312 struct csr_roam_session *pSession;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05306313 struct tag_csrscan_result *pScanResult = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006314 tSirBssDescription *pBssDesc = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306315 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306316
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006317 sessionId = pCommand->sessionId;
6318 pSession = CSR_GET_SESSION(pMac, sessionId);
6319
6320 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006321 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306322 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006323 }
6324
6325 if (CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming) {
6326 /* the roaming is cancelled. Simply complete the command */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006327 sme_debug("Roam command canceled");
Krunal Sonif3583022017-02-10 17:18:10 -08006328 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306329 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006330 }
6331 if (pCommand->u.roamCmd.pRoamBssEntry) {
6332 pScanResult =
6333 GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05306334 struct tag_csrscan_result, Link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006335 pBssDesc = &pScanResult->Result.BssDescriptor;
6336 } else {
6337 /* the roaming is cancelled. Simply complete the command */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006338 sme_debug("Roam command canceled");
Krunal Sonif3583022017-02-10 17:18:10 -08006339 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306340 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006341 }
6342 status = csr_roam_issue_reassociate(pMac, sessionId, pBssDesc,
6343 (tDot11fBeaconIEs *) (pScanResult->
6344 Result.pvIes),
6345 &pCommand->u.roamCmd.roamProfile);
6346 return status;
6347}
6348
6349/**
6350 * csr_roam_trigger_reassociate() - Helper function to trigger reassociate
6351 * @mac_ctx: pointer to mac context
6352 * @cmd: sme command
6353 * @roam_info: Roaming infor structure
6354 * @session_ptr: session pointer
6355 * @session_id: session id
6356 *
6357 * This function will trigger reassociate.
6358 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306359 * Return: QDF_STATUS for success or failure.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006360 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306361static QDF_STATUS csr_roam_trigger_reassociate(
Jeff Johnson172237b2017-11-07 15:32:59 -08006362tpAniSirGlobal mac_ctx, tSmeCmd *cmd, struct csr_roam_info *roam_info,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306363 struct csr_roam_session *session_ptr,
6364 uint32_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006365{
6366 tDot11fBeaconIEs *pIes = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306367 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006368
6369 if (session_ptr->pConnectBssDesc) {
6370 status = csr_get_parsed_bss_description_ies(mac_ctx,
6371 session_ptr->pConnectBssDesc, &pIes);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306372 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006373 sme_err("fail to parse IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006374 } else {
6375 roam_info->reasonCode =
6376 eCsrRoamReasonStaCapabilityChanged;
6377 csr_roam_call_callback(mac_ctx, session_ptr->sessionId,
6378 roam_info, 0, eCSR_ROAM_ROAMING_START,
6379 eCSR_ROAM_RESULT_NONE);
6380 session_ptr->roamingReason = eCsrReassocRoaming;
6381 roam_info->pBssDesc = session_ptr->pConnectBssDesc;
6382 roam_info->pProfile = &cmd->u.roamCmd.roamProfile;
6383 session_ptr->bRefAssocStartCnt++;
6384 csr_roam_call_callback(mac_ctx, session_id, roam_info,
6385 cmd->u.roamCmd.roamId,
6386 eCSR_ROAM_ASSOCIATION_START,
6387 eCSR_ROAM_RESULT_NONE);
6388
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006389 sme_debug("calling csr_roam_issue_reassociate");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006390 status = csr_roam_issue_reassociate(mac_ctx, session_id,
6391 session_ptr->pConnectBssDesc, pIes,
6392 &cmd->u.roamCmd.roamProfile);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306393 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006394 sme_err("failed status %d", status);
Krunal Sonidea45952017-02-15 11:58:15 -08006395 csr_release_command(mac_ctx, cmd);
Zhu Jianmine5594d12017-07-11 12:22:46 +08006396 } else {
6397 csr_neighbor_roam_state_transition(mac_ctx,
6398 eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING,
6399 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006400 }
6401
Zhu Jianmine5594d12017-07-11 12:22:46 +08006402
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306403 qdf_mem_free(pIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006404 pIes = NULL;
6405 }
6406 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006407 sme_err("reassoc to same AP failed as connected BSS is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306408 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006409 }
6410 return status;
6411}
6412
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306413QDF_STATUS csr_roam_process_command(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006414{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306415 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -08006416 struct csr_roam_info roamInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006417 uint32_t sessionId = pCommand->sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306418 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006419
6420 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006421 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306422 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006423 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006424 sme_debug("Roam Reason: %d sessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006425 pCommand->u.roamCmd.roamReason, sessionId);
6426
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07006427 pSession->disconnect_reason = pCommand->u.roamCmd.disconnect_reason;
6428
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006429 switch (pCommand->u.roamCmd.roamReason) {
6430 case eCsrForcedDisassoc:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006431 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
6432 true, false);
6433 csr_free_roam_profile(pMac, sessionId);
6434 break;
6435 case eCsrSmeIssuedDisassocForHandoff:
6436 /* Not to free pMac->roam.pCurRoamProfile (via
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306437 * csr_free_roam_profile) because its needed after disconnect
6438 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006439 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
6440 true, false);
6441
6442 break;
6443 case eCsrForcedDisassocMICFailure:
6444 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
6445 true, true);
6446 csr_free_roam_profile(pMac, sessionId);
6447 break;
6448 case eCsrForcedDeauth:
6449 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
6450 false, false);
6451 csr_free_roam_profile(pMac, sessionId);
6452 break;
6453 case eCsrHddIssuedReassocToSameAP:
6454 case eCsrSmeIssuedReassocToSameAP:
6455 status = csr_roam_trigger_reassociate(pMac, pCommand, &roamInfo,
6456 pSession, sessionId);
6457 break;
6458 case eCsrCapsChange:
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006459 sme_err("received eCsrCapsChange ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006460 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
6461 sessionId);
6462 status = csr_roam_issue_disassociate(pMac, sessionId,
6463 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
6464 false);
6465 break;
6466 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006467 sme_debug("received FT Reassoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006468 status = csr_process_ft_reassoc_roam_command(pMac, pCommand);
6469 break;
6470
6471 case eCsrStopBss:
6472 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
6473 sessionId);
6474 status = csr_roam_issue_stop_bss(pMac, sessionId,
6475 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
6476 break;
6477
6478 case eCsrForcedDisassocSta:
6479 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
6480 sessionId);
6481 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ,
6482 sessionId);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006483 sme_debug("Disassociate issued with reason: %d",
yeshwanth sriram guntuka46f004f2017-02-07 12:22:31 +05306484 pCommand->u.roamCmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006485 status = csr_send_mb_disassoc_req_msg(pMac, sessionId,
6486 pCommand->u.roamCmd.peerMac,
6487 pCommand->u.roamCmd.reason);
6488 break;
6489
6490 case eCsrForcedDeauthSta:
6491 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
6492 sessionId);
6493 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ,
6494 sessionId);
6495 status = csr_send_mb_deauth_req_msg(pMac, sessionId,
6496 pCommand->u.roamCmd.peerMac,
6497 pCommand->u.roamCmd.reason);
6498 break;
6499
6500 case eCsrPerformPreauth:
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006501 sme_debug("Attempting FT PreAuth Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006502 status = csr_roam_issue_ft_preauth_req(pMac, sessionId,
6503 pCommand->u.roamCmd.pLastRoamBss);
6504 break;
6505 default:
6506 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
6507 sessionId);
6508
6509 if (pCommand->u.roamCmd.fUpdateCurRoamProfile) {
6510 /* Remember the roaming profile */
6511 csr_free_roam_profile(pMac, sessionId);
6512 pSession->pCurRoamProfile =
Jeff Johnson66ee8a92018-03-17 15:24:26 -07006513 qdf_mem_malloc(sizeof(struct csr_roam_profile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006514 if (NULL != pSession->pCurRoamProfile) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006515 csr_roam_copy_profile(pMac,
6516 pSession->pCurRoamProfile,
6517 &pCommand->u.roamCmd.roamProfile);
6518 }
6519 }
6520 /*
6521 * At this point original uapsd_mask is saved in
6522 * pCurRoamProfile. uapsd_mask in the pCommand may change from
6523 * this point on. Attempt to roam with the new scan results
6524 * (if we need to..)
6525 */
6526 status = csr_roam(pMac, pCommand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306527 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006528 sme_warn("csr_roam() failed with status = 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006529 status);
6530 break;
6531 }
6532 return status;
6533}
6534
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006535void csr_reinit_roam_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
6536{
6537 if (pCommand->u.roamCmd.fReleaseBssList) {
6538 csr_scan_result_purge(pMac, pCommand->u.roamCmd.hBSSList);
6539 pCommand->u.roamCmd.fReleaseBssList = false;
6540 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6541 }
6542 if (pCommand->u.roamCmd.fReleaseProfile) {
6543 csr_release_profile(pMac, &pCommand->u.roamCmd.roamProfile);
6544 pCommand->u.roamCmd.fReleaseProfile = false;
6545 }
6546 pCommand->u.roamCmd.pRoamBssEntry = NULL;
6547 /* Because u.roamCmd is union and share with scanCmd and StatusChange */
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306548 qdf_mem_set(&pCommand->u.roamCmd, sizeof(struct roam_cmd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006549}
6550
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306551void csr_reinit_wm_status_change_cmd(tpAniSirGlobal pMac,
6552 tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006553{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306554 qdf_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(
6555 struct wmstatus_changecmd),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006556 0);
6557}
6558
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306559void csr_roam_complete(tpAniSirGlobal mac_ctx,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05306560 enum csr_roamcomplete_result Result,
6561 void *Context, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006562{
Krunal Sonia8270f52017-02-23 19:51:25 -08006563 tSmeCmd *sme_cmd;
6564 struct wlan_serialization_command *cmd;
6565
6566 cmd = wlan_serialization_peek_head_active_cmd_using_psoc(
6567 mac_ctx->psoc, false);
6568 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006569 sme_err("Roam completion called but cmd is not active");
Krunal Sonia8270f52017-02-23 19:51:25 -08006570 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006571 }
Krunal Sonia8270f52017-02-23 19:51:25 -08006572 sme_cmd = cmd->umac_cmd;
6573 if (!sme_cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07006574 sme_err("sme_cmd is NULL");
Krunal Sonia8270f52017-02-23 19:51:25 -08006575 return;
6576 }
6577 if (eSmeCommandRoam == sme_cmd->command) {
6578 csr_roam_process_results(mac_ctx, sme_cmd, Result, Context);
6579 csr_release_command(mac_ctx, sme_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006580 }
6581}
6582
Krunal Sonia8270f52017-02-23 19:51:25 -08006583
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306584void csr_reset_pmkid_candidate_list(tpAniSirGlobal pMac,
6585 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006586{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306587 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306588
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006589 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306590 sme_err("session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006591 return;
6592 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306593 qdf_mem_set(&(pSession->PmkidCandidateInfo[0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006594 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
6595 pSession->NumPmkidCandidate = 0;
6596}
6597
6598#ifdef FEATURE_WLAN_WAPI
6599void csr_reset_bkid_candidate_list(tpAniSirGlobal pMac, uint32_t sessionId)
6600{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306601 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306602
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006603 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306604 sme_err("session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006605 return;
6606 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306607 qdf_mem_set(&(pSession->BkidCandidateInfo[0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006608 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
6609 pSession->NumBkidCandidate = 0;
6610}
6611#endif /* FEATURE_WLAN_WAPI */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006612
6613/**
6614 * csr_roam_save_params() - Helper function to save params
6615 * @mac_ctx: pointer to mac context
6616 * @session_ptr: Session pointer
6617 * @auth_type: auth type
6618 * @ie_ptr: pointer to ie
6619 * @ie_local: pointr to local ie
6620 *
6621 * This function will save params to session
6622 *
6623 * Return: none.
6624 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306625static QDF_STATUS csr_roam_save_params(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306626 struct csr_roam_session *session_ptr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006627 eCsrAuthType auth_type,
6628 tDot11fBeaconIEs *ie_ptr,
6629 tDot11fBeaconIEs *ie_local)
6630{
6631 uint32_t nIeLen;
6632 uint8_t *pIeBuf;
6633
6634 if ((eCSR_AUTH_TYPE_RSN == auth_type) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006635 (eCSR_AUTH_TYPE_FT_RSN == auth_type) ||
6636 (eCSR_AUTH_TYPE_FT_RSN_PSK == auth_type) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006637#if defined WLAN_FEATURE_11W
6638 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == auth_type) ||
6639 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == auth_type) ||
6640#endif
6641 (eCSR_AUTH_TYPE_RSN_PSK == auth_type)) {
6642 if (ie_local->RSN.present) {
6643 tDot11fIERSN *rsnie = &ie_local->RSN;
6644 /*
6645 * Calculate the actual length
6646 * version + gp_cipher_suite + pwise_cipher_suite_count
Abhishek Singh3f13a812018-01-16 14:24:44 +05306647 * + akm_suite_cnt + reserved + pwise_cipher_suites
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006648 */
6649 nIeLen = 8 + 2 + 2
6650 + (rsnie->pwise_cipher_suite_count * 4)
Abhishek Singh3f13a812018-01-16 14:24:44 +05306651 + (rsnie->akm_suite_cnt * 4);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006652 if (rsnie->pmkid_count)
6653 /* pmkid */
6654 nIeLen += 2 + rsnie->pmkid_count * 4;
6655
6656 /* nIeLen doesn't count EID and length fields */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306657 session_ptr->pWpaRsnRspIE = qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006658 if (NULL == session_ptr->pWpaRsnRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306659 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006660
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006661 session_ptr->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
6662 session_ptr->pWpaRsnRspIE[1] = (uint8_t) nIeLen;
Abhishek Singh3f13a812018-01-16 14:24:44 +05306663 /* copy upto akm_suite */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006664 pIeBuf = session_ptr->pWpaRsnRspIE + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306665 qdf_mem_copy(pIeBuf, &rsnie->version,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006666 sizeof(rsnie->version));
6667 pIeBuf += sizeof(rsnie->version);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306668 qdf_mem_copy(pIeBuf, &rsnie->gp_cipher_suite,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006669 sizeof(rsnie->gp_cipher_suite));
6670 pIeBuf += sizeof(rsnie->gp_cipher_suite);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306671 qdf_mem_copy(pIeBuf, &rsnie->pwise_cipher_suite_count,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006672 sizeof(rsnie->pwise_cipher_suite_count));
6673 pIeBuf += sizeof(rsnie->pwise_cipher_suite_count);
6674 if (rsnie->pwise_cipher_suite_count) {
6675 /* copy pwise_cipher_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306676 qdf_mem_copy(pIeBuf, rsnie->pwise_cipher_suites,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006677 rsnie->pwise_cipher_suite_count * 4);
6678 pIeBuf += rsnie->pwise_cipher_suite_count * 4;
6679 }
Abhishek Singh3f13a812018-01-16 14:24:44 +05306680 qdf_mem_copy(pIeBuf, &rsnie->akm_suite_cnt, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006681 pIeBuf += 2;
Abhishek Singh3f13a812018-01-16 14:24:44 +05306682 if (rsnie->akm_suite_cnt) {
6683 /* copy akm_suite */
6684 qdf_mem_copy(pIeBuf, rsnie->akm_suite,
6685 rsnie->akm_suite_cnt * 4);
6686 pIeBuf += rsnie->akm_suite_cnt * 4;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006687 }
6688 /* copy the rest */
Abhishek Singh3f13a812018-01-16 14:24:44 +05306689 qdf_mem_copy(pIeBuf, rsnie->akm_suite +
6690 rsnie->akm_suite_cnt * 4,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006691 2 + rsnie->pmkid_count * 4);
6692 session_ptr->nWpaRsnRspIeLength = nIeLen + 2;
6693 }
6694 } else if ((eCSR_AUTH_TYPE_WPA == auth_type) ||
6695 (eCSR_AUTH_TYPE_WPA_PSK == auth_type)) {
6696 if (ie_local->WPA.present) {
6697 tDot11fIEWPA *wpaie = &ie_local->WPA;
6698 /* Calculate the actual length wpaie */
6699 nIeLen = 12 + 2 /* auth_suite_count */
6700 + wpaie->unicast_cipher_count * 4
6701 + wpaie->auth_suite_count * 4;
6702
6703 /* The WPA capabilities follows the Auth Suite
6704 * (two octects)-- this field is optional, and
6705 * we always "send" zero, so just remove it. This is
6706 * consistent with our assumptions in the frames
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306707 * compiler; nIeLen doesn't count EID & length fields
6708 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306709 session_ptr->pWpaRsnRspIE = qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006710 if (NULL == session_ptr->pWpaRsnRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306711 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006712 session_ptr->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
6713 session_ptr->pWpaRsnRspIE[1] = (uint8_t) nIeLen;
6714 pIeBuf = session_ptr->pWpaRsnRspIE + 2;
6715 /* Copy WPA OUI */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306716 qdf_mem_copy(pIeBuf, &csr_wpa_oui[1], 4);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006717 pIeBuf += 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306718 qdf_mem_copy(pIeBuf, &wpaie->version,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006719 8 + wpaie->unicast_cipher_count * 4);
6720 pIeBuf += 8 + wpaie->unicast_cipher_count * 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306721 qdf_mem_copy(pIeBuf, &wpaie->auth_suite_count,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006722 2 + wpaie->auth_suite_count * 4);
6723 pIeBuf += wpaie->auth_suite_count * 4;
6724 session_ptr->nWpaRsnRspIeLength = nIeLen + 2;
6725 }
6726 }
6727#ifdef FEATURE_WLAN_WAPI
6728 else if ((eCSR_AUTH_TYPE_WAPI_WAI_PSK == auth_type) ||
6729 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ==
6730 auth_type)) {
6731 if (ie_local->WAPI.present) {
6732 tDot11fIEWAPI *wapi_ie = &ie_local->WAPI;
6733 /* Calculate the actual length of wapi ie*/
6734 nIeLen = 4 + 2 /* pwise_cipher_suite_count */
6735 + wapi_ie->akm_suite_count * 4
6736 + wapi_ie->unicast_cipher_suite_count * 4
6737 + 6; /* gp_cipher_suite + preauth + reserved */
6738
6739 if (wapi_ie->bkid_count)
6740 nIeLen += 2 + wapi_ie->bkid_count * 4;
6741
6742 /* nIeLen doesn't count EID and length fields */
6743 session_ptr->pWapiRspIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306744 qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006745 if (NULL == session_ptr->pWapiRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306746 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006747 session_ptr->pWapiRspIE[0] = DOT11F_EID_WAPI;
6748 session_ptr->pWapiRspIE[1] = (uint8_t) nIeLen;
6749 pIeBuf = session_ptr->pWapiRspIE + 2;
6750 /* copy upto akm_suite_count */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306751 qdf_mem_copy(pIeBuf, &wapi_ie->version, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006752 pIeBuf += 4;
6753 if (wapi_ie->akm_suite_count) {
6754 /* copy akm_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306755 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006756 wapi_ie->akm_suites,
6757 wapi_ie->akm_suite_count * 4);
6758 pIeBuf += wapi_ie->akm_suite_count * 4;
6759 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306760 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006761 &wapi_ie->unicast_cipher_suite_count, 2);
6762 pIeBuf += 2;
6763 if (wapi_ie->unicast_cipher_suite_count) {
6764 uint16_t suite_size =
6765 wapi_ie->unicast_cipher_suite_count * 4;
6766 /* copy pwise_cipher_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306767 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006768 wapi_ie->unicast_cipher_suites,
6769 suite_size);
6770 pIeBuf += suite_size;
6771 }
6772 /* gp_cipher_suite */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306773 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006774 wapi_ie->multicast_cipher_suite, 4);
6775 pIeBuf += 4;
6776 /* preauth + reserved */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306777 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006778 wapi_ie->multicast_cipher_suite + 4, 2);
6779 pIeBuf += 2;
6780 if (wapi_ie->bkid_count) {
6781 /* bkid_count */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306782 qdf_mem_copy(pIeBuf, &wapi_ie->bkid_count, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006783 pIeBuf += 2;
6784 /* copy akm_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306785 qdf_mem_copy(pIeBuf, wapi_ie->bkid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006786 wapi_ie->bkid_count * 4);
6787 pIeBuf += wapi_ie->bkid_count * 4;
6788 }
6789 session_ptr->nWapiRspIeLength = nIeLen + 2;
6790 }
6791 }
6792#endif /* FEATURE_WLAN_WAPI */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306793 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006794}
6795
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306796static QDF_STATUS csr_roam_save_security_rsp_ie(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006797 uint32_t sessionId,
6798 eCsrAuthType authType,
6799 tSirBssDescription *pSirBssDesc,
6800 tDot11fBeaconIEs *pIes)
6801{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306802 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306803 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006804 tDot11fBeaconIEs *pIesLocal = pIes;
6805
6806 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006807 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306808 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006809 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006810
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006811 sme_debug("authType %d session %d", authType, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006812 if ((eCSR_AUTH_TYPE_WPA == authType) ||
6813 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
6814 (eCSR_AUTH_TYPE_RSN == authType) ||
6815 (eCSR_AUTH_TYPE_RSN_PSK == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006816 || (eCSR_AUTH_TYPE_FT_RSN == authType) ||
6817 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006818#ifdef FEATURE_WLAN_WAPI
6819 || (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
6820 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
6821#endif /* FEATURE_WLAN_WAPI */
6822#ifdef WLAN_FEATURE_11W
6823 || (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
6824 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
6825#endif /* FEATURE_WLAN_WAPI */
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05306826 || (eCSR_AUTH_TYPE_SAE == authType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306827 if (!pIesLocal && !QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006828 (csr_get_parsed_bss_description_ies(pMac,
6829 pSirBssDesc, &pIesLocal)))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006830 sme_err(" cannot parse IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006831 if (pIesLocal) {
6832 status = csr_roam_save_params(pMac, pSession, authType,
6833 pIes, pIesLocal);
6834 if (!pIes)
6835 /* locally allocated */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306836 qdf_mem_free(pIesLocal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006837 }
6838 }
6839 return status;
6840}
6841
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006842/* Returns whether the current association is a 11r assoc or not */
6843bool csr_roam_is11r_assoc(tpAniSirGlobal pMac, uint8_t sessionId)
6844{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006845 return csr_neighbor_roam_is11r_assoc(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006846}
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -08006847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006848/* Returns whether "Legacy Fast Roaming" is currently enabled...or not */
6849bool csr_roam_is_fast_roam_enabled(tpAniSirGlobal pMac, uint32_t sessionId)
6850{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306851 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006852
6853 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
6854 pSession = CSR_GET_SESSION(pMac, sessionId);
6855 if (NULL != pSession->pCurRoamProfile) {
6856 if (pSession->pCurRoamProfile->csrPersona !=
Anurag Chouhan6d760662016-02-20 16:05:43 +05306857 QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006858 return false;
6859 }
6860 }
6861 }
6862 if (true == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac)) {
6863 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
6864 } else {
6865 return pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
6866 (!csr_is_concurrent_session_running(pMac));
6867 }
6868}
6869
Sandeep Puligilla68908f22018-02-28 18:20:41 -08006870static void csr_update_scan_entry_associnfo(tpAniSirGlobal mac_ctx,
6871 struct bss_info *bss, enum scan_entry_connection_state state)
6872{
6873 QDF_STATUS status;
6874 struct mlme_info mlme;
6875
6876 sme_debug("Update MLME info in scan database. bssid %pM state: %d",
6877 bss->bssid.bytes, state);
6878 mlme.assoc_state = state;
6879 status = ucfg_scan_update_mlme_by_bssinfo(mac_ctx->pdev, bss, &mlme);
6880 if (QDF_IS_STATUS_ERROR(status))
6881 sme_debug("Failed to update the MLME info in scan entry");
6882}
6883
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006884#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
Jeff Johnson29e2ca12016-10-14 12:50:38 -07006885static eCsrPhyMode csr_roamdot11mode_to_phymode(uint8_t dot11mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006886{
6887 eCsrPhyMode phymode = eCSR_DOT11_MODE_abg;
6888
6889 switch (dot11mode) {
6890 case WNI_CFG_DOT11_MODE_ALL:
6891 phymode = eCSR_DOT11_MODE_abg;
6892 break;
6893 case WNI_CFG_DOT11_MODE_11A:
6894 phymode = eCSR_DOT11_MODE_11a;
6895 break;
6896 case WNI_CFG_DOT11_MODE_11B:
6897 phymode = eCSR_DOT11_MODE_11b;
6898 break;
6899 case WNI_CFG_DOT11_MODE_11G:
6900 phymode = eCSR_DOT11_MODE_11g;
6901 break;
6902 case WNI_CFG_DOT11_MODE_11N:
6903 phymode = eCSR_DOT11_MODE_11n;
6904 break;
6905 case WNI_CFG_DOT11_MODE_11G_ONLY:
6906 phymode = eCSR_DOT11_MODE_11g_ONLY;
6907 break;
6908 case WNI_CFG_DOT11_MODE_11N_ONLY:
6909 phymode = eCSR_DOT11_MODE_11n_ONLY;
6910 break;
6911 case WNI_CFG_DOT11_MODE_11AC:
6912 phymode = eCSR_DOT11_MODE_11ac;
6913 break;
6914 case WNI_CFG_DOT11_MODE_11AC_ONLY:
6915 phymode = eCSR_DOT11_MODE_11ac_ONLY;
6916 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08006917 case WNI_CFG_DOT11_MODE_11AX:
6918 phymode = eCSR_DOT11_MODE_11ax;
6919 break;
6920 case WNI_CFG_DOT11_MODE_11AX_ONLY:
6921 phymode = eCSR_DOT11_MODE_11ax_ONLY;
6922 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006923 default:
6924 break;
6925 }
6926
6927 return phymode;
6928}
6929#endif
6930
6931#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306932static void csr_roam_synch_clean_up(tpAniSirGlobal mac, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006933{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006934 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006935 struct roam_offload_synch_fail *roam_offload_failed = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05306936 struct csr_roam_session *session = &mac->roam.roamSession[session_id];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006937
6938 /* Clean up the roam synch in progress for LFR3 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306939 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006940 "%s: Roam Synch Failed, Clean Up", __func__);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08006941 session->roam_synch_in_progress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006942
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306943 roam_offload_failed = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006944 sizeof(struct roam_offload_synch_fail));
6945 if (NULL == roam_offload_failed) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306946 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306947 "%s: unable to allocate memory for roam synch fail",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006948 __func__);
6949 return;
6950 }
6951
6952 roam_offload_failed->session_id = session_id;
6953 msg.type = WMA_ROAM_OFFLOAD_SYNCH_FAIL;
6954 msg.reserved = 0;
6955 msg.bodyptr = roam_offload_failed;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006956 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006957 &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306958 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006959 "%s: Unable to post WMA_ROAM_OFFLOAD_SYNCH_FAIL to WMA",
6960 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306961 qdf_mem_free(roam_offload_failed);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006962 }
6963}
6964#endif
6965
6966#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6967/**
6968 * csr_roam_copy_ht_profile() - Copy from src to dst
6969 * @dst_profile: Destination HT profile
6970 * @src_profile: Source HT profile
6971 *
6972 * Copy the HT profile from the given source to destination
6973 *
6974 * Return: None
6975 */
6976static void csr_roam_copy_ht_profile(tCsrRoamHTProfile *dst_profile,
6977 tSirSmeHTProfile *src_profile)
6978{
6979 dst_profile->phymode =
6980 csr_roamdot11mode_to_phymode(src_profile->dot11mode);
6981 dst_profile->htCapability = src_profile->htCapability;
6982 dst_profile->htSupportedChannelWidthSet =
6983 src_profile->htSupportedChannelWidthSet;
6984 dst_profile->htRecommendedTxWidthSet =
6985 src_profile->htRecommendedTxWidthSet;
6986 dst_profile->htSecondaryChannelOffset =
6987 src_profile->htSecondaryChannelOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006988 dst_profile->vhtCapability = src_profile->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006989 dst_profile->apCenterChan = src_profile->apCenterChan;
6990 dst_profile->apChanWidth = src_profile->apChanWidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006991}
6992#endif
6993
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05306994#if defined(WLAN_FEATURE_FILS_SK)
6995/**
6996 * csr_update_fils_seq_number() - Copy FILS sequence number to roam info
6997 * @session: CSR Roam Session
6998 * @roam_info: Roam info
6999 *
7000 * Return: None
7001 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307002static void csr_update_fils_seq_number(struct csr_roam_session *session,
Jeff Johnson172237b2017-11-07 15:32:59 -08007003 struct csr_roam_info *roam_info)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307004{
7005 roam_info->is_fils_connection = true;
7006 roam_info->fils_seq_num = session->fils_seq_num;
7007 pe_debug("FILS sequence number %x", session->fils_seq_num);
7008}
7009#else
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307010static inline void csr_update_fils_seq_number(struct csr_roam_session *session,
Jeff Johnson172237b2017-11-07 15:32:59 -08007011 struct csr_roam_info *roam_info)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307012{}
7013#endif
7014
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007015/**
7016 * csr_roam_process_results_default() - Process the result for start bss
7017 * @mac_ctx: Global MAC Context
7018 * @cmd: Command to be processed
7019 * @context: Additional data in context of the cmd
7020 *
7021 * Return: None
7022 */
7023static void csr_roam_process_results_default(tpAniSirGlobal mac_ctx,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05307024 tSmeCmd *cmd, void *context, enum csr_roamcomplete_result
7025 res)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007026{
7027 uint32_t session_id = cmd->sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307028 struct csr_roam_session *session;
Jeff Johnson172237b2017-11-07 15:32:59 -08007029 struct csr_roam_info roam_info;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307030 QDF_STATUS status;
Sandeep Puligilla68908f22018-02-28 18:20:41 -08007031 struct bss_info bss_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007032
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07007033 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007034 sme_err("Invalid session id %d", session_id);
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07007035 return;
7036 }
7037 session = CSR_GET_SESSION(mac_ctx, session_id);
7038
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307039 sme_debug("receives no association indication; FILS %d",
7040 session->is_fils_connection);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007041 sme_debug("Assoc ref count: %d", session->bRefAssocStartCnt);
Sandeep Puligilla68908f22018-02-28 18:20:41 -08007042
7043 if (CSR_IS_INFRASTRUCTURE(&session->connectedProfile)) {
7044 qdf_copy_macaddr(&bss_info.bssid,
7045 &session->connectedProfile.bssid);
7046 bss_info.chan = session->connectedProfile.operationChannel;
7047 bss_info.ssid.length = session->connectedProfile.SSID.length;
7048 qdf_mem_copy(&bss_info.ssid.ssid,
7049 &session->connectedProfile.SSID.ssId,
7050 bss_info.ssid.length);
7051 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007052 if (CSR_IS_INFRASTRUCTURE(&session->connectedProfile)
7053 || CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ(mac_ctx, session_id)) {
7054 /*
7055 * do not free for the other profiles as we need
7056 * to send down stop BSS later
7057 */
7058 csr_free_connect_bss_desc(mac_ctx, session_id);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08007059 csr_roam_free_connect_profile(&session->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007060 csr_roam_free_connected_info(mac_ctx, &session->connectedInfo);
7061 csr_set_default_dot11_mode(mac_ctx);
7062 }
7063
Jeff Johnson172237b2017-11-07 15:32:59 -08007064 qdf_mem_set(&roam_info, sizeof(struct csr_roam_info), 0);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307065 /* Copy FILS sequence number used to be updated to userspace */
7066 if (session->is_fils_connection)
7067 csr_update_fils_seq_number(session, &roam_info);
7068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007069 switch (cmd->u.roamCmd.roamReason) {
7070 /*
7071 * If this transition is because of an 802.11 OID, then we
7072 * transition back to INIT state so we sit waiting for more
7073 * OIDs to be issued and we don't start the IDLE timer.
7074 */
7075 case eCsrSmeIssuedFTReassoc:
7076 case eCsrSmeIssuedAssocToSimilarAP:
7077 case eCsrHddIssued:
7078 case eCsrSmeIssuedDisassocForHandoff:
7079 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
7080 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007081 roam_info.pBssDesc = cmd->u.roamCmd.pLastRoamBss;
7082 roam_info.pProfile = &cmd->u.roamCmd.roamProfile;
7083 roam_info.statusCode = session->joinFailStatusCode.statusCode;
7084 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307085 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007086 &session->joinFailStatusCode.bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307087 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007088
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007089 /*
7090 * If Join fails while Handoff is in progress, indicate
7091 * disassociated event to supplicant to reconnect
7092 */
7093 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)) {
7094 csr_neighbor_roam_indicate_connect(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307095 (uint8_t)session_id, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007096 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007097 if (session->bRefAssocStartCnt > 0) {
7098 session->bRefAssocStartCnt--;
7099 if (eCsrJoinFailureDueToConcurrency == res)
7100 csr_roam_call_callback(mac_ctx, session_id,
7101 &roam_info, cmd->u.roamCmd.roamId,
7102 eCSR_ROAM_ASSOCIATION_COMPLETION,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307103 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007104 else
7105 csr_roam_call_callback(mac_ctx, session_id,
7106 &roam_info, cmd->u.roamCmd.roamId,
7107 eCSR_ROAM_ASSOCIATION_COMPLETION,
7108 eCSR_ROAM_RESULT_FAILURE);
7109 } else {
7110 /*
7111 * bRefAssocStartCnt is not incremented when
7112 * eRoamState == eCsrStopRoamingDueToConcurrency
7113 * in csr_roam_join_next_bss API. so handle this in
7114 * else case by sending assoc failure
7115 */
7116 csr_roam_call_callback(mac_ctx, session_id,
Abhishek Singh221cf992018-02-22 13:44:53 +05307117 &roam_info, cmd->u.roamCmd.roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007118 eCSR_ROAM_ASSOCIATION_FAILURE,
7119 eCSR_ROAM_RESULT_FAILURE);
7120 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007121 sme_debug("roam(reason %d) failed", cmd->u.roamCmd.roamReason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007122#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7123 sme_qos_update_hand_off((uint8_t) session_id, false);
7124 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
7125 SME_QOS_CSR_DISCONNECT_IND, NULL);
7126#endif
7127 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
7128 eCSR_ROAM_RESULT_FAILURE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007129 break;
7130 case eCsrHddIssuedReassocToSameAP:
7131 case eCsrSmeIssuedReassocToSameAP:
7132 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
7133 session_id);
7134
7135 csr_roam_call_callback(mac_ctx, session_id, NULL,
7136 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
7137 eCSR_ROAM_RESULT_FORCED);
7138#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7139 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
7140 SME_QOS_CSR_DISCONNECT_IND, NULL);
7141#endif
7142 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
7143 eCSR_ROAM_RESULT_FAILURE, false);
7144 break;
7145 case eCsrForcedDisassoc:
7146 case eCsrForcedDeauth:
7147 case eCsrSmeIssuedIbssJoinFailure:
7148 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
7149 session_id);
7150
7151 if (eCsrSmeIssuedIbssJoinFailure == cmd->u.roamCmd.roamReason)
7152 /* notify HDD that IBSS join failed */
7153 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
7154 eCSR_ROAM_IBSS_IND,
7155 eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
7156 else
7157 csr_roam_call_callback(mac_ctx, session_id, NULL,
7158 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
7159 eCSR_ROAM_RESULT_FORCED);
7160#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7161 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
7162 SME_QOS_CSR_DISCONNECT_IND,
7163 NULL);
7164#endif
Sandeep Puligilla68908f22018-02-28 18:20:41 -08007165 csr_update_scan_entry_associnfo(mac_ctx, &bss_info,
7166 SCAN_ENTRY_CON_STATE_NONE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007167 csr_roam_link_down(mac_ctx, session_id);
7168
7169 if (mac_ctx->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007170 sme_warn("FW still in connected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007171 break;
7172 }
7173 break;
7174 case eCsrForcedIbssLeave:
7175 csr_roam_call_callback(mac_ctx, session_id, NULL,
7176 cmd->u.roamCmd.roamId, eCSR_ROAM_IBSS_LEAVE,
7177 eCSR_ROAM_RESULT_IBSS_STOP);
Krunal Soni2c68f232015-10-26 20:52:51 -07007178 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007179 break;
7180 case eCsrForcedDisassocMICFailure:
7181 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
7182 session_id);
7183
7184 csr_roam_call_callback(mac_ctx, session_id, NULL,
7185 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
7186 eCSR_ROAM_RESULT_MIC_FAILURE);
7187#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7188 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
7189 SME_QOS_CSR_DISCONNECT_REQ, NULL);
7190#endif
7191 break;
7192 case eCsrStopBss:
7193 csr_roam_call_callback(mac_ctx, session_id, NULL,
7194 cmd->u.roamCmd.roamId, eCSR_ROAM_INFRA_IND,
7195 eCSR_ROAM_RESULT_INFRA_STOPPED);
7196 break;
7197 case eCsrForcedDisassocSta:
7198 case eCsrForcedDeauthSta:
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +05307199 roam_info.rssi = mac_ctx->peer_rssi;
7200 roam_info.tx_rate = mac_ctx->peer_txrate;
7201 roam_info.rx_rate = mac_ctx->peer_rxrate;
7202
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007203 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
7204 session_id);
7205 session = CSR_GET_SESSION(mac_ctx, session_id);
7206 if (CSR_IS_SESSION_VALID(mac_ctx, session_id) &&
7207 CSR_IS_INFRA_AP(&session->connectedProfile)) {
7208 roam_info.u.pConnectedProfile =
7209 &session->connectedProfile;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307210 qdf_mem_copy(roam_info.peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007211 cmd->u.roamCmd.peerMac,
7212 sizeof(tSirMacAddr));
Ashish Kumar Dhanotiyad39c8b52018-03-27 18:18:52 +05307213 roam_info.reasonCode = eCSR_ROAM_RESULT_FORCED;
7214 /* Update the MAC reason code */
7215 roam_info.disassoc_reason = cmd->u.roamCmd.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007216 roam_info.statusCode = eSIR_SME_SUCCESS;
7217 status = csr_roam_call_callback(mac_ctx, session_id,
7218 &roam_info, cmd->u.roamCmd.roamId,
7219 eCSR_ROAM_LOSTLINK,
7220 eCSR_ROAM_RESULT_FORCED);
7221 }
7222 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007223 default:
7224 csr_roam_state_change(mac_ctx,
7225 eCSR_ROAMING_STATE_IDLE, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007226 break;
7227 }
7228}
7229
7230/**
7231 * csr_roam_process_start_bss_success() - Process the result for start bss
7232 * @mac_ctx: Global MAC Context
7233 * @cmd: Command to be processed
7234 * @context: Additional data in context of the cmd
7235 *
7236 * Return: None
7237 */
7238static void csr_roam_process_start_bss_success(tpAniSirGlobal mac_ctx,
7239 tSmeCmd *cmd, void *context)
7240{
7241 uint32_t session_id = cmd->sessionId;
Jeff Johnson66ee8a92018-03-17 15:24:26 -07007242 struct csr_roam_profile *profile = &cmd->u.roamCmd.roamProfile;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307243 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007244 tSirBssDescription *bss_desc = NULL;
Jeff Johnson172237b2017-11-07 15:32:59 -08007245 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007246 tSirSmeStartBssRsp *start_bss_rsp = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007247 eRoamCmdStatus roam_status;
7248 eCsrRoamResult roam_result;
7249 tDot11fBeaconIEs *ies_ptr = NULL;
7250 tSirMacAddr bcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307251 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007252 host_log_ibss_pkt_type *ibss_log;
7253 uint32_t bi;
7254#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
7255 tSirSmeHTProfile *src_profile = NULL;
7256 tCsrRoamHTProfile *dst_profile = NULL;
7257#endif
7258
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07007259 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007260 sme_err("Invalid session id %d", session_id);
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07007261 return;
7262 }
7263 session = CSR_GET_SESSION(mac_ctx, session_id);
7264
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007265 /*
7266 * on the StartBss Response, LIM is returning the Bss Description that
7267 * we are beaconing. Add this Bss Description to our scan results and
7268 * chain the Profile to this Bss Description. On a Start BSS, there was
7269 * no detected Bss description (no partner) so we issued the Start Bss
7270 * to start the Ibss without any Bss description. Lim was kind enough
7271 * to return the Bss Description that we start beaconing for the newly
7272 * started Ibss.
7273 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007274 sme_debug("receives start BSS ok indication");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307275 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007276 start_bss_rsp = (tSirSmeStartBssRsp *) context;
Jeff Johnson172237b2017-11-07 15:32:59 -08007277 qdf_mem_set(&roam_info, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007278 if (CSR_IS_IBSS(profile))
7279 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
7280 else if (CSR_IS_INFRA_AP(profile))
7281 session->connectState =
7282 eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007283 else if (CSR_IS_NDI(profile))
7284 session->connectState = eCSR_CONNECT_STATE_TYPE_NDI_STARTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007285 else
7286 session->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007287
7288 bss_desc = &start_bss_rsp->bssDescription;
7289 if (CSR_IS_NDI(profile)) {
7290 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
7291 session_id);
7292 csr_roam_save_ndi_connected_info(mac_ctx, session_id, profile,
7293 bss_desc);
7294 roam_info.u.pConnectedProfile = &session->connectedProfile;
7295 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
7296 sizeof(struct qdf_mac_addr));
Naveen Rawatcb186cf2016-07-11 13:47:19 -07007297 } else {
7298 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
7299 session_id);
7300 if (!QDF_IS_STATUS_SUCCESS
7301 (csr_get_parsed_bss_description_ies(mac_ctx, bss_desc,
7302 &ies_ptr))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007303 sme_warn("cannot parse IBSS IEs");
Naveen Rawatcb186cf2016-07-11 13:47:19 -07007304 roam_info.pBssDesc = bss_desc;
7305 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
7306 cmd->u.roamCmd.roamId, eCSR_ROAM_IBSS_IND,
7307 eCSR_ROAM_RESULT_IBSS_START_FAILED);
7308 return;
7309 }
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007310 }
Naveen Rawat334c51b2017-05-05 17:33:32 -07007311 if (!CSR_IS_INFRA_AP(profile) && !CSR_IS_NDI(profile)) {
Abhishek Singhf723e3d2018-02-20 18:02:37 +05307312 csr_scan_append_bss_description(mac_ctx, bss_desc);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007313 }
7314 csr_roam_save_connected_bss_desc(mac_ctx, session_id, bss_desc);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08007315 csr_roam_free_connect_profile(&session->connectedProfile);
7316 csr_roam_free_connected_info(mac_ctx, &session->connectedInfo);
Jeff Johnson536249f2018-05-12 16:48:38 -07007317 csr_roam_save_connected_information(mac_ctx, session_id,
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007318 profile, bss_desc, ies_ptr);
7319 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307320 sizeof(struct qdf_mac_addr));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007321 /* We are done with the IEs so free it */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307322 qdf_mem_free(ies_ptr);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007323#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7324 WLAN_HOST_DIAG_LOG_ALLOC(ibss_log,
7325 host_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7326 if (ibss_log) {
7327 if (CSR_INVALID_SCANRESULT_HANDLE ==
7328 cmd->u.roamCmd.hBSSList) {
7329 /*
7330 * We start the IBSS (didn't find any
7331 * matched IBSS out there)
7332 */
7333 ibss_log->eventId =
7334 WLAN_IBSS_EVENT_START_IBSS_RSP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007335 } else {
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007336 ibss_log->eventId =
7337 WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
7338 }
7339 if (bss_desc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307340 qdf_mem_copy(ibss_log->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307341 bss_desc->bssId, QDF_MAC_ADDR_SIZE);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007342 ibss_log->operatingChannel =
7343 bss_desc->channelId;
7344 }
7345 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(
7346 mac_ctx,
7347 WNI_CFG_BEACON_INTERVAL,
7348 &bi)))
7349 /* U8 is not enough for BI */
7350 ibss_log->beaconInterval = (uint8_t) bi;
7351 WLAN_HOST_DIAG_LOG_REPORT(ibss_log);
7352 }
7353#endif
7354 /*
7355 * Only set context for non-WDS_STA. We don't even need it for
7356 * WDS_AP. But since the encryption.
7357 * is WPA2-PSK so it won't matter.
7358 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08007359 if (session->pCurRoamProfile &&
7360 !CSR_IS_INFRA_AP(session->pCurRoamProfile)) {
7361 if (CSR_IS_ENC_TYPE_STATIC(
7362 profile->negotiatedUCEncryptionType)) {
7363 /*
7364 * Issue the set Context request to LIM to establish
7365 * the Broadcast STA context for the Ibss. In Rome IBSS
7366 * case, dummy key installation will break proper BSS
7367 * key installation, so skip it.
7368 */
7369 if (!CSR_IS_IBSS(session->pCurRoamProfile)) {
7370 /* NO keys. these key parameters don't matter */
7371 csr_roam_issue_set_context_req(mac_ctx,
7372 session_id,
7373 profile->negotiatedMCEncryptionType,
7374 bss_desc, &bcast_mac, false,
7375 false, eSIR_TX_RX, 0, 0, NULL, 0);
7376 }
7377 }
7378 if (CSR_IS_IBSS(session->pCurRoamProfile) &&
7379 (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
7380 profile->negotiatedUCEncryptionType ||
7381 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
7382 profile->negotiatedUCEncryptionType ||
7383 eCSR_ENCRYPT_TYPE_TKIP ==
7384 profile->negotiatedUCEncryptionType ||
7385 eCSR_ENCRYPT_TYPE_AES ==
7386 profile->negotiatedUCEncryptionType)) {
7387 roam_info.fAuthRequired = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007388 }
7389 }
7390 /*
7391 * Only tell upper layer is we start the BSS because Vista doesn't like
7392 * multiple connection indications. If we don't start the BSS ourself,
7393 * handler of eSIR_SME_JOINED_NEW_BSS will trigger the connection start
7394 * indication in Vista
7395 */
7396 if (!CSR_IS_JOIN_TO_IBSS(profile)) {
7397 roam_status = eCSR_ROAM_IBSS_IND;
7398 roam_result = eCSR_ROAM_RESULT_IBSS_STARTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007399 if (CSR_IS_INFRA_AP(profile)) {
7400 roam_status = eCSR_ROAM_INFRA_IND;
7401 roam_result = eCSR_ROAM_RESULT_INFRA_STARTED;
7402 }
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07007403 roam_info.staId = (uint8_t) start_bss_rsp->staId;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007404 if (CSR_IS_NDI(profile)) {
7405 csr_roam_update_ndp_return_params(mac_ctx,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07007406 eCsrStartBssSuccess,
7407 &roam_status,
7408 &roam_result,
7409 &roam_info);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007410 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007411 /*
7412 * Only tell upper layer is we start the BSS because Vista
7413 * doesn't like multiple connection indications. If we don't
7414 * start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS
7415 * will trigger the connection start indication in Vista
7416 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007417 roam_info.statusCode = session->joinFailStatusCode.statusCode;
7418 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
7419 /* We start the IBSS (didn't find any matched IBSS out there) */
7420 roam_info.pBssDesc = bss_desc;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007421 if (bss_desc)
7422 qdf_mem_copy(roam_info.bssid.bytes, bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307423 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007424 if (!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
7425 (csr_is_concurrent_session_running(mac_ctx))) {
7426 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
7427 }
7428#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
7429 dst_profile = &session->connectedProfile.HTProfile;
7430 src_profile = &start_bss_rsp->HTProfile;
7431 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307432 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007433 csr_roam_copy_ht_profile(dst_profile, src_profile);
7434#endif
7435 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
7436 cmd->u.roamCmd.roamId,
7437 roam_status, roam_result);
7438 }
7439
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007440}
7441
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307442#ifdef WLAN_FEATURE_FILS_SK
7443/**
7444 * populate_fils_params_join_rsp() - Copy FILS params from JOIN rsp
7445 * @mac_ctx: Global MAC Context
7446 * @roam_info: CSR Roam Info
7447 * @join_rsp: SME Join response
7448 *
7449 * Copy the FILS params from the join results
7450 *
7451 * Return: QDF_STATUS
7452 */
7453static QDF_STATUS populate_fils_params_join_rsp(tpAniSirGlobal mac_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -08007454 struct csr_roam_info *roam_info,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307455 tSirSmeJoinRsp *join_rsp)
7456{
7457 QDF_STATUS status = QDF_STATUS_SUCCESS;
7458 struct fils_join_rsp_params *roam_fils_info,
7459 *fils_join_rsp = join_rsp->fils_join_rsp;
7460
7461 if (!fils_join_rsp->fils_pmk_len ||
7462 !fils_join_rsp->fils_pmk || !fils_join_rsp->tk_len ||
7463 !fils_join_rsp->kek_len || !fils_join_rsp->gtk_len) {
7464 sme_err("fils join rsp err: pmk len %d tk len %d kek len %d gtk len %d",
7465 fils_join_rsp->fils_pmk_len,
7466 fils_join_rsp->tk_len,
7467 fils_join_rsp->kek_len,
7468 fils_join_rsp->gtk_len);
7469 status = QDF_STATUS_E_FAILURE;
7470 goto free_fils_join_rsp;
7471 }
7472
7473 roam_info->fils_join_rsp = qdf_mem_malloc(sizeof(*fils_join_rsp));
7474 if (!roam_info->fils_join_rsp) {
7475 sme_err("fils_join_rsp malloc fails!");
7476 status = QDF_STATUS_E_FAILURE;
7477 goto free_fils_join_rsp;
7478 }
7479
7480 roam_fils_info = roam_info->fils_join_rsp;
7481 roam_fils_info->fils_pmk = qdf_mem_malloc(fils_join_rsp->fils_pmk_len);
7482 if (!roam_fils_info->fils_pmk) {
7483 qdf_mem_free(roam_info->fils_join_rsp);
7484 roam_info->fils_join_rsp = NULL;
7485 sme_err("fils_pmk malloc fails!");
7486 status = QDF_STATUS_E_FAILURE;
7487 goto free_fils_join_rsp;
7488 }
7489
7490 roam_info->fils_seq_num = join_rsp->fils_seq_num;
7491 roam_fils_info->fils_pmk_len = fils_join_rsp->fils_pmk_len;
7492 qdf_mem_copy(roam_fils_info->fils_pmk,
7493 fils_join_rsp->fils_pmk, roam_fils_info->fils_pmk_len);
7494
7495 qdf_mem_copy(roam_fils_info->fils_pmkid,
7496 fils_join_rsp->fils_pmkid, PMKID_LEN);
7497
7498 roam_fils_info->kek_len = fils_join_rsp->kek_len;
7499 qdf_mem_copy(roam_fils_info->kek,
7500 fils_join_rsp->kek, roam_fils_info->kek_len);
7501
7502 roam_fils_info->tk_len = fils_join_rsp->tk_len;
7503 qdf_mem_copy(roam_fils_info->tk,
7504 fils_join_rsp->tk, fils_join_rsp->tk_len);
7505
7506 roam_fils_info->gtk_len = fils_join_rsp->gtk_len;
7507 qdf_mem_copy(roam_fils_info->gtk,
7508 fils_join_rsp->gtk, roam_fils_info->gtk_len);
7509
Vignesh Viswanathana1bb0922017-09-15 12:58:48 +05307510 cds_copy_hlp_info(&fils_join_rsp->dst_mac, &fils_join_rsp->src_mac,
7511 fils_join_rsp->hlp_data_len, fils_join_rsp->hlp_data,
7512 &roam_fils_info->dst_mac, &roam_fils_info->src_mac,
7513 &roam_fils_info->hlp_data_len,
7514 roam_fils_info->hlp_data);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307515 sme_debug("FILS connect params copied to CSR!");
7516
7517free_fils_join_rsp:
7518 qdf_mem_free(fils_join_rsp->fils_pmk);
7519 qdf_mem_free(fils_join_rsp);
7520 return status;
7521}
7522
7523/**
7524 * csr_process_fils_join_rsp() - Process join rsp for FILS connection
7525 * @mac_ctx: Global MAC Context
7526 * @profile: CSR Roam Profile
7527 * @session_id: Session ID
7528 * @roam_info: CSR Roam Info
7529 * @bss_desc: BSS description
7530 * @join_rsp: SME Join rsp
7531 *
7532 * Process SME join response for FILS connection
7533 *
7534 * Return: None
7535 */
7536static void csr_process_fils_join_rsp(tpAniSirGlobal mac_ctx,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07007537 struct csr_roam_profile *profile,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307538 uint32_t session_id,
Jeff Johnson172237b2017-11-07 15:32:59 -08007539 struct csr_roam_info *roam_info,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307540 tSirBssDescription *bss_desc,
7541 tSirSmeJoinRsp *join_rsp)
7542{
7543 tSirMacAddr bcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
7544 QDF_STATUS status;
7545
7546 if (!join_rsp || !join_rsp->fils_join_rsp) {
7547 sme_err("Join rsp doesn't have FILS info");
7548 goto process_fils_join_rsp_fail;
7549 }
7550
7551 /* Copy FILS params */
7552 status = populate_fils_params_join_rsp(mac_ctx, roam_info, join_rsp);
7553 if (!QDF_IS_STATUS_SUCCESS(status)) {
7554 sme_err("Copy FILS params join rsp fails");
7555 goto process_fils_join_rsp_fail;
7556 }
7557
7558 status = csr_roam_issue_set_context_req(mac_ctx, session_id,
7559 profile->negotiatedMCEncryptionType,
7560 bss_desc, &bcast_mac, true, false,
7561 eSIR_RX_ONLY, 2,
7562 roam_info->fils_join_rsp->gtk_len,
7563 roam_info->fils_join_rsp->gtk, 0);
7564 if (!QDF_IS_STATUS_SUCCESS(status)) {
7565 sme_err("Set context for bcast fail");
7566 goto process_fils_join_rsp_fail;
7567 }
7568
7569 status = csr_roam_issue_set_context_req(mac_ctx, session_id,
7570 profile->negotiatedUCEncryptionType,
7571 bss_desc, &(bss_desc->bssId), true,
7572 true, eSIR_TX_RX, 0,
7573 roam_info->fils_join_rsp->tk_len,
7574 roam_info->fils_join_rsp->tk, 0);
7575 if (!QDF_IS_STATUS_SUCCESS(status)) {
7576 sme_err("Set context for unicast fail");
7577 goto process_fils_join_rsp_fail;
7578 }
7579 return;
7580
7581process_fils_join_rsp_fail:
7582 csr_roam_substate_change(mac_ctx, eCSR_ROAM_SUBSTATE_NONE, session_id);
7583}
7584#else
7585
7586static inline void csr_process_fils_join_rsp(tpAniSirGlobal mac_ctx,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07007587 struct csr_roam_profile *profile,
7588 uint32_t session_id,
7589 struct csr_roam_info *roam_info,
7590 tSirBssDescription *bss_desc,
7591 tSirSmeJoinRsp *join_rsp)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307592{}
7593#endif
7594
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007595/**
7596 * csr_roam_process_join_res() - Process the Join results
7597 * @mac_ctx: Global MAC Context
7598 * @result: Result after the command was processed
7599 * @cmd: Command to be processed
7600 * @context: Additional data in context of the cmd
7601 *
Jeff Johnson3370f3a2018-05-11 09:54:12 -07007602 * Process the join results which are obtained in a successful join
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007603 *
7604 * Return: None
7605 */
7606static void csr_roam_process_join_res(tpAniSirGlobal mac_ctx,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05307607 enum csr_roamcomplete_result res, tSmeCmd *cmd, void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007608{
7609 tSirMacAddr bcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
7610 sme_QosAssocInfo assoc_info;
7611 uint32_t key_timeout_interval = 0;
7612 uint8_t acm_mask = 0; /* HDD needs ACM mask in assoc rsp callback */
7613 uint32_t session_id = cmd->sessionId;
Jeff Johnson66ee8a92018-03-17 15:24:26 -07007614 struct csr_roam_profile *profile = &cmd->u.roamCmd.roamProfile;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307615 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007616 tSirBssDescription *bss_desc = NULL;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05307617 struct tag_csrscan_result *scan_res = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007618 sme_qos_csr_event_indType ind_qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007619#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
7620 tSirSmeHTProfile *src_profile = NULL;
7621 tCsrRoamHTProfile *dst_profile = NULL;
7622#endif
7623 tCsrRoamConnectedProfile *conn_profile = NULL;
7624 tDot11fBeaconIEs *ies_ptr = NULL;
Jeff Johnson172237b2017-11-07 15:32:59 -08007625 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007626 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
7627 tSirSmeJoinRsp *join_rsp = (tSirSmeJoinRsp *) context;
7628 uint32_t len;
Sandeep Puligilla68908f22018-02-28 18:20:41 -08007629 struct bss_info bss_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007630
Nishank Aggarwal68d39272017-05-15 17:05:14 +05307631 if (!join_rsp) {
7632 sme_err("join_rsp is NULL");
7633 return;
7634 }
7635
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07007636 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007637 sme_err("Invalid session id %d", session_id);
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07007638 return;
7639 }
7640 session = CSR_GET_SESSION(mac_ctx, session_id);
7641
Zhang Qian32fd43e2017-08-24 18:36:28 +08007642 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007643 conn_profile = &session->connectedProfile;
Anurag Chouhan5de8d172016-07-13 14:44:28 +05307644 if (eCsrReassocSuccess == res) {
7645 roam_info.reassoc = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007646 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
Anurag Chouhan5de8d172016-07-13 14:44:28 +05307647 } else {
7648 roam_info.reassoc = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007649 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
Anurag Chouhan5de8d172016-07-13 14:44:28 +05307650 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007651 sme_debug("receives association indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007652 /* always free the memory here */
7653 if (session->pWpaRsnRspIE) {
7654 session->nWpaRsnRspIeLength = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307655 qdf_mem_free(session->pWpaRsnRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007656 session->pWpaRsnRspIE = NULL;
7657 }
7658#ifdef FEATURE_WLAN_WAPI
7659 if (session->pWapiRspIE) {
7660 session->nWapiRspIeLength = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307661 qdf_mem_free(session->pWapiRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007662 session->pWapiRspIE = NULL;
7663 }
7664#endif /* FEATURE_WLAN_WAPI */
7665#ifdef FEATURE_WLAN_BTAMP_UT_RF
7666 session->maxRetryCount = 0;
7667 csr_roam_stop_join_retry_timer(mac_ctx, session_id);
7668#endif
7669 /*
7670 * Reset remain_in_power_active_till_dhcp as
7671 * it might have been set by last failed secured connection.
7672 * It should be set only for secured connection.
7673 */
7674 ps_global_info->remain_in_power_active_till_dhcp = false;
7675 if (CSR_IS_INFRASTRUCTURE(profile))
7676 session->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
7677 else
7678 session->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
7679 /*
7680 * Use the last connected bssdesc for reassoc-ing to the same AP.
7681 * NOTE: What to do when reassoc to a different AP???
7682 */
7683 if ((eCsrHddIssuedReassocToSameAP == cmd->u.roamCmd.roamReason)
7684 || (eCsrSmeIssuedReassocToSameAP ==
7685 cmd->u.roamCmd.roamReason)) {
7686 bss_desc = session->pConnectBssDesc;
7687 if (bss_desc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307688 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307689 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007690 } else {
7691 if (cmd->u.roamCmd.pRoamBssEntry) {
7692 scan_res = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05307693 struct tag_csrscan_result, Link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007694 if (scan_res != NULL) {
7695 bss_desc = &scan_res->Result.BssDescriptor;
7696 ies_ptr = (tDot11fBeaconIEs *)
7697 (scan_res->Result.pvIes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307698 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307699 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007700 }
7701 }
7702 }
7703 if (bss_desc) {
7704 roam_info.staId = STA_INVALID_IDX;
Jeff Johnson536249f2018-05-12 16:48:38 -07007705 csr_roam_save_connected_information(mac_ctx, session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007706 profile, bss_desc, ies_ptr);
7707 /* Save WPA/RSN IE */
7708 csr_roam_save_security_rsp_ie(mac_ctx, session_id,
7709 profile->negotiatedAuthType, bss_desc, ies_ptr);
7710#ifdef FEATURE_WLAN_ESE
7711 roam_info.isESEAssoc = conn_profile->isESEAssoc;
7712#endif
7713
7714 /*
7715 * csr_roam_state_change also affects sub-state.
7716 * Hence, csr_roam_state_change happens first and then
7717 * substate change.
7718 * Moving even save profile above so that below
7719 * mentioned conditon is also met.
7720 * JEZ100225: Moved to after saving the profile.
7721 * Fix needed in main/latest
7722 */
7723 csr_roam_state_change(mac_ctx,
7724 eCSR_ROAMING_STATE_JOINED, session_id);
7725
7726 /*
7727 * Make sure the Set Context is issued before link
7728 * indication to NDIS. After link indication is
7729 * made to NDIS, frames could start flowing.
7730 * If we have not set context with LIM, the frames
7731 * will be dropped for the security context may not
7732 * be set properly.
7733 *
7734 * this was causing issues in the 2c_wlan_wep WHQL test
7735 * when the SetContext was issued after the link
7736 * indication. (Link Indication happens in the
7737 * profFSMSetConnectedInfra call).
7738 *
7739 * this reordering was done on titan_prod_usb branch
7740 * and is being replicated here.
7741 */
7742
7743 if (CSR_IS_ENC_TYPE_STATIC
7744 (profile->negotiatedUCEncryptionType) &&
7745 !profile->bWPSAssociation) {
7746 /*
7747 * Issue the set Context request to LIM to establish
7748 * the Unicast STA context
7749 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307750 if (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007751 csr_roam_issue_set_context_req(mac_ctx,
7752 session_id,
7753 profile->negotiatedUCEncryptionType,
7754 bss_desc, &(bss_desc->bssId),
7755 false, true,
7756 eSIR_TX_RX, 0, 0, NULL, 0))) {
7757 /* NO keys. these key parameters don't matter */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007758 sme_err("Set context for unicast fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007759 csr_roam_substate_change(mac_ctx,
7760 eCSR_ROAM_SUBSTATE_NONE, session_id);
7761 }
7762 /*
7763 * Issue the set Context request to LIM
7764 * to establish the Broadcast STA context
7765 * NO keys. these key parameters don't matter
7766 */
7767 csr_roam_issue_set_context_req(mac_ctx, session_id,
7768 profile->negotiatedMCEncryptionType,
7769 bss_desc, &bcast_mac, false, false,
7770 eSIR_TX_RX, 0, 0, NULL, 0);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307771 } else if (CSR_IS_AUTH_TYPE_FILS(profile->negotiatedAuthType)
7772 && join_rsp->is_fils_connection) {
7773 roam_info.is_fils_connection = true;
7774 csr_process_fils_join_rsp(mac_ctx, profile, session_id,
7775 &roam_info, bss_desc, join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007776 } else {
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007777 /* Need to wait for supplicant authtication */
7778 roam_info.fAuthRequired = true;
7779 /*
7780 * Set the substate to WaitForKey in case
7781 * authentiation is needed
7782 */
7783 csr_roam_substate_change(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007784 eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY,
7785 session_id);
7786
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007787 /*
7788 * Set remain_in_power_active_till_dhcp to make
7789 * sure we wait for until keys are set before
7790 * going into BMPS.
7791 */
7792 ps_global_info->remain_in_power_active_till_dhcp
7793 = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007794
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007795 if (profile->bWPSAssociation)
7796 key_timeout_interval =
7797 CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
7798 else
7799 key_timeout_interval =
7800 CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007801
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007802 /* Save session_id in case of timeout */
7803 mac_ctx->roam.WaitForKeyTimerInfo.sessionId =
7804 (uint8_t) session_id;
7805 /*
7806 * This time should be long enough for the rest
7807 * of the process plus setting key
7808 */
7809 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007810 (csr_roam_start_wait_for_key_timer(
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007811 mac_ctx, key_timeout_interval))
7812 ) {
7813 /* Reset state so nothing is blocked. */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007814 sme_err("Failed preauth timer start");
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007815 csr_roam_substate_change(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007816 eCSR_ROAM_SUBSTATE_NONE,
7817 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007818 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007819 }
7820
7821 assoc_info.pBssDesc = bss_desc; /* could be NULL */
7822 assoc_info.pProfile = profile;
7823 if (context) {
7824#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007825 if (session->roam_synch_in_progress)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307826 QDF_TRACE(QDF_MODULE_ID_SME,
7827 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007828 FL("LFR3:Clear Connected info"));
7829#endif
7830 csr_roam_free_connected_info(mac_ctx,
7831 &session->connectedInfo);
7832 len = join_rsp->assocReqLength +
7833 join_rsp->assocRspLength +
7834 join_rsp->beaconLength;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007835 len += join_rsp->parsedRicRspLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007836#ifdef FEATURE_WLAN_ESE
7837 len += join_rsp->tspecIeLen;
7838#endif
7839 if (len) {
7840 session->connectedInfo.pbFrames =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307841 qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007842 if (session->connectedInfo.pbFrames !=
7843 NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307844 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007845 session->connectedInfo.pbFrames,
7846 join_rsp->frames, len);
7847 session->connectedInfo.nAssocReqLength =
7848 join_rsp->assocReqLength;
7849 session->connectedInfo.nAssocRspLength =
7850 join_rsp->assocRspLength;
7851 session->connectedInfo.nBeaconLength =
7852 join_rsp->beaconLength;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007853 session->connectedInfo.nRICRspLength =
7854 join_rsp->parsedRicRspLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007855#ifdef FEATURE_WLAN_ESE
7856 session->connectedInfo.nTspecIeLength =
7857 join_rsp->tspecIeLen;
7858#endif
7859 roam_info.nAssocReqLength =
7860 join_rsp->assocReqLength;
7861 roam_info.nAssocRspLength =
7862 join_rsp->assocRspLength;
7863 roam_info.nBeaconLength =
7864 join_rsp->beaconLength;
7865 roam_info.pbFrames =
7866 session->connectedInfo.pbFrames;
7867 }
7868 }
7869 if (cmd->u.roamCmd.fReassoc)
7870 roam_info.fReassocReq =
7871 roam_info.fReassocRsp = true;
7872 conn_profile->vht_channel_width =
7873 join_rsp->vht_channel_width;
7874 session->connectedInfo.staId =
7875 (uint8_t) join_rsp->staId;
7876 roam_info.staId = (uint8_t) join_rsp->staId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007877 roam_info.timingMeasCap = join_rsp->timingMeasCap;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05307878 roam_info.chan_info.nss = join_rsp->nss;
7879 roam_info.chan_info.rate_flags =
7880 join_rsp->max_rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007881#ifdef FEATURE_WLAN_TDLS
7882 roam_info.tdls_prohibited = join_rsp->tdls_prohibited;
7883 roam_info.tdls_chan_swit_prohibited =
7884 join_rsp->tdls_chan_swit_prohibited;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007885 sme_debug("tdls:prohibit: %d chan_swit_prohibit: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007886 roam_info.tdls_prohibited,
7887 roam_info.tdls_chan_swit_prohibited);
7888#endif
7889#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
7890 src_profile = &join_rsp->HTProfile;
7891 dst_profile = &conn_profile->HTProfile;
7892 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307893 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007894 csr_roam_copy_ht_profile(dst_profile,
7895 src_profile);
7896#endif
Anurag Chouhan5de8d172016-07-13 14:44:28 +05307897 roam_info.vht_caps = join_rsp->vht_caps;
7898 roam_info.ht_caps = join_rsp->ht_caps;
7899 roam_info.hs20vendor_ie = join_rsp->hs20vendor_ie;
7900 roam_info.ht_operation = join_rsp->ht_operation;
7901 roam_info.vht_operation = join_rsp->vht_operation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007902 } else {
7903 if (cmd->u.roamCmd.fReassoc) {
7904 roam_info.fReassocReq =
7905 roam_info.fReassocRsp = true;
7906 roam_info.nAssocReqLength =
7907 session->connectedInfo.nAssocReqLength;
7908 roam_info.nAssocRspLength =
7909 session->connectedInfo.nAssocRspLength;
7910 roam_info.nBeaconLength =
7911 session->connectedInfo.nBeaconLength;
7912 roam_info.pbFrames =
7913 session->connectedInfo.pbFrames;
7914 }
7915 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007916 /*
7917 * Update the staId from the previous connected profile info
7918 * as the reassociation is triggred at SME/HDD
7919 */
7920
7921 if ((eCsrHddIssuedReassocToSameAP ==
7922 cmd->u.roamCmd.roamReason) ||
7923 (eCsrSmeIssuedReassocToSameAP ==
7924 cmd->u.roamCmd.roamReason))
7925 roam_info.staId = session->connectedInfo.staId;
7926
7927#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7928 /*
7929 * Indicate SME-QOS with reassoc success event,
7930 * only after copying the frames
7931 */
7932 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id, ind_qos,
7933 &assoc_info);
7934#endif
7935 roam_info.pBssDesc = bss_desc;
7936 roam_info.statusCode =
7937 session->joinFailStatusCode.statusCode;
7938 roam_info.reasonCode =
7939 session->joinFailStatusCode.reasonCode;
7940#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7941 acm_mask = sme_qos_get_acm_mask(mac_ctx, bss_desc, NULL);
7942#endif
7943 conn_profile->acm_mask = acm_mask;
7944 /*
7945 * start UAPSD if uapsd_mask is not 0 because HDD will
7946 * configure for trigger frame It may be better to let QoS do
7947 * this????
7948 */
7949 if (conn_profile->modifyProfileFields.uapsd_mask) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007950 sme_err(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007951 " uapsd_mask (0x%X) set, request UAPSD now",
7952 conn_profile->modifyProfileFields.uapsd_mask);
7953 sme_ps_start_uapsd(mac_ctx, session_id,
7954 NULL, NULL);
7955 }
7956 conn_profile->dot11Mode = session->bssParams.uCfgDot11Mode;
7957 roam_info.u.pConnectedProfile = conn_profile;
7958
7959 if (session->bRefAssocStartCnt > 0) {
7960 session->bRefAssocStartCnt--;
7961 if (!IS_FEATURE_SUPPORTED_BY_FW
7962 (SLM_SESSIONIZATION) &&
7963 (csr_is_concurrent_session_running(mac_ctx))) {
7964 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
7965 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007966 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
7967 cmd->u.roamCmd.roamId,
7968 eCSR_ROAM_ASSOCIATION_COMPLETION,
7969 eCSR_ROAM_RESULT_ASSOCIATED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007970 }
7971
Sandeep Puligilla68908f22018-02-28 18:20:41 -08007972 qdf_copy_macaddr(&bss_info.bssid, &conn_profile->bssid);
7973 bss_info.chan = conn_profile->operationChannel;
7974 bss_info.ssid.length =
7975 conn_profile->SSID.length;
7976 qdf_mem_copy(&bss_info.ssid.ssid,
7977 &conn_profile->SSID.ssId,
7978 bss_info.ssid.length);
7979 csr_update_scan_entry_associnfo(mac_ctx,
7980 &bss_info, SCAN_ENTRY_CON_STATE_ASSOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007981 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
7982 eCSR_ROAM_RESULT_NONE, true);
7983 csr_reset_pmkid_candidate_list(mac_ctx, session_id);
7984#ifdef FEATURE_WLAN_WAPI
7985 csr_reset_bkid_candidate_list(mac_ctx, session_id);
7986#endif
7987 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007988 sme_warn("Roam command doesn't have a BSS desc");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007989 }
7990 /* Not to signal link up because keys are yet to be set.
7991 * The linkup function will overwrite the sub-state that
7992 * we need to keep at this point.
7993 */
7994 if (!CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id)) {
7995#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007996 if (session->roam_synch_in_progress) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307997 QDF_TRACE(QDF_MODULE_ID_SME,
7998 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007999 FL
8000 ("NO CSR_IS_WAIT_FOR_KEY -> csr_roam_link_up"));
8001 }
8002#endif
8003 csr_roam_link_up(mac_ctx, conn_profile->bssid);
8004 }
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308005 sme_free_join_rsp_fils_params(&roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008006}
8007
8008/**
8009 * csr_roam_process_results() - Process the Roam Results
8010 * @mac_ctx: Global MAC Context
8011 * @cmd: Command that has been processed
8012 * @res: Results available after processing the command
8013 * @context: Context
8014 *
8015 * Process the available results and make an appropriate decision
8016 *
8017 * Return: true if the command can be released, else not.
8018 */
8019static bool csr_roam_process_results(tpAniSirGlobal mac_ctx, tSmeCmd *cmd,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05308020 enum csr_roamcomplete_result res,
8021 void *context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008022{
8023 bool release_cmd = true;
8024 tSirBssDescription *bss_desc = NULL;
Jeff Johnson172237b2017-11-07 15:32:59 -08008025 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008026 uint32_t session_id = cmd->sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308027 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008028 struct csr_roam_profile *profile = &cmd->u.roamCmd.roamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008029 eRoamCmdStatus roam_status;
8030 eCsrRoamResult roam_result;
8031 host_log_ibss_pkt_type *ibss_log;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07008032 tSirSmeStartBssRsp *start_bss_rsp = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008033
8034 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008035 sme_err("session %d not found ", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008036 return false;
8037 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008038
8039 sme_debug("Processing ROAM results...");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008040 switch (res) {
8041 case eCsrJoinSuccess:
8042 case eCsrReassocSuccess:
8043 csr_roam_process_join_res(mac_ctx, res, cmd, context);
8044 break;
8045 case eCsrStartBssSuccess:
8046 csr_roam_process_start_bss_success(mac_ctx, cmd, context);
8047 break;
8048 case eCsrStartBssFailure:
8049#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8050 WLAN_HOST_DIAG_LOG_ALLOC(ibss_log,
8051 host_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8052 if (ibss_log) {
8053 ibss_log->status = WLAN_IBSS_STATUS_FAILURE;
8054 WLAN_HOST_DIAG_LOG_REPORT(ibss_log);
8055 }
8056#endif
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07008057 start_bss_rsp = (tSirSmeStartBssRsp *)context;
8058 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008059 roam_status = eCSR_ROAM_IBSS_IND;
8060 roam_result = eCSR_ROAM_RESULT_IBSS_STARTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008061 if (CSR_IS_INFRA_AP(profile)) {
8062 roam_status = eCSR_ROAM_INFRA_IND;
8063 roam_result = eCSR_ROAM_RESULT_INFRA_START_FAILED;
8064 }
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07008065 if (CSR_IS_NDI(profile)) {
8066 csr_roam_update_ndp_return_params(mac_ctx,
8067 eCsrStartBssFailure,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07008068 &roam_status, &roam_result, &roam_info);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07008069 }
8070
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308071 if (context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008072 bss_desc = (tSirBssDescription *) context;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308073 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008074 bss_desc = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008075 roam_info.pBssDesc = bss_desc;
8076 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
8077 cmd->u.roamCmd.roamId, roam_status,
8078 roam_result);
8079 csr_set_default_dot11_mode(mac_ctx);
8080 break;
8081 case eCsrSilentlyStopRoaming:
8082 /*
8083 * We are here because we try to start the same IBSS.
8084 * No message to PE. return the roaming state to Joined.
8085 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008086 sme_debug("receives silently stop roam ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008087 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
8088 session_id);
8089 csr_roam_substate_change(mac_ctx, eCSR_ROAM_SUBSTATE_NONE,
8090 session_id);
Jeff Johnson172237b2017-11-07 15:32:59 -08008091 qdf_mem_set(&roam_info, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008092 roam_info.pBssDesc = session->pConnectBssDesc;
8093 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308094 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008095 &roam_info.pBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05308096 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008097 /*
8098 * Since there is no change in the current state, simply pass
8099 * back no result otherwise HDD may be mistakenly mark to
8100 * disconnected state.
8101 */
8102 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
8103 cmd->u.roamCmd.roamId,
8104 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE);
8105 break;
8106 case eCsrSilentlyStopRoamingSaveState:
8107 /* We are here because we try to connect to the same AP */
8108 /* No message to PE */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008109 sme_debug("receives silently stop roaming indication");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308110 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008111
8112 /* to aviod resetting the substate to NONE */
8113 mac_ctx->roam.curState[session_id] = eCSR_ROAMING_STATE_JOINED;
8114 /*
8115 * No need to change substate to wai_for_key because there
8116 * is no state change
8117 */
8118 roam_info.pBssDesc = session->pConnectBssDesc;
8119 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308120 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008121 &roam_info.pBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05308122 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008123 roam_info.statusCode = session->joinFailStatusCode.statusCode;
8124 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
8125 roam_info.nBeaconLength = session->connectedInfo.nBeaconLength;
8126 roam_info.nAssocReqLength =
8127 session->connectedInfo.nAssocReqLength;
8128 roam_info.nAssocRspLength =
8129 session->connectedInfo.nAssocRspLength;
8130 roam_info.pbFrames = session->connectedInfo.pbFrames;
8131 roam_info.staId = session->connectedInfo.staId;
8132 roam_info.u.pConnectedProfile = &session->connectedProfile;
Abhishek Singhacfdc922015-12-30 17:31:21 +05308133 if (0 == roam_info.staId)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308134 QDF_ASSERT(0);
Abhishek Singhacfdc922015-12-30 17:31:21 +05308135
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008136 session->bRefAssocStartCnt--;
8137 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
8138 cmd->u.roamCmd.roamId,
8139 eCSR_ROAM_ASSOCIATION_COMPLETION,
8140 eCSR_ROAM_RESULT_ASSOCIATED);
8141 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
8142 eCSR_ROAM_RESULT_ASSOCIATED, true);
8143 break;
8144 case eCsrReassocFailure:
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07008145 /*
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308146 * Currently Reassoc failure is handled through eCsrJoinFailure
8147 * Need to revisit for eCsrReassocFailure handling
8148 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008149#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8150 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
8151 SME_QOS_CSR_REASSOC_FAILURE, NULL);
8152#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008153 break;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07008154 case eCsrStopBssSuccess:
8155 if (CSR_IS_NDI(profile)) {
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05308156 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07008157 csr_roam_update_ndp_return_params(mac_ctx, res,
8158 &roam_status, &roam_result, &roam_info);
8159 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
8160 cmd->u.roamCmd.roamId,
8161 roam_status, roam_result);
8162 }
8163 break;
8164 case eCsrStopBssFailure:
8165 if (CSR_IS_NDI(profile)) {
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05308166 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07008167 csr_roam_update_ndp_return_params(mac_ctx, res,
8168 &roam_status, &roam_result, &roam_info);
8169 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
8170 cmd->u.roamCmd.roamId,
8171 roam_status, roam_result);
8172 }
8173 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008174 case eCsrJoinFailure:
8175 case eCsrNothingToJoin:
8176 case eCsrJoinFailureDueToConcurrency:
8177 default:
8178 csr_roam_process_results_default(mac_ctx, cmd, context, res);
8179 break;
8180 }
8181 return release_cmd;
8182}
8183
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308184#ifdef WLAN_FEATURE_FILS_SK
8185/*
8186 * update_profile_fils_info: API to update FILS info from
8187 * source profile to destination profile.
8188 * @des_profile: pointer to destination profile
8189 * @src_profile: pointer to souce profile
8190 *
8191 * Return: None
8192 */
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008193static void update_profile_fils_info(struct csr_roam_profile *des_profile,
8194 struct csr_roam_profile *src_profile)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308195{
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308196 if (!src_profile || !src_profile->fils_con_info)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308197 return;
8198
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308199 sme_debug("is fils %d", src_profile->fils_con_info->is_fils_connection);
8200
8201 if (!src_profile->fils_con_info->is_fils_connection)
8202 return;
8203
8204 des_profile->fils_con_info =
8205 qdf_mem_malloc(sizeof(struct cds_fils_connection_info));
8206 if (!des_profile->fils_con_info) {
8207 sme_err("failed to allocate memory");
8208 return;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308209 }
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05308210
8211 qdf_mem_copy(des_profile->fils_con_info,
8212 src_profile->fils_con_info,
8213 sizeof(struct cds_fils_connection_info));
8214
8215 des_profile->hlp_ie =
8216 qdf_mem_malloc(src_profile->hlp_ie_len);
8217 if (!des_profile->hlp_ie) {
8218 sme_err("failed to allocate memory for hlp ie");
8219 return;
8220 }
8221
8222 qdf_mem_copy(des_profile->hlp_ie, src_profile->hlp_ie,
8223 src_profile->hlp_ie_len);
8224 des_profile->hlp_ie_len = src_profile->hlp_ie_len;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308225}
8226#else
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008227static inline
8228void update_profile_fils_info(struct csr_roam_profile *des_profile,
8229 struct csr_roam_profile *src_profile)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308230{ }
8231#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308232QDF_STATUS csr_roam_copy_profile(tpAniSirGlobal pMac,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008233 struct csr_roam_profile *pDstProfile,
8234 struct csr_roam_profile *pSrcProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008235{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308236 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008237 uint32_t size = 0;
8238
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008239 qdf_mem_set(pDstProfile, sizeof(struct csr_roam_profile), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008240 if (pSrcProfile->BSSIDs.numOfBSSIDs) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308241 size = sizeof(struct qdf_mac_addr) * pSrcProfile->BSSIDs.
8242 numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308243 pDstProfile->BSSIDs.bssid = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008244 if (NULL == pDstProfile->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308245 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008246 goto end;
8247 }
8248 pDstProfile->BSSIDs.numOfBSSIDs =
8249 pSrcProfile->BSSIDs.numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308250 qdf_mem_copy(pDstProfile->BSSIDs.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008251 pSrcProfile->BSSIDs.bssid, size);
8252 }
8253 if (pSrcProfile->SSIDs.numOfSSIDs) {
8254 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308255 pDstProfile->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008256 if (NULL == pDstProfile->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308257 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008258 goto end;
8259 }
8260 pDstProfile->SSIDs.numOfSSIDs =
8261 pSrcProfile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308262 qdf_mem_copy(pDstProfile->SSIDs.SSIDList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008263 pSrcProfile->SSIDs.SSIDList, size);
8264 }
8265 if (pSrcProfile->nWPAReqIELength) {
8266 pDstProfile->pWPAReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308267 qdf_mem_malloc(pSrcProfile->nWPAReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008268 if (NULL == pDstProfile->pWPAReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308269 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008270 goto end;
8271 }
8272 pDstProfile->nWPAReqIELength =
8273 pSrcProfile->nWPAReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308274 qdf_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008275 pSrcProfile->nWPAReqIELength);
8276 }
8277 if (pSrcProfile->nRSNReqIELength) {
8278 pDstProfile->pRSNReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308279 qdf_mem_malloc(pSrcProfile->nRSNReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008280 if (NULL == pDstProfile->pRSNReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308281 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008282 goto end;
8283 }
8284 pDstProfile->nRSNReqIELength =
8285 pSrcProfile->nRSNReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308286 qdf_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008287 pSrcProfile->nRSNReqIELength);
8288 }
8289#ifdef FEATURE_WLAN_WAPI
8290 if (pSrcProfile->nWAPIReqIELength) {
8291 pDstProfile->pWAPIReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308292 qdf_mem_malloc(pSrcProfile->nWAPIReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008293 if (NULL == pDstProfile->pWAPIReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308294 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008295 goto end;
8296 }
8297 pDstProfile->nWAPIReqIELength =
8298 pSrcProfile->nWAPIReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308299 qdf_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008300 pSrcProfile->nWAPIReqIELength);
8301 }
8302#endif /* FEATURE_WLAN_WAPI */
8303 if (pSrcProfile->nAddIEScanLength) {
8304 pDstProfile->pAddIEScan =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308305 qdf_mem_malloc(pSrcProfile->nAddIEScanLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008306 if (NULL == pDstProfile->pAddIEScan) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308307 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008308 goto end;
8309 }
8310 pDstProfile->nAddIEScanLength =
8311 pSrcProfile->nAddIEScanLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308312 qdf_mem_copy(pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008313 pSrcProfile->nAddIEScanLength);
8314 }
8315 if (pSrcProfile->nAddIEAssocLength) {
8316 pDstProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308317 qdf_mem_malloc(pSrcProfile->nAddIEAssocLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008318 if (NULL == pDstProfile->pAddIEAssoc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308319 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008320 goto end;
8321 }
8322 pDstProfile->nAddIEAssocLength =
8323 pSrcProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308324 qdf_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008325 pSrcProfile->nAddIEAssocLength);
8326 }
8327 if (pSrcProfile->ChannelInfo.ChannelList) {
8328 pDstProfile->ChannelInfo.ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308329 qdf_mem_malloc(pSrcProfile->ChannelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008330 numOfChannels);
8331 if (NULL == pDstProfile->ChannelInfo.ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308332 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008333 goto end;
8334 }
8335 pDstProfile->ChannelInfo.numOfChannels =
8336 pSrcProfile->ChannelInfo.numOfChannels;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308337 qdf_mem_copy(pDstProfile->ChannelInfo.ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008338 pSrcProfile->ChannelInfo.ChannelList,
8339 pSrcProfile->ChannelInfo.numOfChannels);
8340 }
8341 pDstProfile->AuthType = pSrcProfile->AuthType;
8342 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
8343 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
8344 pDstProfile->negotiatedUCEncryptionType =
8345 pSrcProfile->negotiatedUCEncryptionType;
8346 pDstProfile->negotiatedMCEncryptionType =
8347 pSrcProfile->negotiatedMCEncryptionType;
8348 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
8349#ifdef WLAN_FEATURE_11W
8350 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
8351 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
8352 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
8353#endif
8354 pDstProfile->BSSType = pSrcProfile->BSSType;
8355 pDstProfile->phyMode = pSrcProfile->phyMode;
8356 pDstProfile->csrPersona = pSrcProfile->csrPersona;
8357
8358#ifdef FEATURE_WLAN_WAPI
8359 if (csr_is_profile_wapi(pSrcProfile))
8360 if (pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
8361 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
8362#endif /* FEATURE_WLAN_WAPI */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008363 pDstProfile->ch_params.ch_width = pSrcProfile->ch_params.ch_width;
8364 pDstProfile->ch_params.center_freq_seg0 =
8365 pSrcProfile->ch_params.center_freq_seg0;
8366 pDstProfile->ch_params.center_freq_seg1 =
8367 pSrcProfile->ch_params.center_freq_seg1;
8368 pDstProfile->ch_params.sec_ch_offset =
8369 pSrcProfile->ch_params.sec_ch_offset;
8370 /*Save the WPS info */
8371 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
8372 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Abhishek Singhb59f8d42017-07-31 14:42:47 +05308373 pDstProfile->force_24ghz_in_ht20 = pSrcProfile->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008374 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
8375 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
8376 pDstProfile->privacy = pSrcProfile->privacy;
8377 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
8378 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
8379 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
8380 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
8381 pDstProfile->SSIDs.SSIDList[0].ssidHidden =
8382 pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
8383 pDstProfile->protEnabled = pSrcProfile->protEnabled;
8384 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
8385 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
8386 pDstProfile->wps_state = pSrcProfile->wps_state;
8387 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
8388 pDstProfile->sap_dot11mc = pSrcProfile->sap_dot11mc;
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -07008389 pDstProfile->supplicant_disabled_roaming =
8390 pSrcProfile->supplicant_disabled_roaming;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308391 qdf_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008392 sizeof(pDstProfile->Keys));
8393#ifdef WLAN_FEATURE_11W
8394 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
8395 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
8396 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
8397#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008398 if (pSrcProfile->MDID.mdiePresent) {
8399 pDstProfile->MDID.mdiePresent = 1;
8400 pDstProfile->MDID.mobilityDomain =
8401 pSrcProfile->MDID.mobilityDomain;
8402 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308403 qdf_mem_copy(&pDstProfile->addIeParams, &pSrcProfile->addIeParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008404 sizeof(tSirAddIeParams));
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308405
8406 update_profile_fils_info(pDstProfile, pSrcProfile);
8407
Jiachao Wu712d4fd2017-08-23 16:52:34 +08008408 pDstProfile->beacon_tx_rate = pSrcProfile->beacon_tx_rate;
8409
Agrawal Ashish06e76d22016-08-18 16:44:48 +05308410 if (pSrcProfile->supported_rates.numRates) {
8411 qdf_mem_copy(pDstProfile->supported_rates.rate,
8412 pSrcProfile->supported_rates.rate,
8413 pSrcProfile->supported_rates.numRates);
8414 pDstProfile->supported_rates.numRates =
8415 pSrcProfile->supported_rates.numRates;
8416 }
8417 if (pSrcProfile->extended_rates.numRates) {
8418 qdf_mem_copy(pDstProfile->extended_rates.rate,
8419 pSrcProfile->extended_rates.rate,
8420 pSrcProfile->extended_rates.numRates);
8421 pDstProfile->extended_rates.numRates =
8422 pSrcProfile->extended_rates.numRates;
8423 }
Arif Hussain671a1902017-03-17 09:08:32 -07008424 pDstProfile->cac_duration_ms = pSrcProfile->cac_duration_ms;
8425 pDstProfile->dfs_regdomain = pSrcProfile->dfs_regdomain;
hqu16d6e082017-09-04 10:52:31 +08008426 pDstProfile->chan_switch_hostapd_rate_enabled =
8427 pSrcProfile->chan_switch_hostapd_rate_enabled;
Abhishek Singh6454ad32017-12-20 10:42:21 +05308428 pDstProfile->force_rsne_override = pSrcProfile->force_rsne_override;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008429end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308430 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008431 csr_release_profile(pMac, pDstProfile);
8432 pDstProfile = NULL;
8433 }
8434
8435 return status;
8436}
8437
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308438QDF_STATUS csr_roam_copy_connected_profile(tpAniSirGlobal pMac,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008439 uint32_t sessionId,
8440 struct csr_roam_profile *pDstProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008441{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308442 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008443 tCsrRoamConnectedProfile *pSrcProfile =
8444 &pMac->roam.roamSession[sessionId].connectedProfile;
8445
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008446 qdf_mem_set(pDstProfile, sizeof(struct csr_roam_profile), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008447
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308448 pDstProfile->BSSIDs.bssid = qdf_mem_malloc(sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008449 if (NULL == pDstProfile->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308450 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008451 sme_err("failed to allocate memory for BSSID "
8452 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008453 MAC_ADDR_ARRAY(pSrcProfile->bssid.bytes));
8454 goto end;
8455 }
8456 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Anurag Chouhanc5548422016-02-24 18:33:27 +05308457 qdf_copy_macaddr(pDstProfile->BSSIDs.bssid, &pSrcProfile->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008458
Yingying Tangd5661072016-10-20 17:53:01 +08008459 if (pSrcProfile->SSID.length > 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008460 pDstProfile->SSIDs.SSIDList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308461 qdf_mem_malloc(sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008462 if (NULL == pDstProfile->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308463 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008464 sme_err("failed to allocate memory for SSID "
8465 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008466 MAC_ADDR_ARRAY(pSrcProfile->bssid.bytes));
8467 goto end;
8468 }
8469 pDstProfile->SSIDs.numOfSSIDs = 1;
8470 pDstProfile->SSIDs.SSIDList[0].handoffPermitted =
8471 pSrcProfile->handoffPermitted;
8472 pDstProfile->SSIDs.SSIDList[0].ssidHidden =
8473 pSrcProfile->ssidHidden;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308474 qdf_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008475 &pSrcProfile->SSID, sizeof(tSirMacSSid));
8476 }
8477 if (pSrcProfile->nAddIEAssocLength) {
8478 pDstProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308479 qdf_mem_malloc(pSrcProfile->nAddIEAssocLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008480 if (NULL == pDstProfile->pAddIEAssoc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308481 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008482 sme_err("failed to allocate mem for additional ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008483 goto end;
8484 }
8485 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308486 qdf_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008487 pSrcProfile->nAddIEAssocLength);
8488 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308489 pDstProfile->ChannelInfo.ChannelList = qdf_mem_malloc(1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008490 if (NULL == pDstProfile->ChannelInfo.ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308491 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008492 goto end;
8493 }
8494 pDstProfile->ChannelInfo.numOfChannels = 1;
8495 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
8496 pDstProfile->AuthType.numEntries = 1;
8497 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
8498 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
8499 pDstProfile->EncryptionType.numEntries = 1;
8500 pDstProfile->EncryptionType.encryptionType[0] =
8501 pSrcProfile->EncryptionType;
8502 pDstProfile->negotiatedUCEncryptionType =
8503 pSrcProfile->EncryptionType;
8504 pDstProfile->mcEncryptionType.numEntries = 1;
8505 pDstProfile->mcEncryptionType.encryptionType[0] =
8506 pSrcProfile->mcEncryptionType;
8507 pDstProfile->negotiatedMCEncryptionType =
8508 pSrcProfile->mcEncryptionType;
8509 pDstProfile->BSSType = pSrcProfile->BSSType;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308510 qdf_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008511 sizeof(pDstProfile->Keys));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008512 if (pSrcProfile->MDID.mdiePresent) {
8513 pDstProfile->MDID.mdiePresent = 1;
8514 pDstProfile->MDID.mobilityDomain =
8515 pSrcProfile->MDID.mobilityDomain;
8516 }
Krunal Sonib2f13042015-11-02 18:41:08 -08008517#ifdef WLAN_FEATURE_11W
8518 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
8519 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
8520 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
8521#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008522
8523end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308524 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008525 csr_release_profile(pMac, pDstProfile);
8526 pDstProfile = NULL;
8527 }
8528
8529 return status;
8530}
8531
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308532QDF_STATUS csr_roam_issue_connect(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008533 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008534 tScanResultHandle hBSSList,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308535 enum csr_roam_reason reason, uint32_t roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008536 bool fImediate, bool fClearScan)
8537{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308538 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008539 tSmeCmd *pCommand;
8540
8541 pCommand = csr_get_command_buffer(pMac);
8542 if (NULL == pCommand) {
Will Huang8e8d3002018-05-11 10:48:03 +08008543 csr_scan_result_purge(pMac, hBSSList);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008544 sme_err(" fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308545 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008546 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308547 if (fClearScan)
Abhishek Singh9fabbbb2018-01-29 17:38:36 +05308548 csr_scan_abort_mac_scan(pMac, sessionId, INVAL_SCAN_ID);
8549
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008550 pCommand->u.roamCmd.fReleaseProfile = false;
8551 if (NULL == pProfile) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308552 /* We can roam now
8553 * Since pProfile is NULL, we need to build our own
8554 * profile, set everything to default We can only
8555 * support open and no encryption
8556 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008557 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
8558 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] =
8559 eCSR_AUTH_TYPE_OPEN_SYSTEM;
8560 pCommand->u.roamCmd.roamProfile.EncryptionType.
8561 numEntries = 1;
8562 pCommand->u.roamCmd.roamProfile.EncryptionType.
8563 encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
8564 pCommand->u.roamCmd.roamProfile.csrPersona =
Anurag Chouhan6d760662016-02-20 16:05:43 +05308565 QDF_STA_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008566 } else {
8567 /* make a copy of the profile */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308568 status = csr_roam_copy_profile(pMac, &pCommand->u.
8569 roamCmd.roamProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008570 pProfile);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308571 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008572 pCommand->u.roamCmd.fReleaseProfile = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008573 }
8574
8575 pCommand->command = eSmeCommandRoam;
8576 pCommand->sessionId = (uint8_t) sessionId;
8577 pCommand->u.roamCmd.hBSSList = hBSSList;
8578 pCommand->u.roamCmd.roamId = roamId;
8579 pCommand->u.roamCmd.roamReason = reason;
8580 /* We need to free the BssList when the command is done */
8581 pCommand->u.roamCmd.fReleaseBssList = true;
8582 pCommand->u.roamCmd.fUpdateCurRoamProfile = true;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008583 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
8584 FL("CSR PERSONA=%d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008585 pCommand->u.roamCmd.roamProfile.csrPersona);
8586 status = csr_queue_sme_command(pMac, pCommand, fImediate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308587 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308588 sme_err("fail to send message status: %d", status);
8589 csr_release_command_roam(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008590 }
8591 }
8592
8593 return status;
8594}
8595
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308596QDF_STATUS csr_roam_issue_reassoc(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008597 struct csr_roam_profile *pProfile,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308598 tCsrRoamModifyProfileFields
8599 *pMmodProfileFields,
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308600 enum csr_roam_reason reason, uint32_t roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008601 bool fImediate)
8602{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308603 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008604 tSmeCmd *pCommand;
8605
8606 pCommand = csr_get_command_buffer(pMac);
8607 if (NULL == pCommand) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308608 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308609 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008610 } else {
Abhishek Singh9fabbbb2018-01-29 17:38:36 +05308611 csr_scan_abort_mac_scan(pMac, sessionId, INVAL_SCAN_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008612 if (pProfile) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308613 /* This is likely trying to reassoc to
8614 * different profile
8615 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008616 pCommand->u.roamCmd.fReleaseProfile = false;
8617 /* make a copy of the profile */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308618 status = csr_roam_copy_profile(pMac, &pCommand->u.
8619 roamCmd.roamProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008620 pProfile);
8621 pCommand->u.roamCmd.fUpdateCurRoamProfile = true;
8622 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308623 status = csr_roam_copy_connected_profile(pMac,
8624 sessionId,
8625 &pCommand->u.roamCmd.
8626 roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008627 /* how to update WPA/WPA2 info in roamProfile?? */
8628 pCommand->u.roamCmd.roamProfile.uapsd_mask =
8629 pMmodProfileFields->uapsd_mask;
8630 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308631 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008632 pCommand->u.roamCmd.fReleaseProfile = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008633 pCommand->command = eSmeCommandRoam;
8634 pCommand->sessionId = (uint8_t) sessionId;
8635 pCommand->u.roamCmd.roamId = roamId;
8636 pCommand->u.roamCmd.roamReason = reason;
8637 /* We need to free the BssList when the command is done */
8638 /* For reassoc there is no BSS list, so the bool set to false */
8639 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
8640 pCommand->u.roamCmd.fReleaseBssList = false;
8641 pCommand->u.roamCmd.fReassoc = true;
8642 csr_roam_remove_duplicate_command(pMac, sessionId, pCommand,
8643 reason);
8644 status = csr_queue_sme_command(pMac, pCommand, fImediate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308645 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308646 sme_err("fail to send message status = %d", status);
Krunal Soniaa179db2017-10-13 19:28:17 -07008647 csr_roam_completion(pMac, sessionId, NULL, NULL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008648 eCSR_ROAM_RESULT_FAILURE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008649 }
8650 }
8651 return status;
8652}
8653
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308654QDF_STATUS csr_dequeue_roam_command(tpAniSirGlobal pMac,
8655 enum csr_roam_reason reason,
Krunal Sonif3583022017-02-10 17:18:10 -08008656 uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008657{
8658 tListElem *pEntry;
8659 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308660
Krunal Sonia8270f52017-02-23 19:51:25 -08008661 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308662
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008663 if (pEntry) {
8664 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8665 if ((eSmeCommandRoam == pCommand->command) &&
8666 (eCsrPerformPreauth == reason)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008667 sme_debug("DQ-Command = %d, Reason = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008668 pCommand->command,
8669 pCommand->u.roamCmd.roamReason);
Krunal Soni72dba662017-02-15 20:13:17 -08008670 if (csr_nonscan_active_ll_remove_entry(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008671 LL_ACCESS_LOCK)) {
Paul Zhang43626972017-11-21 18:25:58 +08008672 csr_release_command(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008673 }
8674 } else if ((eSmeCommandRoam == pCommand->command) &&
8675 (eCsrSmeIssuedFTReassoc == reason)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008676 sme_debug("DQ-Command = %d, Reason = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008677 pCommand->command,
8678 pCommand->u.roamCmd.roamReason);
Krunal Soni72dba662017-02-15 20:13:17 -08008679 if (csr_nonscan_active_ll_remove_entry(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008680 LL_ACCESS_LOCK)) {
Krunal Sonidea45952017-02-15 11:58:15 -08008681 csr_release_command(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008682 }
8683 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008684 sme_err("Command = %d, Reason = %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008685 pCommand->command,
8686 pCommand->u.roamCmd.roamReason);
8687 }
8688 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008689 sme_err("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008690 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308691 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008692}
8693
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308694#ifdef WLAN_FEATURE_FILS_SK
8695/**
8696 * csr_is_fils_connection() - API to check if FILS connection
8697 * @profile: CSR Roam Profile
8698 *
8699 * Return: true, if fils connection, false otherwise
8700 */
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008701static bool csr_is_fils_connection(struct csr_roam_profile *profile)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308702{
8703 if (!profile->fils_con_info)
8704 return false;
8705
8706 return profile->fils_con_info->is_fils_connection;
8707}
8708#else
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008709static bool csr_is_fils_connection(struct csr_roam_profile *pProfile)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308710{
8711 return false;
8712}
8713#endif
8714
Abhishek Singhb58164a2017-07-19 18:47:23 +05308715/**
8716 * csr_roam_print_candidate_aps() - print all candidate AP in sorted
8717 * score.
8718 * @results: scan result
8719 *
8720 * Return : void
8721 */
8722static void csr_roam_print_candidate_aps(tScanResultHandle results)
8723{
8724 tListElem *entry;
8725 struct tag_csrscan_result *bss_desc = NULL;
8726 struct scan_result_list *bss_list = NULL;
8727
8728 if (!results)
8729 return;
8730 bss_list = (struct scan_result_list *)results;
8731 entry = csr_ll_peek_head(&bss_list->List, LL_ACCESS_NOLOCK);
8732 while (entry) {
8733 bss_desc = GET_BASE_ADDR(entry,
8734 struct tag_csrscan_result, Link);
8735 sme_debug("BSSID" MAC_ADDRESS_STR "score is %d",
8736 MAC_ADDR_ARRAY(bss_desc->Result.BssDescriptor.bssId),
8737 bss_desc->bss_score);
8738
8739 entry = csr_ll_next(&bss_list->List, entry,
8740 LL_ACCESS_NOLOCK);
8741 }
8742}
8743
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308744QDF_STATUS csr_roam_connect(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008745 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008746 uint32_t *pRoamId)
8747{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308748 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008749 tScanResultHandle hBSSList;
8750 tCsrScanResultFilter *pScanFilter;
8751 uint32_t roamId = 0;
8752 bool fCallCallback = false;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308753 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +05308754 tSirBssDescription *first_ap_profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008755
8756 if (NULL == pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008757 sme_err("session does not exist for given sessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008758 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308759 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008760 }
8761
8762 if (NULL == pProfile) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008763 sme_err("No profile specified");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308764 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008765 }
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +05308766
8767 first_ap_profile = qdf_mem_malloc(sizeof(*first_ap_profile));
8768 if (NULL == first_ap_profile) {
8769 sme_err("malloc fails for first_ap_profile");
8770 return QDF_STATUS_E_NOMEM;
8771 }
8772
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008773 /* Initialize the count before proceeding with the Join requests */
8774 pSession->join_bssid_count = 0;
Abhishek Singhd5686472017-09-20 15:18:50 +05308775 pSession->discon_in_progress = false;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05308776 pSession->is_fils_connection = csr_is_fils_connection(pProfile);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008777 sme_debug(
8778 "called BSSType = %s (%d) authtype = %d encryType = %d",
Rajeev Kumar43e25b12016-04-15 16:26:36 -07008779 sme_bss_type_to_string(pProfile->BSSType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008780 pProfile->BSSType, pProfile->AuthType.authType[0],
8781 pProfile->EncryptionType.encryptionType[0]);
8782 csr_roam_cancel_roaming(pMac, sessionId);
Abhishek Singh9fabbbb2018-01-29 17:38:36 +05308783 csr_scan_abort_mac_scan(pMac, sessionId, INVAL_SCAN_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008784 csr_roam_remove_duplicate_command(pMac, sessionId, NULL, eCsrHddIssued);
8785 /* Check whether ssid changes */
8786 if (csr_is_conn_state_connected(pMac, sessionId) &&
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308787 pProfile->SSIDs.numOfSSIDs && !csr_is_ssid_in_list(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008788 &pSession->connectedProfile.SSID, &pProfile->SSIDs))
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308789 csr_roam_issue_disassociate_cmd(pMac, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008790 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Abhishek Singhacfdc922015-12-30 17:31:21 +05308791 /*
8792 * If roamSession.connectState is disconnecting that mean
8793 * disconnect was received with scan for ssid in progress
8794 * and dropped. This state will ensure that connect will
8795 * not be issued from scan for ssid completion. Thus
8796 * if this fresh connect also issue scan for ssid the connect
8797 * command will be dropped assuming disconnect is in progress.
8798 * Thus reset connectState here
8799 */
8800 if (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING ==
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308801 pMac->roam.roamSession[sessionId].connectState)
8802 pMac->roam.roamSession[sessionId].connectState =
8803 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008804#ifdef FEATURE_WLAN_BTAMP_UT_RF
8805 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
8806#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308807 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008808 if (NULL == pScanFilter) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308809 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008810 goto end;
8811 }
8812
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008813 /* Try to connect to any BSS */
8814 if (NULL == pProfile) {
8815 /* No encryption */
8816 pScanFilter->EncryptionType.numEntries = 1;
8817 pScanFilter->EncryptionType.encryptionType[0] =
8818 eCSR_ENCRYPT_TYPE_NONE;
8819 } else {
8820 /* Here is the profile we need to connect to */
8821 status = csr_roam_prepare_filter_from_profile(pMac,
8822 pProfile, pScanFilter);
8823 }
8824 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
8825 if (pRoamId)
8826 *pRoamId = roamId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308827 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308828 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008829 goto end;
8830 }
8831
8832 /*Save the WPS info */
8833 if (NULL != pProfile) {
8834 pScanFilter->bWPSAssociation =
8835 pProfile->bWPSAssociation;
8836 pScanFilter->bOSENAssociation =
8837 pProfile->bOSENAssociation;
8838 } else {
8839 pScanFilter->bWPSAssociation = 0;
8840 pScanFilter->bOSENAssociation = 0;
8841 }
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07008842 if (pProfile && CSR_IS_INFRA_AP(pProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008843 /* This can be started right away */
8844 status = csr_roam_issue_connect(pMac, sessionId, pProfile, NULL,
8845 eCsrHddIssued, roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308846 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308847 sme_err("CSR failed to issue start BSS cmd with status: 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008848 status);
8849 fCallCallback = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308850 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008851 sme_debug("Connect request to proceed for sap mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008852
8853 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308854 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008855 goto end;
8856 }
8857 status = csr_scan_get_result(pMac, pScanFilter, &hBSSList);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308858 sme_debug("csr_scan_get_result Status: %d", status);
Abhishek Singhb58164a2017-07-19 18:47:23 +05308859 csr_roam_print_candidate_aps(hBSSList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308860 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008861 /* check if set hw mode needs to be done */
Krunal Soni3091bcc2016-06-23 12:28:21 -07008862 if ((pScanFilter->csrPersona == QDF_STA_MODE) ||
8863 (pScanFilter->csrPersona == QDF_P2P_CLIENT_MODE)) {
Ajit Pal Singh64aff0c2017-06-20 16:35:26 +05308864 bool ok;
8865
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008866 csr_get_bssdescr_from_scan_handle(hBSSList,
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +05308867 first_ap_profile);
Ajit Pal Singh64aff0c2017-06-20 16:35:26 +05308868 status = policy_mgr_is_chan_ok_for_dnbs(pMac->psoc,
8869 first_ap_profile->channelId, &ok);
8870 if (QDF_IS_STATUS_ERROR(status)) {
8871 sme_debug("policy_mgr_is_chan_ok_for_dnbs():error:%d",
8872 status);
8873 csr_scan_result_purge(pMac, hBSSList);
8874 fCallCallback = true;
8875 goto error;
8876 }
8877 if (!ok) {
8878 sme_debug("chan:%d not ok for DNBS",
8879 first_ap_profile->channelId);
8880 csr_scan_result_purge(pMac, hBSSList);
8881 fCallCallback = true;
8882 status = QDF_STATUS_E_INVAL;
8883 goto error;
8884 }
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08008885 status = policy_mgr_handle_conc_multiport(pMac->psoc,
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +05308886 sessionId, first_ap_profile->channelId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308887 if ((QDF_IS_STATUS_SUCCESS(status)) &&
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05308888 (!csr_wait_for_connection_update(pMac, true))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008889 sme_debug("conn update error");
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05308890 csr_scan_result_purge(pMac, hBSSList);
8891 fCallCallback = true;
Abhishek Singh471652b2017-04-14 12:28:32 +05308892 status = QDF_STATUS_E_TIMEOUT;
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05308893 goto error;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308894 } else if (status == QDF_STATUS_E_FAILURE) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008895 sme_debug("conn update error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008896 csr_scan_result_purge(pMac, hBSSList);
8897 fCallCallback = true;
8898 goto error;
8899 }
8900 }
8901
8902 status = csr_roam_issue_connect(pMac, sessionId, pProfile,
8903 hBSSList, eCsrHddIssued, roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308904 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308905 sme_err("CSR failed to issue connect cmd with status: 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008906 status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008907 fCallCallback = true;
8908 }
8909 } else if (NULL != pProfile) {
8910 /* Check whether it is for start ibss */
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07008911 if (CSR_IS_START_IBSS(pProfile) ||
8912 CSR_IS_NDI(pProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008913 status = csr_roam_issue_connect(pMac, sessionId,
8914 pProfile, NULL, eCsrHddIssued,
8915 roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308916 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008917 sme_err("Failed with status = 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008918 status);
8919 fCallCallback = true;
8920 }
8921 } else {
8922 /* scan for this SSID */
8923 status = csr_scan_for_ssid(pMac, sessionId, pProfile,
8924 roamId, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308925 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308926 sme_err("CSR failed to issue SSID scan cmd with status: 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008927 status);
8928 fCallCallback = true;
8929 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008930 sme_debug("SSID scan requested");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008931 }
8932 }
8933 } else {
8934 fCallCallback = true;
8935 }
8936
8937error:
8938 if (NULL != pProfile)
8939 /*
8940 * we need to free memory for filter
8941 * if profile exists
8942 */
8943 csr_free_scan_filter(pMac, pScanFilter);
8944
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308945 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008946end:
8947 /* tell the caller if we fail to trigger a join request */
8948 if (fCallCallback) {
8949 csr_roam_call_callback(pMac, sessionId, NULL, roamId,
8950 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
8951 }
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +05308952 qdf_mem_free(first_ap_profile);
8953
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008954 return status;
8955}
8956
8957/**
8958 * csr_roam_reassoc() - process reassoc command
8959 * @mac_ctx: mac global context
8960 * @session_id: session id
8961 * @profile: roam profile
8962 * @mod_fields: AC info being modified in reassoc
8963 * @roam_id: roam id to be populated
8964 *
8965 * Return: status of operation
8966 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308967QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008968csr_roam_reassoc(tpAniSirGlobal mac_ctx, uint32_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07008969 struct csr_roam_profile *profile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008970 tCsrRoamModifyProfileFields mod_fields,
8971 uint32_t *roam_id)
8972{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308973 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008974 bool fCallCallback = true;
8975 uint32_t roamId = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05308976 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308977
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008978 if (NULL == profile) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008979 sme_err("No profile specified");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308980 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008981 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008982 sme_debug(
8983 "called BSSType = %s (%d) authtype = %d encryType = %d",
Rajeev Kumar43e25b12016-04-15 16:26:36 -07008984 sme_bss_type_to_string(profile->BSSType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008985 profile->BSSType, profile->AuthType.authType[0],
8986 profile->EncryptionType.encryptionType[0]);
8987 csr_roam_cancel_roaming(mac_ctx, session_id);
Abhishek Singh9fabbbb2018-01-29 17:38:36 +05308988 csr_scan_abort_mac_scan(mac_ctx, session_id, INVAL_SCAN_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008989 csr_roam_remove_duplicate_command(mac_ctx, session_id, NULL,
8990 eCsrHddIssuedReassocToSameAP);
8991 if (csr_is_conn_state_connected(mac_ctx, session_id)) {
8992 if (profile) {
8993 if (profile->SSIDs.numOfSSIDs &&
8994 csr_is_ssid_in_list(mac_ctx,
8995 &session->connectedProfile.SSID,
8996 &profile->SSIDs)) {
8997 fCallCallback = false;
8998 } else {
8999 /*
9000 * Connected SSID did not match with what is
9001 * asked in profile
9002 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009003 sme_debug("SSID mismatch");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009004 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309005 } else if (qdf_mem_cmp(&mod_fields,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009006 &session->connectedProfile.modifyProfileFields,
9007 sizeof(tCsrRoamModifyProfileFields))) {
9008 fCallCallback = false;
9009 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009010 sme_debug(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009011 /*
9012 * Either the profile is NULL or none of the
9013 * fields in tCsrRoamModifyProfileFields got
9014 * modified
9015 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009016 "Profile NULL or nothing to modify");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009017 }
9018 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009019 sme_debug("Not connected! No need to reassoc");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009020 }
9021 if (!fCallCallback) {
9022 roamId = GET_NEXT_ROAM_ID(&mac_ctx->roam);
9023 if (roam_id)
9024 *roam_id = roamId;
9025 status = csr_roam_issue_reassoc(mac_ctx, session_id, profile,
9026 &mod_fields, eCsrHddIssuedReassocToSameAP,
9027 roamId, false);
9028 } else {
9029 status = csr_roam_call_callback(mac_ctx, session_id, NULL,
9030 roamId, eCSR_ROAM_FAILED,
9031 eCSR_ROAM_RESULT_FAILURE);
9032 }
9033 return status;
9034}
9035
Jeff Johnson29e2ca12016-10-14 12:50:38 -07009036static QDF_STATUS csr_roam_join_last_profile(tpAniSirGlobal pMac,
9037 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009038{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309039 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009040 tScanResultHandle hBSSList = NULL;
9041 tCsrScanResultFilter *pScanFilter = NULL;
9042 uint32_t roamId;
Jeff Johnson66ee8a92018-03-17 15:24:26 -07009043 struct csr_roam_profile *pProfile = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309044 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009045
9046 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009047 sme_err("session %d not found ", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309048 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009049 }
9050
9051 if (pSession->pCurRoamProfile) {
Abhishek Singh9fabbbb2018-01-29 17:38:36 +05309052 csr_scan_abort_mac_scan(pMac, sessionId, INVAL_SCAN_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009053 /* We have to make a copy of pCurRoamProfile because it
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309054 * will be free inside csr_roam_issue_connect
9055 */
Jeff Johnson66ee8a92018-03-17 15:24:26 -07009056 pProfile = qdf_mem_malloc(sizeof(struct csr_roam_profile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009057 if (NULL == pProfile) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309058 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009059 goto end;
9060 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009061 status = csr_roam_copy_profile(pMac, pProfile,
9062 pSession->pCurRoamProfile);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309063 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009064 goto end;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309065 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009066 if (NULL == pScanFilter) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309067 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009068 goto end;
9069 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009070 status = csr_roam_prepare_filter_from_profile(pMac, pProfile,
9071 pScanFilter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309072 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009073 goto end;
9074 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
9075 status = csr_scan_get_result(pMac, pScanFilter, &hBSSList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309076 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009077 /* we want to put the last connected BSS to the
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309078 * very beginning, if possible
9079 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009080 csr_move_bss_to_head_from_bssid(pMac,
9081 &pSession->connectedProfile.bssid, hBSSList);
9082 status = csr_roam_issue_connect(pMac, sessionId,
9083 pProfile, hBSSList, eCsrHddIssued,
9084 roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309085 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009086 goto end;
9087 }
9088 } else {
9089 /* scan for this SSID only incase AP suppresses SSID */
9090 status = csr_scan_for_ssid(pMac, sessionId, pProfile,
9091 roamId, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309092 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009093 goto end;
9094 }
9095 } /* We have a profile */
9096 else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009097 sme_warn("cannot find a roaming profile");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009098 goto end;
9099 }
9100end:
9101 if (pScanFilter) {
9102 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309103 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009104 }
9105 if (NULL != pProfile) {
9106 csr_release_profile(pMac, pProfile);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309107 qdf_mem_free(pProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009108 }
9109 return status;
9110}
9111
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309112QDF_STATUS csr_roam_reconnect(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009113{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309114 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309115
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009116 if (csr_is_conn_state_connected(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309117 status = csr_roam_issue_disassociate_cmd(pMac, sessionId,
9118 eCSR_DISCONNECT_REASON_UNSPECIFIED);
9119 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009120 status = csr_roam_join_last_profile(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009121 }
9122 return status;
9123}
9124
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309125QDF_STATUS csr_roam_connect_to_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;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009129
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009130 csr_roam_cancel_roaming(pMac, sessionId);
9131 csr_roam_remove_duplicate_command(pMac, sessionId, NULL, eCsrHddIssued);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309132 if (csr_is_conn_state_disconnected(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009133 status = csr_roam_join_last_profile(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309134
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009135 return status;
9136}
9137
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309138QDF_STATUS csr_roam_process_disassoc_deauth(tpAniSirGlobal pMac,
9139 tSmeCmd *pCommand,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009140 bool fDisassoc, bool fMICFailure)
9141{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309142 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009143 bool fComplete = false;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309144 enum csr_roam_substate NewSubstate;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009145 uint32_t sessionId = pCommand->sessionId;
9146
9147 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309148 sme_debug("Stop Wait for key timer and change substate to eCSR_ROAM_SUBSTATE_NONE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009149 csr_roam_stop_wait_for_key_timer(pMac);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309150 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
9151 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009152 }
9153 /* change state to 'Roaming'... */
9154 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
9155
9156 if (csr_is_conn_state_ibss(pMac, sessionId)) {
9157 /* If we are in an IBSS, then stop the IBSS... */
9158 status =
9159 csr_roam_issue_stop_bss(pMac, sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309160 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309161 fComplete = (!QDF_IS_STATUS_SUCCESS(status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009162 } else if (csr_is_conn_state_infra(pMac, sessionId)) {
9163 /*
9164 * in Infrastructure, we need to disassociate from the
9165 * Infrastructure network...
9166 */
9167 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
9168 if (eCsrSmeIssuedDisassocForHandoff ==
9169 pCommand->u.roamCmd.roamReason) {
9170 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
9171 } else
9172 if ((eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason)
9173 && (eSIR_MAC_DISASSOC_LEAVING_BSS_REASON ==
9174 pCommand->u.roamCmd.reason)) {
9175 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009176 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
9177 "set to substate eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009178 }
Abhishek Singhe0680852015-12-16 14:28:48 +05309179 if (eCsrSmeIssuedDisassocForHandoff !=
9180 pCommand->u.roamCmd.roamReason) {
9181 /*
9182 * If we are in neighbor preauth done state then
9183 * on receiving disassoc or deauth we dont roam
9184 * instead we just disassoc from current ap and
9185 * then go to disconnected state.
9186 * This happens for ESE and 11r FT connections ONLY.
9187 */
Abhishek Singhe0680852015-12-16 14:28:48 +05309188 if (csr_roam_is11r_assoc(pMac, sessionId) &&
9189 (csr_neighbor_roam_state_preauth_done(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309190 sessionId)))
Abhishek Singhe0680852015-12-16 14:28:48 +05309191 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
9192 pMac, sessionId);
Abhishek Singhe0680852015-12-16 14:28:48 +05309193#ifdef FEATURE_WLAN_ESE
9194 if (csr_roam_is_ese_assoc(pMac, sessionId) &&
9195 (csr_neighbor_roam_state_preauth_done(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309196 sessionId)))
Abhishek Singhe0680852015-12-16 14:28:48 +05309197 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
9198 pMac, sessionId);
Abhishek Singhe0680852015-12-16 14:28:48 +05309199#endif
Abhishek Singhe0680852015-12-16 14:28:48 +05309200 if (csr_roam_is_fast_roam_enabled(pMac, sessionId) &&
9201 (csr_neighbor_roam_state_preauth_done(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309202 sessionId)))
Abhishek Singhe0680852015-12-16 14:28:48 +05309203 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
9204 pMac, sessionId);
Abhishek Singhe0680852015-12-16 14:28:48 +05309205 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309206 if (fDisassoc)
9207 status = csr_roam_issue_disassociate(pMac, sessionId,
9208 NewSubstate,
9209 fMICFailure);
9210 else
9211 status = csr_roam_issue_deauth(pMac, sessionId,
9212 eCSR_ROAM_SUBSTATE_DEAUTH_REQ);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309213 fComplete = (!QDF_IS_STATUS_SUCCESS(status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009214 } else {
9215 /* we got a dis-assoc request while not connected to any peer */
9216 /* just complete the command */
9217 fComplete = true;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309218 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009219 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309220 if (fComplete)
Krunal Sonif3583022017-02-10 17:18:10 -08009221 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009222
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309223 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009224 if (csr_is_conn_state_infra(pMac, sessionId)) {
9225 /* Set the state to disconnect here */
9226 pMac->roam.roamSession[sessionId].connectState =
9227 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9228 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309229 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009230 sme_warn(" failed with status %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009231 return status;
9232}
9233
9234/**
9235 * csr_prepare_disconnect_command() - function to prepare disconnect command
9236 * @mac: pointer to global mac structure
9237 * @session_id: sme session index
9238 * @sme_cmd: pointer to sme command being prepared
9239 *
9240 * Function to prepare internal sme disconnect command
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309241 * Return: QDF_STATUS_SUCCESS on success else QDF_STATUS_E_RESOURCES on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009242 */
9243
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309244QDF_STATUS csr_prepare_disconnect_command(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009245 uint32_t session_id, tSmeCmd **sme_cmd)
9246{
9247 tSmeCmd *command;
9248
9249 command = csr_get_command_buffer(mac);
9250 if (!command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009251 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309252 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009253 }
9254
9255 command->command = eSmeCommandRoam;
9256 command->sessionId = (uint8_t)session_id;
9257 command->u.roamCmd.roamReason = eCsrForcedDisassoc;
9258
9259 *sme_cmd = command;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309260 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009261}
9262
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309263QDF_STATUS csr_roam_issue_disassociate_cmd(tpAniSirGlobal pMac,
9264 uint32_t sessionId,
9265 eCsrRoamDisconnectReason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009266{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309267 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009268 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309269
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009270 do {
9271 pCommand = csr_get_command_buffer(pMac);
9272 if (!pCommand) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009273 sme_err(" fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309274 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009275 break;
9276 }
9277 /* Change the substate in case it is wait-for-key */
9278 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
9279 csr_roam_stop_wait_for_key_timer(pMac);
9280 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
9281 sessionId);
9282 }
9283 pCommand->command = eSmeCommandRoam;
9284 pCommand->sessionId = (uint8_t) sessionId;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009285 sme_debug(
9286 "Disassociate reason: %d, sessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009287 reason, sessionId);
9288 switch (reason) {
9289 case eCSR_DISCONNECT_REASON_MIC_ERROR:
9290 pCommand->u.roamCmd.roamReason =
9291 eCsrForcedDisassocMICFailure;
9292 break;
9293 case eCSR_DISCONNECT_REASON_DEAUTH:
9294 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
9295 break;
9296 case eCSR_DISCONNECT_REASON_HANDOFF:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009297 pCommand->u.roamCmd.roamReason =
9298 eCsrSmeIssuedDisassocForHandoff;
9299 break;
9300 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
9301 case eCSR_DISCONNECT_REASON_DISASSOC:
9302 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
9303 break;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07009304 case eCSR_DISCONNECT_REASON_ROAM_HO_FAIL:
9305 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
9306 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009307 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
9308 pCommand->u.roamCmd.roamReason =
9309 eCsrSmeIssuedIbssJoinFailure;
9310 break;
9311 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
9312 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
9313 break;
9314 case eCSR_DISCONNECT_REASON_STA_HAS_LEFT:
9315 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
9316 pCommand->u.roamCmd.reason =
9317 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009318 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
9319 "SME convert to internal reason code eCsrStaHasLeft");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009320 break;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07009321 case eCSR_DISCONNECT_REASON_NDI_DELETE:
9322 pCommand->u.roamCmd.roamReason = eCsrStopBss;
9323 pCommand->u.roamCmd.roamProfile.BSSType =
9324 eCSR_BSS_TYPE_NDI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009325 default:
9326 break;
9327 }
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07009328 pCommand->u.roamCmd.disconnect_reason = reason;
Abhishek Singhb7b2a3b2015-12-03 16:09:38 +05309329 status = csr_queue_sme_command(pMac, pCommand, true);
Krunal Soniaa179db2017-10-13 19:28:17 -07009330 if (!QDF_IS_STATUS_SUCCESS(status))
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309331 sme_err("fail to send message status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009332 } while (0);
9333 return status;
9334}
9335
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309336QDF_STATUS csr_roam_issue_stop_bss_cmd(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009337 bool fHighPriority)
9338{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309339 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009340 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309341
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009342 pCommand = csr_get_command_buffer(pMac);
9343 if (NULL != pCommand) {
9344 /* Change the substate in case it is wait-for-key */
9345 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
9346 csr_roam_stop_wait_for_key_timer(pMac);
9347 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
9348 sessionId);
9349 }
9350 pCommand->command = eSmeCommandRoam;
9351 pCommand->sessionId = (uint8_t) sessionId;
9352 pCommand->u.roamCmd.roamReason = eCsrStopBss;
9353 status = csr_queue_sme_command(pMac, pCommand, fHighPriority);
Krunal Soniaa179db2017-10-13 19:28:17 -07009354 if (!QDF_IS_STATUS_SUCCESS(status))
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309355 sme_err("fail to send message status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009356 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309357 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309358 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009359 }
9360 return status;
9361}
9362
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309363QDF_STATUS csr_roam_disconnect_internal(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009364 eCsrRoamDisconnectReason reason)
9365{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309366 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309367 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009368
9369 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309370 sme_err("session: %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309371 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009372 }
9373#ifdef FEATURE_WLAN_BTAMP_UT_RF
9374 /* Stop the retry */
9375 pSession->maxRetryCount = 0;
9376 csr_roam_stop_join_retry_timer(pMac, sessionId);
9377#endif
9378 /* Not to call cancel roaming here */
9379 /* Only issue disconnect when necessary */
9380 if (csr_is_conn_state_connected(pMac, sessionId)
9381 || csr_is_bss_type_ibss(pSession->connectedProfile.BSSType)
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07009382 || csr_is_roam_command_waiting_for_session(pMac, sessionId)
9383 || CSR_IS_CONN_NDI(&pSession->connectedProfile)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009384 sme_debug("called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009385 status = csr_roam_issue_disassociate_cmd(pMac, sessionId,
9386 reason);
9387 } else {
kaliu154d7892015-12-30 17:27:58 +05309388 pMac->roam.roamSession[sessionId].connectState =
9389 eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING;
Abhishek Singh9fabbbb2018-01-29 17:38:36 +05309390 csr_scan_abort_mac_scan(pMac, sessionId, INVAL_SCAN_ID);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309391 status = QDF_STATUS_CMD_NOT_QUEUED;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309392 sme_debug("Disconnect cmd not queued, Roam command is not present return with status: %d",
9393 status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009394 }
9395 return status;
9396}
9397
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309398QDF_STATUS csr_roam_disconnect(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009399 eCsrRoamDisconnectReason reason)
9400{
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309401 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009402
9403 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309404 sme_err("session: %d not found ", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309405 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009406 }
9407
9408 csr_roam_cancel_roaming(pMac, sessionId);
9409 csr_roam_remove_duplicate_command(pMac, sessionId, NULL,
9410 eCsrForcedDisassoc);
9411
9412 return csr_roam_disconnect_internal(pMac, sessionId, reason);
9413}
9414
Jeff Johnson536249f2018-05-12 16:48:38 -07009415QDF_STATUS csr_roam_save_connected_information(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009416 uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07009417 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009418 tSirBssDescription *pSirBssDesc,
9419 tDot11fBeaconIEs *pIes)
9420{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309421 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009422 tDot11fBeaconIEs *pIesTemp = pIes;
9423 uint8_t index;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309424 struct csr_roam_session *pSession = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009425 tCsrRoamConnectedProfile *pConnectProfile = NULL;
9426
9427 pSession = CSR_GET_SESSION(pMac, sessionId);
9428 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309429 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309430 "session: %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309431 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009432 }
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +05309433
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309434 sme_debug("session id: %d", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009435 pConnectProfile = &pSession->connectedProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009436 if (pConnectProfile->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309437 qdf_mem_free(pConnectProfile->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009438 pConnectProfile->pAddIEAssoc = NULL;
9439 }
Varun Reddy Yeturud5216002016-02-03 17:09:09 -08009440 /*
9441 * In case of LFR2.0, the connected profile is copied into a temporary
9442 * profile and cleared and then is copied back. This is not needed for
9443 * LFR3.0, since the profile is not cleared.
9444 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009445 if (!pSession->roam_synch_in_progress) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309446 qdf_mem_set(&pSession->connectedProfile,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009447 sizeof(tCsrRoamConnectedProfile), 0);
9448 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
9449 pConnectProfile->AuthInfo = pProfile->AuthType;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009450 pConnectProfile->EncryptionType =
9451 pProfile->negotiatedUCEncryptionType;
9452 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
9453 pConnectProfile->mcEncryptionType =
9454 pProfile->negotiatedMCEncryptionType;
9455 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
9456 pConnectProfile->BSSType = pProfile->BSSType;
9457 pConnectProfile->modifyProfileFields.uapsd_mask =
9458 pProfile->uapsd_mask;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309459 qdf_mem_copy(&pConnectProfile->Keys, &pProfile->Keys,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009460 sizeof(tCsrKeys));
9461 if (pProfile->nAddIEAssocLength) {
9462 pConnectProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309463 qdf_mem_malloc(pProfile->nAddIEAssocLength);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009464 if (NULL == pConnectProfile->pAddIEAssoc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309465 status = QDF_STATUS_E_NOMEM;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009466 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309467 status = QDF_STATUS_SUCCESS;
9468 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309469 sme_err("Failed to allocate memory for IE");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309470 return QDF_STATUS_E_FAILURE;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009471 }
9472 pConnectProfile->nAddIEAssocLength =
9473 pProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309474 qdf_mem_copy(pConnectProfile->pAddIEAssoc,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08009475 pProfile->pAddIEAssoc,
9476 pProfile->nAddIEAssocLength);
9477 }
9478#ifdef WLAN_FEATURE_11W
9479 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
9480 pConnectProfile->MFPRequired = pProfile->MFPRequired;
9481 pConnectProfile->MFPCapable = pProfile->MFPCapable;
9482#endif
9483 }
9484 /* Save bssid */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009485 pConnectProfile->operationChannel = pSirBssDesc->channelId;
9486 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309487 if (!pConnectProfile->beaconInterval)
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009488 sme_err("ERROR: Beacon interval is ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009489 csr_get_bss_id_bss_desc(pMac, pSirBssDesc, &pConnectProfile->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009490 if (pSirBssDesc->mdiePresent) {
9491 pConnectProfile->MDID.mdiePresent = 1;
9492 pConnectProfile->MDID.mobilityDomain =
9493 (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
9494 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309495 if (NULL == pIesTemp)
9496 status = csr_get_parsed_bss_description_ies(pMac, pSirBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009497 &pIesTemp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009498#ifdef FEATURE_WLAN_ESE
9499 if ((csr_is_profile_ese(pProfile) ||
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309500 (QDF_IS_STATUS_SUCCESS(status) && (pIesTemp->ESEVersion.present)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009501 && (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)))
9502 && (pMac->roam.configParam.isEseIniFeatureEnabled)) {
9503 pConnectProfile->isESEAssoc = 1;
9504 }
9505#endif
9506 /* save ssid */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309507 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009508 if (pIesTemp->SSID.present) {
9509 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309510 qdf_mem_copy(pConnectProfile->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009511 pIesTemp->SSID.ssid,
9512 pIesTemp->SSID.num_ssid);
9513 }
9514 /* Save the bss desc */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309515 status = csr_roam_save_connected_bss_desc(pMac, sessionId,
9516 pSirBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009517
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309518 if (CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
9519 /* Some HT AP's dont send WMM IE so in that case we
9520 * assume all HT Ap's are Qos Enabled AP's
9521 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009522 pConnectProfile->qap = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309523 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009524 pConnectProfile->qap = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009525
9526 if (pIesTemp->ExtCap.present) {
9527 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
9528 pIesTemp->ExtCap.bytes;
9529 pConnectProfile->proxyARPService = p_ext_cap->
9530 proxy_arp_service;
9531 }
9532
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309533 if (NULL == pIes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009534 /* Free memory if it allocated locally */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309535 qdf_mem_free(pIesTemp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009536 }
9537 /* Save Qos connection */
9538 pConnectProfile->qosConnection =
9539 pMac->roam.roamSession[sessionId].fWMMConnection;
9540
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309541 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009542 csr_free_connect_bss_desc(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309543
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009544 for (index = 0; index < pProfile->SSIDs.numOfSSIDs; index++) {
9545 if ((pProfile->SSIDs.SSIDList[index].SSID.length ==
9546 pConnectProfile->SSID.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309547 && (!qdf_mem_cmp(pProfile->SSIDs.SSIDList[index].SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009548 ssId, pConnectProfile->SSID.ssId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309549 pConnectProfile->SSID.length))) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309550 pConnectProfile->handoffPermitted = pProfile->SSIDs.
9551 SSIDList[index].handoffPermitted;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009552 break;
9553 }
9554 pConnectProfile->handoffPermitted = false;
9555 }
9556
9557 return status;
9558}
9559
9560
Abhishek Singhb1d73ab2015-12-03 16:14:00 +05309561bool is_disconnect_pending(tpAniSirGlobal pmac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009562 uint8_t sessionid)
9563{
9564 tListElem *entry = NULL;
9565 tListElem *next_entry = NULL;
9566 tSmeCmd *command = NULL;
9567 bool disconnect_cmd_exist = false;
9568
Krunal Soni20126cb2017-02-15 16:26:57 -08009569 csr_nonscan_pending_ll_lock(pmac);
Krunal Sonia8270f52017-02-23 19:51:25 -08009570 entry = csr_nonscan_pending_ll_peek_head(pmac, LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009571 while (entry) {
Krunal Soni72dba662017-02-15 20:13:17 -08009572 next_entry = csr_nonscan_pending_ll_next(pmac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009573 entry, LL_ACCESS_NOLOCK);
9574
9575 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
9576 if (command && CSR_IS_DISCONNECT_COMMAND(command) &&
9577 command->sessionId == sessionid){
9578 disconnect_cmd_exist = true;
9579 break;
9580 }
9581 entry = next_entry;
9582 }
Krunal Soni20126cb2017-02-15 16:26:57 -08009583 csr_nonscan_pending_ll_unlock(pmac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009584 return disconnect_cmd_exist;
9585}
9586
9587static void csr_roam_join_rsp_processor(tpAniSirGlobal pMac,
9588 tSirSmeJoinRsp *pSmeJoinRsp)
9589{
9590 tListElem *pEntry = NULL;
9591 tSmeCmd *pCommand = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309592 struct csr_roam_session *session_ptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009593
9594 if (pSmeJoinRsp) {
9595 session_ptr = CSR_GET_SESSION(pMac, pSmeJoinRsp->sessionId);
9596 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309597 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009598 FL("Sme Join Response is NULL"));
9599 return;
9600 }
9601 if (!session_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309602 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009603 ("session %d not found"), pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009604 return;
9605 }
9606 /* The head of the active list is the request we sent */
Krunal Sonia8270f52017-02-23 19:51:25 -08009607 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309608 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009609 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309610
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05309611 sme_debug("is_fils_connection %d", pSmeJoinRsp->is_fils_connection);
9612 /* Copy Sequence Number last used for FILS assoc failure case */
9613 if (session_ptr->is_fils_connection)
9614 session_ptr->fils_seq_num = pSmeJoinRsp->fils_seq_num;
9615
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009616 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode) {
9617 if (pCommand
9618 && eCsrSmeIssuedAssocToSimilarAP ==
9619 pCommand->u.roamCmd.roamReason) {
9620#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9621 sme_qos_csr_event_ind(pMac, pSmeJoinRsp->sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309622 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009623#endif
9624 }
Archana Ramachandran20d2e232016-02-11 16:58:40 -08009625
9626 session_ptr->supported_nss_1x1 =
9627 pSmeJoinRsp->supported_nss_1x1;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309628 sme_debug("SME session supported nss: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08009629 session_ptr->supported_nss_1x1);
9630
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309631 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009632 * The join bssid count can be reset as soon as
9633 * we are done with the join requests and returning
9634 * the response to upper layers
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309635 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009636 session_ptr->join_bssid_count = 0;
Krunal Sonif3583022017-02-10 17:18:10 -08009637 csr_roam_complete(pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp,
9638 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009639 } else {
9640 uint32_t roamId = 0;
9641 bool is_dis_pending;
9642
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309643 /* The head of the active list is the request we sent
9644 * Try to get back the same profile and roam again
9645 */
9646 if (pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009647 roamId = pCommand->u.roamCmd.roamId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009648 session_ptr->joinFailStatusCode.statusCode =
9649 pSmeJoinRsp->statusCode;
9650 session_ptr->joinFailStatusCode.reasonCode =
9651 pSmeJoinRsp->protStatusCode;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309652 sme_warn("SmeJoinReq failed with statusCode= 0x%08X [%d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009653 pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309654 /* If Join fails while Handoff is in progress, indicate
9655 * disassociated event to supplicant to reconnect
9656 */
9657 if (csr_roam_is_handoff_in_progress(pMac,
9658 pSmeJoinRsp->sessionId)) {
9659 csr_roam_call_callback(pMac, pSmeJoinRsp->sessionId,
9660 NULL, roamId,
9661 eCSR_ROAM_DISASSOCIATED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009662 eCSR_ROAM_RESULT_FORCED);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309663 /* Should indicate neighbor roam algorithm about the
9664 * connect failure here
9665 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009666 csr_neighbor_roam_indicate_connect(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309667 pSmeJoinRsp->sessionId,
9668 QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009669 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009670 /*
9671 * if userspace has issued disconnection,
9672 * driver should not continue connecting
9673 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309674 is_dis_pending = is_disconnect_pending(pMac,
9675 session_ptr->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009676 if (pCommand && (session_ptr->join_bssid_count <
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309677 CSR_MAX_BSSID_COUNT) && !is_dis_pending)
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07009678 csr_roam(pMac, pCommand);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309679 else {
9680 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009681 * When the upper layers issue a connect command, there
9682 * is a roam command with reason eCsrHddIssued that
9683 * gets enqueued and an associated timer for the SME
9684 * command timeout is started which is currently 120
9685 * seconds. This command would be dequeued only upon
Jeff Johnson3370f3a2018-05-11 09:54:12 -07009686 * successful connections. In case of join failures, if
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009687 * there are too many BSS in the cache, and if we fail
9688 * Join requests with all of them, there is a chance of
9689 * timing out the above timer.
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309690 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009691 if (session_ptr->join_bssid_count >=
9692 CSR_MAX_BSSID_COUNT)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309693 QDF_TRACE(QDF_MODULE_ID_SME,
9694 QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009695 "Excessive Join Req Failures");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009696
9697 if (is_dis_pending)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309698 QDF_TRACE(QDF_MODULE_ID_SME,
9699 QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009700 "disconnect is pending, complete roam");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009701
Abhishek Singh6e4621c2017-03-31 13:13:10 +05309702 if (session_ptr->bRefAssocStartCnt)
9703 session_ptr->bRefAssocStartCnt--;
9704
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009705 session_ptr->join_bssid_count = 0;
Abhishek Singh6e4621c2017-03-31 13:13:10 +05309706
9707 csr_roam_call_callback(pMac, session_ptr->sessionId,
9708 NULL, roamId,
9709 eCSR_ROAM_ASSOCIATION_COMPLETION,
9710 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
9711
Krunal Sonif3583022017-02-10 17:18:10 -08009712 csr_roam_complete(pMac, eCsrNothingToJoin, NULL,
9713 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009714 }
9715 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
9716}
9717
Jeff Johnson29e2ca12016-10-14 12:50:38 -07009718static QDF_STATUS csr_roam_issue_join(tpAniSirGlobal pMac, uint32_t sessionId,
9719 tSirBssDescription *pSirBssDesc,
9720 tDot11fBeaconIEs *pIes,
Jeff Johnson66ee8a92018-03-17 15:24:26 -07009721 struct csr_roam_profile *pProfile,
Jeff Johnson29e2ca12016-10-14 12:50:38 -07009722 uint32_t roamId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009723{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309724 QDF_STATUS status;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309725
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009726 sme_debug("Attempting to Join Bssid= " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009727 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
9728
9729 /* Set the roaming substate to 'join attempt'... */
9730 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
9731 /* attempt to Join this BSS... */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309732 status = csr_send_join_req_msg(pMac, sessionId, pSirBssDesc, pProfile,
9733 pIes, eWNI_SME_JOIN_REQ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009734 return status;
9735}
9736
Krunal Sonif3583022017-02-10 17:18:10 -08009737static void
9738csr_roam_reissue_roam_command(tpAniSirGlobal pMac, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009739{
9740 tListElem *pEntry;
9741 tSmeCmd *pCommand;
Jeff Johnson172237b2017-11-07 15:32:59 -08009742 struct csr_roam_info roamInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009743 uint32_t sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309744 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009745
Krunal Sonia8270f52017-02-23 19:51:25 -08009746 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009747 if (NULL == pEntry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309748 sme_err("Disassoc rsp can't continue, no active CMD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009749 return;
9750 }
9751 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9752 if (eSmeCommandRoam != pCommand->command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009753 sme_err("Active cmd, is not a roaming CMD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009754 return;
9755 }
9756 sessionId = pCommand->sessionId;
9757 pSession = CSR_GET_SESSION(pMac, sessionId);
9758
9759 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009760 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009761 return;
9762 }
9763
9764 if (!pCommand->u.roamCmd.fStopWds) {
9765 if (pSession->bRefAssocStartCnt > 0) {
9766 /*
9767 * bRefAssocStartCnt was incremented in
9768 * csr_roam_join_next_bss when the roam command issued
9769 * previously. As part of reissuing the roam command
9770 * again csr_roam_join_next_bss is going increment
9771 * RefAssocStartCnt. So make sure to decrement the
9772 * bRefAssocStartCnt
9773 */
9774 pSession->bRefAssocStartCnt--;
9775 }
9776 if (eCsrStopRoaming == csr_roam_join_next_bss(pMac, pCommand,
9777 true)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009778 sme_warn("Failed to reissue join command");
Krunal Sonif3583022017-02-10 17:18:10 -08009779 csr_roam_complete(pMac, eCsrNothingToJoin, NULL,
9780 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009781 }
9782 return;
9783 }
Jeff Johnson172237b2017-11-07 15:32:59 -08009784 qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009785 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
9786 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
9787 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07009788 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
9789 csr_roam_call_callback(pMac, sessionId, &roamInfo,
9790 pCommand->u.roamCmd.roamId,
9791 eCSR_ROAM_INFRA_IND,
9792 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009793
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309794 if (!QDF_IS_STATUS_SUCCESS(csr_roam_issue_stop_bss(pMac, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009795 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009796 sme_err("Failed to reissue stop_bss command for WDS");
Krunal Sonif3583022017-02-10 17:18:10 -08009797 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009798 }
9799}
9800
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309801bool csr_is_roam_command_waiting_for_session(tpAniSirGlobal pMac,
9802 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009803{
9804 bool fRet = false;
9805 tListElem *pEntry;
9806 tSmeCmd *pCommand = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309807
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009808 /* alwasy lock active list before locking pending list */
Krunal Soni20126cb2017-02-15 16:26:57 -08009809 csr_nonscan_active_ll_lock(pMac);
Krunal Sonia8270f52017-02-23 19:51:25 -08009810 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009811 if (pEntry) {
9812 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9813 if ((eSmeCommandRoam == pCommand->command)
9814 && (sessionId == pCommand->sessionId)) {
9815 fRet = true;
9816 }
9817 }
9818 if (false == fRet) {
Krunal Soni20126cb2017-02-15 16:26:57 -08009819 csr_nonscan_pending_ll_lock(pMac);
Krunal Sonia8270f52017-02-23 19:51:25 -08009820 pEntry = csr_nonscan_pending_ll_peek_head(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009821 LL_ACCESS_NOLOCK);
9822 while (pEntry) {
9823 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9824 if ((eSmeCommandRoam == pCommand->command)
9825 && (sessionId == pCommand->sessionId)) {
9826 fRet = true;
9827 break;
9828 }
Krunal Soni72dba662017-02-15 20:13:17 -08009829 pEntry = csr_nonscan_pending_ll_next(pMac, pEntry,
9830 LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009831 }
Krunal Soni20126cb2017-02-15 16:26:57 -08009832 csr_nonscan_pending_ll_unlock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009833 }
Krunal Soni20126cb2017-02-15 16:26:57 -08009834 csr_nonscan_active_ll_unlock(pMac);
9835
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009836 return fRet;
9837}
9838
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009839static void
9840csr_roaming_state_config_cnf_processor(tpAniSirGlobal mac_ctx,
Krunal Sonia8270f52017-02-23 19:51:25 -08009841 tSmeCmd *cmd, uint32_t result, uint8_t sme_session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009842{
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05309843 struct tag_csrscan_result *scan_result = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009844 tSirBssDescription *bss_desc = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009845 uint32_t session_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05309846 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009847 tDot11fBeaconIEs *local_ies = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309848 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009849
Krunal Sonia8270f52017-02-23 19:51:25 -08009850 if (NULL == cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009851 sme_err("given sme cmd is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009852 return;
9853 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009854 session_id = cmd->sessionId;
9855 session = CSR_GET_SESSION(mac_ctx, session_id);
9856
9857 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009858 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009859 return;
9860 }
9861
9862 if (CSR_IS_ROAMING(session) && session->fCancelRoaming) {
9863 /* the roaming is cancelled. Simply complete the command */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009864 sme_warn("Roam command canceled");
Krunal Sonif3583022017-02-10 17:18:10 -08009865 csr_roam_complete(mac_ctx, eCsrNothingToJoin, NULL,
9866 sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009867 return;
9868 }
9869
9870 /* If the roaming has stopped, not to continue the roaming command */
9871 if (!CSR_IS_ROAMING(session) && CSR_IS_ROAMING_COMMAND(cmd)) {
9872 /* No need to complete roaming here as it already completes */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009873 sme_warn(
9874 "Roam cmd (reason %d) aborted(roaming completed)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009875 cmd->u.roamCmd.roamReason);
9876 csr_set_abort_roaming_command(mac_ctx, cmd);
Krunal Sonif3583022017-02-10 17:18:10 -08009877 csr_roam_complete(mac_ctx, eCsrNothingToJoin, NULL,
9878 sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009879 return;
9880 }
9881
9882 if (!IS_SIR_STATUS_SUCCESS(result)) {
9883 /*
9884 * In the event the configuration failed, for infra let the roam
9885 * processor attempt to join something else...
9886 */
9887 if (cmd->u.roamCmd.pRoamBssEntry
9888 && CSR_IS_INFRASTRUCTURE(&cmd->u.roamCmd.roamProfile)) {
9889 csr_roam(mac_ctx, cmd);
9890 } else {
9891 /* We need to complete the command */
9892 if (csr_is_bss_type_ibss
9893 (cmd->u.roamCmd.roamProfile.BSSType)) {
9894 csr_roam_complete(mac_ctx, eCsrStartBssFailure,
Krunal Sonif3583022017-02-10 17:18:10 -08009895 NULL, sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009896 } else {
9897 csr_roam_complete(mac_ctx, eCsrNothingToJoin,
Krunal Sonif3583022017-02-10 17:18:10 -08009898 NULL, sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009899 }
9900 }
9901 return;
9902 }
9903
9904 /* we have active entry */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009905 sme_debug("Cfg sequence complete");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009906 /*
9907 * Successfully set the configuration parameters for the new Bss.
9908 * Attempt to join the roaming Bss
9909 */
9910 if (cmd->u.roamCmd.pRoamBssEntry) {
9911 scan_result = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +05309912 struct tag_csrscan_result,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009913 Link);
9914 bss_desc = &scan_result->Result.BssDescriptor;
9915 }
9916 if (csr_is_bss_type_ibss(cmd->u.roamCmd.roamProfile.BSSType)
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07009917 || CSR_IS_INFRA_AP(&cmd->u.roamCmd.roamProfile)
9918 || CSR_IS_NDI(&cmd->u.roamCmd.roamProfile)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309919 if (!QDF_IS_STATUS_SUCCESS(csr_roam_issue_start_bss(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009920 session_id, &session->bssParams,
9921 &cmd->u.roamCmd.roamProfile,
9922 bss_desc,
9923 cmd->u.roamCmd.roamId))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009924 sme_err("CSR start BSS failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009925 /* We need to complete the command */
Krunal Sonif3583022017-02-10 17:18:10 -08009926 csr_roam_complete(mac_ctx, eCsrStartBssFailure, NULL,
9927 sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009928 }
9929 return;
9930 }
9931
9932 if (!cmd->u.roamCmd.pRoamBssEntry) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009933 sme_err("pRoamBssEntry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009934 /* We need to complete the command */
Krunal Sonif3583022017-02-10 17:18:10 -08009935 csr_roam_complete(mac_ctx, eCsrJoinFailure, NULL,
9936 sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009937 return;
9938 }
9939
9940 if (NULL == scan_result) {
9941 /* If we are roaming TO an Infrastructure BSS... */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309942 QDF_ASSERT(scan_result != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009943 return;
9944 }
9945
9946 if (!csr_is_infra_bss_desc(bss_desc)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009947 sme_warn("found BSSType mismatching the one in BSS descp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009948 return;
9949 }
9950
9951 local_ies = (tDot11fBeaconIEs *) scan_result->Result.pvIes;
9952 if (!local_ies) {
9953 status = csr_get_parsed_bss_description_ies(mac_ctx, bss_desc,
9954 &local_ies);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309955 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009956 return;
9957 }
9958
9959 if (csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
9960 if (csr_is_ssid_equal(mac_ctx, session->pConnectBssDesc,
9961 bss_desc, local_ies)) {
9962 cmd->u.roamCmd.fReassoc = true;
9963 csr_roam_issue_reassociate(mac_ctx, session_id,
9964 bss_desc, local_ies,
9965 &cmd->u.roamCmd.roamProfile);
9966 } else {
9967 /*
9968 * otherwise, we have to issue a new Join request to LIM
9969 * because we disassociated from the previously
9970 * associated AP.
9971 */
9972 status = csr_roam_issue_join(mac_ctx, session_id,
9973 bss_desc, local_ies,
9974 &cmd->u.roamCmd.roamProfile,
9975 cmd->u.roamCmd.roamId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309976 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009977 /* try something else */
9978 csr_roam(mac_ctx, cmd);
9979 }
9980 }
9981 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309982 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009983 /*
9984 * We need to come with other way to figure out that this is
9985 * because of HO in BMP The below API will be only available for
9986 * Android as it uses a different HO algorithm. Reassoc request
9987 * will be used only for ESE and 11r handoff whereas other
9988 * legacy roaming should use join request
9989 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009990 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
9991 && csr_roam_is11r_assoc(mac_ctx, session_id)) {
9992 status = csr_roam_issue_reassociate(mac_ctx,
9993 session_id, bss_desc,
Will Huang03b54ee2017-06-21 10:57:05 +08009994 local_ies,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009995 &cmd->u.roamCmd.roamProfile);
9996 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009997#ifdef FEATURE_WLAN_ESE
9998 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
9999 && csr_roam_is_ese_assoc(mac_ctx, session_id)) {
10000 /* Now serialize the reassoc command. */
10001 status = csr_roam_issue_reassociate_cmd(mac_ctx,
10002 session_id);
10003 } else
10004#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010005 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
10006 && csr_roam_is_fast_roam_enabled(mac_ctx, session_id)) {
10007 /* Now serialize the reassoc command. */
10008 status = csr_roam_issue_reassociate_cmd(mac_ctx,
10009 session_id);
Deepak Dhamdhereecce9742015-11-08 01:16:43 -080010010 } else {
10011 /*
10012 * else we are not connected and attempting to Join.
10013 * Issue the Join request.
10014 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010015 status = csr_roam_issue_join(mac_ctx, session_id,
10016 bss_desc,
Will Huang03b54ee2017-06-21 10:57:05 +080010017 local_ies,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010018 &cmd->u.roamCmd.roamProfile,
10019 cmd->u.roamCmd.roamId);
10020 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010021 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010022 /* try something else */
10023 csr_roam(mac_ctx, cmd);
10024 }
10025 }
10026 if (!scan_result->Result.pvIes) {
10027 /* Locally allocated */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010028 qdf_mem_free(local_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010029 }
10030}
10031
10032static void csr_roam_roaming_state_reassoc_rsp_processor(tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010033 tpSirSmeJoinRsp pSmeJoinRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010034{
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053010035 enum csr_roamcomplete_result result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010036 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
10037 &pMac->roam.neighborRoamInfo[pSmeJoinRsp->sessionId];
Jeff Johnson172237b2017-11-07 15:32:59 -080010038 struct csr_roam_info roamInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010039 uint32_t roamId = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010040 struct csr_roam_session *csr_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010041
10042 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010043 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010044 "CSR SmeReassocReq Successful");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010045 result = eCsrReassocSuccess;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -070010046 csr_session = CSR_GET_SESSION(pMac, pSmeJoinRsp->sessionId);
10047 if (NULL != csr_session) {
10048 csr_session->supported_nss_1x1 =
10049 pSmeJoinRsp->supported_nss_1x1;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010050 sme_debug("SME session supported nss: %d",
Archana Ramachandran5482d6a2016-03-29 17:09:22 -070010051 csr_session->supported_nss_1x1);
10052 }
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080010053 /*
10054 * Since the neighbor roam algorithm uses reassoc req for
10055 * handoff instead of join, we need the response contents while
10056 * processing the result in csr_roam_process_results()
10057 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010058 if (csr_roam_is_handoff_in_progress(pMac,
10059 pSmeJoinRsp->sessionId)) {
10060 /* Need to dig more on indicating events to
10061 * SME QoS module
10062 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010063 sme_qos_csr_event_ind(pMac, pSmeJoinRsp->sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010064 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
Krunal Sonif3583022017-02-10 17:18:10 -080010065 csr_roam_complete(pMac, result, pSmeJoinRsp,
10066 pSmeJoinRsp->sessionId);
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080010067 } else {
Krunal Sonif3583022017-02-10 17:18:10 -080010068 csr_roam_complete(pMac, result, NULL,
10069 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010070 }
10071 }
10072 /* Should we handle this similar to handling the join failure? Is it ok
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010073 * to call csr_roam_complete() with state as CsrJoinFailure
10074 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010075 else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010076 sme_warn(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010077 "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]",
10078 pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode);
10079 result = eCsrReassocFailure;
Abhishek Singh5ea86532016-04-27 14:10:53 +053010080 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
10081 WLAN_LOG_INDICATOR_HOST_DRIVER,
10082 WLAN_LOG_REASON_ROAM_FAIL,
10083 true, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010084 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE ==
10085 pSmeJoinRsp->statusCode)
10086 || (eSIR_SME_FT_REASSOC_FAILURE ==
10087 pSmeJoinRsp->statusCode)
10088 || (eSIR_SME_INVALID_PARAMETERS ==
10089 pSmeJoinRsp->statusCode)) {
10090 /* Inform HDD to turn off FT flag in HDD */
10091 if (pNeighborRoamInfo) {
Jeff Johnson172237b2017-11-07 15:32:59 -080010092 qdf_mem_zero(&roamInfo, sizeof(roamInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010093 csr_roam_call_callback(pMac,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070010094 pSmeJoinRsp->sessionId,
10095 &roamInfo, roamId,
10096 eCSR_ROAM_FT_REASSOC_FAILED,
10097 eCSR_ROAM_RESULT_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010098 /*
10099 * Since the above callback sends a disconnect
10100 * to HDD, we should clean-up our state
10101 * machine as well to be in sync with the upper
10102 * layers. There is no need to send a disassoc
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010103 * since: 1) we will never reassoc to the
10104 * current AP in LFR, and 2) there is no need
10105 * to issue a disassoc to the AP with which we
10106 * were trying to reassoc.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010107 */
Krunal Sonif3583022017-02-10 17:18:10 -080010108 csr_roam_complete(pMac, eCsrJoinFailure, NULL,
10109 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010110 return;
10111 }
10112 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010113 /* In the event that the Reassociation fails, then we need to
10114 * Disassociate the current association and keep roaming. Note
10115 * that we will attempt to Join the AP instead of a Reassoc
10116 * since we may have attempted a 'Reassoc to self', which AP's
10117 * that don't support Reassoc will force a Disassoc. The
10118 * isassoc rsp message will remove the command from active list
10119 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010120 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010121 (csr_roam_issue_disassociate
10122 (pMac, pSmeJoinRsp->sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010123 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE,
10124 false))) {
Krunal Sonif3583022017-02-10 17:18:10 -080010125 csr_roam_complete(pMac, eCsrJoinFailure, NULL,
10126 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010127 }
10128 }
10129}
10130
10131static void csr_roam_roaming_state_stop_bss_rsp_processor(tpAniSirGlobal pMac,
10132 tSirSmeRsp *pSmeRsp)
10133{
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053010134 enum csr_roamcomplete_result result_code = eCsrNothingToJoin;
Jeff Johnson66ee8a92018-03-17 15:24:26 -070010135 struct csr_roam_profile *profile;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070010136
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010137#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10138 {
10139 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010140
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010141 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
10142 LOG_WLAN_IBSS_C);
10143 if (pIbssLog) {
10144 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010145 if (eSIR_SME_SUCCESS != pSmeRsp->statusCode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010146 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010147 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
10148 }
10149 }
10150#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10151 pMac->roam.roamSession[pSmeRsp->sessionId].connectState =
10152 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10153 if (CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ(pMac, pSmeRsp->sessionId)) {
Naveen Rawatefd71c32016-10-25 17:05:47 -070010154 profile =
10155 pMac->roam.roamSession[pSmeRsp->sessionId].pCurRoamProfile;
10156 if (profile && CSR_IS_CONN_NDI(profile)) {
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070010157 result_code = eCsrStopBssSuccess;
10158 if (pSmeRsp->statusCode != eSIR_SME_SUCCESS)
10159 result_code = eCsrStopBssFailure;
10160 }
Krunal Sonif3583022017-02-10 17:18:10 -080010161 csr_roam_complete(pMac, result_code, NULL, pSmeRsp->sessionId);
Naveen Rawatefd71c32016-10-25 17:05:47 -070010162 } else if (CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE(pMac,
10163 pSmeRsp->sessionId)) {
Krunal Sonif3583022017-02-10 17:18:10 -080010164 csr_roam_reissue_roam_command(pMac, pSmeRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010165 }
10166}
10167
10168/**
10169 * csr_dequeue_command() - removes a command from active cmd list
10170 * @pMac: mac global context
10171 *
10172 * Return: void
10173 */
10174static void
10175csr_dequeue_command(tpAniSirGlobal mac_ctx)
10176{
10177 bool fRemoveCmd;
10178 tSmeCmd *cmd = NULL;
Krunal Sonia8270f52017-02-23 19:51:25 -080010179 tListElem *entry = csr_nonscan_active_ll_peek_head(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010180 LL_ACCESS_LOCK);
10181 if (!entry) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010182 sme_err("NO commands are active");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010183 return;
10184 }
10185
10186 cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
10187 /*
10188 * If the head of the queue is Active and it is a given cmd type, remove
10189 * and put this on the Free queue.
10190 */
10191 if (eSmeCommandRoam != cmd->command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010192 sme_err("Roam command not active");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010193 return;
10194 }
10195 /*
10196 * we need to process the result first before removing it from active
10197 * list because state changes still happening insides
10198 * roamQProcessRoamResults so no other roam command should be issued.
10199 */
Krunal Soni72dba662017-02-15 20:13:17 -080010200 fRemoveCmd = csr_nonscan_active_ll_remove_entry(mac_ctx, entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010201 LL_ACCESS_LOCK);
10202 if (cmd->u.roamCmd.fReleaseProfile) {
10203 csr_release_profile(mac_ctx, &cmd->u.roamCmd.roamProfile);
10204 cmd->u.roamCmd.fReleaseProfile = false;
10205 }
10206 if (fRemoveCmd)
Krunal Sonidea45952017-02-15 11:58:15 -080010207 csr_release_command(mac_ctx, cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010208 else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010209 sme_err("fail to remove cmd reason %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010210 cmd->u.roamCmd.roamReason);
10211}
10212
10213/**
10214 * csr_post_roam_failure() - post roam failure back to csr and issues a disassoc
10215 * @pMac: mac global context
10216 * @session_id: session id
10217 * @roam_info: roam info struct
10218 * @scan_filter: scan filter to free
10219 * @cur_roam_profile: current csr roam profile
10220 *
10221 * Return: void
10222 */
10223static void
10224csr_post_roam_failure(tpAniSirGlobal mac_ctx,
10225 uint32_t session_id,
Jeff Johnson172237b2017-11-07 15:32:59 -080010226 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010227 tCsrScanResultFilter *scan_filter,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070010228 struct csr_roam_profile *cur_roam_profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010229{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010230 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010231
10232 if (scan_filter) {
10233 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010234 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010235 }
10236 if (cur_roam_profile)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010237 qdf_mem_free(cur_roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010238
10239#ifdef WLAN_FEATURE_ROAM_OFFLOAD
10240 csr_roam_synch_clean_up(mac_ctx, session_id);
10241#endif
10242 /* Inform the upper layers that the reassoc failed */
Jeff Johnson172237b2017-11-07 15:32:59 -080010243 qdf_mem_zero(roam_info, sizeof(struct csr_roam_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010244 csr_roam_call_callback(mac_ctx, session_id, roam_info, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070010245 eCSR_ROAM_FT_REASSOC_FAILED,
10246 eCSR_ROAM_RESULT_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010247 /*
10248 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT
10249 * session. Upon success, we would re-enter this routine after receiving
10250 * the disassoc response and will fall into the reassoc fail sub-state.
10251 * And, eventually call csr_roam_complete which would remove the roam
10252 * command from SME active queue.
10253 */
10254 status = csr_roam_issue_disassociate(mac_ctx, session_id,
10255 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010256 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010257 sme_err(
10258 "csr_roam_issue_disassociate failed, status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010259 status);
Krunal Sonif3583022017-02-10 17:18:10 -080010260 csr_roam_complete(mac_ctx, eCsrJoinFailure, NULL, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010261 }
10262}
10263
10264/**
10265 * csr_check_profile_in_scan_cache() - finds if roam profile is present in scan
10266 * cache or not
10267 * @pMac: mac global context
10268 * @scan_filter: out param, scan filter
10269 * @neighbor_roam_info: roam info struct
10270 * @hBSSList: scan result
10271 *
10272 * Return: true if found else false.
10273 */
10274static bool
10275csr_check_profile_in_scan_cache(tpAniSirGlobal mac_ctx,
10276 tCsrScanResultFilter **scan_filter,
10277 tpCsrNeighborRoamControlInfo neighbor_roam_info,
10278 tScanResultHandle *hBSSList)
10279{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010280 QDF_STATUS status;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010281 *scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010282 if (NULL == *scan_filter) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010283 sme_err("alloc for ScanFilter failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010284 return false;
10285 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010286 (*scan_filter)->scan_filter_for_roam = 1;
10287 status = csr_roam_prepare_filter_from_profile(mac_ctx,
10288 &neighbor_roam_info->csrNeighborRoamProfile,
10289 *scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010290 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010291 sme_err(
10292 "failed to prepare scan filter, status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010293 status);
10294 return false;
10295 }
10296 status = csr_scan_get_result(mac_ctx, *scan_filter, hBSSList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010297 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010298 sme_err(
10299 "csr_scan_get_result failed, status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010300 status);
10301 return false;
10302 }
10303 return true;
10304}
10305
Jeff Johnson29e2ca12016-10-14 12:50:38 -070010306static
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010307void csr_roam_roaming_state_disassoc_rsp_processor(tpAniSirGlobal pMac,
10308 tSirSmeDisassocRsp *pSmeRsp)
10309{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010310 tScanResultHandle hBSSList;
Jeff Johnson172237b2017-11-07 15:32:59 -080010311 struct csr_roam_info *roamInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010312 tCsrScanResultFilter *pScanFilter = NULL;
10313 uint32_t roamId = 0;
Jeff Johnson66ee8a92018-03-17 15:24:26 -070010314 struct csr_roam_profile *pCurRoamProfile = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010315 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010316 uint32_t sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010317 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010318 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
10319 tSirSmeDisassocRsp SmeDisassocRsp;
10320
10321 csr_ser_des_unpack_diassoc_rsp((uint8_t *) pSmeRsp, &SmeDisassocRsp);
10322 sessionId = SmeDisassocRsp.sessionId;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010323 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, "sessionId %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010324 sessionId);
10325
10326 if (csr_is_conn_state_infra(pMac, sessionId)) {
10327 pMac->roam.roamSession[sessionId].connectState =
10328 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10329 }
10330
10331 pSession = CSR_GET_SESSION(pMac, sessionId);
10332 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010333 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010334 return;
10335 }
10336
Kapil Guptaffa26022017-08-16 12:20:09 +053010337 roamInfo = qdf_mem_malloc(sizeof(*roamInfo));
10338
10339 if (!roamInfo) {
10340 sme_err("failed to allocate memory");
10341 return;
10342 }
10343
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010344 if (CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010345 sme_debug("***eCsrNothingToJoin***");
Krunal Sonif3583022017-02-10 17:18:10 -080010346 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010347 } else if (CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED(pMac, sessionId) ||
10348 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ(pMac, sessionId)) {
10349 if (eSIR_SME_SUCCESS == SmeDisassocRsp.statusCode) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010350 sme_debug("CSR force disassociated successful");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010351 /*
10352 * A callback to HDD will be issued from
10353 * csr_roam_complete so no need to do anything here
10354 */
10355 }
Krunal Sonif3583022017-02-10 17:18:10 -080010356 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010357 } else if (CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010358 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010359 "CSR SmeDisassocReq due to HO on session %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010360 sessionId);
10361 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010362 /*
10363 * First ensure if the roam profile is in the scan cache.
10364 * If not, post a reassoc failure and disconnect.
10365 */
10366 if (!csr_check_profile_in_scan_cache(pMac, &pScanFilter,
10367 pNeighborRoamInfo, &hBSSList))
10368 goto POST_ROAM_FAILURE;
10369
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010370 /* notify HDD about handoff and provide the BSSID too */
Kapil Guptaffa26022017-08-16 12:20:09 +053010371 roamInfo->reasonCode = eCsrRoamReasonBetterAP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010372
Kapil Guptaffa26022017-08-16 12:20:09 +053010373 qdf_copy_macaddr(&roamInfo->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010374 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid);
10375
Kapil Guptaffa26022017-08-16 12:20:09 +053010376 csr_roam_call_callback(pMac, sessionId, roamInfo, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010377 eCSR_ROAM_ROAMING_START,
10378 eCSR_ROAM_RESULT_NONE);
10379
10380 /*
10381 * Copy the connected profile to apply the same for this
10382 * connection as well
10383 */
Jeff Johnson66ee8a92018-03-17 15:24:26 -070010384 pCurRoamProfile = qdf_mem_malloc(sizeof(*pCurRoamProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010385 if (pCurRoamProfile != NULL) {
10386 /*
10387 * notify sub-modules like QoS etc. that handoff
10388 * happening
10389 */
10390 sme_qos_csr_event_ind(pMac, sessionId,
10391 SME_QOS_CSR_HANDOFF_ASSOC_REQ,
10392 NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010393 csr_roam_copy_profile(pMac, pCurRoamProfile,
10394 pSession->pCurRoamProfile);
Zhu Jianmin3c83a842018-03-14 20:50:24 +080010395 /*
10396 * After ensuring that the roam profile is in the scan
10397 * result list, and pSession->pCurRoamProfile is saved,
10398 * dequeue the command from the active list.
10399 */
10400 csr_dequeue_command(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010401 /* make sure to put it at the head of the cmd queue */
10402 status = csr_roam_issue_connect(pMac, sessionId,
10403 pCurRoamProfile, hBSSList,
10404 eCsrSmeIssuedAssocToSimilarAP,
10405 roamId, true, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010406 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010407 sme_err(
10408 "issue_connect failed. status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010409 status);
10410
10411 csr_release_profile(pMac, pCurRoamProfile);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010412 qdf_mem_free(pCurRoamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010413 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010414 qdf_mem_free(pScanFilter);
Kapil Guptaffa26022017-08-16 12:20:09 +053010415 qdf_mem_free(roamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010416 return;
Arif Hussainfdb25e22017-02-05 17:38:16 -080010417 } else {
Zhu Jianmin3c83a842018-03-14 20:50:24 +080010418 sme_err("pCurRoamProfile memory alloc failed");
10419 QDF_ASSERT(0);
10420 csr_dequeue_command(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010421 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010422 csr_scan_result_purge(pMac, hBSSList);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010423
10424POST_ROAM_FAILURE:
Kapil Guptaffa26022017-08-16 12:20:09 +053010425 csr_post_roam_failure(pMac, sessionId, roamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010426 pScanFilter, pCurRoamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010427 } /* else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) ) */
10428 else if (CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL(pMac, sessionId)) {
10429 /* Disassoc due to Reassoc failure falls into this codepath */
Krunal Sonif3583022017-02-10 17:18:10 -080010430 csr_roam_complete(pMac, eCsrJoinFailure, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010431 } else {
10432 if (eSIR_SME_SUCCESS == SmeDisassocRsp.statusCode) {
10433 /*
10434 * Successfully disassociated from the 'old' Bss.
10435 * We get Disassociate response in three conditions.
10436 * 1) The case where we are disasociating from an Infra
10437 * Bss to start an IBSS.
10438 * 2) When we are disassociating from an Infra Bss to
10439 * join an IBSS or a new infra network.
10440 * 3) Where we are doing an Infra to Infra roam between
10441 * networks with different SSIDs.
10442 * In all cases, we set the new Bss configuration here
10443 * and attempt to join
10444 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010445 sme_debug("Disassociated successfully");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010446 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010447 sme_err(
10448 "DisassocReq failed, statusCode= 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010449 SmeDisassocRsp.statusCode);
10450 }
10451 /* We are not done yet. Get the data and continue roaming */
Krunal Sonif3583022017-02-10 17:18:10 -080010452 csr_roam_reissue_roam_command(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010453 }
Kapil Guptaffa26022017-08-16 12:20:09 +053010454 qdf_mem_free(roamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010455}
10456
10457static void csr_roam_roaming_state_deauth_rsp_processor(tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010458 tSirSmeDeauthRsp *pSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010459{
10460 tSirResultCodes statusCode;
10461 /* No one is sending eWNI_SME_DEAUTH_REQ to PE. */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010462 sme_debug("is no-op");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010463 statusCode = csr_get_de_auth_rsp_status_code(pSmeRsp);
10464 pMac->roam.deauthRspStatus = statusCode;
10465 if (CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ(pMac, pSmeRsp->sessionId)) {
Krunal Sonif3583022017-02-10 17:18:10 -080010466 csr_roam_complete(pMac, eCsrNothingToJoin, NULL,
10467 pSmeRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010468 } else {
10469 if (eSIR_SME_SUCCESS == statusCode) {
10470 /* Successfully deauth from the 'old' Bss... */
10471 /* */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010472 sme_debug(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010473 "CSR SmeDeauthReq disassociated Successfully");
10474 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010475 sme_warn(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010476 "SmeDeauthReq failed with statusCode= 0x%08X",
10477 statusCode);
10478 }
10479 /* We are not done yet. Get the data and continue roaming */
Krunal Sonif3583022017-02-10 17:18:10 -080010480 csr_roam_reissue_roam_command(pMac, pSmeRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010481 }
10482}
10483
10484static void csr_roam_roaming_state_start_bss_rsp_processor(tpAniSirGlobal pMac,
10485 tSirSmeStartBssRsp *
10486 pSmeStartBssRsp)
10487{
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053010488 enum csr_roamcomplete_result result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010489
10490 if (eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010491 sme_debug("SmeStartBssReq Successful");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010492 result = eCsrStartBssSuccess;
10493 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010494 sme_warn("SmeStartBssReq failed with statusCode= 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010495 pSmeStartBssRsp->statusCode);
10496 /* Let csr_roam_complete decide what to do */
10497 result = eCsrStartBssFailure;
10498 }
Krunal Sonif3583022017-02-10 17:18:10 -080010499 csr_roam_complete(pMac, result, pSmeStartBssRsp,
10500 pSmeStartBssRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010501}
10502
10503/**
10504 * csr_roaming_state_msg_processor() - process roaming messages
10505 * @pMac: mac global context
10506 * @pMsgBuf: message buffer
10507 *
10508 * We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of
10509 * strucutres. It depends on how the message is constructed. If the message is
10510 * sent by lim_send_sme_rsp, the pMsgBuf is only a generic response and can only
10511 * be used as pointer to tSirSmeRsp. For the messages where sender allocates
10512 * memory for specific structures, then it can be cast accordingly.
10513 *
10514 * Return: status of operation
10515 */
10516void csr_roaming_state_msg_processor(tpAniSirGlobal pMac, void *pMsgBuf)
10517{
10518 tSirSmeRsp *pSmeRsp;
10519 tSmeIbssPeerInd *pIbssPeerInd;
Rajeev Kumara57db6b2017-11-14 16:36:59 -080010520 struct csr_roam_info *roam_info;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010521
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010522 pSmeRsp = (tSirSmeRsp *) pMsgBuf;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010523 sme_debug("Message %d[0x%04X] received in substate %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010524 pSmeRsp->messageType, pSmeRsp->messageType,
10525 mac_trace_getcsr_roam_sub_state(
10526 pMac->roam.curSubState[pSmeRsp->sessionId]));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010527
10528 switch (pSmeRsp->messageType) {
10529
10530 case eWNI_SME_JOIN_RSP:
10531 /* in Roaming state, process the Join response message... */
10532 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
10533 /* We sent a JOIN_REQ */
10534 csr_roam_join_rsp_processor(pMac,
10535 (tSirSmeJoinRsp *) pSmeRsp);
10536 break;
10537 case eWNI_SME_REASSOC_RSP:
10538 /* or the Reassociation response message... */
10539 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ(pMac, pSmeRsp->sessionId))
10540 csr_roam_roaming_state_reassoc_rsp_processor(pMac,
10541 (tpSirSmeJoinRsp) pSmeRsp);
10542 break;
10543 case eWNI_SME_STOP_BSS_RSP:
10544 /* or the Stop Bss response message... */
10545 csr_roam_roaming_state_stop_bss_rsp_processor(pMac, pSmeRsp);
10546 break;
10547 case eWNI_SME_DISASSOC_RSP:
10548 /* or the Disassociate response message... */
10549 if (CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ(pMac, pSmeRsp->sessionId)
10550 || CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN(pMac,
10551 pSmeRsp->sessionId)
10552 || CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL(pMac,
10553 pSmeRsp->sessionId)
10554 || CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED(pMac,
10555 pSmeRsp->sessionId)
10556 || CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE(pMac,
10557 pSmeRsp->sessionId)
10558 || CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac,
10559 pSmeRsp->sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010560 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010561 "eWNI_SME_DISASSOC_RSP subState = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010562 mac_trace_getcsr_roam_sub_state(
10563 pMac->roam.curSubState[pSmeRsp->sessionId]));
10564 csr_roam_roaming_state_disassoc_rsp_processor(pMac,
10565 (tSirSmeDisassocRsp *) pSmeRsp);
10566 }
10567 break;
10568 case eWNI_SME_DEAUTH_RSP:
10569 /* or the Deauthentication response message... */
Selvaraj, Sridharfd889b52016-06-24 12:37:04 +053010570 if (CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ(pMac, pSmeRsp->sessionId)) {
Krunal Soni72dba662017-02-15 20:13:17 -080010571 csr_remove_nonscan_cmd_from_pending_list(pMac,
Selvaraj, Sridharfd889b52016-06-24 12:37:04 +053010572 pSmeRsp->sessionId,
Selvaraj, Sridharfd889b52016-06-24 12:37:04 +053010573 eSmeCommandWmStatusChange);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010574 csr_roam_roaming_state_deauth_rsp_processor(pMac,
10575 (tSirSmeDeauthRsp *) pSmeRsp);
Selvaraj, Sridharfd889b52016-06-24 12:37:04 +053010576 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010577 break;
10578 case eWNI_SME_START_BSS_RSP:
10579 /* or the Start BSS response message... */
10580 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ(pMac,
10581 pSmeRsp->sessionId))
10582 csr_roam_roaming_state_start_bss_rsp_processor(pMac,
10583 (tSirSmeStartBssRsp *) pSmeRsp);
10584 break;
10585 /* In case CSR issues STOP_BSS, we need to tell HDD about peer departed
Jeff Johnson698eacd2018-05-12 17:00:03 -070010586 * because PE is removing them
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010587 */
10588 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10589 pIbssPeerInd = (tSmeIbssPeerInd *) pSmeRsp;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010590 sme_err("Peer departed ntf from LIM in joining state");
Rajeev Kumara57db6b2017-11-14 16:36:59 -080010591 roam_info = qdf_mem_malloc(sizeof(*roam_info));
10592 if (!roam_info) {
10593 sme_err("failed to allocate memory for roam_info");
10594 break;
10595 }
10596
10597 roam_info->staId = (uint8_t) pIbssPeerInd->staId;
Rajeev Kumara57db6b2017-11-14 16:36:59 -080010598 qdf_copy_macaddr(&roam_info->peerMac, &pIbssPeerInd->peer_addr);
10599 csr_roam_call_callback(pMac, pSmeRsp->sessionId, roam_info, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010600 eCSR_ROAM_CONNECT_STATUS_UPDATE,
10601 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
Rajeev Kumara57db6b2017-11-14 16:36:59 -080010602 qdf_mem_free(roam_info);
10603 roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010604 break;
10605 case eWNI_SME_GET_RSSI_REQ:
10606 {
10607 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq *) pMsgBuf;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010608
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010609 if (NULL != pGetRssiReq->rssiCallback)
10610 ((tCsrRssiCallback) pGetRssiReq->rssiCallback)
10611 (pGetRssiReq->lastRSSI, pGetRssiReq->staId,
10612 pGetRssiReq->pDevContext);
10613 else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010614 sme_err("pGetRssiReq->rssiCallback is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010615 }
10616 break;
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +053010617 case eWNI_SME_TRIGGER_SAE:
10618 sme_debug("Invoke SAE callback");
10619 csr_sae_callback(pMac, pSmeRsp);
10620 break;
10621
Vignesh Viswanathan200f5c12018-02-27 14:01:59 +053010622 case eWNI_SME_SETCONTEXT_RSP:
10623 csr_roam_check_for_link_status_change(pMac, pSmeRsp);
10624 break;
10625
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010626 default:
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010627 sme_debug("Unexpected message type: %d[0x%X] received in substate %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010628 pSmeRsp->messageType, pSmeRsp->messageType,
10629 mac_trace_getcsr_roam_sub_state(
10630 pMac->roam.curSubState[pSmeRsp->sessionId]));
10631 /* If we are connected, check the link status change */
10632 if (!csr_is_conn_state_disconnected(pMac, pSmeRsp->sessionId))
10633 csr_roam_check_for_link_status_change(pMac, pSmeRsp);
10634 break;
10635 }
10636}
10637
10638void csr_roam_joined_state_msg_processor(tpAniSirGlobal pMac, void *pMsgBuf)
10639{
10640 tSirSmeRsp *pSirMsg = (tSirSmeRsp *) pMsgBuf;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010641
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010642 switch (pSirMsg->messageType) {
10643 case eWNI_SME_GET_STATISTICS_RSP:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010644 sme_debug("Stats rsp from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010645 csr_roam_stats_rsp_processor(pMac, pSirMsg);
10646 break;
10647 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
10648 {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010649 struct csr_roam_session *pSession;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010650 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
Jeff Johnson172237b2017-11-07 15:32:59 -080010651 struct csr_roam_info roamInfo;
10652 struct csr_roam_info *roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010653 uint32_t sessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010654 QDF_STATUS status;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010655
10656 sme_debug("ASSOCIATION confirmation can be given to upper layer ");
Jeff Johnson172237b2017-11-07 15:32:59 -080010657 qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0);
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010658 roam_info = &roamInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010659 pUpperLayerAssocCnf =
10660 (tSirSmeAssocIndToUpperLayerCnf *) pMsgBuf;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010661 status = csr_roam_get_session_id_from_bssid(pMac,
10662 (struct qdf_mac_addr *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010663 pUpperLayerAssocCnf->
10664 bssId, &sessionId);
10665 pSession = CSR_GET_SESSION(pMac, sessionId);
10666
10667 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010668 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010669 return;
10670 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010671 /* send the status code as Success */
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010672 roam_info->statusCode = eSIR_SME_SUCCESS;
10673 roam_info->u.pConnectedProfile =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010674 &pSession->connectedProfile;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010675 roam_info->staId = (uint8_t) pUpperLayerAssocCnf->aid;
10676 roam_info->rsnIELen =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010677 (uint8_t) pUpperLayerAssocCnf->rsnIE.length;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010678 roam_info->prsnIE =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010679 pUpperLayerAssocCnf->rsnIE.rsnIEdata;
10680#ifdef FEATURE_WLAN_WAPI
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010681 roam_info->wapiIELen =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010682 (uint8_t) pUpperLayerAssocCnf->wapiIE.length;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010683 roam_info->pwapiIE =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010684 pUpperLayerAssocCnf->wapiIE.wapiIEdata;
10685#endif
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010686 roam_info->addIELen =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010687 (uint8_t) pUpperLayerAssocCnf->addIE.length;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010688 roam_info->paddIE =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010689 pUpperLayerAssocCnf->addIE.addIEdata;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010690 qdf_mem_copy(roam_info->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010691 pUpperLayerAssocCnf->peerMacAddr,
10692 sizeof(tSirMacAddr));
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010693 qdf_mem_copy(&roam_info->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010694 pUpperLayerAssocCnf->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010695 sizeof(struct qdf_mac_addr));
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010696 roam_info->wmmEnabledSta =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010697 pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010698 roam_info->timingMeasCap =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010699 pUpperLayerAssocCnf->timingMeasCap;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010700 qdf_mem_copy(&roam_info->chan_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010701 &pUpperLayerAssocCnf->chan_info,
10702 sizeof(tSirSmeChanInfo));
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010703 roam_info->ampdu = pUpperLayerAssocCnf->ampdu;
10704 roam_info->sgi_enable = pUpperLayerAssocCnf->sgi_enable;
10705 roam_info->tx_stbc = pUpperLayerAssocCnf->tx_stbc;
10706 roam_info->tx_stbc = pUpperLayerAssocCnf->rx_stbc;
10707 roam_info->ch_width = pUpperLayerAssocCnf->ch_width;
10708 roam_info->mode = pUpperLayerAssocCnf->mode;
10709 roam_info->max_supp_idx = pUpperLayerAssocCnf->max_supp_idx;
10710 roam_info->max_ext_idx = pUpperLayerAssocCnf->max_ext_idx;
10711 roam_info->max_mcs_idx = pUpperLayerAssocCnf->max_mcs_idx;
10712 roam_info->rx_mcs_map = pUpperLayerAssocCnf->rx_mcs_map;
10713 roam_info->tx_mcs_map = pUpperLayerAssocCnf->tx_mcs_map;
10714 roam_info->ecsa_capable = pUpperLayerAssocCnf->ecsa_capable;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053010715 if (pUpperLayerAssocCnf->ht_caps.present)
10716 roam_info->ht_caps = pUpperLayerAssocCnf->ht_caps;
10717 if (pUpperLayerAssocCnf->vht_caps.present)
10718 roam_info->vht_caps = pUpperLayerAssocCnf->vht_caps;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010719 if (CSR_IS_INFRA_AP(roam_info->u.pConnectedProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010720 pMac->roam.roamSession[sessionId].connectState =
10721 eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010722 roam_info->fReassocReq =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010723 pUpperLayerAssocCnf->reassocReq;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010724 status = csr_roam_call_callback(pMac, sessionId,
Jeff Johnsoneddf5442017-10-04 10:55:53 -070010725 roam_info, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010726 eCSR_ROAM_INFRA_IND,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010727 eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010728 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010729 }
10730 break;
10731 default:
10732 csr_roam_check_for_link_status_change(pMac, pSirMsg);
10733 break;
10734 }
10735}
10736
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010737QDF_STATUS csr_roam_issue_set_context_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010738 uint32_t sessionId,
10739 eCsrEncryptionType EncryptType,
10740 tSirBssDescription *pBssDescription,
10741 tSirMacAddr *bssId, bool addKey,
10742 bool fUnicast,
10743 tAniKeyDirection aniKeyDirection,
10744 uint8_t keyId, uint16_t keyLength,
10745 uint8_t *pKey, uint8_t paeRole)
10746{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010747 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010748 tAniEdType edType;
10749
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010750 sme_debug("sessionId: %d EncryptType: %d", sessionId, EncryptType);
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +053010751
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010752 if (eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010753 EncryptType = eCSR_ENCRYPT_TYPE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010754
10755 edType = csr_translate_encrypt_type_to_ed_type(EncryptType);
10756
10757 /*
10758 * Allow 0 keys to be set for the non-WPA encrypt types. For WPA encrypt
10759 * types, the num keys must be non-zero or LIM will reject the set
10760 * context (assumes the SET_CONTEXT does not occur until the keys are
10761 * distrubuted).
10762 */
10763 if (CSR_IS_ENC_TYPE_STATIC(EncryptType) || addKey) {
10764 tCsrRoamSetKey setKey;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010765
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010766 setKey.encType = EncryptType;
10767 setKey.keyDirection = aniKeyDirection;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010768 qdf_mem_copy(&setKey.peerMac, bssId, sizeof(struct
10769 qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010770 /* 0 for supplicant */
10771 setKey.paeRole = paeRole;
10772 /* Key index */
10773 setKey.keyId = keyId;
10774 setKey.keyLength = keyLength;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010775 if (keyLength)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010776 qdf_mem_copy(setKey.Key, pKey, keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010777 status = csr_roam_issue_set_key_command(pMac, sessionId,
10778 &setKey, 0);
10779 }
10780 return status;
10781}
10782
10783/**
10784 * csr_update_key_cmd() - update key info in set key command
10785 * @mac_ctx: mac global context
10786 * @session: roam session
10787 * @set_key: input set key command
10788 * @set_key_cmd: set key command to update
Krunal Sonid3676732017-05-10 14:12:18 -070010789 * @is_key_valid: indicates if key is valid
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010790 *
Krunal Sonid3676732017-05-10 14:12:18 -070010791 * This function will validate the key length, adjust if too long. It will
Jeff Johnson11d7c9d2018-05-06 15:44:09 -070010792 * update is_key_valid flag to false if some error has occurred key are local.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010793 *
10794 * Return: status of operation
10795 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010796static QDF_STATUS
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010797csr_update_key_cmd(tpAniSirGlobal mac_ctx, struct csr_roam_session *session,
10798 tCsrRoamSetKey *set_key, struct setkey_cmd *set_key_cmd,
Krunal Sonid3676732017-05-10 14:12:18 -070010799 bool *is_key_valid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010800{
10801 switch (set_key->encType) {
10802 case eCSR_ENCRYPT_TYPE_WEP40:
10803 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
10804 /* KeyLength maybe 0 for static WEP */
10805 if (set_key->keyLength) {
10806 if (set_key->keyLength < CSR_WEP40_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010807 sme_warn("Invalid WEP40 keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010808 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010809 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010810 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010811 }
10812
Krunal Sonid3676732017-05-10 14:12:18 -070010813 set_key_cmd->keyLength = CSR_WEP40_KEY_LEN;
10814 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010815 CSR_WEP40_KEY_LEN);
10816 }
Krunal Sonid3676732017-05-10 14:12:18 -070010817 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010818 break;
10819 case eCSR_ENCRYPT_TYPE_WEP104:
10820 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
10821 /* KeyLength maybe 0 for static WEP */
10822 if (set_key->keyLength) {
10823 if (set_key->keyLength < CSR_WEP104_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010824 sme_warn("Invalid WEP104 keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010825 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010826 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010827 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010828 }
10829
Krunal Sonid3676732017-05-10 14:12:18 -070010830 set_key_cmd->keyLength = CSR_WEP104_KEY_LEN;
10831 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010832 CSR_WEP104_KEY_LEN);
10833 }
Krunal Sonid3676732017-05-10 14:12:18 -070010834 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010835 break;
10836 case eCSR_ENCRYPT_TYPE_TKIP:
10837 if (set_key->keyLength < CSR_TKIP_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010838 sme_warn("Invalid TKIP keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010839 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010840 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010841 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010842 }
Krunal Sonid3676732017-05-10 14:12:18 -070010843 set_key_cmd->keyLength = CSR_TKIP_KEY_LEN;
10844 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010845 CSR_TKIP_KEY_LEN);
Krunal Sonid3676732017-05-10 14:12:18 -070010846 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010847 break;
10848 case eCSR_ENCRYPT_TYPE_AES:
10849 if (set_key->keyLength < CSR_AES_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010850 sme_warn("Invalid AES/CCMP keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010851 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010852 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010853 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010854 }
Krunal Sonid3676732017-05-10 14:12:18 -070010855 set_key_cmd->keyLength = CSR_AES_KEY_LEN;
10856 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010857 CSR_AES_KEY_LEN);
Krunal Sonid3676732017-05-10 14:12:18 -070010858 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010859 break;
Mukul Sharma05504ac2017-06-08 12:35:53 +053010860 case eCSR_ENCRYPT_TYPE_AES_GCMP:
10861 if (set_key->keyLength < CSR_AES_GCMP_KEY_LEN) {
10862 sme_warn(
10863 "Invalid AES_GCMP keylength [= %d]",
10864 set_key->keyLength);
10865 *is_key_valid = false;
10866 return QDF_STATUS_E_INVAL;
10867 }
10868 set_key_cmd->keyLength = CSR_AES_GCMP_KEY_LEN;
10869 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
10870 CSR_AES_GCMP_KEY_LEN);
10871 *is_key_valid = true;
10872 break;
10873 case eCSR_ENCRYPT_TYPE_AES_GCMP_256:
10874 if (set_key->keyLength < CSR_AES_GCMP_256_KEY_LEN) {
10875 sme_warn(
10876 "Invalid AES_GCMP_256 keylength [= %d]",
10877 set_key->keyLength);
10878 *is_key_valid = false;
10879 return QDF_STATUS_E_INVAL;
10880 }
10881 set_key_cmd->keyLength = CSR_AES_GCMP_256_KEY_LEN;
10882 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
10883 CSR_AES_GCMP_256_KEY_LEN);
10884 *is_key_valid = true;
10885 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010886#ifdef FEATURE_WLAN_WAPI
10887 case eCSR_ENCRYPT_TYPE_WPI:
10888 if (set_key->keyLength < CSR_WAPI_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010889 sme_warn("Invalid WAPI keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010890 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010891 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010892 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010893 }
Krunal Sonid3676732017-05-10 14:12:18 -070010894 set_key_cmd->keyLength = CSR_WAPI_KEY_LEN;
10895 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010896 CSR_WAPI_KEY_LEN);
10897 if (session->pCurRoamProfile) {
10898 session->pCurRoamProfile->negotiatedUCEncryptionType =
10899 eCSR_ENCRYPT_TYPE_WPI;
10900 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010901 sme_err("pCurRoamProfile is NULL");
Krunal Sonid3676732017-05-10 14:12:18 -070010902 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010903 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010904 }
Krunal Sonid3676732017-05-10 14:12:18 -070010905 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010906 break;
10907#endif /* FEATURE_WLAN_WAPI */
10908#ifdef FEATURE_WLAN_ESE
10909 case eCSR_ENCRYPT_TYPE_KRK:
10910 /* no need to enqueue KRK key request, since they are local */
Krunal Sonid3676732017-05-10 14:12:18 -070010911 *is_key_valid = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010912 if (set_key->keyLength < CSR_KRK_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010913 sme_warn("Invalid KRK keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010914 set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010915 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010916 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010917 qdf_mem_copy(session->eseCckmInfo.krk, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010918 CSR_KRK_KEY_LEN);
10919 session->eseCckmInfo.reassoc_req_num = 1;
10920 session->eseCckmInfo.krk_plumbed = true;
10921 break;
10922#ifdef WLAN_FEATURE_ROAM_OFFLOAD
10923 case eCSR_ENCRYPT_TYPE_BTK:
10924 /* no need to enqueue KRK key request, since they are local */
Krunal Sonid3676732017-05-10 14:12:18 -070010925 *is_key_valid = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010926 if (set_key->keyLength < SIR_BTK_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010927 sme_warn("LFR3:Invalid BTK keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010928 set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010929 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010930 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010931 qdf_mem_copy(session->eseCckmInfo.btk, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010932 SIR_BTK_KEY_LEN);
Padma, Santhosh Kumar2d1f77c2017-11-22 16:20:28 +053010933 /*
10934 * KRK and BTK are updated by upper layer back to back. Send
10935 * updated KRK and BTK together to FW here.
10936 */
10937 csr_roam_offload_scan(mac_ctx, session->sessionId,
10938 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
10939 REASON_ROAM_PSK_PMK_CHANGED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010940 break;
10941#endif
10942#endif /* FEATURE_WLAN_ESE */
10943#ifdef WLAN_FEATURE_11W
10944 /* Check for 11w BIP */
10945 case eCSR_ENCRYPT_TYPE_AES_CMAC:
10946 if (set_key->keyLength < CSR_AES_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010947 sme_warn("Invalid AES/CCMP keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010948 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010949 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010950 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010951 }
Krunal Sonid3676732017-05-10 14:12:18 -070010952 set_key_cmd->keyLength = CSR_AES_KEY_LEN;
10953 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010954 CSR_AES_KEY_LEN);
Krunal Sonid3676732017-05-10 14:12:18 -070010955 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010956 break;
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +053010957
10958 case eCSR_ENCRYPT_TYPE_AES_GMAC_128:
10959 if (set_key->keyLength < CSR_AES_GMAC_128_KEY_LEN) {
10960 sme_warn("Invalid AES GMAC 128 keylength [= %d]",
10961 set_key->keyLength);
10962 *is_key_valid = false;
10963 return QDF_STATUS_E_INVAL;
10964 }
10965 set_key_cmd->keyLength = CSR_AES_GMAC_128_KEY_LEN;
10966 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
10967 CSR_AES_GMAC_128_KEY_LEN);
10968 *is_key_valid = true;
10969 break;
10970
10971 case eCSR_ENCRYPT_TYPE_AES_GMAC_256:
10972 if (set_key->keyLength < CSR_AES_GMAC_256_KEY_LEN) {
10973 sme_warn("Invalid AES GMAC 256 keylength [= %d]",
10974 set_key->keyLength);
10975 *is_key_valid = false;
10976 return QDF_STATUS_E_INVAL;
10977 }
10978 set_key_cmd->keyLength = CSR_AES_GMAC_256_KEY_LEN;
10979 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
10980 CSR_AES_GMAC_256_KEY_LEN);
10981 *is_key_valid = true;
10982 break;
10983
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010984#endif /* WLAN_FEATURE_11W */
10985 default:
10986 /* for open security also we want to enqueue command */
Krunal Sonid3676732017-05-10 14:12:18 -070010987 *is_key_valid = true;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010988 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010989 } /* end of switch */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010990 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010991}
10992
10993
gaurank kathpalia14e2f912017-08-31 14:51:45 +053010994static QDF_STATUS csr_roam_issue_set_key_command(
10995tpAniSirGlobal mac_ctx, uint32_t session_id,
10996 tCsrRoamSetKey *set_key,
10997 uint32_t roam_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010998{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010999 QDF_STATUS status = QDF_STATUS_E_INVAL;
Krunal Sonid3676732017-05-10 14:12:18 -070011000 bool is_key_valid = true;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011001 struct setkey_cmd set_key_cmd;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011002#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_WAPI)
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011003 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011004
Krunal Sonid3676732017-05-10 14:12:18 -070011005 if (NULL == session) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011006 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Krunal Sonid3676732017-05-10 14:12:18 -070011007 "session %d not found", session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011008 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011009 }
11010#endif /* FEATURE_WLAN_ESE */
11011
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011012 qdf_mem_zero(&set_key_cmd, sizeof(struct setkey_cmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011013 /*
11014 * following function will validate the key length, Adjust if too long.
11015 * for static WEP the keys are not set thru' SetContextReq
11016 *
Jeff Johnson11d7c9d2018-05-06 15:44:09 -070011017 * it will update bool is_key_valid, to false if some error has occurred
Krunal Sonid3676732017-05-10 14:12:18 -070011018 * key are local. enqueue sme command only if is_key_valid is true
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011019 * status is indication of success or failure and will be returned to
11020 * called of current function if command is not enqueued due to key req
11021 * being local
11022 */
Krunal Sonid3676732017-05-10 14:12:18 -070011023 status = csr_update_key_cmd(mac_ctx, session, set_key,
11024 &set_key_cmd, &is_key_valid);
11025 if (is_key_valid) {
11026 set_key_cmd.roamId = roam_id;
11027 set_key_cmd.encType = set_key->encType;
11028 set_key_cmd.keyDirection = set_key->keyDirection;
11029 qdf_copy_macaddr(&set_key_cmd.peermac,
11030 &set_key->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011031 /* 0 for supplicant */
Krunal Sonid3676732017-05-10 14:12:18 -070011032 set_key_cmd.paeRole = set_key->paeRole;
11033 set_key_cmd.keyId = set_key->keyId;
11034 qdf_mem_copy(set_key_cmd.keyRsc, set_key->keyRsc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011035 CSR_MAX_RSC_LEN);
11036 /*
11037 * Always put set key to the head of the Q because it is the
11038 * only thing to get executed in case of WT_KEY state
11039 */
Krunal Sonid3676732017-05-10 14:12:18 -070011040 sme_debug("set key req for session-%d authtype-%d",
11041 session_id, set_key->encType);
11042 status = csr_roam_send_set_key_cmd(mac_ctx, session_id,
11043 &set_key_cmd);
11044 if (!QDF_IS_STATUS_SUCCESS(status))
11045 sme_err("fail to send message status = %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011046 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011047 return status;
11048}
11049
Krunal Sonid3676732017-05-10 14:12:18 -070011050QDF_STATUS csr_roam_send_set_key_cmd(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011051 uint32_t session_id,
11052 struct setkey_cmd *set_key_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011053{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011054 QDF_STATUS status;
Krunal Sonid3676732017-05-10 14:12:18 -070011055 uint8_t num_keys = (set_key_cmd->keyLength) ? 1 : 0;
11056 tAniEdType ed_type = csr_translate_encrypt_type_to_ed_type(
11057 set_key_cmd->encType);
11058 bool unicast = (set_key_cmd->peermac.bytes[0] == 0xFF) ? false : true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011059#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011060 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011061
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011062 WLAN_HOST_DIAG_EVENT_DEF(setKeyEvent,
11063 host_event_wlan_security_payload_type);
11064
Krunal Sonid3676732017-05-10 14:12:18 -070011065 if (NULL == session) {
11066 sme_err("session %d not found", session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011067 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011068 }
11069
Krunal Sonid3676732017-05-10 14:12:18 -070011070 if (eSIR_ED_NONE != ed_type) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011071 qdf_mem_set(&setKeyEvent,
Krunal Sonid3676732017-05-10 14:12:18 -070011072 sizeof(host_event_wlan_security_payload_type), 0);
11073 if (qdf_is_macaddr_group(&set_key_cmd->peermac)) {
Abhishek Singh7a995582016-04-27 13:53:36 +053011074 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011075 setKeyEvent.encryptionModeMulticast =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011076 (uint8_t) diag_enc_type_from_csr_type(
Krunal Sonid3676732017-05-10 14:12:18 -070011077 set_key_cmd->encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011078 setKeyEvent.encryptionModeUnicast =
Krunal Sonid3676732017-05-10 14:12:18 -070011079 (uint8_t) diag_enc_type_from_csr_type(session->
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011080 connectedProfile.
11081 EncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011082 } else {
Abhishek Singh7a995582016-04-27 13:53:36 +053011083 setKeyEvent.eventId =
11084 WLAN_SECURITY_EVENT_SET_UNICAST_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011085 setKeyEvent.encryptionModeUnicast =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011086 (uint8_t) diag_enc_type_from_csr_type(
Krunal Sonid3676732017-05-10 14:12:18 -070011087 set_key_cmd->encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011088 setKeyEvent.encryptionModeMulticast =
Krunal Sonid3676732017-05-10 14:12:18 -070011089 (uint8_t) diag_enc_type_from_csr_type(session->
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011090 connectedProfile.
11091 mcEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011092 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011093 qdf_mem_copy(setKeyEvent.bssid,
Krunal Sonid3676732017-05-10 14:12:18 -070011094 session->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053011095 QDF_MAC_ADDR_SIZE);
Krunal Sonid3676732017-05-10 14:12:18 -070011096 if (CSR_IS_ENC_TYPE_STATIC(set_key_cmd->encType)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011097 uint32_t defKeyId;
11098 /* It has to be static WEP here */
Krunal Sonid3676732017-05-10 14:12:18 -070011099 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(mac_ctx,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011100 WNI_CFG_WEP_DEFAULT_KEYID,
11101 &defKeyId))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011102 setKeyEvent.keyId = (uint8_t) defKeyId;
11103 }
11104 } else {
Krunal Sonid3676732017-05-10 14:12:18 -070011105 setKeyEvent.keyId = set_key_cmd->keyId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011106 }
11107 setKeyEvent.authMode =
Krunal Sonid3676732017-05-10 14:12:18 -070011108 (uint8_t) diag_auth_type_from_csr_type(session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011109 connectedProfile.
11110 AuthType);
11111 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
11112 }
11113#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
Krunal Sonid3676732017-05-10 14:12:18 -070011114 if (csr_is_set_key_allowed(mac_ctx, session_id)) {
11115 status = csr_send_mb_set_context_req_msg(mac_ctx, session_id,
11116 set_key_cmd->peermac,
11117 num_keys, ed_type, unicast,
11118 set_key_cmd->keyDirection,
11119 set_key_cmd->keyId,
11120 set_key_cmd->keyLength,
11121 set_key_cmd->Key,
11122 set_key_cmd->paeRole,
11123 set_key_cmd->keyRsc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011124 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011125 sme_warn(" cannot process not connected");
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011126 /* Set this status so the error handling take
11127 * care of the case.
11128 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011129 status = QDF_STATUS_CSR_WRONG_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011130 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011131 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011132 sme_err(" error status %d", status);
Krunal Sonid3676732017-05-10 14:12:18 -070011133 csr_roam_call_callback(mac_ctx, session_id, NULL,
11134 set_key_cmd->roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011135 eCSR_ROAM_SET_KEY_COMPLETE,
11136 eCSR_ROAM_RESULT_FAILURE);
11137#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Krunal Sonid3676732017-05-10 14:12:18 -070011138 if (eSIR_ED_NONE != ed_type) {
11139 if (qdf_is_macaddr_group(&set_key_cmd->peermac))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011140 setKeyEvent.eventId =
Abhishek Singh7a995582016-04-27 13:53:36 +053011141 WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Krunal Sonid3676732017-05-10 14:12:18 -070011142 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011143 setKeyEvent.eventId =
Abhishek Singh7a995582016-04-27 13:53:36 +053011144 WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011145 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
11146 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent,
11147 EVENT_WLAN_SECURITY);
11148 }
11149#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
11150 }
11151 return status;
11152}
11153
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011154QDF_STATUS csr_roam_set_key(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011155 tCsrRoamSetKey *pSetKey, uint32_t roamId)
11156{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011157 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011158
11159 if (!csr_is_set_key_allowed(pMac, sessionId)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011160 status = QDF_STATUS_CSR_WRONG_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011161 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011162 status = csr_roam_issue_set_key_command(pMac, sessionId,
11163 pSetKey, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011164 }
11165 return status;
11166}
11167
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053011168#ifdef WLAN_FEATURE_FILS_SK
11169/*
11170 * csr_create_fils_realm_hash: API to create hash using realm
11171 * @fils_con_info: fils connection info obtained from supplicant
11172 * @tmp_hash: pointer to new hash
11173 *
11174 * Return: None
11175 */
11176static bool
11177csr_create_fils_realm_hash(struct cds_fils_connection_info *fils_con_info,
11178 uint8_t *tmp_hash)
11179{
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053011180 uint8_t *hash;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053011181 uint8_t *data[1];
11182
11183 if (!fils_con_info->realm_len)
11184 return false;
11185
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053011186 hash = qdf_mem_malloc(SHA256_DIGEST_SIZE);
11187 if (!hash) {
11188 sme_err("malloc fails in fils realm");
11189 return false;
11190 }
11191
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053011192 data[0] = fils_con_info->realm;
11193 qdf_get_hash(SHA256_CRYPTO_TYPE, 1, data,
11194 &fils_con_info->realm_len, hash);
11195 qdf_trace_hex_dump(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG,
11196 hash, SHA256_DIGEST_SIZE);
11197 qdf_mem_copy(tmp_hash, hash, 2);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053011198 qdf_mem_free(hash);
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053011199 return true;
11200}
11201
11202/*
11203 * csr_update_fils_scan_filter: update scan filter in case of fils session
11204 * @scan_fltr: pointer to scan filer
11205 * @profile: csr profile pointer
11206 *
11207 * Return: None
11208 */
11209static void csr_update_fils_scan_filter(tCsrScanResultFilter *scan_fltr,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070011210 struct csr_roam_profile *profile)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053011211{
11212 if (profile->fils_con_info &&
11213 profile->fils_con_info->is_fils_connection) {
11214 uint8_t realm_hash[2];
11215
11216 sme_debug("creating realm based on fils info %d",
11217 profile->fils_con_info->is_fils_connection);
11218 scan_fltr->realm_check = csr_create_fils_realm_hash(
11219 profile->fils_con_info, realm_hash);
11220 memcpy(scan_fltr->fils_realm, realm_hash,
11221 sizeof(uint8_t) * 2);
11222 }
11223
11224}
11225#else
11226static void csr_update_fils_scan_filter(tCsrScanResultFilter *scan_fltr,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070011227 struct csr_roam_profile *profile)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053011228{ }
11229#endif
11230
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011231/*
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011232 * Prepare a filter base on a profile for parsing the scan results.
11233 * Upon successful return, caller MUST call csr_free_scan_filter on
11234 *pScanFilter when it is done with the filter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011235 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011236QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011237csr_roam_prepare_filter_from_profile(tpAniSirGlobal mac_ctx,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070011238 struct csr_roam_profile *profile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011239 tCsrScanResultFilter *scan_fltr)
11240{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011241 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011242 uint32_t size = 0;
11243 uint8_t idx = 0;
11244 tCsrChannelInfo *fltr_ch_info = &scan_fltr->ChannelInfo;
11245 tCsrChannelInfo *profile_ch_info = &profile->ChannelInfo;
11246 struct roam_ext_params *roam_params;
11247 uint8_t i;
11248
11249 roam_params = &mac_ctx->roam.configParam.roam_params;
11250
11251 if (profile->BSSIDs.numOfBSSIDs) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011252 size = sizeof(struct qdf_mac_addr) * profile->BSSIDs.
11253 numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011254 scan_fltr->BSSIDs.bssid = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011255 if (NULL == scan_fltr->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011256 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011257 goto free_filter;
11258 }
11259 scan_fltr->BSSIDs.numOfBSSIDs = profile->BSSIDs.numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011260 qdf_mem_copy(scan_fltr->BSSIDs.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011261 profile->BSSIDs.bssid, size);
11262 }
11263
11264 if (profile->SSIDs.numOfSSIDs) {
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070011265 scan_fltr->SSIDs.numOfSSIDs = profile->SSIDs.numOfSSIDs;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011266 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011267 ("No of Allowed List:%d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011268 roam_params->num_ssid_allowed_list);
11269 if (scan_fltr->scan_filter_for_roam
11270 && roam_params->num_ssid_allowed_list) {
11271 scan_fltr->SSIDs.numOfSSIDs =
11272 roam_params->num_ssid_allowed_list;
11273 size = sizeof(tCsrSSIDInfo) *
11274 scan_fltr->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011275 scan_fltr->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011276 if (NULL == scan_fltr->SSIDs.SSIDList)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011277 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011278 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011279 status = QDF_STATUS_SUCCESS;
11280 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011281 goto free_filter;
11282 for (i = 0;
11283 i < roam_params->num_ssid_allowed_list;
11284 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011285 qdf_mem_copy((void *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011286 scan_fltr->SSIDs.SSIDList[i].SSID.ssId,
11287 roam_params->ssid_allowed_list[i].ssId,
11288 roam_params->ssid_allowed_list[i].length);
11289 scan_fltr->SSIDs.SSIDList[i].SSID.length =
11290 roam_params->ssid_allowed_list[i].length;
11291 scan_fltr->SSIDs.SSIDList[i].handoffPermitted =
11292 1;
11293 scan_fltr->SSIDs.SSIDList[i].ssidHidden = 0;
11294 }
11295 } else {
11296 size = sizeof(tCsrSSIDInfo) *
11297 profile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011298 scan_fltr->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011299 if (NULL == scan_fltr->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011300 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011301 goto free_filter;
11302 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011303 qdf_mem_copy(scan_fltr->SSIDs.SSIDList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011304 profile->SSIDs.SSIDList, size);
11305 }
11306 }
11307
11308 if (!profile_ch_info->ChannelList
11309 || (profile_ch_info->ChannelList[0] == 0)) {
11310 fltr_ch_info->numOfChannels = 0;
11311 fltr_ch_info->ChannelList = NULL;
11312 } else if (profile_ch_info->numOfChannels) {
11313 fltr_ch_info->numOfChannels = 0;
11314 fltr_ch_info->ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011315 qdf_mem_malloc(sizeof(*(fltr_ch_info->ChannelList)) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011316 profile_ch_info->numOfChannels);
11317 if (NULL == fltr_ch_info->ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011318 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011319 goto free_filter;
11320 }
11321
11322 for (idx = 0; idx < profile_ch_info->numOfChannels; idx++) {
11323 if (csr_roam_is_channel_valid(mac_ctx,
11324 profile_ch_info->ChannelList[idx])) {
11325 fltr_ch_info->
11326 ChannelList[fltr_ch_info->numOfChannels]
11327 = profile_ch_info->ChannelList[idx];
11328 fltr_ch_info->numOfChannels++;
11329 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011330 sme_debug(
11331 "Channel (%d) is invalid",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011332 profile_ch_info->ChannelList[idx]);
11333 }
11334 }
11335 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011336 sme_err("Channel list empty");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011337 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011338 goto free_filter;
11339 }
11340 scan_fltr->uapsd_mask = profile->uapsd_mask;
11341 scan_fltr->authType = profile->AuthType;
11342 scan_fltr->EncryptionType = profile->EncryptionType;
11343 scan_fltr->mcEncryptionType = profile->mcEncryptionType;
11344 scan_fltr->BSSType = profile->BSSType;
11345 scan_fltr->phyMode = profile->phyMode;
11346#ifdef FEATURE_WLAN_WAPI
11347 /*
11348 * check if user asked for WAPI with 11n or auto mode, in that
11349 * case modify the phymode to 11g
11350 */
11351 if (csr_is_profile_wapi(profile)) {
11352 if (scan_fltr->phyMode & eCSR_DOT11_MODE_11n)
11353 scan_fltr->phyMode &= ~eCSR_DOT11_MODE_11n;
11354 if (scan_fltr->phyMode & eCSR_DOT11_MODE_AUTO)
11355 scan_fltr->phyMode &= ~eCSR_DOT11_MODE_AUTO;
11356 if (!scan_fltr->phyMode)
11357 scan_fltr->phyMode = eCSR_DOT11_MODE_11g;
11358 }
11359#endif /* FEATURE_WLAN_WAPI */
11360 /*Save the WPS info */
11361 scan_fltr->bWPSAssociation = profile->bWPSAssociation;
11362 scan_fltr->bOSENAssociation = profile->bOSENAssociation;
11363 if (profile->countryCode[0]) {
11364 /*
11365 * This causes the matching function to use countryCode as one
11366 * of the criteria.
11367 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011368 qdf_mem_copy(scan_fltr->countryCode, profile->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011369 WNI_CFG_COUNTRY_CODE_LEN);
11370 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011371 if (profile->MDID.mdiePresent) {
11372 scan_fltr->MDID.mdiePresent = 1;
11373 scan_fltr->MDID.mobilityDomain = profile->MDID.mobilityDomain;
11374 }
Abhishek Singh3c9910e2017-01-06 17:56:47 +053011375 qdf_mem_copy(scan_fltr->bssid_hint.bytes,
11376 profile->bssid_hint.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011377
11378#ifdef WLAN_FEATURE_11W
11379 /* Management Frame Protection */
11380 scan_fltr->MFPEnabled = profile->MFPEnabled;
11381 scan_fltr->MFPRequired = profile->MFPRequired;
11382 scan_fltr->MFPCapable = profile->MFPCapable;
11383#endif
11384 scan_fltr->csrPersona = profile->csrPersona;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053011385 csr_update_fils_scan_filter(scan_fltr, profile);
Abhishek Singhedb73602018-02-20 15:20:26 +053011386 scan_fltr->force_rsne_override = profile->force_rsne_override;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011387
11388free_filter:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011389 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011390 csr_free_scan_filter(mac_ctx, scan_fltr);
11391
11392 return status;
11393}
11394
Jeff Johnson29e2ca12016-10-14 12:50:38 -070011395static
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011396bool csr_roam_issue_wm_status_change(tpAniSirGlobal pMac, uint32_t sessionId,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011397 enum csr_roam_wmstatus_changetypes Type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011398 tSirSmeRsp *pSmeRsp)
11399{
11400 bool fCommandQueued = false;
11401 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011402
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011403 do {
11404 /* Validate the type is ok... */
11405 if ((eCsrDisassociated != Type)
11406 && (eCsrDeauthenticated != Type))
11407 break;
11408 pCommand = csr_get_command_buffer(pMac);
11409 if (!pCommand) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011410 sme_err(" fail to get command buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011411 break;
11412 }
11413 /* Change the substate in case it is waiting for key */
11414 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
11415 csr_roam_stop_wait_for_key_timer(pMac);
11416 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
11417 sessionId);
11418 }
11419 pCommand->command = eSmeCommandWmStatusChange;
11420 pCommand->sessionId = (uint8_t) sessionId;
11421 pCommand->u.wmStatusChangeCmd.Type = Type;
11422 if (eCsrDisassociated == Type) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011423 qdf_mem_copy(&pCommand->u.wmStatusChangeCmd.u.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011424 DisassocIndMsg, pSmeRsp,
11425 sizeof(pCommand->u.wmStatusChangeCmd.u.
11426 DisassocIndMsg));
11427 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011428 qdf_mem_copy(&pCommand->u.wmStatusChangeCmd.u.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011429 DeauthIndMsg, pSmeRsp,
11430 sizeof(pCommand->u.wmStatusChangeCmd.u.
11431 DeauthIndMsg));
11432 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011433 if (QDF_IS_STATUS_SUCCESS
Krunal Soniaa179db2017-10-13 19:28:17 -070011434 (csr_queue_sme_command(pMac, pCommand, true)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011435 fCommandQueued = true;
Krunal Soniaa179db2017-10-13 19:28:17 -070011436 else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011437 sme_err("fail to send message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011438
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011439 /* AP has issued Dissac/Deauth, Set the operating mode
11440 * value to configured value
11441 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011442 csr_set_default_dot11_mode(pMac);
11443 } while (0);
11444 return fCommandQueued;
11445}
11446
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011447static QDF_STATUS csr_send_snr_request(void *pGetRssiReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011448{
11449 void *wma_handle;
11450
Anurag Chouhan6d760662016-02-20 16:05:43 +053011451 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011452 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011453 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011454 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011455 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011456 }
11457
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011458 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011459 wma_send_snr_request(wma_handle, pGetRssiReq)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011460 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011461 "Failed to Trigger wma stats request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011462 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011463 }
11464
11465 /* dont send success, otherwise call back
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011466 * will released with out values
11467 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011468 return QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011469}
11470
11471static void csr_update_rssi(tpAniSirGlobal pMac, void *pMsg)
11472{
11473 int8_t rssi = 0;
11474 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq *) pMsg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011475 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011476
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011477 if (pGetRssiReq) {
Jeff Johnson8bd23352017-09-26 11:39:24 -070011478 qdf_status = csr_send_snr_request(pGetRssiReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011479
11480 if (NULL != pGetRssiReq->rssiCallback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011481 if (qdf_status != QDF_STATUS_E_BUSY)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011482 ((tCsrRssiCallback) (pGetRssiReq->rssiCallback))
11483 (rssi, pGetRssiReq->staId,
11484 pGetRssiReq->pDevContext);
11485 else
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011486 sme_debug("rssi request is posted. waiting for reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011487 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011488 sme_err("GetRssiReq->rssiCallback is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011489 return;
11490 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011491 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011492 sme_err("pGetRssiReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011493
11494}
11495
11496static void csr_update_snr(tpAniSirGlobal pMac, void *pMsg)
11497{
11498 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq *) pMsg;
11499
11500 if (pGetSnrReq) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011501 if (QDF_STATUS_SUCCESS != wma_get_snr(pGetSnrReq)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011502 sme_err("Error in wma_get_snr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011503 return;
11504 }
11505
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011506 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011507 sme_err("pGetSnrReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011508}
11509
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011510static QDF_STATUS csr_send_reset_ap_caps_changed(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +053011511 struct qdf_mac_addr *bssId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011512{
11513 tpSirResetAPCapsChange pMsg;
11514 uint16_t len;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011515 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011516
11517 /* Create the message and send to lim */
11518 len = sizeof(tSirResetAPCapsChange);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011519 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011520 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011521 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011522 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011523 status = QDF_STATUS_SUCCESS;
Srinivas Girigowda40567b92015-09-24 15:17:25 -070011524
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011525 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011526 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
11527 pMsg->length = len;
Anurag Chouhanc5548422016-02-24 18:33:27 +053011528 qdf_copy_macaddr(&pMsg->bssId, bssId);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011529 sme_debug(
11530 "CSR reset caps change for Bssid= " MAC_ADDRESS_STR,
Srinivas Girigowda40567b92015-09-24 15:17:25 -070011531 MAC_ADDR_ARRAY(pMsg->bssId.bytes));
Rajeev Kumard138ac52017-01-30 18:38:37 -080011532 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011533 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011534 sme_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011535 }
11536 return status;
11537}
11538
11539static void
11540csr_roam_chk_lnk_assoc_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11541{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011542 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011543 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011544 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080011545 struct csr_roam_info *roam_info_ptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011546 tSirSmeAssocInd *pAssocInd;
Jeff Johnson172237b2017-11-07 15:32:59 -080011547 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011548
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011549 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011550 sme_debug("Receive WNI_SME_ASSOC_IND from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011551 pAssocInd = (tSirSmeAssocInd *) msg_ptr;
11552 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011553 (struct qdf_mac_addr *) pAssocInd->bssId,
11554 &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011555 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011556 sme_debug("Couldn't find session_id for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011557 return;
11558 }
11559 session = CSR_GET_SESSION(mac_ctx, sessionId);
11560 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011561 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011562 return;
11563 }
11564 roam_info_ptr = &roam_info;
11565 /* Required for indicating the frames to upper layer */
11566 roam_info_ptr->assocReqLength = pAssocInd->assocReqLength;
11567 roam_info_ptr->assocReqPtr = pAssocInd->assocReqPtr;
11568 roam_info_ptr->beaconPtr = pAssocInd->beaconPtr;
11569 roam_info_ptr->beaconLength = pAssocInd->beaconLength;
11570 roam_info_ptr->statusCode = eSIR_SME_SUCCESS;
11571 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
11572 roam_info_ptr->staId = (uint8_t) pAssocInd->staId;
11573 roam_info_ptr->rsnIELen = (uint8_t) pAssocInd->rsnIE.length;
11574 roam_info_ptr->prsnIE = pAssocInd->rsnIE.rsnIEdata;
11575#ifdef FEATURE_WLAN_WAPI
11576 roam_info_ptr->wapiIELen = (uint8_t) pAssocInd->wapiIE.length;
11577 roam_info_ptr->pwapiIE = pAssocInd->wapiIE.wapiIEdata;
11578#endif
11579 roam_info_ptr->addIELen = (uint8_t) pAssocInd->addIE.length;
11580 roam_info_ptr->paddIE = pAssocInd->addIE.addIEdata;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011581 qdf_mem_copy(roam_info_ptr->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011582 pAssocInd->peerMacAddr,
11583 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011584 qdf_mem_copy(roam_info_ptr->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011585 pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053011586 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011587 roam_info_ptr->wmmEnabledSta = pAssocInd->wmmEnabledSta;
11588 roam_info_ptr->timingMeasCap = pAssocInd->timingMeasCap;
gaolez7bb1e742017-03-21 16:37:38 +080011589 roam_info_ptr->ecsa_capable = pAssocInd->ecsa_capable;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011590 qdf_mem_copy(&roam_info_ptr->chan_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011591 &pAssocInd->chan_info,
11592 sizeof(tSirSmeChanInfo));
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053011593
11594 if (pAssocInd->HTCaps.present)
11595 qdf_mem_copy(&roam_info_ptr->ht_caps,
11596 &pAssocInd->HTCaps,
11597 sizeof(tDot11fIEHTCaps));
11598 if (pAssocInd->VHTCaps.present)
11599 qdf_mem_copy(&roam_info_ptr->vht_caps,
11600 &pAssocInd->VHTCaps,
11601 sizeof(tDot11fIEVHTCaps));
11602
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011603 if (CSR_IS_INFRA_AP(roam_info_ptr->u.pConnectedProfile)) {
11604 if (session->pCurRoamProfile &&
11605 CSR_IS_ENC_TYPE_STATIC(
11606 session->pCurRoamProfile->negotiatedUCEncryptionType)) {
11607 /* NO keys... these key parameters don't matter. */
11608 csr_roam_issue_set_context_req(mac_ctx, sessionId,
11609 session->pCurRoamProfile->negotiatedUCEncryptionType,
11610 session->pConnectBssDesc,
11611 &(roam_info_ptr->peerMac.bytes),
11612 false, true, eSIR_TX_RX, 0, 0, NULL, 0);
11613 roam_info_ptr->fAuthRequired = false;
11614 } else {
11615 roam_info_ptr->fAuthRequired = true;
11616 }
11617 status = csr_roam_call_callback(mac_ctx, sessionId,
11618 roam_info_ptr, 0, eCSR_ROAM_INFRA_IND,
11619 eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011620 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011621 /* Refused due to Mac filtering */
11622 roam_info_ptr->statusCode = eSIR_SME_ASSOC_REFUSED;
11623 }
11624
11625 /* Send Association completion message to PE */
11626 status = csr_send_assoc_cnf_msg(mac_ctx, pAssocInd, status);
11627 /*
11628 * send a message to CSR itself just to avoid the EAPOL frames going
11629 * OTA before association response
11630 */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070011631 if (CSR_IS_INFRA_AP(roam_info_ptr->u.pConnectedProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011632 && (roam_info_ptr->statusCode != eSIR_SME_ASSOC_REFUSED)) {
11633 roam_info_ptr->fReassocReq = pAssocInd->reassocReq;
11634 status = csr_send_assoc_ind_to_upper_layer_cnf_msg(mac_ctx,
11635 pAssocInd, status, sessionId);
11636 }
11637}
11638
11639static void
11640csr_roam_chk_lnk_disassoc_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11641{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011642 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011643 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011644 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011645 tSirSmeDisassocInd *pDisassocInd;
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011646 tSmeCmd *cmd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011647
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011648 cmd = qdf_mem_malloc(sizeof(*cmd));
11649 if (NULL == cmd) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011650 sme_err("memory allocation failed for size: %zu", sizeof(*cmd));
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011651 return;
11652 }
11653
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011654 /*
11655 * Check if AP dis-associated us because of MIC failure. If so,
11656 * then we need to take action immediately and not wait till the
11657 * the WmStatusChange requests is pushed and processed
11658 */
11659 pDisassocInd = (tSirSmeDisassocInd *) msg_ptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011660 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080011661 &pDisassocInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011662 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011663 sme_err("Session Id not found for BSSID "MAC_ADDRESS_STR,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080011664 MAC_ADDR_ARRAY(pDisassocInd->bssid.bytes));
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011665 qdf_mem_free(cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011666 return;
11667 }
11668
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011669 sme_err("DISASSOCIATION from peer =" MAC_ADDRESS_STR "reason: %d status: %d session: %d",
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080011670 MAC_ADDR_ARRAY(pDisassocInd->peer_macaddr.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011671 pDisassocInd->reasonCode,
Srinivas Girigowda0ee96442016-08-17 19:10:56 -070011672 pDisassocInd->statusCode, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011673 /*
11674 * If we are in neighbor preauth done state then on receiving
11675 * disassoc or deauth we dont roam instead we just disassoc
11676 * from current ap and then go to disconnected state
11677 * This happens for ESE and 11r FT connections ONLY.
11678 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011679 if (csr_roam_is11r_assoc(mac_ctx, sessionId) &&
11680 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
11681 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
11682 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011683#ifdef FEATURE_WLAN_ESE
11684 if (csr_roam_is_ese_assoc(mac_ctx, sessionId) &&
11685 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
11686 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
11687 mac_ctx, sessionId);
11688#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011689 if (csr_roam_is_fast_roam_enabled(mac_ctx, sessionId) &&
11690 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
11691 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
11692 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011693 session = CSR_GET_SESSION(mac_ctx, sessionId);
11694 if (!session) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011695 sme_err("session: %d not found", sessionId);
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011696 qdf_mem_free(cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011697 return;
11698 }
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053011699
11700 /* Update the disconnect stats */
11701 session->disconnect_stats.disconnection_cnt++;
11702 session->disconnect_stats.disassoc_by_peer++;
11703
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011704 if (csr_is_conn_state_infra(mac_ctx, sessionId))
11705 session->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
11706#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11707 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
11708 SME_QOS_CSR_DISCONNECT_IND, NULL);
11709#endif
11710 csr_roam_link_down(mac_ctx, sessionId);
11711 csr_roam_issue_wm_status_change(mac_ctx, sessionId,
11712 eCsrDisassociated, msg_ptr);
11713 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011714 /*
11715 * STA/P2P client got disassociated so remove any pending
11716 * deauth commands in sme pending list
11717 */
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011718 cmd->command = eSmeCommandRoam;
11719 cmd->sessionId = (uint8_t) sessionId;
11720 cmd->u.roamCmd.roamReason = eCsrForcedDeauthSta;
11721 qdf_mem_copy(cmd->u.roamCmd.peerMac,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080011722 pDisassocInd->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053011723 QDF_MAC_ADDR_SIZE);
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011724 csr_roam_remove_duplicate_command(mac_ctx, sessionId, cmd,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011725 eCsrForcedDeauthSta);
11726 }
Aggarwal Nishank51dece42016-08-24 12:11:19 +053011727 qdf_mem_free(cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011728}
11729
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053011730/**
11731 * csr_roam_send_disconnect_done_indication() - Send disconnect ind to HDD.
11732 *
11733 * @mac_ctx: mac global context
11734 * @msg_ptr: incoming message
11735 *
11736 * This function gives final disconnect event to HDD after all cleanup in
11737 * lower layers is done.
11738 *
11739 * Return: None
11740 */
11741static void
11742csr_roam_send_disconnect_done_indication(tpAniSirGlobal mac_ctx, tSirSmeRsp
11743 *msg_ptr)
11744{
11745 struct sir_sme_discon_done_ind *discon_ind =
11746 (struct sir_sme_discon_done_ind *)(msg_ptr);
Jeff Johnson172237b2017-11-07 15:32:59 -080011747 struct csr_roam_info roam_info;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011748 struct csr_roam_session *session;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053011749
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011750 sme_debug("eWNI_SME_DISCONNECT_DONE_IND RC:%d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053011751 discon_ind->reason_code);
11752
11753 if (CSR_IS_SESSION_VALID(mac_ctx, discon_ind->session_id)) {
11754 roam_info.reasonCode = discon_ind->reason_code;
11755 roam_info.statusCode = eSIR_SME_STA_NOT_ASSOCIATED;
11756 qdf_mem_copy(roam_info.peerMac.bytes, discon_ind->peer_mac,
11757 ETH_ALEN);
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053011758
11759 roam_info.rssi = mac_ctx->peer_rssi;
11760 roam_info.tx_rate = mac_ctx->peer_txrate;
11761 roam_info.rx_rate = mac_ctx->peer_rxrate;
Ashish Kumar Dhanotiyad39c8b52018-03-27 18:18:52 +053011762 roam_info.disassoc_reason = discon_ind->reason_code;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053011763
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053011764 csr_roam_call_callback(mac_ctx, discon_ind->session_id,
11765 &roam_info, 0, eCSR_ROAM_LOSTLINK,
11766 eCSR_ROAM_RESULT_DISASSOC_IND);
11767 session = CSR_GET_SESSION(mac_ctx, discon_ind->session_id);
11768 if (session &&
11769 !CSR_IS_INFRA_AP(&session->connectedProfile))
11770 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
11771 discon_ind->session_id);
11772
11773 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011774 sme_err("Inactive session %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053011775 discon_ind->session_id);
Himanshu Agarwald519b4a2018-03-27 15:36:09 +053011776
11777 /*
11778 * Release WM status change command as eWNI_SME_DISCONNECT_DONE_IND
11779 * has been sent to HDD and there is nothing else left to do.
11780 */
11781 csr_roam_wm_status_change_complete(mac_ctx, discon_ind->session_id);
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053011782}
11783
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011784static void
11785csr_roam_chk_lnk_deauth_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11786{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011787 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011788 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011789 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011790 tSirSmeDeauthInd *pDeauthInd;
Jeff Johnson172237b2017-11-07 15:32:59 -080011791 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011792
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011793 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011794 sme_debug("DEAUTHENTICATION Indication from MAC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011795 pDeauthInd = (tpSirSmeDeauthInd) msg_ptr;
11796 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080011797 &pDeauthInd->bssid,
11798 &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011799 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011800 return;
11801 /* If we are in neighbor preauth done state then on receiving
11802 * disassoc or deauth we dont roam instead we just disassoc
11803 * from current ap and then go to disconnected state
11804 * This happens for ESE and 11r FT connections ONLY.
11805 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011806 if (csr_roam_is11r_assoc(mac_ctx, sessionId) &&
11807 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
11808 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
11809 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011810#ifdef FEATURE_WLAN_ESE
11811 if (csr_roam_is_ese_assoc(mac_ctx, sessionId) &&
11812 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
11813 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
11814 mac_ctx, sessionId);
11815#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011816 if (csr_roam_is_fast_roam_enabled(mac_ctx, sessionId) &&
11817 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
11818 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
11819 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011820 session = CSR_GET_SESSION(mac_ctx, sessionId);
11821 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011822 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011823 return;
11824 }
11825
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053011826 /* Update the disconnect stats */
11827 switch (pDeauthInd->reasonCode) {
11828 case eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON:
11829 session->disconnect_stats.disconnection_cnt++;
11830 session->disconnect_stats.peer_kickout++;
11831 break;
11832 case eSIR_MAC_UNSPEC_FAILURE_REASON:
11833 case eSIR_MAC_PREV_AUTH_NOT_VALID_REASON:
11834 case eSIR_MAC_DEAUTH_LEAVING_BSS_REASON:
11835 case eSIR_MAC_CLASS2_FRAME_FROM_NON_AUTH_STA_REASON:
11836 case eSIR_MAC_CLASS3_FRAME_FROM_NON_ASSOC_STA_REASON:
11837 case eSIR_MAC_STA_NOT_PRE_AUTHENTICATED_REASON:
11838 session->disconnect_stats.disconnection_cnt++;
11839 session->disconnect_stats.deauth_by_peer++;
11840 break;
11841 case eSIR_BEACON_MISSED:
11842 session->disconnect_stats.disconnection_cnt++;
11843 session->disconnect_stats.bmiss++;
11844 break;
11845 default:
11846 /* Unknown reason code */
11847 break;
11848 }
11849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011850 if (csr_is_conn_state_infra(mac_ctx, sessionId))
11851 session->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
11852#ifndef WLAN_MDM_CODE_REDUCTION_OPT
11853 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
11854 SME_QOS_CSR_DISCONNECT_IND, NULL);
11855#endif
11856 csr_roam_link_down(mac_ctx, sessionId);
11857 csr_roam_issue_wm_status_change(mac_ctx, sessionId,
11858 eCsrDeauthenticated,
11859 msg_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011860}
11861
11862static void
11863csr_roam_chk_lnk_swt_ch_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11864{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011865 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011866 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011867 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011868 tpSirSmeSwitchChannelInd pSwitchChnInd;
Jeff Johnson172237b2017-11-07 15:32:59 -080011869 struct csr_roam_info roamInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011870
11871 /* in case of STA, the SWITCH_CHANNEL originates from its AP */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011872 sme_debug("eWNI_SME_SWITCH_CHL_IND from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011873 pSwitchChnInd = (tpSirSmeSwitchChannelInd) msg_ptr;
11874 /* Update with the new channel id. The channel id is hidden in the
11875 * statusCode.
11876 */
11877 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda591c5652015-12-30 17:39:50 -080011878 &pSwitchChnInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011879 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011880 session = CSR_GET_SESSION(mac_ctx, sessionId);
11881 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011882 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011883 return;
11884 }
11885 session->connectedProfile.operationChannel =
11886 (uint8_t) pSwitchChnInd->newChannelId;
11887 if (session->pConnectBssDesc) {
11888 session->pConnectBssDesc->channelId =
11889 (uint8_t) pSwitchChnInd->newChannelId;
11890 }
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +053011891
Jeff Johnson172237b2017-11-07 15:32:59 -080011892 qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +053011893 roamInfo.chan_info.chan_id = pSwitchChnInd->newChannelId;
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +053011894 roamInfo.chan_info.ch_width =
11895 pSwitchChnInd->chan_params.ch_width;
11896 roamInfo.chan_info.sec_ch_offset =
11897 pSwitchChnInd->chan_params.sec_ch_offset;
11898 roamInfo.chan_info.band_center_freq1 =
11899 pSwitchChnInd->chan_params.center_freq_seg0;
11900 roamInfo.chan_info.band_center_freq2 =
11901 pSwitchChnInd->chan_params.center_freq_seg1;
bings58ce8622017-07-10 15:55:36 +080011902 if (CSR_IS_PHY_MODE_11ac(mac_ctx->roam.configParam.phyMode))
11903 roamInfo.mode = SIR_SME_PHY_MODE_VHT;
11904 else if (CSR_IS_PHY_MODE_11n(mac_ctx->roam.configParam.phyMode))
11905 roamInfo.mode = SIR_SME_PHY_MODE_HT;
11906 else
11907 roamInfo.mode = SIR_SME_PHY_MODE_LEGACY;
11908
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +053011909 status = csr_roam_call_callback(mac_ctx, sessionId,
11910 &roamInfo, 0, eCSR_ROAM_STA_CHANNEL_SWITCH,
11911 eCSR_ROAM_RESULT_NONE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011912 }
11913}
11914
11915static void
11916csr_roam_chk_lnk_deauth_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11917{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011918 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011919 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011920 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080011921 struct csr_roam_info *roam_info_ptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011922 tSirSmeDeauthRsp *pDeauthRsp = (tSirSmeDeauthRsp *) msg_ptr;
Jeff Johnson172237b2017-11-07 15:32:59 -080011923 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011924
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011925 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011926 sme_debug("eWNI_SME_DEAUTH_RSP from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011927 sessionId = pDeauthRsp->sessionId;
11928 if (!CSR_IS_SESSION_VALID(mac_ctx, sessionId))
11929 return;
11930 session = CSR_GET_SESSION(mac_ctx, sessionId);
11931 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
11932 roam_info_ptr = &roam_info;
11933 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
Anurag Chouhanc5548422016-02-24 18:33:27 +053011934 qdf_copy_macaddr(&roam_info_ptr->peerMac,
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -080011935 &pDeauthRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011936 roam_info_ptr->reasonCode = eCSR_ROAM_RESULT_FORCED;
11937 roam_info_ptr->statusCode = pDeauthRsp->statusCode;
11938 status = csr_roam_call_callback(mac_ctx, sessionId,
11939 roam_info_ptr, 0,
11940 eCSR_ROAM_LOSTLINK,
11941 eCSR_ROAM_RESULT_FORCED);
11942 }
11943}
11944
11945static void
11946csr_roam_chk_lnk_disassoc_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11947{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011948 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011949 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011950 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080011951 struct csr_roam_info *roam_info_ptr = NULL;
11952 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011953 /*
11954 * session id is invalid here so cant use it to access the array
11955 * curSubstate as index
11956 */
11957 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *) msg_ptr;
11958
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011959 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011960 sme_debug("eWNI_SME_DISASSOC_RSP from SME ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011961 sessionId = pDisassocRsp->sessionId;
11962 if (!CSR_IS_SESSION_VALID(mac_ctx, sessionId))
11963 return;
11964 session = CSR_GET_SESSION(mac_ctx, sessionId);
11965 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
11966 roam_info_ptr = &roam_info;
11967 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
Anurag Chouhanc5548422016-02-24 18:33:27 +053011968 qdf_copy_macaddr(&roam_info_ptr->peerMac,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -080011969 &pDisassocRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011970 roam_info_ptr->reasonCode = eCSR_ROAM_RESULT_FORCED;
11971 roam_info_ptr->statusCode = pDisassocRsp->statusCode;
11972 status = csr_roam_call_callback(mac_ctx, sessionId,
11973 roam_info_ptr, 0,
11974 eCSR_ROAM_LOSTLINK,
11975 eCSR_ROAM_RESULT_FORCED);
11976 }
11977}
11978
11979#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11980static void
11981csr_roam_diag_mic_fail(tpAniSirGlobal mac_ctx, uint32_t sessionId)
11982{
11983 WLAN_HOST_DIAG_EVENT_DEF(secEvent,
11984 host_event_wlan_security_payload_type);
gaurank kathpalia14e2f912017-08-31 14:51:45 +053011985 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011986
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011987 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011988 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011989 return;
11990 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011991 qdf_mem_set(&secEvent, sizeof(host_event_wlan_security_payload_type),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011992 0);
11993 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
11994 secEvent.encryptionModeMulticast =
11995 (uint8_t) diag_enc_type_from_csr_type(
11996 session->connectedProfile.mcEncryptionType);
11997 secEvent.encryptionModeUnicast =
11998 (uint8_t) diag_enc_type_from_csr_type(
11999 session->connectedProfile.EncryptionType);
12000 secEvent.authMode =
12001 (uint8_t) diag_auth_type_from_csr_type(
12002 session->connectedProfile.AuthType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012003 qdf_mem_copy(secEvent.bssid, session->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012004 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012005 WLAN_HOST_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12006}
12007#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12008
12009static void
12010csr_roam_chk_lnk_mic_fail_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
12011{
12012 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012013 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080012014 struct csr_roam_info *roam_info_ptr = NULL;
12015 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012016 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd) msg_ptr;
12017 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
12018
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012019 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012020 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda37c133b2015-09-24 16:14:15 -070012021 &pMicInd->bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012022 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson172237b2017-11-07 15:32:59 -080012023 qdf_mem_set(&roam_info, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012024 roam_info.u.pMICFailureInfo = &pMicInd->info;
12025 roam_info_ptr = &roam_info;
12026 if (pMicInd->info.multicast)
12027 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
12028 else
12029 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
12030 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
12031 eCSR_ROAM_MIC_ERROR_IND, result);
12032 }
12033#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12034 csr_roam_diag_mic_fail(mac_ctx, sessionId);
12035#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12036}
12037
12038static void
12039csr_roam_chk_lnk_pbs_probe_req_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
12040{
12041 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012042 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080012043 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012044 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd) msg_ptr;
12045
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012046 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012047 sme_debug("WPS PBC Probe request Indication from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012048
12049 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowdad6673be2015-11-24 14:18:13 -080012050 &pProbeReqInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012051 if (QDF_IS_STATUS_SUCCESS(status)) {
Jeff Johnson172237b2017-11-07 15:32:59 -080012052 qdf_mem_set(&roam_info, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012053 roam_info.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
12054 csr_roam_call_callback(mac_ctx, sessionId, &roam_info,
12055 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
12056 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
12057 }
12058}
12059
12060#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12061static void
12062csr_roam_diag_joined_new_bss(tpAniSirGlobal mac_ctx,
12063 tSirSmeNewBssInfo *pNewBss)
12064{
12065 host_log_ibss_pkt_type *pIbssLog;
12066 uint32_t bi;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012068 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
12069 LOG_WLAN_IBSS_C);
12070 if (!pIbssLog)
12071 return;
12072 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
12073 if (pNewBss) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053012074 qdf_copy_macaddr(&pIbssLog->bssid, &pNewBss->bssId);
Arif Hussain186d7a02018-05-08 23:20:43 -070012075 if (pNewBss->ssId.length > HOST_LOG_MAX_SSID_SIZE)
12076 pNewBss->ssId.length = HOST_LOG_MAX_SSID_SIZE;
12077 qdf_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
12078 pNewBss->ssId.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012079 pIbssLog->operatingChannel = pNewBss->channelNumber;
12080 }
12081 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(mac_ctx,
12082 WNI_CFG_BEACON_INTERVAL,
12083 &bi)))
12084 /* U8 is not enough for beacon interval */
12085 pIbssLog->beaconInterval = (uint8_t) bi;
12086 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
12087}
12088#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12089
12090static void
12091csr_roam_chk_lnk_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
12092 tSirSmeRsp *msg_ptr)
12093{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012094 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012095 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012096 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080012097 struct csr_roam_info *roam_info_ptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012098 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
Jeff Johnson172237b2017-11-07 15:32:59 -080012099 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012100 tSirSmeApNewCaps *pApNewCaps;
12101 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
12102 tSirMacAddr Broadcastaddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
12103 tSirSmeNewBssInfo *pNewBss;
12104 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
12105
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012106 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012107 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *) msg_ptr;
12108 switch (pStatusChangeMsg->statusChangeCode) {
12109 case eSIR_SME_IBSS_ACTIVE:
12110 sessionId = csr_find_ibss_session(mac_ctx);
12111 if (CSR_SESSION_ID_INVALID == sessionId)
12112 break;
12113 session = CSR_GET_SESSION(mac_ctx, sessionId);
12114 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012115 sme_err("session %d not found",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012116 sessionId);
12117 return;
12118 }
12119 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
12120 if (session->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012121 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012122 session->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012123 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012124 roam_info.u.pConnectedProfile =
12125 &session->connectedProfile;
12126 roam_info_ptr = &roam_info;
12127 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012128 sme_err("CSR: connected BSS is empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012129 }
12130 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
12131 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
12132 break;
12133
12134 case eSIR_SME_IBSS_INACTIVE:
12135 sessionId = csr_find_ibss_session(mac_ctx);
12136 if (CSR_SESSION_ID_INVALID != sessionId) {
12137 session = CSR_GET_SESSION(mac_ctx, sessionId);
12138 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012139 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012140 return;
12141 }
12142 session->connectState =
12143 eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
12144 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
12145 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
12146 }
12147 break;
12148
12149 case eSIR_SME_JOINED_NEW_BSS:
12150 /* IBSS coalescing. */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012151 sme_debug("CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012152 sessionId = csr_find_ibss_session(mac_ctx);
12153 if (CSR_SESSION_ID_INVALID == sessionId)
12154 break;
12155 session = CSR_GET_SESSION(mac_ctx, sessionId);
12156 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012157 sme_err("session %d not found",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012158 sessionId);
12159 return;
12160 }
12161 /* update the connection state information */
12162 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
12163#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12164 csr_roam_diag_joined_new_bss(mac_ctx, pNewBss);
12165#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12166 csr_roam_update_connected_profile_from_new_bss(mac_ctx,
12167 sessionId,
12168 pNewBss);
12169
12170 if ((eCSR_ENCRYPT_TYPE_NONE ==
12171 session->connectedProfile.EncryptionType)) {
12172 csr_roam_issue_set_context_req(mac_ctx,
12173 sessionId,
12174 session->connectedProfile.EncryptionType,
12175 session->pConnectBssDesc,
12176 &Broadcastaddr, false, false,
12177 eSIR_TX_RX, 0, 0, NULL, 0);
12178 }
12179 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
12180 roamStatus = eCSR_ROAM_IBSS_IND;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012181 qdf_mem_copy(&roam_info.bssid, &pNewBss->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012182 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012183 roam_info_ptr = &roam_info;
12184 /* This BSSID is the real BSSID, save it */
12185 if (session->pConnectBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012186 qdf_mem_copy(session->pConnectBssDesc->bssId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012187 &pNewBss->bssId, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012188 break;
12189
12190 /*
12191 * detection by LIM that the capabilities of the associated
12192 * AP have changed.
12193 */
12194 case eSIR_SME_AP_CAPS_CHANGED:
12195 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012196 sme_debug("CSR handling eSIR_SME_AP_CAPS_CHANGED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012197 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda26ebb192015-09-24 15:12:09 -070012198 &pApNewCaps->bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012199 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012200 break;
12201 if (eCSR_ROAMING_STATE_JOINED ==
wadesonga8637bb2018-01-23 15:11:19 +080012202 sme_get_current_roam_state(mac_ctx, sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012203 && ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC
12204 == mac_ctx->roam.curSubState[sessionId])
12205 || (eCSR_ROAM_SUBSTATE_NONE ==
12206 mac_ctx->roam.curSubState[sessionId])
12207 || (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC
12208 == mac_ctx->roam.curSubState[sessionId])
12209 || (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC ==
12210 mac_ctx->roam.curSubState[sessionId]))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012211 sme_warn("Calling csr_roam_disconnect_internal");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012212 csr_roam_disconnect_internal(mac_ctx, sessionId,
12213 eCSR_DISCONNECT_REASON_UNSPECIFIED);
12214 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012215 sme_warn("Skipping the new scan as CSR is in state: %s and sub-state: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012216 mac_trace_getcsr_roam_state(
12217 mac_ctx->roam.curState[sessionId]),
12218 mac_trace_getcsr_roam_sub_state(
12219 mac_ctx->roam.curSubState[sessionId]));
12220 /* We ignore the caps change event if CSR is not in full
12221 * connected state. Send one event to PE to reset
12222 * limSentCapsChangeNtf Once limSentCapsChangeNtf set
12223 * 0, lim can send sub sequent CAPS change event
12224 * otherwise lim cannot send any CAPS change events to
12225 * SME
12226 */
12227 csr_send_reset_ap_caps_changed(mac_ctx,
12228 &pApNewCaps->bssId);
12229 }
12230 break;
12231
12232 default:
12233 roamStatus = eCSR_ROAM_FAILED;
12234 result = eCSR_ROAM_RESULT_NONE;
12235 break;
12236 } /* end switch on statusChangeCode */
12237 if (eCSR_ROAM_RESULT_NONE != result) {
12238 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
12239 roamStatus, result);
12240 }
12241}
12242
12243static void
12244csr_roam_chk_lnk_ibss_new_peer_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
12245{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012246 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012247 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012248 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080012249 struct csr_roam_info *roam_info_ptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012250 tSmeIbssPeerInd *pIbssPeerInd = (tSmeIbssPeerInd *) msg_ptr;
Jeff Johnson172237b2017-11-07 15:32:59 -080012251 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012252#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12253 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012254
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012255 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
12256 LOG_WLAN_IBSS_C);
12257 if (pIbssLog) {
12258 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Anurag Chouhanc5548422016-02-24 18:33:27 +053012259 qdf_copy_macaddr(&pIbssLog->peer_macaddr,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080012260 &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012261 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
12262 }
12263#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12264
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012265 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012266 sessionId = csr_find_ibss_session(mac_ctx);
12267 if (CSR_SESSION_ID_INVALID == sessionId)
12268 return;
12269 session = CSR_GET_SESSION(mac_ctx, sessionId);
12270 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012271 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012272 return;
12273 }
12274 /*
12275 * Issue the set Context request to LIM to establish the Unicast STA
12276 * context for the new peer...
12277 */
12278 if (!session->pConnectBssDesc) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012279 sme_warn("CSR: connected BSS is empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012280 goto callback_and_free;
12281 }
Anurag Chouhanc5548422016-02-24 18:33:27 +053012282 qdf_copy_macaddr(&roam_info.peerMac, &pIbssPeerInd->peer_addr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012283 qdf_mem_copy(&roam_info.bssid, session->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012284 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012285 if (pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012286 roam_info.pbFrames = qdf_mem_malloc((pIbssPeerInd->mesgLen -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012287 sizeof(tSmeIbssPeerInd)));
12288 if (NULL == roam_info.pbFrames) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012289 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012290 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012291 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012292 roam_info.nBeaconLength = pIbssPeerInd->mesgLen -
12293 sizeof(tSmeIbssPeerInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012294 qdf_mem_copy(roam_info.pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012295 ((uint8_t *) pIbssPeerInd) +
12296 sizeof(tSmeIbssPeerInd),
12297 roam_info.nBeaconLength);
12298 }
12299 roam_info.staId = (uint8_t) pIbssPeerInd->staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012300 roam_info.pBssDesc = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012301 session->pConnectBssDesc->length);
12302 if (NULL == roam_info.pBssDesc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012303 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012304 if (roam_info.pbFrames)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012305 qdf_mem_free(roam_info.pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012306 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012307 qdf_mem_free(roam_info.pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012308 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012309 status = QDF_STATUS_SUCCESS;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012310 qdf_mem_copy(roam_info.pBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012311 session->pConnectBssDesc,
12312 session->pConnectBssDesc->length);
12313 roam_info_ptr = &roam_info;
12314 }
12315 } else {
12316 roam_info_ptr = &roam_info;
12317 }
12318 if ((eCSR_ENCRYPT_TYPE_NONE ==
12319 session->connectedProfile.EncryptionType)) {
12320 /* NO keys. these key parameters don't matter */
12321 csr_roam_issue_set_context_req(mac_ctx, sessionId,
12322 session->connectedProfile.EncryptionType,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080012323 session->pConnectBssDesc,
12324 &pIbssPeerInd->peer_addr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012325 false, true, eSIR_TX_RX, 0, 0, NULL, 0);
12326 }
12327
12328callback_and_free:
12329 /* send up the sec type for the new peer */
12330 if (roam_info_ptr)
12331 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
12332 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
12333 eCSR_ROAM_CONNECT_STATUS_UPDATE,
12334 eCSR_ROAM_RESULT_IBSS_NEW_PEER);
12335 if (roam_info_ptr) {
12336 if (roam_info.pbFrames)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012337 qdf_mem_free(roam_info.pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012338 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012339 qdf_mem_free(roam_info.pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012340 }
12341}
12342
12343static void
12344csr_roam_chk_lnk_ibss_peer_departed_ind(tpAniSirGlobal mac_ctx,
12345 tSirSmeRsp *msg_ptr)
12346{
12347 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Jeff Johnson172237b2017-11-07 15:32:59 -080012348 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012349 tSmeIbssPeerInd *pIbssPeerInd;
12350
12351 if (NULL == msg_ptr) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012352 sme_err("IBSS peer ind. message is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012353 return;
12354 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012355 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012356 pIbssPeerInd = (tSmeIbssPeerInd *) msg_ptr;
12357 sessionId = csr_find_ibss_session(mac_ctx);
12358 if (CSR_SESSION_ID_INVALID != sessionId) {
12359#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12360 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012361
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012362 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
12363 LOG_WLAN_IBSS_C);
12364 if (pIbssLog) {
12365 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
12366 if (pIbssPeerInd) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053012367 qdf_copy_macaddr(&pIbssLog->peer_macaddr,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080012368 &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012369 }
12370 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
12371 }
12372#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012373 sme_debug("CSR: Peer departed notification from LIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012374 roam_info.staId = (uint8_t) pIbssPeerInd->staId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053012375 qdf_copy_macaddr(&roam_info.peerMac, &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012376 csr_roam_call_callback(mac_ctx, sessionId, &roam_info, 0,
12377 eCSR_ROAM_CONNECT_STATUS_UPDATE,
12378 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
12379 }
12380}
12381
12382#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12383static void
12384csr_roam_diag_set_ctx_rsp(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012385 struct csr_roam_session *session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012386 tSirSmeSetContextRsp *pRsp)
12387{
12388 WLAN_HOST_DIAG_EVENT_DEF(setKeyEvent,
12389 host_event_wlan_security_payload_type);
12390 if (eCSR_ENCRYPT_TYPE_NONE ==
12391 session->connectedProfile.EncryptionType)
12392 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012393 qdf_mem_set(&setKeyEvent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012394 sizeof(host_event_wlan_security_payload_type), 0);
Anurag Chouhanc5548422016-02-24 18:33:27 +053012395 if (qdf_is_macaddr_group(&pRsp->peer_macaddr))
Abhishek Singh7a995582016-04-27 13:53:36 +053012396 setKeyEvent.eventId =
12397 WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012398 else
Abhishek Singh7a995582016-04-27 13:53:36 +053012399 setKeyEvent.eventId =
12400 WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012401 setKeyEvent.encryptionModeMulticast =
12402 (uint8_t) diag_enc_type_from_csr_type(
12403 session->connectedProfile.mcEncryptionType);
12404 setKeyEvent.encryptionModeUnicast =
12405 (uint8_t) diag_enc_type_from_csr_type(
12406 session->connectedProfile.EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012407 qdf_mem_copy(setKeyEvent.bssid, session->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012408 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012409 setKeyEvent.authMode =
12410 (uint8_t) diag_auth_type_from_csr_type(
12411 session->connectedProfile.AuthType);
12412 if (eSIR_SME_SUCCESS != pRsp->statusCode)
12413 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
12414 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
12415}
12416#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12417
12418static void
12419csr_roam_chk_lnk_set_ctx_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
12420{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012421 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012422 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012423 QDF_STATUS status;
Jeff Johnson172237b2017-11-07 15:32:59 -080012424 struct csr_roam_info *roam_info_ptr = NULL;
12425 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012426 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
12427 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *) msg_ptr;
Krunal Sonid3676732017-05-10 14:12:18 -070012428
12429
12430 if (!pRsp) {
12431 sme_err("set key response is NULL");
12432 return;
12433 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012434
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012435 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Krunal Sonid3676732017-05-10 14:12:18 -070012436 sessionId = pRsp->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012437 session = CSR_GET_SESSION(mac_ctx, sessionId);
12438 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012439 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012440 return;
12441 }
12442#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12443 csr_roam_diag_set_ctx_rsp(mac_ctx, session, pRsp);
12444#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12445 if (CSR_IS_WAIT_FOR_KEY(mac_ctx, sessionId)) {
12446 csr_roam_stop_wait_for_key_timer(mac_ctx);
12447 /* We are done with authentication, whethere succeed or not */
12448 csr_roam_substate_change(mac_ctx, eCSR_ROAM_SUBSTATE_NONE,
12449 sessionId);
12450 /* We do it here because this linkup function is not called
12451 * after association when a key needs to be set.
12452 */
12453 if (csr_is_conn_state_connected_infra(mac_ctx, sessionId))
12454 csr_roam_link_up(mac_ctx,
12455 session->connectedProfile.bssid);
12456 }
12457 if (eSIR_SME_SUCCESS == pRsp->statusCode) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053012458 qdf_copy_macaddr(&roam_info.peerMac, &pRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012459 /* Make sure we install the GTK before indicating to HDD as
12460 * authenticated. This is to prevent broadcast packets go out
12461 * after PTK and before GTK.
12462 */
Anurag Chouhanc5548422016-02-24 18:33:27 +053012463 if (qdf_is_macaddr_broadcast(&pRsp->peer_macaddr)) {
Sandeep Puligilla829d6ac2016-08-11 17:27:50 -070012464 /*
12465 * OBSS SCAN Indication will be sent to Firmware
12466 * to start OBSS Scan
12467 */
12468 if (CSR_IS_CHANNEL_24GHZ(
12469 session->connectedProfile.operationChannel)
12470 && (session->connectState ==
12471 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
12472 && session->pCurRoamProfile
12473 && ((QDF_P2P_CLIENT_MODE ==
12474 session->pCurRoamProfile->csrPersona)
12475 || (QDF_STA_MODE ==
12476 session->pCurRoamProfile->csrPersona))) {
12477 struct sme_obss_ht40_scanind_msg *msg;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012478
Sandeep Puligilla829d6ac2016-08-11 17:27:50 -070012479 msg = qdf_mem_malloc(sizeof(
12480 struct sme_obss_ht40_scanind_msg));
Naveen Rawat63ad2b62016-11-17 11:38:21 -080012481 if (NULL == msg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012482 sme_err("Malloc failed");
Krunal Sonid3676732017-05-10 14:12:18 -070012483 return;
Naveen Rawat63ad2b62016-11-17 11:38:21 -080012484 }
Sandeep Puligilla829d6ac2016-08-11 17:27:50 -070012485 msg->msg_type = eWNI_SME_HT40_OBSS_SCAN_IND;
12486 msg->length =
12487 sizeof(struct sme_obss_ht40_scanind_msg);
12488 qdf_copy_macaddr(&msg->mac_addr,
12489 &session->connectedProfile.bssid);
Rajeev Kumard138ac52017-01-30 18:38:37 -080012490 status = umac_send_mb_message_to_mac(msg);
Sandeep Puligilla829d6ac2016-08-11 17:27:50 -070012491 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012492 result = eCSR_ROAM_RESULT_AUTHENTICATED;
12493 } else {
12494 result = eCSR_ROAM_RESULT_NONE;
12495 }
12496 roam_info_ptr = &roam_info;
12497 } else {
12498 result = eCSR_ROAM_RESULT_FAILURE;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012499 sme_err(
12500 "CSR: setkey command failed(err=%d) PeerMac "
12501 MAC_ADDRESS_STR,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080012502 pRsp->statusCode,
12503 MAC_ADDR_ARRAY(pRsp->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012504 }
Krunal Sonid3676732017-05-10 14:12:18 -070012505 /* keeping roam_id = 0 as nobody is using roam_id for set_key */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012506 csr_roam_call_callback(mac_ctx, sessionId, &roam_info,
Krunal Sonid3676732017-05-10 14:12:18 -070012507 0, eCSR_ROAM_SET_KEY_COMPLETE, result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012508 /* Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
12509 * can go ahead and initiate the TSPEC if any are pending
12510 */
12511 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
12512 SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
12513#ifdef FEATURE_WLAN_ESE
12514 /* Send Adjacent AP repot to new AP. */
12515 if (result == eCSR_ROAM_RESULT_AUTHENTICATED
12516 && session->isPrevApInfoValid
12517 && session->connectedProfile.isESEAssoc) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012518 csr_send_ese_adjacent_ap_rep_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012519 session->isPrevApInfoValid = false;
12520 }
12521#endif
Krunal Sonia8270f52017-02-23 19:51:25 -080012522 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012523}
12524
12525
12526static void
12527csr_roam_chk_lnk_max_assoc_exceeded(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
12528{
12529 uint32_t sessionId = CSR_SESSION_ID_INVALID;
12530 tSmeMaxAssocInd *pSmeMaxAssocInd;
Jeff Johnson172237b2017-11-07 15:32:59 -080012531 struct csr_roam_info roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012532
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012533 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012534 pSmeMaxAssocInd = (tSmeMaxAssocInd *) msg_ptr;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012535 sme_debug(
12536 "max assoc have been reached, new peer cannot be accepted");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012537 sessionId = pSmeMaxAssocInd->sessionId;
12538 roam_info.sessionId = sessionId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053012539 qdf_copy_macaddr(&roam_info.peerMac, &pSmeMaxAssocInd->peer_mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012540 csr_roam_call_callback(mac_ctx, sessionId, &roam_info, 0,
12541 eCSR_ROAM_INFRA_IND,
12542 eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
12543}
12544
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012545void csr_roam_check_for_link_status_change(tpAniSirGlobal pMac,
12546 tSirSmeRsp *pSirMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012547{
12548 if (NULL == pSirMsg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012549 sme_err("pSirMsg is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012550 return;
12551 }
12552 switch (pSirMsg->messageType) {
12553 case eWNI_SME_ASSOC_IND:
12554 csr_roam_chk_lnk_assoc_ind(pMac, pSirMsg);
12555 break;
12556 case eWNI_SME_DISASSOC_IND:
12557 csr_roam_chk_lnk_disassoc_ind(pMac, pSirMsg);
12558 break;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053012559 case eWNI_SME_DISCONNECT_DONE_IND:
12560 csr_roam_send_disconnect_done_indication(pMac, pSirMsg);
12561 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012562 case eWNI_SME_DEAUTH_IND:
12563 csr_roam_chk_lnk_deauth_ind(pMac, pSirMsg);
12564 break;
12565 case eWNI_SME_SWITCH_CHL_IND:
12566 csr_roam_chk_lnk_swt_ch_ind(pMac, pSirMsg);
12567 break;
12568 case eWNI_SME_DEAUTH_RSP:
12569 csr_roam_chk_lnk_deauth_rsp(pMac, pSirMsg);
12570 break;
12571 case eWNI_SME_DISASSOC_RSP:
12572 csr_roam_chk_lnk_disassoc_rsp(pMac, pSirMsg);
12573 break;
12574 case eWNI_SME_MIC_FAILURE_IND:
12575 csr_roam_chk_lnk_mic_fail_ind(pMac, pSirMsg);
12576 break;
12577 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
12578 csr_roam_chk_lnk_pbs_probe_req_ind(pMac, pSirMsg);
12579 break;
12580 case eWNI_SME_WM_STATUS_CHANGE_NTF:
12581 csr_roam_chk_lnk_wm_status_change_ntf(pMac, pSirMsg);
12582 break;
12583 case eWNI_SME_IBSS_NEW_PEER_IND:
12584 csr_roam_chk_lnk_ibss_new_peer_ind(pMac, pSirMsg);
12585 break;
12586 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
12587 csr_roam_chk_lnk_ibss_peer_departed_ind(pMac, pSirMsg);
12588 break;
12589 case eWNI_SME_SETCONTEXT_RSP:
12590 csr_roam_chk_lnk_set_ctx_rsp(pMac, pSirMsg);
12591 break;
12592 case eWNI_SME_GET_STATISTICS_RSP:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012593 sme_debug("Stats rsp from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012594 csr_roam_stats_rsp_processor(pMac, pSirMsg);
12595 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -080012596#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012597 case eWNI_SME_GET_TSM_STATS_RSP:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012598 sme_debug("TSM Stats rsp from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012599 csr_tsm_stats_rsp_processor(pMac, pSirMsg);
12600 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -080012601#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012602 case eWNI_SME_GET_RSSI_REQ:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012603 sme_debug("GetRssiReq from self");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012604 csr_update_rssi(pMac, pSirMsg);
12605 break;
12606 case eWNI_SME_GET_SNR_REQ:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012607 sme_debug("GetSnrReq from self");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012608 csr_update_snr(pMac, pSirMsg);
12609 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012610 case eWNI_SME_FT_PRE_AUTH_RSP:
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012611 csr_roam_ft_pre_auth_rsp_processor(pMac,
12612 (tpSirFTPreAuthRsp) pSirMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012613 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012614 case eWNI_SME_MAX_ASSOC_EXCEEDED:
12615 csr_roam_chk_lnk_max_assoc_exceeded(pMac, pSirMsg);
12616 break;
12617 case eWNI_SME_CANDIDATE_FOUND_IND:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012618 sme_debug("Candidate found indication from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012619 csr_neighbor_roam_candidate_found_ind_hdlr(pMac, pSirMsg);
12620 break;
12621 case eWNI_SME_HANDOFF_REQ:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012622 sme_debug("Handoff Req from self");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012623 csr_neighbor_roam_handoff_req_hdlr(pMac, pSirMsg);
12624 break;
Padma, Santhosh Kumarb38ab512018-01-16 16:16:46 +053012625
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012626 default:
12627 break;
12628 } /* end switch on message type */
12629}
12630
12631void csr_call_roaming_completion_callback(tpAniSirGlobal pMac,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012632 struct csr_roam_session *pSession,
Jeff Johnson172237b2017-11-07 15:32:59 -080012633 struct csr_roam_info *roam_info,
12634 uint32_t roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012635 eCsrRoamResult roamResult)
12636{
12637 if (pSession) {
12638 if (pSession->bRefAssocStartCnt) {
12639 pSession->bRefAssocStartCnt--;
12640
12641 if (0 != pSession->bRefAssocStartCnt) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012642 QDF_ASSERT(pSession->bRefAssocStartCnt == 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012643 return;
12644 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012645 /* Need to call association_completion because there
12646 * is an assoc_start pending.
12647 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012648 csr_roam_call_callback(pMac, pSession->sessionId, NULL,
12649 roamId,
12650 eCSR_ROAM_ASSOCIATION_COMPLETION,
12651 eCSR_ROAM_RESULT_FAILURE);
12652 }
Jeff Johnsoneddf5442017-10-04 10:55:53 -070012653 csr_roam_call_callback(pMac, pSession->sessionId, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012654 roamId, eCSR_ROAM_ROAMING_COMPLETION,
12655 roamResult);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012656 } else
12657 sme_err("pSession is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012658}
12659
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012660/* return a bool to indicate whether roaming completed or continue. */
12661bool csr_roam_complete_roaming(tpAniSirGlobal pMac, uint32_t sessionId,
12662 bool fForce, eCsrRoamResult roamResult)
12663{
12664 bool fCompleted = true;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012665 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012666
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012667 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012668 sme_err("session %d not found ", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012669 return false;
12670 }
12671 /* Check whether time is up */
12672 if (pSession->fCancelRoaming || fForce ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012673 eCsrReassocRoaming == pSession->roamingReason ||
12674 eCsrDynamicRoaming == pSession->roamingReason) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012675 sme_debug("indicates roaming completion");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012676 if (pSession->fCancelRoaming
12677 && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012678 /* roaming is cancelled, tell HDD to indicate disconnect
12679 * Because LIM overload deauth_ind for both deauth frame
12680 * and missed beacon we need to use this logic to
12681 * detinguish it. For missed beacon, LIM set reason to
12682 * be eSIR_BEACON_MISSED
12683 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012684 if (eSIR_BEACON_MISSED == pSession->roamingStatusCode) {
12685 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
12686 } else if (eCsrLostlinkRoamingDisassoc ==
12687 pSession->roamingReason) {
12688 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
12689 } else if (eCsrLostlinkRoamingDeauth ==
12690 pSession->roamingReason) {
12691 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
12692 } else {
12693 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
12694 }
12695 }
12696 csr_call_roaming_completion_callback(pMac, pSession, NULL, 0,
12697 roamResult);
12698 pSession->roamingReason = eCsrNotRoaming;
12699 } else {
12700 pSession->roamResult = roamResult;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012701 if (!QDF_IS_STATUS_SUCCESS(csr_roam_start_roaming_timer(pMac,
12702 sessionId, QDF_MC_TIMER_TO_SEC_UNIT))) {
12703 csr_call_roaming_completion_callback(pMac, pSession,
12704 NULL, 0, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012705 pSession->roamingReason = eCsrNotRoaming;
12706 } else {
12707 fCompleted = false;
12708 }
12709 }
12710 return fCompleted;
12711}
12712
12713void csr_roam_cancel_roaming(tpAniSirGlobal pMac, uint32_t sessionId)
12714{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012715 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012716
12717 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012718 sme_err("session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012719 return;
12720 }
12721
12722 if (CSR_IS_ROAMING(pSession)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012723 sme_debug("Cancel roaming");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012724 pSession->fCancelRoaming = true;
12725 if (CSR_IS_ROAM_JOINING(pMac, sessionId)
12726 && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012727 /* No need to do anything in here because the handler
12728 * takes care of it
12729 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012730 } else {
12731 eCsrRoamResult roamResult =
12732 CSR_IS_LOSTLINK_ROAMING(pSession->
12733 roamingReason) ?
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012734 eCSR_ROAM_RESULT_LOSTLINK :
12735 eCSR_ROAM_RESULT_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012736 /* Roaming is stopped after here */
12737 csr_roam_complete_roaming(pMac, sessionId, true,
12738 roamResult);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012739 /* Since CSR may be in lostlink roaming situation,
12740 * abort all roaming related activities
12741 */
Abhishek Singh9fabbbb2018-01-29 17:38:36 +053012742 csr_scan_abort_mac_scan(pMac, sessionId, INVAL_SCAN_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012743 csr_roam_stop_roaming_timer(pMac, sessionId);
12744 }
12745 }
12746}
12747
12748void csr_roam_roaming_timer_handler(void *pv)
12749{
12750 tCsrTimerInfo *pInfo = (tCsrTimerInfo *) pv;
12751 tpAniSirGlobal pMac = pInfo->pMac;
12752 uint32_t sessionId = pInfo->sessionId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012753 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012754
12755 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012756 sme_err(" session %d not found ", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012757 return;
12758 }
12759
12760 if (false == pSession->fCancelRoaming) {
Abhinav Kumarf9989582018-02-06 17:42:22 +053012761 csr_call_roaming_completion_callback(pMac, pSession,
12762 NULL, 0,
12763 pSession->roamResult);
12764 pSession->roamingReason = eCsrNotRoaming;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012765 }
12766}
12767
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070012768/**
12769 * csr_roam_roaming_offload_timeout_handler() - Handler for roaming failure
12770 * @timer_data: Carries the mac_ctx and session info
12771 *
12772 * This function would be invoked when the roaming_offload_timer expires.
12773 * The timer is waiting in anticipation of a related roaming event from
12774 * the firmware after receiving the ROAM_START event.
12775 *
12776 * Return: None
12777 */
12778void csr_roam_roaming_offload_timeout_handler(void *timer_data)
12779{
12780 tCsrTimerInfo *timer_info = (tCsrTimerInfo *) timer_data;
12781
12782 if (timer_info) {
12783 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012784 "LFR3:roaming offload timer expired, session: %d",
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070012785 timer_info->sessionId);
12786 } else {
12787 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012788 "Invalid Session");
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070012789 return;
12790 }
12791 csr_roam_disconnect(timer_info->pMac, timer_info->sessionId,
12792 eCSR_DISCONNECT_REASON_UNSPECIFIED);
12793}
12794
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012795QDF_STATUS csr_roam_start_roaming_timer(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012796 uint32_t interval)
12797{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012798 QDF_STATUS status;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012799 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012800
12801 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012802 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012803 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012804 }
12805
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012806 sme_debug("csrScanStartRoamingTimer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012807 pSession->roamingTimerInfo.sessionId = (uint8_t) sessionId;
Anurag Chouhan210db072016-02-22 18:42:15 +053012808 status = qdf_mc_timer_start(&pSession->hTimerRoaming,
12809 interval / QDF_MC_TIMER_TO_MS_UNIT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012810
12811 return status;
12812}
12813
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012814QDF_STATUS csr_roam_stop_roaming_timer(tpAniSirGlobal pMac,
12815 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012816{
Anurag Chouhan210db072016-02-22 18:42:15 +053012817 return qdf_mc_timer_stop
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012818 (&pMac->roam.roamSession[sessionId].hTimerRoaming);
12819}
12820
12821void csr_roam_wait_for_key_time_out_handler(void *pv)
12822{
12823 tCsrTimerInfo *pInfo = (tCsrTimerInfo *) pv;
12824 tpAniSirGlobal pMac = pInfo->pMac;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012825 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
12826 pInfo->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012827 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012828
12829 if (pSession == NULL) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012830 sme_err("session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012831 return;
12832 }
12833
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012834 sme_debug("WaitForKey timer expired in state: %s sub-state: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012835 mac_trace_get_neighbour_roam_state(pMac->roam.
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012836 neighborRoamInfo[pInfo->sessionId].
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012837 neighborRoamState),
12838 mac_trace_getcsr_roam_sub_state(pMac->roam.
12839 curSubState[pInfo->sessionId]));
Padma, Santhosh Kumar510f60c2017-12-07 16:58:41 +053012840 spin_lock(&pMac->roam.roam_state_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012841 if (CSR_IS_WAIT_FOR_KEY(pMac, pInfo->sessionId)) {
Padma, Santhosh Kumar510f60c2017-12-07 16:58:41 +053012842 /* Change the substate so command queue is unblocked. */
12843 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
12844 pMac->roam.curSubState[pInfo->sessionId] =
12845 eCSR_ROAM_SUBSTATE_NONE;
12846 spin_unlock(&pMac->roam.roam_state_lock);
12847
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012848 if (csr_neighbor_roam_is_handoff_in_progress(pMac,
12849 pInfo->sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012850 /*
12851 * Enable heartbeat timer when hand-off is in progress
12852 * and Key Wait timer expired.
12853 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012854 sme_debug("Enabling HB timer after WaitKey expiry nHBCount: %d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012855 pMac->roam.configParam.HeartbeatThresh24);
12856 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012857 pMac->roam.configParam.HeartbeatThresh24);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012858 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012859 sme_debug("SME pre-auth state timeout");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012860
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012861 if (csr_is_conn_state_connected_infra(pMac, pInfo->sessionId)) {
12862 csr_roam_link_up(pMac,
12863 pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012864 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012865 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012866 csr_roam_disconnect(pMac, pInfo->sessionId,
12867 eCSR_DISCONNECT_REASON_UNSPECIFIED);
12868 sme_release_global_lock(&pMac->sme);
12869 }
12870 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012871 sme_err("session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012872 }
Padma, Santhosh Kumar510f60c2017-12-07 16:58:41 +053012873 } else {
12874 spin_unlock(&pMac->roam.roam_state_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012875 }
12876
12877}
12878
Yingying Tang87f01392017-03-22 17:29:54 +080012879#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070012880/**
12881 * csr_roam_roaming_offload_timer_action() - API to start/stop the timer
12882 * @mac_ctx: MAC Context
12883 * @interval: Value to be set for the timer
12884 * @session_id: Session on which the timer should be operated
12885 * @action: Start/Stop action for the timer
12886 *
12887 * API to start/stop the roaming offload timer
12888 *
12889 * Return: None
12890 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012891void csr_roam_roaming_offload_timer_action(
12892 tpAniSirGlobal mac_ctx, uint32_t interval, uint8_t session_id,
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070012893 uint8_t action)
12894{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012895 struct csr_roam_session *csr_session = CSR_GET_SESSION(mac_ctx,
12896 session_id);
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070012897
12898 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012899 ("LFR3: timer action %d, session %d, intvl %d"),
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070012900 action, session_id, interval);
12901 if (mac_ctx) {
12902 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
12903 } else {
12904 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012905 ("LFR3: Invalid MAC Context"));
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070012906 return;
12907 }
12908 if (!csr_session) {
12909 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012910 ("LFR3: session %d not found"), session_id);
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070012911 return;
12912 }
12913 csr_session->roamingTimerInfo.sessionId = (uint8_t) session_id;
12914 if (action == ROAMING_OFFLOAD_TIMER_START)
12915 qdf_mc_timer_start(&csr_session->roaming_offload_timer,
12916 interval / QDF_MC_TIMER_TO_MS_UNIT);
12917 if (action == ROAMING_OFFLOAD_TIMER_STOP)
12918 qdf_mc_timer_stop(&csr_session->roaming_offload_timer);
12919
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070012920}
Yingying Tang87f01392017-03-22 17:29:54 +080012921#endif
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070012922
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012923static QDF_STATUS csr_roam_start_wait_for_key_timer(
12924 tpAniSirGlobal pMac, uint32_t interval)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012925{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012926 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012927 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
12928 &pMac->roam.neighborRoamInfo[pMac->roam.WaitForKeyTimerInfo.
12929 sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012930 if (csr_neighbor_roam_is_handoff_in_progress(pMac,
Deepak Dhamdhereecce9742015-11-08 01:16:43 -080012931 pMac->roam.WaitForKeyTimerInfo.
12932 sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012933 /* Disable heartbeat timer when hand-off is in progress */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012934 sme_debug("disabling HB timer in state: %s sub-state: %s",
Deepak Dhamdhereecce9742015-11-08 01:16:43 -080012935 mac_trace_get_neighbour_roam_state(
12936 pNeighborRoamInfo->neighborRoamState),
12937 mac_trace_getcsr_roam_sub_state(
12938 pMac->roam.curSubState[pMac->roam.
12939 WaitForKeyTimerInfo.sessionId]));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012940 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0);
12941 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012942 sme_debug("csrScanStartWaitForKeyTimer");
Anurag Chouhan210db072016-02-22 18:42:15 +053012943 status = qdf_mc_timer_start(&pMac->roam.hTimerWaitForKey,
12944 interval / QDF_MC_TIMER_TO_MS_UNIT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012945
12946 return status;
12947}
12948
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012949QDF_STATUS csr_roam_stop_wait_for_key_timer(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012950{
12951 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
12952 &pMac->roam.neighborRoamInfo[pMac->roam.WaitForKeyTimerInfo.
12953 sessionId];
12954
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012955 sme_debug("WaitForKey timer stopped in state: %s sub-state: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012956 mac_trace_get_neighbour_roam_state(pNeighborRoamInfo->
12957 neighborRoamState),
12958 mac_trace_getcsr_roam_sub_state(pMac->roam.
12959 curSubState[pMac->roam.
12960 WaitForKeyTimerInfo.
12961 sessionId]));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012962 if (csr_neighbor_roam_is_handoff_in_progress(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012963 pMac->roam.WaitForKeyTimerInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012964 sessionId)) {
12965 /*
12966 * Enable heartbeat timer when hand-off is in progress
12967 * and Key Wait timer got stopped for some reason
12968 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012969 sme_debug("Enabling HB timer after WaitKey stop nHBCount: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012970 pMac->roam.configParam.HeartbeatThresh24);
12971 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
12972 pMac->roam.configParam.HeartbeatThresh24);
12973 }
Anurag Chouhan210db072016-02-22 18:42:15 +053012974 return qdf_mc_timer_stop(&pMac->roam.hTimerWaitForKey);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012975}
12976
12977void csr_roam_completion(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson172237b2017-11-07 15:32:59 -080012978 struct csr_roam_info *roam_info, tSmeCmd *pCommand,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012979 eCsrRoamResult roamResult, bool fSuccess)
12980{
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012981 eRoamCmdStatus roamStatus = csr_get_roam_complete_status(pMac,
12982 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012983 uint32_t roamId = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053012984 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012985
12986 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012987 sme_err("session: %d not found ", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012988 return;
12989 }
12990
12991 if (pCommand) {
12992 roamId = pCommand->u.roamCmd.roamId;
12993 if (sessionId != pCommand->sessionId) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012994 QDF_ASSERT(sessionId == pCommand->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012995 return;
12996 }
12997 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012998 if (eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012999 /* if success, force roaming completion */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013000 csr_roam_complete_roaming(pMac, sessionId, fSuccess,
13001 roamResult);
13002 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013003 if (pSession->bRefAssocStartCnt != 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013004 QDF_ASSERT(pSession->bRefAssocStartCnt == 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013005 return;
13006 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013007 sme_debug("indicates association completion roamResult: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013008 roamResult);
Jeff Johnsoneddf5442017-10-04 10:55:53 -070013009 csr_roam_call_callback(pMac, sessionId, roam_info, roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013010 roamStatus, roamResult);
13011 }
13012}
13013
Jeff Johnson29e2ca12016-10-14 12:50:38 -070013014static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013015QDF_STATUS csr_roam_lost_link(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013016 uint32_t type, tSirSmeRsp *pSirMsg)
13017{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013018 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013019 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
13020 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
13021 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
Jeff Johnson172237b2017-11-07 15:32:59 -080013022 struct csr_roam_info roamInfo;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013023 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013024
13025 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013026 sme_err("session: %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013027 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013028 }
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053013029 qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013030 if (eWNI_SME_DISASSOC_IND == type) {
13031 result = eCSR_ROAM_RESULT_DISASSOC_IND;
13032 pDisassocIndMsg = (tSirSmeDisassocInd *) pSirMsg;
13033 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
13034 pSession->joinFailStatusCode.reasonCode =
13035 pDisassocIndMsg->reasonCode;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053013036
13037 qdf_copy_macaddr(&roamInfo.peerMac,
13038 &pDisassocIndMsg->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013039 } else if (eWNI_SME_DEAUTH_IND == type) {
13040 result = eCSR_ROAM_RESULT_DEAUTH_IND;
13041 pDeauthIndMsg = (tSirSmeDeauthInd *) pSirMsg;
13042 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +053013043 pSession->joinFailStatusCode.reasonCode =
13044 pDeauthIndMsg->reasonCode;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053013045
13046 qdf_copy_macaddr(&roamInfo.peerMac,
13047 &pDeauthIndMsg->peer_macaddr);
13048
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013049 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013050 sme_warn("gets an unknown type (%d)", type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013051 result = eCSR_ROAM_RESULT_NONE;
13052 pSession->joinFailStatusCode.reasonCode = 1;
13053 }
13054
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053013055 if (type == eWNI_SME_DISASSOC_IND || type == eWNI_SME_DEAUTH_IND) {
13056 struct sir_peer_info_req req;
13057
13058 req.sessionid = sessionId;
13059 req.peer_macaddr = roamInfo.peerMac;
13060 sme_get_peer_stats(pMac, req);
13061 }
13062 csr_roam_call_callback(pMac, sessionId, NULL, 0,
13063 eCSR_ROAM_LOSTLINK_DETECTED, result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013064
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013065 if (eWNI_SME_DISASSOC_IND == type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013066 status = csr_send_mb_disassoc_cnf_msg(pMac, pDisassocIndMsg);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013067 else if (eWNI_SME_DEAUTH_IND == type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013068 status = csr_send_mb_deauth_cnf_msg(pMac, pDeauthIndMsg);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013069
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013070 /* prepare to tell HDD to disconnect */
Jeff Johnson172237b2017-11-07 15:32:59 -080013071 qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013072 roamInfo.statusCode = (tSirResultCodes) pSession->roamingStatusCode;
13073 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
13074 if (eWNI_SME_DISASSOC_IND == type) {
13075 /* staMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053013076 qdf_copy_macaddr(&roamInfo.peerMac,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080013077 &pDisassocIndMsg->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013078 roamInfo.staId = (uint8_t) pDisassocIndMsg->staId;
13079 roamInfo.reasonCode = pDisassocIndMsg->reasonCode;
13080 } else if (eWNI_SME_DEAUTH_IND == type) {
13081 /* staMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053013082 qdf_copy_macaddr(&roamInfo.peerMac,
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080013083 &pDeauthIndMsg->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013084 roamInfo.staId = (uint8_t) pDeauthIndMsg->staId;
13085 roamInfo.reasonCode = pDeauthIndMsg->reasonCode;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -080013086 roamInfo.rxRssi = pDeauthIndMsg->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013087 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013088 sme_debug("roamInfo.staId: %d", roamInfo.staId);
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -080013089/* Dont initiate internal driver based roaming after disconnection*/
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013090 return status;
13091}
13092
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013093
Himanshu Agarwald519b4a2018-03-27 15:36:09 +053013094void csr_roam_wm_status_change_complete(tpAniSirGlobal pMac,
13095 uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013096{
13097 tListElem *pEntry;
13098 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013099
Krunal Sonia8270f52017-02-23 19:51:25 -080013100 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013101 if (pEntry) {
13102 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
13103 if (eSmeCommandWmStatusChange == pCommand->command) {
13104 /* Nothing to process in a Lost Link completion.... It just kicks off a */
13105 /* roaming sequence. */
Krunal Soni72dba662017-02-15 20:13:17 -080013106 if (csr_nonscan_active_ll_remove_entry(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013107 LL_ACCESS_LOCK)) {
Krunal Sonidea45952017-02-15 11:58:15 -080013108 csr_release_command(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013109 } else {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013110 sme_err(
13111 " ******csr_roam_wm_status_change_complete fail to release command");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013112 }
13113
13114 } else {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013115 sme_warn(
13116"CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ...");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013117 }
13118 } else {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013119 sme_warn(
13120 "CSR: WmStatusChange Completion called but NO commands are ACTIVE ...");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013121 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013122}
13123
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013124void csr_roam_process_wm_status_change_command(
13125 tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013126{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013127 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013128 tSirSmeRsp *pSirSmeMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013129 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
13130 pCommand->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013131
13132 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013133 sme_err("session %d not found", pCommand->sessionId);
Himanshu Agarwald519b4a2018-03-27 15:36:09 +053013134 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013135 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013136 sme_debug("session:%d, CmdType : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013137 pCommand->sessionId, pCommand->u.wmStatusChangeCmd.Type);
13138
13139 switch (pCommand->u.wmStatusChangeCmd.Type) {
13140 case eCsrDisassociated:
13141 pSirSmeMsg =
13142 (tSirSmeRsp *) &pCommand->u.wmStatusChangeCmd.u.
13143 DisassocIndMsg;
13144 status =
13145 csr_roam_lost_link(pMac, pCommand->sessionId,
13146 eWNI_SME_DISASSOC_IND, pSirSmeMsg);
13147 break;
13148 case eCsrDeauthenticated:
13149 pSirSmeMsg =
13150 (tSirSmeRsp *) &pCommand->u.wmStatusChangeCmd.u.
13151 DeauthIndMsg;
13152 status =
13153 csr_roam_lost_link(pMac, pCommand->sessionId,
13154 eWNI_SME_DEAUTH_IND, pSirSmeMsg);
13155 break;
13156 default:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013157 sme_warn("gets an unknown command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013158 pCommand->u.wmStatusChangeCmd.Type);
13159 break;
13160 }
Himanshu Agarwald519b4a2018-03-27 15:36:09 +053013161
13162end:
13163 if (status != QDF_STATUS_SUCCESS) {
13164 /*
13165 * As status returned is not success, there is nothing else
13166 * left to do so release WM status change command here.
13167 */
13168 csr_roam_wm_status_change_complete(pMac, pCommand->sessionId);
13169 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013170}
13171
13172
13173/**
13174 * csr_compute_mode_and_band() - computes dot11mode
13175 * @pMac: mac global context
13176 * @dot11_mode: out param, do11 mode calculated
13177 * @band: out param, band caclculated
13178 * @opr_ch: operating channels
13179 *
13180 * This function finds dot11 mode based on current mode, operating channel and
13181 * fw supported modes.
13182 *
13183 * Return: void
13184 */
13185static void
13186csr_compute_mode_and_band(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013187 enum csr_cfgdot11mode *dot11_mode,
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013188 enum band_info *band,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013189 uint8_t opr_ch)
13190{
13191 bool vht_24_ghz = mac_ctx->roam.configParam.enableVhtFor24GHz;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080013192
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013193 switch (mac_ctx->roam.configParam.uCfgDot11Mode) {
13194 case eCSR_CFG_DOT11_MODE_11A:
13195 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013196 *band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013197 break;
13198 case eCSR_CFG_DOT11_MODE_11B:
13199 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013200 *band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013201 break;
13202 case eCSR_CFG_DOT11_MODE_11G:
13203 *dot11_mode = eCSR_CFG_DOT11_MODE_11G;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013204 *band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013205 break;
13206 case eCSR_CFG_DOT11_MODE_11N:
13207 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13208 *band = CSR_GET_BAND(opr_ch);
13209 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013210 case eCSR_CFG_DOT11_MODE_11AC:
13211 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
13212 /*
13213 * If the operating channel is in 2.4 GHz band, check
13214 * for INI item to disable VHT operation in 2.4 GHz band
13215 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013216 if (WLAN_REG_IS_24GHZ_CH(opr_ch) && !vht_24_ghz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013217 /* Disable 11AC operation */
13218 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13219 else
13220 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC;
13221 } else {
13222 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13223 }
13224 *band = CSR_GET_BAND(opr_ch);
13225 break;
13226 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
13227 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
13228 /*
13229 * If the operating channel is in 2.4 GHz band, check
13230 * for INI item to disable VHT operation in 2.4 GHz band
13231 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013232 if (WLAN_REG_IS_24GHZ_CH(opr_ch) && !vht_24_ghz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013233 /* Disable 11AC operation */
13234 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13235 else
13236 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
13237 } else {
13238 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13239 }
13240 *band = CSR_GET_BAND(opr_ch);
13241 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080013242 case eCSR_CFG_DOT11_MODE_11AX:
13243 case eCSR_CFG_DOT11_MODE_11AX_ONLY:
13244 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX)) {
13245 *dot11_mode = mac_ctx->roam.configParam.uCfgDot11Mode;
13246 } else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
13247 /*
13248 * If the operating channel is in 2.4 GHz band, check
13249 * for INI item to disable VHT operation in 2.4 GHz band
13250 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013251 if (WLAN_REG_IS_24GHZ_CH(opr_ch) && !vht_24_ghz)
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080013252 /* Disable 11AC operation */
13253 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13254 else
13255 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC;
13256 } else {
13257 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13258 }
13259 *band = CSR_GET_BAND(opr_ch);
13260 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013261 case eCSR_CFG_DOT11_MODE_AUTO:
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080013262 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX)) {
13263 *dot11_mode = eCSR_CFG_DOT11_MODE_11AX;
13264 } else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013265 /*
13266 * If the operating channel is in 2.4 GHz band,
13267 * check for INI item to disable VHT operation
13268 * in 2.4 GHz band
13269 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013270 if (WLAN_REG_IS_24GHZ_CH(opr_ch)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013271 && !vht_24_ghz)
13272 /* Disable 11AC operation */
13273 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13274 else
13275 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC;
13276 } else {
13277 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
13278 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013279 *band = CSR_GET_BAND(opr_ch);
13280 break;
13281 default:
13282 /*
13283 * Global dot11 Mode setting is 11a/b/g. use the channel number
13284 * to determine the Mode setting.
13285 */
13286 if (eCSR_OPERATING_CHANNEL_AUTO == opr_ch) {
13287 *band = mac_ctx->roam.configParam.eBand;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013288 if (BAND_2G == *band) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013289 /*
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013290 * See reason in else if ( WLAN_REG_IS_24GHZ_CH
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013291 * (opr_ch) ) to pick 11B
13292 */
13293 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
13294 } else {
13295 /* prefer 5GHz */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013296 *band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013297 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
13298 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013299 } else if (WLAN_REG_IS_24GHZ_CH(opr_ch)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013300 /*
13301 * WiFi tests require IBSS networks to start in 11b mode
13302 * without any change to the default parameter settings
13303 * on the adapter. We use ACU to start an IBSS through
13304 * creation of a startIBSS profile. This startIBSS
13305 * profile has Auto MACProtocol and the adapter property
13306 * setting for dot11Mode is also AUTO. So in this case,
13307 * let's start the IBSS network in 11b mode instead of
13308 * 11g mode. So this is for Auto=profile->MacProtocol &&
13309 * Auto=Global. dot11Mode && profile->channel is < 14,
13310 * then start the IBSS in b mode.
13311 *
13312 * Note: we used to have this start as an 11g IBSS for
13313 * best performance. now to specify that the user will
13314 * have to set the do11Mode in the property page to 11g
13315 * to force it.
13316 */
13317 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013318 *band = BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013319 } else {
13320 /* else, it's a 5.0GHz channel. Set mode to 11a. */
13321 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013322 *band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013323 }
13324 break;
13325 } /* switch */
13326}
13327
13328/**
13329 * csr_roam_get_phy_mode_band_for_bss() - This function returns band and mode
13330 * information.
13331 * @mac_ctx: mac global context
13332 * @profile: bss profile
13333 * @band: out param, band caclculated
13334 * @opr_ch: operating channels
13335 *
13336 * This function finds dot11 mode based on current mode, operating channel and
13337 * fw supported modes. The only tricky part is that if phyMode is set to 11abg,
13338 * this function may return eCSR_CFG_DOT11_MODE_11B instead of
13339 * eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
13340 *
13341 * Return: dot11mode
13342 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013343static enum csr_cfgdot11mode
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013344csr_roam_get_phy_mode_band_for_bss(tpAniSirGlobal mac_ctx,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070013345 struct csr_roam_profile *profile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013346 uint8_t opr_chn,
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013347 enum band_info *p_band)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013348{
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013349 enum band_info band;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013350enum csr_cfgdot11mode curr_mode = mac_ctx->roam.configParam.uCfgDot11Mode;
13351 enum csr_cfgdot11mode cfg_dot11_mode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013352 csr_get_cfg_dot11_mode_from_csr_phy_mode(profile,
13353 (eCsrPhyMode) profile->phyMode,
13354 mac_ctx->roam.configParam.ProprietaryRatesEnabled);
13355
13356 /*
13357 * If the global setting for dot11Mode is set to auto/abg, we overwrite
13358 * the setting in the profile.
13359 */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070013360 if ((!CSR_IS_INFRA_AP(profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013361 && ((eCSR_CFG_DOT11_MODE_AUTO == curr_mode)
13362 || (eCSR_CFG_DOT11_MODE_ABG == curr_mode)))
13363 || (eCSR_CFG_DOT11_MODE_AUTO == cfg_dot11_mode)
13364 || (eCSR_CFG_DOT11_MODE_ABG == cfg_dot11_mode)) {
13365 csr_compute_mode_and_band(mac_ctx, &cfg_dot11_mode,
13366 &band, opr_chn);
13367 } /* if( eCSR_CFG_DOT11_MODE_ABG == cfg_dot11_mode ) */
13368 else {
13369 /* dot11 mode is set, lets pick the band */
13370 if (eCSR_OPERATING_CHANNEL_AUTO == opr_chn) {
13371 /* channel is Auto also. */
13372 band = mac_ctx->roam.configParam.eBand;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013373 if (BAND_ALL == band) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013374 /* prefer 5GHz */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013375 band = BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013376 }
13377 } else{
13378 band = CSR_GET_BAND(opr_chn);
13379 }
13380 }
13381 if (p_band)
13382 *p_band = band;
13383
13384 if (opr_chn == 14) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013385 sme_err("Switching to Dot11B mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013386 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11B;
13387 }
13388
Gupta, Kapil76ed25e2016-04-22 15:13:55 +053013389 if (IS_24G_CH(opr_chn) &&
13390 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
13391 (eCSR_CFG_DOT11_MODE_11AC == cfg_dot11_mode ||
13392 eCSR_CFG_DOT11_MODE_11AC_ONLY == cfg_dot11_mode))
13393 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11N;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013394 /*
13395 * Incase of WEP Security encryption type is coming as part of add key.
13396 * So while STart BSS dont have information
13397 */
13398 if ((!CSR_IS_11n_ALLOWED(profile->EncryptionType.encryptionType[0])
13399 || ((profile->privacy == 1)
13400 && (profile->EncryptionType.encryptionType[0] ==
13401 eCSR_ENCRYPT_TYPE_NONE)))
13402 && ((eCSR_CFG_DOT11_MODE_11N == cfg_dot11_mode) ||
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -080013403 (eCSR_CFG_DOT11_MODE_11AC == cfg_dot11_mode) ||
13404 (eCSR_CFG_DOT11_MODE_11AX == cfg_dot11_mode))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013405 /* We cannot do 11n here */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013406 if (WLAN_REG_IS_24GHZ_CH(opr_chn))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013407 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11G;
13408 else
13409 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11A;
13410 }
Srinivas Girigowda2c263352017-03-17 17:49:53 -070013411 sme_debug("dot11mode: %d", cfg_dot11_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013412 return cfg_dot11_mode;
13413}
13414
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013415QDF_STATUS csr_roam_issue_stop_bss(tpAniSirGlobal pMac,
13416 uint32_t sessionId, enum csr_roam_substate NewSubstate)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013417{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013418 QDF_STATUS status;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053013419 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013420
13421 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013422 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013423 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013424 }
13425#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
13426 {
13427 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013428
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013429 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
13430 LOG_WLAN_IBSS_C);
13431 if (pIbssLog) {
13432 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
13433 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
13434 }
13435 }
13436#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
13437 /* Set the roaming substate to 'stop Bss request'... */
13438 csr_roam_substate_change(pMac, NewSubstate, sessionId);
13439
13440 /* attempt to stop the Bss (reason code is ignored...) */
13441 status = csr_send_mb_stop_bss_req_msg(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013442 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013443 sme_warn(
13444 "csr_send_mb_stop_bss_req_msg failed with status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013445 status);
13446 }
13447 return status;
13448}
13449
13450/* pNumChan is a caller allocated space with the sizeof pChannels */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013451QDF_STATUS csr_get_cfg_valid_channels(tpAniSirGlobal pMac, uint8_t *pChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013452 uint32_t *pNumChan)
13453{
Edhar, Mahesh Kumareb31abd2016-01-21 17:50:47 +053013454 uint8_t num_chan_temp = 0;
13455 int i;
13456
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013457 if (!IS_SIR_STATUS_SUCCESS(wlan_cfg_get_str(pMac,
13458 WNI_CFG_VALID_CHANNEL_LIST,
13459 (uint8_t *) pChannels, pNumChan)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013460 return QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumareb31abd2016-01-21 17:50:47 +053013461
13462 for (i = 0; i < *pNumChan; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013463 if (!WLAN_REG_IS_11P_CH(pChannels[i])) {
Edhar, Mahesh Kumareb31abd2016-01-21 17:50:47 +053013464 pChannels[num_chan_temp] = pChannels[i];
13465 num_chan_temp++;
13466 }
13467 }
13468
13469 *pNumChan = num_chan_temp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013470 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013471}
13472
Amar Singhala297bfa2015-10-15 15:07:29 -070013473int8_t csr_get_cfg_max_tx_power(tpAniSirGlobal pMac, uint8_t channel)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013474{
13475 uint32_t cfgLength = 0;
13476 uint16_t cfgId = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -070013477 int8_t maxTxPwr = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013478 uint8_t *pCountryInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013479 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013480 uint8_t count = 0;
13481 uint8_t firstChannel;
13482 uint8_t maxChannels;
13483
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013484 if (WLAN_REG_IS_5GHZ_CH(channel)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013485 cfgId = WNI_CFG_MAX_TX_POWER_5;
13486 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013487 } else if (WLAN_REG_IS_24GHZ_CH(channel)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013488 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
13489 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
13490 } else
13491 return maxTxPwr;
13492
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013493 pCountryInfo = qdf_mem_malloc(cfgLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013494 if (NULL == pCountryInfo)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013495 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013496 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013497 status = QDF_STATUS_SUCCESS;
13498 if (status != QDF_STATUS_SUCCESS) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013499 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013500 "%s: failed to allocate memory, status = %d",
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013501 __func__, status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013502 goto error;
13503 }
13504 if (wlan_cfg_get_str(pMac, cfgId, (uint8_t *)pCountryInfo,
13505 &cfgLength) != eSIR_SUCCESS) {
13506 goto error;
13507 }
13508 /* Identify the channel and maxtxpower */
13509 while (count <= (cfgLength - (sizeof(tSirMacChanInfo)))) {
13510 firstChannel = pCountryInfo[count++];
13511 maxChannels = pCountryInfo[count++];
13512 maxTxPwr = pCountryInfo[count++];
13513
13514 if ((channel >= firstChannel) &&
13515 (channel < (firstChannel + maxChannels))) {
13516 break;
13517 }
13518 }
13519
13520error:
13521 if (NULL != pCountryInfo)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013522 qdf_mem_free(pCountryInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013523
13524 return maxTxPwr;
13525}
13526
13527bool csr_roam_is_channel_valid(tpAniSirGlobal pMac, uint8_t channel)
13528{
13529 bool fValid = false;
13530 uint32_t idxValidChannels;
13531 uint32_t len = sizeof(pMac->roam.validChannelList);
13532
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013533 if (QDF_IS_STATUS_SUCCESS(csr_get_cfg_valid_channels(pMac,
13534 pMac->roam.validChannelList, &len))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013535 for (idxValidChannels = 0; (idxValidChannels < len);
13536 idxValidChannels++) {
13537 if (channel ==
13538 pMac->roam.validChannelList[idxValidChannels]) {
13539 fValid = true;
13540 break;
13541 }
13542 }
13543 }
13544 pMac->roam.numValidChannels = len;
13545 return fValid;
13546}
13547
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013548/* This function check and validate whether the NIC can do CB (40MHz) */
13549static ePhyChanBondState csr_get_cb_mode_from_ies(tpAniSirGlobal pMac,
13550 uint8_t primaryChn,
13551 tDot11fBeaconIEs *pIes)
13552{
13553 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
13554 uint8_t centerChn;
13555 uint32_t ChannelBondingMode;
Abhishek Singh08b06b72017-08-21 14:12:58 +053013556 struct ch_params ch_params = {0};
13557
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013558 if (WLAN_REG_IS_24GHZ_CH(primaryChn)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013559 ChannelBondingMode =
13560 pMac->roam.configParam.channelBondingMode24GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013561 } else {
13562 ChannelBondingMode =
13563 pMac->roam.configParam.channelBondingMode5GHz;
13564 }
13565
13566 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE == ChannelBondingMode)
13567 return PHY_SINGLE_CHANNEL_CENTERED;
13568
13569 /* Figure what the other side's CB mode */
13570 if (!(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ ==
13571 pIes->HTCaps.supportedChannelWidthSet))) {
13572 return PHY_SINGLE_CHANNEL_CENTERED;
13573 }
13574
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053013575 /* In Case WPA2 and TKIP is the only one cipher suite in Pairwise */
13576 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013577 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053013578 "\x00\x0f\xac\x02", 4))
Abhishek Singh1e39fc22015-12-18 11:23:44 +053013579 /* In Case only WPA1 is supported and TKIP is
13580 * the only one cipher suite in Unicast.
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053013581 */
Abhishek Singh1e39fc22015-12-18 11:23:44 +053013582 || (!pIes->RSN.present && (pIes->WPA.present &&
13583 (pIes->WPA.unicast_cipher_count == 1) &&
13584 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
13585 "\x00\x50\xf2\x02", 4)))) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013586 sme_debug("No channel bonding in TKIP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013587 return PHY_SINGLE_CHANNEL_CENTERED;
13588 }
13589
13590 if (!pIes->HTInfo.present)
13591 return PHY_SINGLE_CHANNEL_CENTERED;
13592
13593 /*
13594 * This is called during INFRA STA/CLIENT and should use the merged
13595 * value of supported channel width and recommended tx width as per
13596 * standard
13597 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013598 sme_debug("scws %u rtws %u sco %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013599 pIes->HTCaps.supportedChannelWidthSet,
13600 pIes->HTInfo.recommendedTxWidthSet,
13601 pIes->HTInfo.secondaryChannelOffset);
13602
13603 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
13604 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
13605 else
13606 eRet = PHY_SINGLE_CHANNEL_CENTERED;
13607
13608 switch (eRet) {
13609 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
13610 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
13611 break;
13612 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
13613 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
13614 break;
13615 case PHY_SINGLE_CHANNEL_CENTERED:
13616 default:
13617 centerChn = primaryChn;
13618 break;
13619 }
13620
Abhishek Singh08b06b72017-08-21 14:12:58 +053013621 if (PHY_SINGLE_CHANNEL_CENTERED != eRet) {
13622 ch_params.ch_width = CH_WIDTH_MAX;
13623
13624 wlan_reg_set_channel_params(pMac->pdev, primaryChn,
13625 0, &ch_params);
13626 if (ch_params.ch_width == CH_WIDTH_20MHZ) {
13627 sme_err("40Mhz not supported for channel %d, continue with 20Mhz",
13628 centerChn);
13629 eRet = PHY_SINGLE_CHANNEL_CENTERED;
13630 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013631 }
13632 return eRet;
13633}
13634
Jeff Johnson29e2ca12016-10-14 12:50:38 -070013635static bool csr_is_encryption_in_list(tpAniSirGlobal pMac,
13636 tCsrEncryptionList *pCipherList,
13637 eCsrEncryptionType encryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013638{
13639 bool fFound = false;
13640 uint32_t idx;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013641
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013642 for (idx = 0; idx < pCipherList->numEntries; idx++) {
13643 if (pCipherList->encryptionType[idx] == encryptionType) {
13644 fFound = true;
13645 break;
13646 }
13647 }
13648 return fFound;
13649}
13650
Jeff Johnson29e2ca12016-10-14 12:50:38 -070013651static bool csr_is_auth_in_list(tpAniSirGlobal pMac, tCsrAuthList *pAuthList,
13652 eCsrAuthType authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013653{
13654 bool fFound = false;
13655 uint32_t idx;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013656
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013657 for (idx = 0; idx < pAuthList->numEntries; idx++) {
13658 if (pAuthList->authType[idx] == authType) {
13659 fFound = true;
13660 break;
13661 }
13662 }
13663 return fFound;
13664}
13665
13666bool csr_is_same_profile(tpAniSirGlobal pMac,
13667 tCsrRoamConnectedProfile *pProfile1,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070013668 struct csr_roam_profile *pProfile2)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013669{
13670 uint32_t i;
13671 bool fCheck = false;
13672 tCsrScanResultFilter *pScanFilter = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013673 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013674
13675 if (!(pProfile1 && pProfile2))
13676 return fCheck;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013677 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013678 if (NULL == pScanFilter)
13679 return fCheck;
13680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013681 status = csr_roam_prepare_filter_from_profile(pMac, pProfile2,
13682 pScanFilter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013683 if (!(QDF_IS_STATUS_SUCCESS(status)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013684 goto free_scan_filter;
13685
13686 for (i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++) {
13687 fCheck = csr_is_ssid_match(pMac,
13688 pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
13689 pScanFilter->SSIDs.SSIDList[i].SSID.length,
13690 pProfile1->SSID.ssId,
13691 pProfile1->SSID.length,
13692 false);
13693 if (fCheck)
13694 break;
13695 }
13696 if (!fCheck)
13697 goto free_scan_filter;
13698
13699 if (!csr_is_auth_in_list(pMac, &pProfile2->AuthType,
13700 pProfile1->AuthType)
13701 || (pProfile2->BSSType != pProfile1->BSSType)
13702 || !csr_is_encryption_in_list(pMac, &pProfile2->EncryptionType,
13703 pProfile1->EncryptionType)) {
13704 fCheck = false;
13705 goto free_scan_filter;
13706 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013707 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent) {
13708 if (pProfile1->MDID.mobilityDomain
13709 != pProfile2->MDID.mobilityDomain) {
13710 fCheck = false;
13711 goto free_scan_filter;
13712 }
13713 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013714 /* Match found */
13715 fCheck = true;
13716free_scan_filter:
13717 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013718 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013719 return fCheck;
13720}
13721
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013722static bool csr_roam_is_same_profile_keys(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013723 tCsrRoamConnectedProfile *pConnProfile,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070013724 struct csr_roam_profile *pProfile2)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013725{
13726 bool fCheck = false;
13727 int i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013728
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013729 do {
13730 /* Only check for static WEP */
13731 if (!csr_is_encryption_in_list
13732 (pMac, &pProfile2->EncryptionType,
13733 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY)
13734 && !csr_is_encryption_in_list(pMac,
13735 &pProfile2->EncryptionType,
13736 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
13737 fCheck = true;
13738 break;
13739 }
13740 if (!csr_is_encryption_in_list
13741 (pMac, &pProfile2->EncryptionType,
13742 pConnProfile->EncryptionType))
13743 break;
13744 if (pConnProfile->Keys.defaultIndex !=
13745 pProfile2->Keys.defaultIndex)
13746 break;
13747 for (i = 0; i < CSR_MAX_NUM_KEY; i++) {
13748 if (pConnProfile->Keys.KeyLength[i] !=
13749 pProfile2->Keys.KeyLength[i])
13750 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013751 if (qdf_mem_cmp(&pConnProfile->Keys.KeyMaterial[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013752 &pProfile2->Keys.KeyMaterial[i],
13753 pProfile2->Keys.KeyLength[i])) {
13754 break;
13755 }
13756 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013757 if (i == CSR_MAX_NUM_KEY)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013758 fCheck = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013759 } while (0);
13760 return fCheck;
13761}
13762
13763/* IBSS */
13764
Jeff Johnson29e2ca12016-10-14 12:50:38 -070013765static uint8_t csr_roam_get_ibss_start_channel_number50(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013766{
13767 uint8_t channel = 0;
13768 uint32_t idx;
13769 uint32_t idxValidChannels;
13770 bool fFound = false;
13771 uint32_t len = sizeof(pMac->roam.validChannelList);
13772
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013773 if (eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.
13774 AdHocChannel5G) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013775 channel = pMac->roam.configParam.AdHocChannel5G;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013776 if (!csr_roam_is_channel_valid(pMac, channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013777 channel = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013778 }
13779 if (0 == channel
13780 &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013781 QDF_IS_STATUS_SUCCESS(csr_get_cfg_valid_channels
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013782 (pMac, (uint8_t *) pMac->roam.
13783 validChannelList, &len))) {
Sandeep Puligilla80038de2017-05-10 10:43:29 -070013784 for (idx = 0; (idx < CSR_NUM_IBSS_START_CHAN_50) && !fFound;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013785 idx++) {
13786 for (idxValidChannels = 0;
13787 (idxValidChannels < len) && !fFound;
13788 idxValidChannels++) {
13789 if (csr_start_ibss_channels50[idx] ==
13790 pMac->roam.
13791 validChannelList[idxValidChannels]) {
13792 fFound = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013793 channel =
13794 csr_start_ibss_channels50[idx];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013795 }
13796 }
13797 }
13798 /*
13799 * this is rare, but if it does happen,
13800 * we find anyone in 11a bandwidth and
13801 * return the first 11a channel found!
13802 */
13803 if (!fFound) {
13804 for (idxValidChannels = 0; idxValidChannels < len;
13805 idxValidChannels++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013806 if (WLAN_REG_IS_5GHZ_CH(pMac->roam.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013807 validChannelList[idxValidChannels])) {
13808 /* the max channel# in 11g is 14 */
13809 if (idxValidChannels <
Sandeep Puligilla80038de2017-05-10 10:43:29 -070013810 CSR_NUM_IBSS_START_CHAN_50) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013811 channel =
13812 pMac->roam.validChannelList
13813 [idxValidChannels];
13814 }
13815 break;
13816 }
13817 }
13818 }
13819 } /* if */
13820
13821 return channel;
13822}
13823
Jeff Johnson29e2ca12016-10-14 12:50:38 -070013824static uint8_t csr_roam_get_ibss_start_channel_number24(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013825{
13826 uint8_t channel = 1;
13827 uint32_t idx;
13828 uint32_t idxValidChannels;
13829 bool fFound = false;
13830 uint32_t len = sizeof(pMac->roam.validChannelList);
13831
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013832 if (eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.
13833 AdHocChannel24) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013834 channel = pMac->roam.configParam.AdHocChannel24;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013835 if (!csr_roam_is_channel_valid(pMac, channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013836 channel = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013837 }
13838
13839 if (0 == channel
13840 &&
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013841 QDF_IS_STATUS_SUCCESS(csr_get_cfg_valid_channels(pMac,
13842 (uint8_t *) pMac->roam.validChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013843 &len))) {
13844 for (idx = 0; (idx < CSR_NUM_IBSS_START_CHANNELS_24) && !fFound;
13845 idx++) {
13846 for (idxValidChannels = 0;
13847 (idxValidChannels < len) && !fFound;
13848 idxValidChannels++) {
13849 if (csr_start_ibss_channels24[idx] ==
13850 pMac->roam.
13851 validChannelList[idxValidChannels]) {
13852 fFound = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013853 channel =
13854 csr_start_ibss_channels24[idx];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013855 }
13856 }
13857 }
13858 }
13859
13860 return channel;
13861}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013862/**
13863 * csr_populate_basic_rates() - populates OFDM or CCK rates
13864 * @rates: rate struct to populate
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013865 * @is_ofdm_rates: true: ofdm rates, false: cck rates
13866 * @is_basic_rates: indicates if rates are to be masked with
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013867 * CSR_DOT11_BASIC_RATE_MASK
13868 *
13869 * This function will populate OFDM or CCK rates
13870 *
13871 * Return: void
13872 */
13873static void
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013874csr_populate_basic_rates(tSirMacRateSet *rate_set, bool is_ofdm_rates,
13875 bool is_basic_rates)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013876{
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013877 int i = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013878 uint8_t ofdm_rates[8] = {
13879 SIR_MAC_RATE_6,
13880 SIR_MAC_RATE_9,
13881 SIR_MAC_RATE_12,
13882 SIR_MAC_RATE_18,
13883 SIR_MAC_RATE_24,
13884 SIR_MAC_RATE_36,
13885 SIR_MAC_RATE_48,
13886 SIR_MAC_RATE_54
13887 };
13888 uint8_t cck_rates[4] = {
13889 SIR_MAC_RATE_1,
13890 SIR_MAC_RATE_2,
13891 SIR_MAC_RATE_5_5,
13892 SIR_MAC_RATE_11
13893 };
13894
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013895 if (is_ofdm_rates == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013896 rate_set->numRates = 8;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013897 qdf_mem_copy(rate_set->rate, ofdm_rates, sizeof(ofdm_rates));
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013898 if (is_basic_rates) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013899 rate_set->rate[0] |= CSR_DOT11_BASIC_RATE_MASK;
13900 rate_set->rate[2] |= CSR_DOT11_BASIC_RATE_MASK;
13901 rate_set->rate[4] |= CSR_DOT11_BASIC_RATE_MASK;
13902 }
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013903 for (i = 0; i < rate_set->numRates; i++)
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013904 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
13905 ("Default OFDM rate is %2x"), rate_set->rate[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013906 } else {
13907 rate_set->numRates = 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013908 qdf_mem_copy(rate_set->rate, cck_rates, sizeof(cck_rates));
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013909 if (is_basic_rates) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013910 rate_set->rate[0] |= CSR_DOT11_BASIC_RATE_MASK;
13911 rate_set->rate[1] |= CSR_DOT11_BASIC_RATE_MASK;
13912 rate_set->rate[2] |= CSR_DOT11_BASIC_RATE_MASK;
13913 rate_set->rate[3] |= CSR_DOT11_BASIC_RATE_MASK;
13914 }
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013915 for (i = 0; i < rate_set->numRates; i++)
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013916 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
13917 ("Default CCK rate is %2x"), rate_set->rate[i]);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013918
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013919 }
13920}
13921
13922/**
13923 * csr_convert_mode_to_nw_type() - convert mode into network type
13924 * @dot11_mode: dot11_mode
13925 * @band: 2.4 or 5 GHz
13926 *
13927 * Return: tSirNwType
13928 */
13929static tSirNwType
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013930csr_convert_mode_to_nw_type(enum csr_cfgdot11mode dot11_mode,
13931 enum band_info band)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013932{
13933 switch (dot11_mode) {
13934 case eCSR_CFG_DOT11_MODE_11G:
13935 return eSIR_11G_NW_TYPE;
13936 case eCSR_CFG_DOT11_MODE_11B:
13937 return eSIR_11B_NW_TYPE;
13938 case eCSR_CFG_DOT11_MODE_11A:
13939 return eSIR_11A_NW_TYPE;
13940 case eCSR_CFG_DOT11_MODE_11N:
13941 default:
13942 /*
13943 * Because LIM only verifies it against 11a, 11b or 11g, set
13944 * only 11g or 11a here
13945 */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080013946 if (BAND_2G == band)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013947 return eSIR_11G_NW_TYPE;
13948 else
13949 return eSIR_11A_NW_TYPE;
13950 }
13951 return eSIR_DONOT_USE_NW_TYPE;
13952}
13953
13954/**
hqu16d6e082017-09-04 10:52:31 +080013955 * csr_populate_supported_rates_from_hostapd() - populates operational
13956 * and extended rates.
13957 * from hostapd.conf file
13958 * @opr_rates: rate struct to populate operational rates
13959 * @ext_rates: rate struct to populate extended rates
13960 * @profile: bss profile
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013961 *
hqu16d6e082017-09-04 10:52:31 +080013962 * Return: void
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013963 */
hqu16d6e082017-09-04 10:52:31 +080013964static void csr_populate_supported_rates_from_hostapd(tSirMacRateSet *opr_rates,
13965 tSirMacRateSet *ext_rates,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070013966 struct csr_roam_profile *profile)
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013967{
hqu16d6e082017-09-04 10:52:31 +080013968 int i = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013969
Ravi Joshib398c852017-07-18 17:55:21 -070013970 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
13971 FL("supported_rates: %d extended_rates: %d"),
hqu16d6e082017-09-04 10:52:31 +080013972 profile->supported_rates.numRates,
13973 profile->extended_rates.numRates);
Ravi Joshib398c852017-07-18 17:55:21 -070013974
hqu16d6e082017-09-04 10:52:31 +080013975 if (profile->supported_rates.numRates > SIR_MAC_RATESET_EID_MAX)
13976 profile->supported_rates.numRates = SIR_MAC_RATESET_EID_MAX;
Ravi Joshib398c852017-07-18 17:55:21 -070013977
hqu16d6e082017-09-04 10:52:31 +080013978 if (profile->extended_rates.numRates > SIR_MAC_RATESET_EID_MAX)
13979 profile->extended_rates.numRates = SIR_MAC_RATESET_EID_MAX;
Ravi Joshib398c852017-07-18 17:55:21 -070013980
hqu16d6e082017-09-04 10:52:31 +080013981 if (profile->supported_rates.numRates) {
13982 opr_rates->numRates = profile->supported_rates.numRates;
13983 qdf_mem_copy(opr_rates->rate,
13984 profile->supported_rates.rate,
13985 profile->supported_rates.numRates);
13986 for (i = 0; i < opr_rates->numRates; i++)
13987 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
13988 FL("Supported Rate is %2x"), opr_rates->rate[i]);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013989 }
hqu16d6e082017-09-04 10:52:31 +080013990 if (profile->extended_rates.numRates) {
13991 ext_rates->numRates =
13992 profile->extended_rates.numRates;
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013993 qdf_mem_copy(ext_rates->rate,
hqu16d6e082017-09-04 10:52:31 +080013994 profile->extended_rates.rate,
13995 profile->extended_rates.numRates);
13996 for (i = 0; i < ext_rates->numRates; i++)
13997 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
13998 FL("Extended Rate is %2x"), ext_rates->rate[i]);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013999 }
14000}
lifenge9245fc2017-02-22 17:23:19 +080014001
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014002/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014003 * csr_roam_get_bss_start_parms() - get bss start param from profile
14004 * @pMac: mac global context
14005 * @pProfile: roam profile
14006 * @pParam: out param, start bss params
Krunal Soni8f8507c2016-12-20 13:54:34 -080014007 * @skip_hostapd_rate: to skip given hostapd's rate
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014008 *
14009 * This function populates start bss param from roam profile
14010 *
14011 * Return: void
14012 */
14013static void
14014csr_roam_get_bss_start_parms(tpAniSirGlobal pMac,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014015 struct csr_roam_profile *pProfile,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014016 struct csr_roamstart_bssparams *pParam,
Krunal Soni8f8507c2016-12-20 13:54:34 -080014017 bool skip_hostapd_rate)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014018{
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014019 enum band_info band;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014020 uint8_t opr_ch = 0;
14021 tSirNwType nw_type;
14022 uint8_t tmp_opr_ch = 0;
14023 tSirMacRateSet *opr_rates = &pParam->operationalRateSet;
14024 tSirMacRateSet *ext_rates = &pParam->extendedRateSet;
14025
14026 if (pProfile->ChannelInfo.numOfChannels
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014027 && pProfile->ChannelInfo.ChannelList)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014028 tmp_opr_ch = pProfile->ChannelInfo.ChannelList[0];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014029
14030 pParam->uCfgDot11Mode = csr_roam_get_phy_mode_band_for_bss(pMac,
14031 pProfile, tmp_opr_ch, &band);
14032
Anurag Chouhan6d760662016-02-20 16:05:43 +053014033 if (((pProfile->csrPersona == QDF_P2P_CLIENT_MODE)
14034 || (pProfile->csrPersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014035 && (pParam->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)) {
14036 /* This should never happen */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053014037 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014038 "For P2P (persona %d) dot11_mode is 11B",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014039 pProfile->csrPersona);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053014040 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014041 }
14042
14043 nw_type = csr_convert_mode_to_nw_type(pParam->uCfgDot11Mode, band);
14044 ext_rates->numRates = 0;
hqu16d6e082017-09-04 10:52:31 +080014045 /*
14046 * hostapd.conf will populate its basic and extended rates
14047 * as per hw_mode, but if acs in ini is enabled driver should
14048 * ignore basic and extended rates from hostapd.conf and should
14049 * populate default rates.
14050 */
14051 if (!cds_is_sub_20_mhz_enabled() && !skip_hostapd_rate &&
14052 (pProfile->supported_rates.numRates ||
14053 pProfile->extended_rates.numRates)) {
14054 csr_populate_supported_rates_from_hostapd(opr_rates,
14055 ext_rates, pProfile);
14056 pParam->operationChn = tmp_opr_ch;
14057 } else {
14058 switch (nw_type) {
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014059 default:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014060 sme_err(
14061 "sees an unknown pSirNwType (%d)",
14062 nw_type);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014063 case eSIR_11A_NW_TYPE:
14064 csr_populate_basic_rates(opr_rates, true, true);
14065 if (eCSR_OPERATING_CHANNEL_ANY != tmp_opr_ch) {
14066 opr_ch = tmp_opr_ch;
14067 break;
14068 }
14069 opr_ch = csr_roam_get_ibss_start_channel_number50(pMac);
14070 if (0 == opr_ch &&
hqu16d6e082017-09-04 10:52:31 +080014071 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
14072 CSR_IS_PHY_MODE_DUAL_BAND(
14073 pMac->roam.configParam.phyMode)) {
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014074 /*
14075 * We could not find a 5G channel by auto pick,
14076 * let's try 2.4G channels. We only do this here
14077 * because csr_roam_get_phy_mode_band_for_bss
14078 * always picks 11a for AUTO
14079 */
14080 nw_type = eSIR_11B_NW_TYPE;
14081 opr_ch =
14082 csr_roam_get_ibss_start_channel_number24(pMac);
14083 csr_populate_basic_rates(opr_rates, false,
hqu16d6e082017-09-04 10:52:31 +080014084 true);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014085 }
14086 break;
14087 case eSIR_11B_NW_TYPE:
14088 csr_populate_basic_rates(opr_rates, false, true);
14089 if (eCSR_OPERATING_CHANNEL_ANY == tmp_opr_ch)
14090 opr_ch =
14091 csr_roam_get_ibss_start_channel_number24(pMac);
14092 else
14093 opr_ch = tmp_opr_ch;
14094 break;
14095 case eSIR_11G_NW_TYPE:
14096 /* For P2P Client and P2P GO, disable 11b rates */
14097 if ((pProfile->csrPersona == QDF_P2P_CLIENT_MODE) ||
hqu16d6e082017-09-04 10:52:31 +080014098 (pProfile->csrPersona == QDF_P2P_GO_MODE) ||
14099 (eCSR_CFG_DOT11_MODE_11G_ONLY ==
14100 pParam->uCfgDot11Mode)) {
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014101 csr_populate_basic_rates(opr_rates, true, true);
14102 } else {
14103 csr_populate_basic_rates(opr_rates, false,
hqu16d6e082017-09-04 10:52:31 +080014104 true);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014105 csr_populate_basic_rates(ext_rates, true,
hqu16d6e082017-09-04 10:52:31 +080014106 false);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053014107 }
14108 if (eCSR_OPERATING_CHANNEL_ANY == tmp_opr_ch)
14109 opr_ch =
14110 csr_roam_get_ibss_start_channel_number24(pMac);
14111 else
14112 opr_ch = tmp_opr_ch;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014113 break;
14114 }
hqu16d6e082017-09-04 10:52:31 +080014115 pParam->operationChn = opr_ch;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014116 }
lifenge9245fc2017-02-22 17:23:19 +080014117
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014118 pParam->sirNwType = nw_type;
14119 pParam->ch_params.ch_width = pProfile->ch_params.ch_width;
14120 pParam->ch_params.center_freq_seg0 =
14121 pProfile->ch_params.center_freq_seg0;
14122 pParam->ch_params.center_freq_seg1 =
14123 pProfile->ch_params.center_freq_seg1;
14124 pParam->ch_params.sec_ch_offset =
14125 pProfile->ch_params.sec_ch_offset;
14126}
14127
14128static void
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014129csr_roam_get_bss_start_parms_from_bss_desc(
14130 tpAniSirGlobal pMac,
14131 tSirBssDescription *pBssDesc,
14132 tDot11fBeaconIEs *pIes,
14133 struct csr_roamstart_bssparams *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014134{
14135 if (!pParam) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014136 sme_err("BSS param's pointer is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014137 return;
14138 }
14139
14140 pParam->sirNwType = pBssDesc->nwType;
14141 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
14142 pParam->operationChn = pBssDesc->channelId;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014143 qdf_mem_copy(&pParam->bssid, pBssDesc->bssId,
14144 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014145
14146 if (!pIes) {
14147 pParam->ssId.length = 0;
14148 pParam->operationalRateSet.numRates = 0;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014149 sme_err("IEs struct pointer is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014150 return;
14151 }
14152
14153 if (pIes->SuppRates.present) {
14154 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
14155 if (pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014156 sme_err(
14157 "num_rates: %d > max val, resetting",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014158 pIes->SuppRates.num_rates);
14159 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
14160 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014161 qdf_mem_copy(pParam->operationalRateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014162 pIes->SuppRates.rates,
14163 sizeof(*pIes->SuppRates.rates) *
14164 pIes->SuppRates.num_rates);
14165 }
14166 if (pIes->ExtSuppRates.present) {
14167 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
14168 if (pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014169 sme_err(
14170 "num_rates: %d > max val, resetting",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014171 pIes->ExtSuppRates.num_rates);
14172 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
14173 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014174 qdf_mem_copy(pParam->extendedRateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014175 pIes->ExtSuppRates.rates,
14176 sizeof(*pIes->ExtSuppRates.rates) *
14177 pIes->ExtSuppRates.num_rates);
14178 }
14179 if (pIes->SSID.present) {
14180 pParam->ssId.length = pIes->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014181 qdf_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014182 pParam->ssId.length);
14183 }
14184 pParam->cbMode = csr_get_cb_mode_from_ies(pMac, pParam->operationChn,
14185 pIes);
14186}
14187
14188static void csr_roam_determine_max_rate_for_ad_hoc(tpAniSirGlobal pMac,
14189 tSirMacRateSet *pSirRateSet)
14190{
14191 uint8_t MaxRate = 0;
14192 uint32_t i;
14193 uint8_t *pRate;
14194
14195 pRate = pSirRateSet->rate;
14196 for (i = 0; i < pSirRateSet->numRates; i++) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014197 MaxRate = CSR_MAX(MaxRate, (pRate[i] &
14198 (~CSR_DOT11_BASIC_RATE_MASK)));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014199 }
14200
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014201 /* Save the max rate in the connected state information.
14202 * modify LastRates variable as well
14203 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014205}
14206
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014207QDF_STATUS csr_roam_issue_start_bss(tpAniSirGlobal pMac, uint32_t sessionId,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014208 struct csr_roamstart_bssparams *pParam,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014209 struct csr_roam_profile *pProfile,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014210 tSirBssDescription *pBssDesc,
14211 uint32_t roamId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014212{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014213 QDF_STATUS status = QDF_STATUS_SUCCESS;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080014214 enum band_info eBand;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014215 /* Set the roaming substate to 'Start BSS attempt'... */
14216 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ,
14217 sessionId);
14218#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
14219 /* Need to figure out whether we need to log WDS??? */
14220 if (CSR_IS_IBSS(pProfile)) {
14221 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014222
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014223 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
14224 LOG_WLAN_IBSS_C);
14225 if (pIbssLog) {
14226 if (pBssDesc) {
14227 pIbssLog->eventId =
14228 WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014229 qdf_mem_copy(pIbssLog->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014230 pBssDesc->bssId, QDF_MAC_ADDR_SIZE);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014231 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014232 pIbssLog->eventId =
14233 WLAN_IBSS_EVENT_START_IBSS_REQ;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014234
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014235 qdf_mem_copy(pIbssLog->ssid, pParam->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014236 pParam->ssId.length);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014237 if (pProfile->ChannelInfo.numOfChannels == 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014238 pIbssLog->channelSetting = AUTO_PICK;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014239 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014240 pIbssLog->channelSetting = SPECIFIED;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014241
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014242 pIbssLog->operatingChannel = pParam->operationChn;
14243 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
14244 }
14245 }
14246#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
14247 /* Put RSN information in for Starting BSS */
14248 pParam->nRSNIELength = (uint16_t) pProfile->nRSNReqIELength;
14249 pParam->pRSNIE = pProfile->pRSNReqIE;
14250
14251 pParam->privacy = pProfile->privacy;
14252 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
14253 pParam->authType = pProfile->csr80211AuthType;
14254 pParam->beaconInterval = pProfile->beaconInterval;
14255 pParam->dtimPeriod = pProfile->dtimPeriod;
14256 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
14257 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
14258 if (CSR_IS_INFRA_AP(pProfile) && (pParam->operationChn != 0)) {
14259 if (csr_is_valid_channel(pMac, pParam->operationChn) !=
Himanshu Agarwal10b44362017-09-20 14:55:20 +053014260 QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014261 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
Himanshu Agarwal10b44362017-09-20 14:55:20 +053014262 pParam->ch_params.ch_width = CH_WIDTH_20MHZ;
14263 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014264 }
14265 pParam->protEnabled = pProfile->protEnabled;
14266 pParam->obssProtEnabled = pProfile->obssProtEnabled;
14267 pParam->ht_protection = pProfile->cfg_protection;
14268 pParam->wps_state = pProfile->wps_state;
14269
14270 pParam->uCfgDot11Mode =
14271 csr_roam_get_phy_mode_band_for_bss(pMac, pProfile,
14272 pParam->
14273 operationChn,
14274 &eBand);
14275 pParam->bssPersona = pProfile->csrPersona;
14276
14277#ifdef WLAN_FEATURE_11W
14278 pParam->mfpCapable = (0 != pProfile->MFPCapable);
14279 pParam->mfpRequired = (0 != pProfile->MFPRequired);
14280#endif
14281
14282 pParam->addIeParams.probeRespDataLen =
14283 pProfile->addIeParams.probeRespDataLen;
14284 pParam->addIeParams.probeRespData_buff =
14285 pProfile->addIeParams.probeRespData_buff;
14286
14287 pParam->addIeParams.assocRespDataLen =
14288 pProfile->addIeParams.assocRespDataLen;
14289 pParam->addIeParams.assocRespData_buff =
14290 pProfile->addIeParams.assocRespData_buff;
14291
14292 if (CSR_IS_IBSS(pProfile)) {
14293 pParam->addIeParams.probeRespBCNDataLen =
14294 pProfile->nWPAReqIELength;
14295 pParam->addIeParams.probeRespBCNData_buff = pProfile->pWPAReqIE;
14296 } else {
14297 pParam->addIeParams.probeRespBCNDataLen =
14298 pProfile->addIeParams.probeRespBCNDataLen;
14299 pParam->addIeParams.probeRespBCNData_buff =
14300 pProfile->addIeParams.probeRespBCNData_buff;
14301 }
14302 pParam->sap_dot11mc = pProfile->sap_dot11mc;
Arif Hussain671a1902017-03-17 09:08:32 -070014303 pParam->cac_duration_ms = pProfile->cac_duration_ms;
14304 pParam->dfs_regdomain = pProfile->dfs_regdomain;
Jiachao Wu712d4fd2017-08-23 16:52:34 +080014305 pParam->beacon_tx_rate = pProfile->beacon_tx_rate;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014306
14307 /* When starting an IBSS, start on the channel from the Profile. */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014308 status = csr_send_mb_start_bss_req_msg(pMac, sessionId,
14309 pProfile->BSSType, pParam,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014310 pBssDesc);
14311 return status;
14312}
14313
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -070014314void csr_roam_prepare_bss_params(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014315 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014316 tSirBssDescription *pBssDesc,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014317 struct bss_config_param *pBssConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014318 tDot11fBeaconIEs *pIes)
14319{
14320 uint8_t Channel;
14321 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014322 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Ganesh Kondabattini4a7f5b92017-11-21 14:58:39 +053014323 bool skip_hostapd_rate = !pProfile->chan_switch_hostapd_rate_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014324
14325 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014326 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014327 return;
14328 }
14329
14330 if (pBssDesc) {
14331 csr_roam_get_bss_start_parms_from_bss_desc(pMac, pBssDesc, pIes,
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -070014332 &pSession->bssParams);
14333 if (CSR_IS_NDI(pProfile)) {
14334 qdf_copy_macaddr(&pSession->bssParams.bssid,
14335 &pSession->selfMacAddr);
14336 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014337 } else {
Krunal Soni8f8507c2016-12-20 13:54:34 -080014338 csr_roam_get_bss_start_parms(pMac, pProfile,
Ganesh Kondabattini4a7f5b92017-11-21 14:58:39 +053014339 &pSession->bssParams,
14340 skip_hostapd_rate);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014341 /* Use the first SSID */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070014342 if (pProfile->SSIDs.numOfSSIDs)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014343 qdf_mem_copy(&pSession->bssParams.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014344 pProfile->SSIDs.SSIDList,
14345 sizeof(tSirMacSSid));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070014346 if (pProfile->BSSIDs.numOfBSSIDs)
14347 /* Use the first BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014348 qdf_mem_copy(&pSession->bssParams.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014349 pProfile->BSSIDs.bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014350 sizeof(struct qdf_mac_addr));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070014351 else
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014352 qdf_mem_set(&pSession->bssParams.bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014353 sizeof(struct qdf_mac_addr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014354 }
14355 Channel = pSession->bssParams.operationChn;
14356 /* Set operating channel in pProfile which will be used */
14357 /* in csr_roam_set_bss_config_cfg() to determine channel bonding */
14358 /* mode and will be configured in CFG later */
14359 pProfile->operationChannel = Channel;
14360
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014361 if (Channel == 0)
14362 sme_err("CSR cannot find a channel to start IBSS");
14363 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014364 csr_roam_determine_max_rate_for_ad_hoc(pMac,
14365 &pSession->bssParams.
14366 operationalRateSet);
14367 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS(pProfile)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014368 if (WLAN_REG_IS_24GHZ_CH(Channel)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014369 cbMode =
14370 pMac->roam.configParam.
14371 channelBondingMode24GHz;
14372 } else {
14373 cbMode =
14374 pMac->roam.configParam.
14375 channelBondingMode5GHz;
14376 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014377 sme_debug("## cbMode %d", cbMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014378 pBssConfig->cbMode = cbMode;
14379 pSession->bssParams.cbMode = cbMode;
14380 }
14381 }
14382}
14383
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014384static QDF_STATUS csr_roam_start_ibss(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014385 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014386 bool *pfSameIbss)
14387{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014388 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014389 bool fSameIbss = false;
14390
14391 if (csr_is_conn_state_ibss(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014392 /* Check if any profile parameter has changed ? If any profile
14393 * parameter has changed then stop old BSS and start a new one
14394 * with new parameters
14395 */
14396 if (csr_is_same_profile(pMac,
14397 &pMac->roam.roamSession[sessionId].
14398 connectedProfile, pProfile))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014399 fSameIbss = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014400 else
14401 status = csr_roam_issue_stop_bss(pMac, sessionId,
14402 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING);
14403
14404 } else if (csr_is_conn_state_connected_infra(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014405 /* Disassociate from the connected Infrastructure network... */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014406 status = csr_roam_issue_disassociate(pMac, sessionId,
14407 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014408 false);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014409 else {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014410 struct bss_config_param *pBssConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014411
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014412 pBssConfig = qdf_mem_malloc(sizeof(struct bss_config_param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014413 if (NULL == pBssConfig)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014414 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014415 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014416 status = QDF_STATUS_SUCCESS;
14417 if (QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014418 /* there is no Bss description before we start an IBSS
14419 * so we need to adopt all Bss configuration parameters
14420 * from the Profile.
14421 */
14422 status = csr_roam_prepare_bss_config_from_profile(pMac,
14423 pProfile,
14424 pBssConfig,
14425 NULL);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014426 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014427 /* save dotMode */
14428 pMac->roam.roamSession[sessionId].bssParams.
14429 uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
14430 /* Prepare some more parameters for this IBSS */
14431 csr_roam_prepare_bss_params(pMac, sessionId,
14432 pProfile, NULL,
14433 pBssConfig, NULL);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014434 status = csr_roam_set_bss_config_cfg(pMac,
14435 sessionId,
14436 pProfile, NULL,
14437 pBssConfig,
14438 NULL, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014439 }
14440
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014441 qdf_mem_free(pBssConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014442 } /* Allocate memory */
14443 }
14444
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014445 if (pfSameIbss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014446 *pfSameIbss = fSameIbss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014447 return status;
14448}
14449
14450static void csr_roam_update_connected_profile_from_new_bss(tpAniSirGlobal pMac,
14451 uint32_t sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014452 tSirSmeNewBssInfo *pNewBss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014453{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014454 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014455
14456 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014457 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014458 return;
14459 }
14460
14461 if (pNewBss) {
14462 /* Set the operating channel. */
14463 pSession->connectedProfile.operationChannel =
14464 pNewBss->channelNumber;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014465 /* move the BSSId from the BSS description into the connected
14466 * state information.
14467 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014468 qdf_mem_copy(&pSession->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014469 &(pNewBss->bssId), sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014470 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014471}
14472
gaurank kathpalia99d06c12018-05-16 16:28:35 +053014473void csr_get_pmk_info(tpAniSirGlobal mac_ctx, uint8_t session_id,
14474 tPmkidCacheInfo *pmk_cache)
14475{
14476 struct csr_roam_session *session = NULL;
14477
14478 if (!mac_ctx) {
14479 sme_err("Mac_ctx is NULL");
14480 return;
14481 }
14482 session = CSR_GET_SESSION(mac_ctx, session_id);
14483 if (!session) {
14484 sme_err("session %d not found", session_id);
14485 return;
14486 }
14487 qdf_mem_copy(pmk_cache->pmk, session->psk_pmk,
14488 sizeof(session->psk_pmk));
14489 pmk_cache->pmk_len = session->pmk_len;
14490}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014491#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014492QDF_STATUS csr_roam_set_psk_pmk(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014493 uint8_t *pPSK_PMK, size_t pmk_len)
14494{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014495 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014496
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014497 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014498 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014499 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014500 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014501 qdf_mem_copy(pSession->psk_pmk, pPSK_PMK, sizeof(pSession->psk_pmk));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014502 pSession->pmk_len = pmk_len;
Padma, Santhosh Kumar2d1f77c2017-11-22 16:20:28 +053014503
14504 if (csr_is_auth_type_ese(pMac->roam.roamSession[sessionId].
14505 connectedProfile.AuthType)) {
14506 sme_debug("PMK update is not required for ESE");
14507 return QDF_STATUS_SUCCESS;
14508 }
14509
Naveen Rawat5f1111b2017-03-31 17:36:20 -070014510 csr_roam_offload_scan(pMac, sessionId,
14511 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
14512 REASON_ROAM_PSK_PMK_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014513 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014514}
14515#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
14516
14517#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
14518static void
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014519csr_roam_diag_set_pmkid(struct csr_roam_session *pSession)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014520{
14521 WLAN_HOST_DIAG_EVENT_DEF(secEvent,
14522 host_event_wlan_security_payload_type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014523 qdf_mem_set(&secEvent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014524 sizeof(host_event_wlan_security_payload_type), 0);
14525 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
14526 secEvent.encryptionModeMulticast =
14527 (uint8_t) diag_enc_type_from_csr_type(
14528 pSession->connectedProfile.mcEncryptionType);
14529 secEvent.encryptionModeUnicast =
14530 (uint8_t) diag_enc_type_from_csr_type(
14531 pSession->connectedProfile.EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014532 qdf_mem_copy(secEvent.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014533 pSession->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014534 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014535 secEvent.authMode = (uint8_t) diag_auth_type_from_csr_type(
14536 pSession->connectedProfile.AuthType);
14537 WLAN_HOST_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
14538}
14539#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
14540
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014541/**
14542 * csr_update_pmk_cache - API to update PMK cache
14543 * @pSession: pointer to session
14544 * @pmksa: pointer to PMKSA struct
14545 *
14546 * Return : None
14547 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014548static void csr_update_pmk_cache(struct csr_roam_session *session,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014549 tPmkidCacheInfo *pmksa)
14550{
14551 uint16_t cache_idx = session->curr_cache_idx;
14552
14553 /* Add entry to the cache */
14554 if (!pmksa->ssid_len) {
14555 qdf_copy_macaddr(
14556 &session->PmkidCacheInfo[cache_idx].BSSID,
14557 &pmksa->BSSID);
14558 session->PmkidCacheInfo[cache_idx].ssid_len = 0;
14559 } else {
14560 qdf_mem_copy(session->PmkidCacheInfo[cache_idx].ssid,
14561 pmksa->ssid, pmksa->ssid_len);
14562 session->PmkidCacheInfo[cache_idx].ssid_len =
14563 pmksa->ssid_len;
14564 qdf_mem_copy(session->PmkidCacheInfo[cache_idx].cache_id,
14565 pmksa->cache_id, CACHE_ID_LEN);
14566
14567 }
14568 qdf_mem_copy(
14569 session->PmkidCacheInfo[cache_idx].PMKID,
14570 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
14571
14572 if (pmksa->pmk_len)
14573 qdf_mem_copy(session->PmkidCacheInfo[cache_idx].pmk,
14574 pmksa->pmk, pmksa->pmk_len);
14575
14576 session->PmkidCacheInfo[cache_idx].pmk_len = pmksa->pmk_len;
14577
14578 /* Increment the CSR local cache index */
14579 if (cache_idx < (CSR_MAX_PMKID_ALLOWED - 1))
14580 session->curr_cache_idx++;
14581 else {
14582 sme_debug("max value reached, setting current index as 0");
14583 session->curr_cache_idx = 0;
14584 }
14585
14586 session->NumPmkidCache++;
14587 if (session->NumPmkidCache > CSR_MAX_PMKID_ALLOWED) {
14588 sme_debug("setting num pmkid cache to %d",
14589 CSR_MAX_PMKID_ALLOWED);
14590 session->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
14591 }
14592}
14593
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014594QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014595csr_roam_set_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId,
14596 tPmkidCacheInfo *pPMKIDCache, uint32_t numItems,
14597 bool update_entire_cache)
14598{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014599 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014600 uint32_t i = 0;
14601 tPmkidCacheInfo *pmksa;
14602
14603 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014604 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014605 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014606 }
14607
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014608 sme_debug("numItems = %d", numItems);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014609
14610 if (numItems > CSR_MAX_PMKID_ALLOWED)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014611 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014612
14613#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
14614 csr_roam_diag_set_pmkid(pSession);
14615#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
14616
14617 if (update_entire_cache) {
14618 if (numItems && pPMKIDCache) {
14619 pSession->NumPmkidCache = (uint16_t) numItems;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014620 qdf_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014621 sizeof(tPmkidCacheInfo) * numItems);
14622 pSession->curr_cache_idx = (uint16_t)numItems;
14623 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014624 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014625 }
14626
14627 for (i = 0; i < numItems; i++) {
14628 pmksa = &pPMKIDCache[i];
14629
14630 /* Delete the entry if present */
14631 csr_roam_del_pmkid_from_cache(pMac, sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014632 pmksa, false);
14633 /* Update new entry */
14634 csr_update_pmk_cache(pSession, pmksa);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014635
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014636 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014637 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014638}
14639
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014640QDF_STATUS csr_roam_del_pmkid_from_cache(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014641 uint32_t sessionId,
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014642 tPmkidCacheInfo *pmksa,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014643 bool flush_cache)
14644{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014645 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014646 bool fMatchFound = false;
14647 uint32_t Index;
14648 uint32_t curr_idx;
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014649 tPmkidCacheInfo *cached_pmksa;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014650 uint32_t i;
14651
14652 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014653 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014654 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014655 }
14656
14657 /* Check if there are no entries to delete */
14658 if (0 == pSession->NumPmkidCache) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014659 sme_debug("No entries to delete/Flush");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014660 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014661 }
14662
14663 if (flush_cache) {
14664 /* Flush the entire cache */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014665 qdf_mem_zero(pSession->PmkidCacheInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014666 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
14667 pSession->NumPmkidCache = 0;
14668 pSession->curr_cache_idx = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014669 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014670 }
14671
14672 /* !flush_cache - so look up in the cache */
14673 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014674 cached_pmksa = &pSession->PmkidCacheInfo[Index];
14675 if ((!cached_pmksa->ssid_len) &&
14676 qdf_is_macaddr_equal(&cached_pmksa->BSSID,
14677 &pmksa->BSSID))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014678 fMatchFound = 1;
14679
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014680 else if (cached_pmksa->ssid_len &&
14681 (!qdf_mem_cmp(cached_pmksa->ssid,
14682 pmksa->ssid, pmksa->ssid_len)) &&
14683 (!qdf_mem_cmp(cached_pmksa->cache_id,
14684 pmksa->cache_id, CACHE_ID_LEN)))
14685 fMatchFound = 1;
14686
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053014687 if (fMatchFound) {
14688 /* Clear this - matched entry */
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014689 qdf_mem_zero(cached_pmksa,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014690 sizeof(tPmkidCacheInfo));
14691 break;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053014692 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014693 }
14694
14695 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014696 sme_debug("No such PMKSA entry exists");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014697 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014698 }
14699
14700 /* Match Found, Readjust the other entries */
14701 curr_idx = pSession->curr_cache_idx;
14702 if (Index < curr_idx) {
14703 for (i = Index; i < (curr_idx - 1); i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014704 qdf_mem_copy(&pSession->PmkidCacheInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014705 &pSession->PmkidCacheInfo[i + 1],
14706 sizeof(tPmkidCacheInfo));
14707 }
14708
14709 pSession->curr_cache_idx--;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014710 qdf_mem_zero(&pSession->PmkidCacheInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014711 [pSession->curr_cache_idx],
14712 sizeof(tPmkidCacheInfo));
14713 } else if (Index > curr_idx) {
14714 for (i = Index; i > (curr_idx); i--) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014715 qdf_mem_copy(&pSession->PmkidCacheInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014716 &pSession->PmkidCacheInfo[i - 1],
14717 sizeof(tPmkidCacheInfo));
14718 }
14719
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014720 qdf_mem_zero(&pSession->PmkidCacheInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014721 [pSession->curr_cache_idx],
14722 sizeof(tPmkidCacheInfo));
14723 }
14724
14725 /* Decrement the count since an entry has been deleted */
14726 pSession->NumPmkidCache--;
Sridhar Selvarajc3684c72017-08-21 14:32:47 +053014727 sme_debug("PMKID at index=%d deleted, current index=%d cache count=%d",
14728 Index, pSession->curr_cache_idx, pSession->NumPmkidCache);
14729
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014730 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014731}
14732
14733uint32_t csr_roam_get_num_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId)
14734{
14735 return pMac->roam.roamSession[sessionId].NumPmkidCache;
14736}
14737
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014738QDF_STATUS csr_roam_get_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014739 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014740{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014741 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014742 tPmkidCacheInfo *pmksa;
14743 uint16_t i, j;
14744
14745 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014746 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014747 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014748 }
14749
14750 if (!pNum || !pPmkidCache) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014751 sme_err("Either pNum or pPmkidCache is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014752 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014753 }
14754
14755 if (pSession->NumPmkidCache == 0) {
14756 *pNum = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014757 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014758 }
14759
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014760 if (*pNum < pSession->NumPmkidCache)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014761 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014762
14763 if (pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014764 sme_err("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014765 pSession->NumPmkidCache);
14766 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
14767 }
14768
14769 for (i = 0, j = 0; ((j < pSession->NumPmkidCache) &&
14770 (i < CSR_MAX_PMKID_ALLOWED)); i++) {
14771 /* Fill the valid entries */
14772 pmksa = &pSession->PmkidCacheInfo[i];
Anurag Chouhanc5548422016-02-24 18:33:27 +053014773 if (!qdf_is_macaddr_zero(&pmksa->BSSID)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014774 qdf_mem_copy(pPmkidCache, pmksa,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014775 sizeof(tPmkidCacheInfo));
14776 pPmkidCache++;
14777 j++;
14778 }
14779 }
14780
14781 *pNum = pSession->NumPmkidCache;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014782 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014783}
14784
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014785QDF_STATUS csr_roam_get_wpa_rsn_req_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014786 uint32_t *pLen, uint8_t *pBuf)
14787{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014788 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014789 uint32_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014790 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014791
14792 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014793 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014794 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014795 }
14796
14797 if (pLen) {
14798 len = *pLen;
14799 *pLen = pSession->nWpaRsnReqIeLength;
14800 if (pBuf) {
14801 if (len >= pSession->nWpaRsnReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014802 qdf_mem_copy(pBuf, pSession->pWpaRsnReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014803 pSession->nWpaRsnReqIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014804 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014805 }
14806 }
14807 }
14808 return status;
14809}
14810
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014811QDF_STATUS csr_roam_get_wpa_rsn_rsp_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014812 uint32_t *pLen, uint8_t *pBuf)
14813{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014814 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014815 uint32_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014816 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014817
14818 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014819 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014820 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014821 }
14822
14823 if (pLen) {
14824 len = *pLen;
14825 *pLen = pSession->nWpaRsnRspIeLength;
14826 if (pBuf) {
14827 if (len >= pSession->nWpaRsnRspIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014828 qdf_mem_copy(pBuf, pSession->pWpaRsnRspIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014829 pSession->nWpaRsnRspIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014830 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014831 }
14832 }
14833 }
14834 return status;
14835}
14836
14837#ifdef FEATURE_WLAN_WAPI
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014838QDF_STATUS csr_roam_get_wapi_req_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014839 uint32_t *pLen, uint8_t *pBuf)
14840{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014841 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014842 uint32_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014843 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014844
14845 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014846 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014847 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014848 }
14849
14850 if (pLen) {
14851 len = *pLen;
14852 *pLen = pSession->nWapiReqIeLength;
14853 if (pBuf) {
14854 if (len >= pSession->nWapiReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014855 qdf_mem_copy(pBuf, pSession->pWapiReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014856 pSession->nWapiReqIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014857 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014858 }
14859 }
14860 }
14861 return status;
14862}
14863
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014864QDF_STATUS csr_roam_get_wapi_rsp_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014865 uint32_t *pLen, uint8_t *pBuf)
14866{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014867 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014868 uint32_t len;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014869 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014870
14871 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014872 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014873 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014874 }
14875
14876 if (pLen) {
14877 len = *pLen;
14878 *pLen = pSession->nWapiRspIeLength;
14879 if (pBuf) {
14880 if (len >= pSession->nWapiRspIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014881 qdf_mem_copy(pBuf, pSession->pWapiRspIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014882 pSession->nWapiRspIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014883 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014884 }
14885 }
14886 }
14887 return status;
14888}
14889#endif /* FEATURE_WLAN_WAPI */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014890eRoamCmdStatus csr_get_roam_complete_status(tpAniSirGlobal pMac,
14891 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014892{
14893 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014894 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014895
14896 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014897 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014898 return retStatus;
14899 }
14900
14901 if (CSR_IS_ROAMING(pSession)) {
14902 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
14903 pSession->fRoaming = false;
14904 }
14905 return retStatus;
14906}
14907
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014908static QDF_STATUS csr_roam_start_wds(tpAniSirGlobal pMac, uint32_t sessionId,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014909 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014910 tSirBssDescription *pBssDesc)
14911{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014912 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014913 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
14914 struct bss_config_param bssConfig;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014915
14916 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014917 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014918 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014919 }
14920
14921 if (csr_is_conn_state_ibss(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014922 status = csr_roam_issue_stop_bss(pMac, sessionId,
14923 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014924 } else if (csr_is_conn_state_connected_infra(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014925 /* Disassociate from the connected Infrastructure network.*/
14926 status = csr_roam_issue_disassociate(pMac, sessionId,
14927 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014928 false);
14929 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014930 /* We don't expect Bt-AMP HDD not to disconnect the last
14931 * connection first at this time. Otherwise we need to add
14932 * code to handle the situation just like IBSS. Though for
14933 * WDS station, we need to send disassoc to PE first then
14934 * send stop_bss to PE, before we can continue.
14935 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014936
14937 if (csr_is_conn_state_wds(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053014938 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014939 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014940 }
gaurank kathpalia14e2f912017-08-31 14:51:45 +053014941 qdf_mem_set(&bssConfig, sizeof(struct bss_config_param), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014942 /* Assume HDD provide bssid in profile */
Anurag Chouhanc5548422016-02-24 18:33:27 +053014943 qdf_copy_macaddr(&pSession->bssParams.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014944 pProfile->BSSIDs.bssid);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014945 /* there is no Bss description before we start an WDS so we
14946 * need to adopt all Bss configuration parameters from the
14947 * Profile.
14948 */
14949 status = csr_roam_prepare_bss_config_from_profile(pMac,
14950 pProfile,
14951 &bssConfig,
14952 pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014953 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014954 /* Save profile for late use */
14955 csr_free_roam_profile(pMac, sessionId);
14956 pSession->pCurRoamProfile =
Jeff Johnson66ee8a92018-03-17 15:24:26 -070014957 qdf_mem_malloc(sizeof(struct csr_roam_profile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014958 if (pSession->pCurRoamProfile != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014959 csr_roam_copy_profile(pMac,
14960 pSession->pCurRoamProfile,
14961 pProfile);
14962 }
14963 /* Prepare some more parameters for this WDS */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014964 csr_roam_prepare_bss_params(pMac, sessionId, pProfile,
14965 NULL, &bssConfig, NULL);
14966 status = csr_roam_set_bss_config_cfg(pMac, sessionId,
14967 pProfile, NULL,
14968 &bssConfig, NULL,
14969 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014970 }
14971 }
14972
14973 return status;
14974}
14975
14976/**
14977 * csr_add_supported_5Ghz_channels()- Add valid 5Ghz channels
14978 * in Join req.
14979 * @mac_ctx: pointer to global mac structure
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053014980 * @chan_list: Pointer to channel list buffer to populate
14981 * @num_chan: Pointer to number of channels value to update
14982 * @supp_chan_ie: Boolean to check if we need to populate as IE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014983 *
14984 * This function is called to update valid 5Ghz channels
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053014985 * in Join req. If @supp_chan_ie is true, supported channels IE
14986 * format[chan num 1, num of channels 1, chan num 2, num of
14987 * channels 2, ..] is populated. Else, @chan_list would be a list
14988 * of supported channels[chan num 1, chan num 2..]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014989 *
14990 * Return: void
14991 */
14992static void csr_add_supported_5Ghz_channels(tpAniSirGlobal mac_ctx,
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053014993 uint8_t *chan_list,
14994 uint8_t *num_chnl,
14995 bool supp_chan_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014996{
14997 uint16_t i, j;
14998 uint32_t size = 0;
14999
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053015000 if (!chan_list) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015001 sme_err("chan_list buffer NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015002 return;
15003 }
15004
15005 size = sizeof(mac_ctx->roam.validChannelList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015006 if (QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015007 (csr_get_cfg_valid_channels(mac_ctx,
15008 (uint8_t *) mac_ctx->roam.validChannelList,
15009 &size))) {
15010 for (i = 0, j = 0; i < size; i++) {
15011 /* Only add 5ghz channels.*/
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015012 if (WLAN_REG_IS_5GHZ_CH
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015013 (mac_ctx->roam.validChannelList[i])) {
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053015014 chan_list[j]
15015 = mac_ctx->roam.validChannelList[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015016 j++;
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053015017
15018 if (supp_chan_ie) {
15019 chan_list[j] = 1;
15020 j++;
15021 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015022 }
15023 }
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053015024 *num_chnl = (uint8_t)j;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015025 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015026 sme_err("can not find any valid channel");
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053015027 *num_chnl = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015028 }
15029}
15030
15031/**
Krunal Soni0193b6f2016-08-15 15:53:43 -070015032 * csr_set_ldpc_exception() - to set allow any LDPC exception permitted
15033 * @mac_ctx: Pointer to mac context
15034 * @session: Pointer to SME/CSR session
15035 * @channel: Given channel number where connection will go
15036 * @usr_cfg_rx_ldpc: User provided RX LDPC setting
15037 *
15038 * This API will check if hardware allows LDPC to be enabled for provided
15039 * channel and user has enabled the RX LDPC selection
15040 *
15041 * Return: QDF_STATUS
15042 */
15043static QDF_STATUS csr_set_ldpc_exception(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053015044 struct csr_roam_session *session, uint8_t channel,
Krunal Soni0193b6f2016-08-15 15:53:43 -070015045 bool usr_cfg_rx_ldpc)
15046{
15047 if (!mac_ctx) {
Varun Reddy Yeturu5a183652016-09-09 15:36:00 -070015048 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15049 "mac_ctx is NULL");
Krunal Soni0193b6f2016-08-15 15:53:43 -070015050 return QDF_STATUS_E_FAILURE;
15051 }
15052 if (!session) {
Varun Reddy Yeturu5a183652016-09-09 15:36:00 -070015053 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
15054 "session is NULL");
Krunal Soni0193b6f2016-08-15 15:53:43 -070015055 return QDF_STATUS_E_FAILURE;
15056 }
15057 if (usr_cfg_rx_ldpc && wma_is_rx_ldpc_supported_for_channel(channel)) {
15058 session->htConfig.ht_rx_ldpc = 1;
15059 session->vht_config.ldpc_coding = 1;
Abhishek Singh245182f2017-08-10 17:41:09 +053015060 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Krunal Soni0193b6f2016-08-15 15:53:43 -070015061 "LDPC enable for chnl[%d]", channel);
15062 } else {
15063 session->htConfig.ht_rx_ldpc = 0;
15064 session->vht_config.ldpc_coding = 0;
Abhishek Singh245182f2017-08-10 17:41:09 +053015065 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Krunal Soni0193b6f2016-08-15 15:53:43 -070015066 "LDPC disable for chnl[%d]", channel);
15067 }
15068 return QDF_STATUS_SUCCESS;
15069}
15070
Abhishek Singhcfb44482017-03-10 12:42:37 +053015071#ifdef WLAN_FEATURE_11W
15072/**
Srinivas Girigowda6519b932017-08-03 14:10:57 -070015073 * csr_is_mfpc_capable() - is MFPC capable
15074 * @ies: AP information element
15075 *
15076 * Return: true if MFPC capable, false otherwise
15077 */
15078bool csr_is_mfpc_capable(struct sDot11fIERSN *rsn)
15079{
15080 bool mfpc_capable = false;
15081
15082 if (rsn && rsn->present &&
15083 ((rsn->RSN_Cap[0] >> 7) & 0x01))
15084 mfpc_capable = true;
15085
15086 return mfpc_capable;
15087}
15088
15089/**
Abhishek Singhcfb44482017-03-10 12:42:37 +053015090 * csr_set_mgmt_enc_type() - set mgmt enc type for PMF
15091 * @profile: roam profile
15092 * @ies: AP ie
15093 * @csr_join_req: csr join req
15094 *
15095 * Return: void
15096 */
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015097static void csr_set_mgmt_enc_type(struct csr_roam_profile *profile,
15098 tDot11fBeaconIEs *ies,
15099 tSirSmeJoinReq *csr_join_req)
Abhishek Singhcfb44482017-03-10 12:42:37 +053015100{
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +053015101 sme_debug("mgmt encryption type %d MFPe %d MFPr %d",
15102 profile->mgmt_encryption_type,
15103 profile->MFPEnabled, profile->MFPRequired);
15104
Abhishek Singhcfb44482017-03-10 12:42:37 +053015105 if (profile->MFPEnabled)
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +053015106 csr_join_req->MgmtEncryptionType =
15107 profile->mgmt_encryption_type;
Abhishek Singhcfb44482017-03-10 12:42:37 +053015108 else
15109 csr_join_req->MgmtEncryptionType = eSIR_ED_NONE;
Padma, Santhosh Kumar4117d7a2017-12-20 17:39:33 +053015110
Abhishek Singhcfb44482017-03-10 12:42:37 +053015111 if (profile->MFPEnabled &&
15112 !(profile->MFPRequired) &&
Srinivas Girigowda6519b932017-08-03 14:10:57 -070015113 !csr_is_mfpc_capable(&ies->RSN))
Abhishek Singhcfb44482017-03-10 12:42:37 +053015114 csr_join_req->MgmtEncryptionType = eSIR_ED_NONE;
15115}
15116#else
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015117static inline void csr_set_mgmt_enc_type(struct csr_roam_profile *profile,
15118 tDot11fBeaconIEs *pIes,
15119 tSirSmeJoinReq *csr_join_req)
Abhishek Singhcfb44482017-03-10 12:42:37 +053015120{
15121}
15122#endif
15123
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053015124#ifdef WLAN_FEATURE_FILS_SK
15125/*
15126 * csr_update_fils_connection_info: Copy fils connection info to join request
15127 * @profile: pointer to profile
15128 * @csr_join_req: csr join request
15129 *
15130 * Return: None
15131 */
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015132static void csr_update_fils_connection_info(struct csr_roam_profile *profile,
15133 tSirSmeJoinReq *csr_join_req)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053015134{
15135 if (!profile->fils_con_info)
15136 return;
15137
15138 if (profile->fils_con_info->is_fils_connection) {
15139 qdf_mem_copy(&csr_join_req->fils_con_info,
15140 profile->fils_con_info,
15141 sizeof(struct cds_fils_connection_info));
15142 } else {
15143 qdf_mem_zero(&csr_join_req->fils_con_info,
15144 sizeof(struct cds_fils_connection_info));
15145 }
15146}
15147#else
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015148static void csr_update_fils_connection_info(struct csr_roam_profile *profile,
15149 tSirSmeJoinReq *csr_join_req)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053015150{ }
15151#endif
Abhishek Singhcfb44482017-03-10 12:42:37 +053015152
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +053015153#ifdef WLAN_FEATURE_SAE
15154/*
15155 * csr_update_sae_config: Copy SAE info to join request
15156 * @profile: pointer to profile
15157 * @csr_join_req: csr join request
15158 *
15159 * Return: None
15160 */
15161static void csr_update_sae_config(tSirSmeJoinReq *csr_join_req,
15162 tpAniSirGlobal mac, struct csr_roam_session *session)
15163{
15164 tPmkidCacheInfo pmkid_cache;
15165 uint32_t index;
15166
15167 qdf_mem_copy(pmkid_cache.BSSID.bytes,
15168 csr_join_req->bssDescription.bssId, QDF_MAC_ADDR_SIZE);
15169
15170 csr_join_req->sae_pmk_cached =
15171 csr_lookup_pmkid_using_bssid(mac, session, &pmkid_cache, &index);
15172
15173 sme_debug("pmk_cached %d for BSSID=" MAC_ADDRESS_STR,
15174 csr_join_req->sae_pmk_cached,
15175 MAC_ADDR_ARRAY(csr_join_req->bssDescription.bssId));
15176}
15177#else
15178static void csr_update_sae_config(tSirSmeJoinReq *csr_join_req,
15179 tpAniSirGlobal mac, struct csr_roam_session *session)
15180{ }
15181#endif
15182
Krunal Soni0193b6f2016-08-15 15:53:43 -070015183/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015184 * The communication between HDD and LIM is thru mailbox (MB).
15185 * Both sides will access the data structure "tSirSmeJoinReq".
15186 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the
15187 * regular way like tSirSmeJoinReq.assocType, this guideline stops at component
15188 * tSirRSNie;
15189 * any acces to the components after tSirRSNie is forbidden because the space
15190 * from tSirRSNie is squeezed with the component "tSirBssDescription" and since
15191 * the size of actual 'tSirBssDescription' varies, the receiving side should
15192 * keep in mind not to access the components DIRECTLY after tSirRSNie.
15193 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015194QDF_STATUS csr_send_join_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015195 tSirBssDescription *pBssDescription,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070015196 struct csr_roam_profile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015197 tDot11fBeaconIEs *pIes, uint16_t messageType)
15198{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015199 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015200 uint8_t acm_mask = 0, uapsd_mask;
15201 uint16_t msgLen, ieLen;
15202 tSirMacRateSet OpRateSet;
15203 tSirMacRateSet ExRateSet;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053015204 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015205 uint32_t dwTmp, ucDot11Mode = 0;
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +053015206 uint8_t *wpaRsnIE = NULL;
Prakash Dhavali2aa7f892016-12-02 09:56:09 -080015207 uint8_t txBFCsnValue = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015208 tSirSmeJoinReq *csr_join_req;
15209 tSirMacCapabilityInfo *pAP_capabilityInfo;
Srinivas Girigowda74a66d62017-06-21 23:28:25 -070015210 bool fTmp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015211 int8_t pwrLimit = 0;
15212 struct ps_global_info *ps_global_info = &pMac->sme.ps_global_info;
15213 struct ps_params *ps_param = &ps_global_info->ps_params[sessionId];
15214 uint8_t ese_config = 0;
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070015215 tpCsrNeighborRoamControlInfo neigh_roam_info;
Krunal Soni53993f72016-07-08 18:20:03 -070015216 uint32_t value = 0, value1 = 0;
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053015217 QDF_STATUS packetdump_timer_status;
Kiran Kumar Lokere9493c722017-12-13 14:42:59 -080015218 tDot11fIEVHTCaps *vht_caps = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015219
15220 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015221 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015222 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015223 }
15224 /* To satisfy klockworks */
15225 if (NULL == pBssDescription) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015226 sme_err(" pBssDescription is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015227 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015228 }
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070015229 neigh_roam_info = &pMac->roam.neighborRoamInfo[sessionId];
15230 if ((eWNI_SME_REASSOC_REQ == messageType) ||
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015231 WLAN_REG_IS_5GHZ_CH(pBssDescription->channelId) ||
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070015232 (abs(pBssDescription->rssi) <
Varun Reddy Yeturuf64252a2016-05-13 15:02:03 -070015233 (neigh_roam_info->cfgParams.neighborLookupThreshold -
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070015234 neigh_roam_info->cfgParams.hi_rssi_scan_rssi_delta))) {
15235 pSession->disable_hi_rssi = true;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015236 sme_debug(
15237 "Disabling HI_RSSI feature, AP channel=%d, rssi=%d",
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070015238 pBssDescription->channelId, pBssDescription->rssi);
15239 } else {
15240 pSession->disable_hi_rssi = false;
15241 }
15242
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015243
15244 do {
15245 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
15246 pSession->joinFailStatusCode.reasonCode = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015247 qdf_mem_copy(&pSession->joinFailStatusCode.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015248 &pBssDescription->bssId, sizeof(tSirMacAddr));
15249 /*
15250 * the tSirSmeJoinReq which includes a single
15251 * bssDescription. it includes a single uint32_t for the
15252 * IE fields, but the length field in the bssDescription
15253 * needs to be interpreted to determine length of IE fields
15254 * So, take the size of the tSirSmeJoinReq, subtract size of
15255 * bssDescription, add the number of bytes indicated by the
15256 * length field of the bssDescription, add the size of length
Jeff Johnsonfe8e9492018-05-06 15:40:52 -070015257 * field because it not included in the length field.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015258 */
15259 msgLen = sizeof(tSirSmeJoinReq) - sizeof(*pBssDescription) +
15260 pBssDescription->length +
15261 sizeof(pBssDescription->length) +
15262 /*
15263 * add in the size of the WPA IE that
15264 * we may build.
15265 */
15266 sizeof(tCsrWpaIe) + sizeof(tCsrWpaAuthIe) +
15267 sizeof(uint16_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015268 csr_join_req = qdf_mem_malloc(msgLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015269 if (NULL == csr_join_req)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015270 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015271 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015272 status = QDF_STATUS_SUCCESS;
15273 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015274 break;
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +053015275
15276 wpaRsnIE = qdf_mem_malloc(DOT11F_IE_RSN_MAX_LEN);
15277 if (NULL == wpaRsnIE)
15278 status = QDF_STATUS_E_NOMEM;
15279
15280 if (!QDF_IS_STATUS_SUCCESS(status))
15281 break;
15282
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015283 csr_join_req->messageType = messageType;
15284 csr_join_req->length = msgLen;
15285 csr_join_req->sessionId = (uint8_t) sessionId;
15286 csr_join_req->transactionId = 0;
15287 if (pIes->SSID.present && pIes->SSID.num_ssid) {
15288 csr_join_req->ssId.length = pIes->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015289 qdf_mem_copy(&csr_join_req->ssId.ssId, pIes->SSID.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015290 pIes->SSID.num_ssid);
15291 } else
15292 csr_join_req->ssId.length = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015293 qdf_mem_copy(&csr_join_req->selfMacAddr, &pSession->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015294 sizeof(tSirMacAddr));
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015295 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 -080015296 pIes->SSID.num_ssid, pIes->SSID.ssid,
15297 MAC_ADDR_ARRAY(pBssDescription->bssId),
15298 pBssDescription->rssi, pBssDescription->channelId,
15299 pMac->scan.countryCodeCurrent[0],
15300 pMac->scan.countryCodeCurrent[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015301 /* bsstype */
15302 dwTmp = csr_translate_bsstype_to_mac_type
15303 (pProfile->BSSType);
Rajeev Kumarc9a50e72016-04-15 15:18:42 -070015304 csr_join_req->bsstype = dwTmp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015305 /* dot11mode */
15306 ucDot11Mode =
15307 csr_translate_to_wni_cfg_dot11_mode(pMac,
15308 pSession->bssParams.
15309 uCfgDot11Mode);
15310 if (pBssDescription->channelId <= 14
15311 && false == pMac->roam.configParam.enableVhtFor24GHz
15312 && WNI_CFG_DOT11_MODE_11AC == ucDot11Mode) {
15313 /* Need to disable VHT operation in 2.4 GHz band */
15314 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
15315 }
15316 csr_join_req->dot11mode = (uint8_t) ucDot11Mode;
Padma, Santhosh Kumar19f57652017-05-26 18:03:45 +053015317 sme_debug("dot11mode=%d, uCfgDot11Mode=%d",
15318 csr_join_req->dot11mode,
15319 pSession->bssParams.uCfgDot11Mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015320#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
15321 csr_join_req->cc_switch_mode =
15322 pMac->roam.configParam.cc_switch_mode;
15323#endif
15324 csr_join_req->staPersona = (uint8_t) pProfile->csrPersona;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +053015325 csr_join_req->wps_registration = pProfile->bWPSAssociation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015326 csr_join_req->cbMode = (uint8_t) pSession->bssParams.cbMode;
Abhishek Singhb59f8d42017-07-31 14:42:47 +053015327 csr_join_req->force_24ghz_in_ht20 =
15328 pProfile->force_24ghz_in_ht20;
15329 sme_debug("CSR PERSONA: %d CSR CbMode: %d force 24gh ht20 %d",
15330 pProfile->csrPersona, pSession->bssParams.cbMode,
15331 csr_join_req->force_24ghz_in_ht20);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015332 csr_join_req->uapsdPerAcBitmask = pProfile->uapsd_mask;
Naveen Rawatcd118312016-11-22 10:46:21 -080015333 pSession->uapsd_mask = pProfile->uapsd_mask;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015334 status =
15335 csr_get_rate_set(pMac, pProfile,
15336 (eCsrPhyMode) pProfile->phyMode,
15337 pBssDescription, pIes, &OpRateSet,
15338 &ExRateSet);
15339 ps_param->uapsd_per_ac_bit_mask =
15340 pProfile->uapsd_mask;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015341 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015342 /* OperationalRateSet */
15343 if (OpRateSet.numRates) {
15344 csr_join_req->operationalRateSet.numRates =
15345 OpRateSet.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015346 qdf_mem_copy(&csr_join_req->operationalRateSet.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015347 rate, OpRateSet.rate,
15348 OpRateSet.numRates);
15349 } else
15350 csr_join_req->operationalRateSet.numRates = 0;
15351
15352 /* ExtendedRateSet */
15353 if (ExRateSet.numRates) {
15354 csr_join_req->extendedRateSet.numRates =
15355 ExRateSet.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015356 qdf_mem_copy(&csr_join_req->extendedRateSet.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015357 rate, ExRateSet.rate,
15358 ExRateSet.numRates);
15359 } else
15360 csr_join_req->extendedRateSet.numRates = 0;
15361 } else {
15362 csr_join_req->operationalRateSet.numRates = 0;
15363 csr_join_req->extendedRateSet.numRates = 0;
15364 }
15365 /* rsnIE */
15366 if (csr_is_profile_wpa(pProfile)) {
15367 /* Insert the Wpa IE into the join request */
15368 ieLen =
15369 csr_retrieve_wpa_ie(pMac, pProfile,
15370 pBssDescription, pIes,
15371 (tCsrWpaIe *) (wpaRsnIE));
15372 } else if (csr_is_profile_rsn(pProfile)) {
15373 /* Insert the RSN IE into the join request */
15374 ieLen =
15375 csr_retrieve_rsn_ie(pMac, sessionId, pProfile,
15376 pBssDescription, pIes,
15377 (tCsrRSNIe *) (wpaRsnIE));
Abhishek Singh6454ad32017-12-20 10:42:21 +053015378 csr_join_req->force_rsne_override =
15379 pProfile->force_rsne_override;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015380 }
15381#ifdef FEATURE_WLAN_WAPI
15382 else if (csr_is_profile_wapi(pProfile)) {
15383 /* Insert the WAPI IE into the join request */
15384 ieLen =
15385 csr_retrieve_wapi_ie(pMac, sessionId, pProfile,
15386 pBssDescription, pIes,
15387 (tCsrWapiIe *) (wpaRsnIE));
15388 }
15389#endif /* FEATURE_WLAN_WAPI */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015390 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015391 ieLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015392 /* remember the IE for future use */
15393 if (ieLen) {
15394 if (ieLen > DOT11F_IE_RSN_MAX_LEN) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015395 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 -080015396 ieLen, DOT11F_IE_RSN_MAX_LEN);
15397 ieLen = DOT11F_IE_RSN_MAX_LEN;
15398 }
15399#ifdef FEATURE_WLAN_WAPI
15400 if (csr_is_profile_wapi(pProfile)) {
15401 /* Check whether we need to allocate more mem */
15402 if (ieLen > pSession->nWapiReqIeLength) {
15403 if (pSession->pWapiReqIE
15404 && pSession->nWapiReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015405 qdf_mem_free(pSession->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015406 pWapiReqIE);
15407 }
15408 pSession->pWapiReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015409 qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015410 if (NULL == pSession->pWapiReqIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015411 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015412 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015413 status = QDF_STATUS_SUCCESS;
15414 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015415 break;
15416 }
15417 pSession->nWapiReqIeLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015418 qdf_mem_copy(pSession->pWapiReqIE, wpaRsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015419 ieLen);
15420 csr_join_req->rsnIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015421 qdf_mem_copy(&csr_join_req->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015422 wpaRsnIE, ieLen);
15423 } else /* should be WPA/WPA2 otherwise */
15424#endif /* FEATURE_WLAN_WAPI */
15425 {
15426 /* Check whether we need to allocate more mem */
15427 if (ieLen > pSession->nWpaRsnReqIeLength) {
15428 if (pSession->pWpaRsnReqIE
15429 && pSession->nWpaRsnReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015430 qdf_mem_free(pSession->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015431 pWpaRsnReqIE);
15432 }
15433 pSession->pWpaRsnReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015434 qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015435 if (NULL == pSession->pWpaRsnReqIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015436 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015437 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015438 status = QDF_STATUS_SUCCESS;
15439 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015440 break;
15441 }
15442 pSession->nWpaRsnReqIeLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015443 qdf_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015444 ieLen);
15445 csr_join_req->rsnIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015446 qdf_mem_copy(&csr_join_req->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015447 wpaRsnIE, ieLen);
15448 }
15449 } else {
15450 /* free whatever old info */
15451 pSession->nWpaRsnReqIeLength = 0;
15452 if (pSession->pWpaRsnReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015453 qdf_mem_free(pSession->pWpaRsnReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015454 pSession->pWpaRsnReqIE = NULL;
15455 }
15456#ifdef FEATURE_WLAN_WAPI
15457 pSession->nWapiReqIeLength = 0;
15458 if (pSession->pWapiReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015459 qdf_mem_free(pSession->pWapiReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015460 pSession->pWapiReqIE = NULL;
15461 }
15462#endif /* FEATURE_WLAN_WAPI */
15463 csr_join_req->rsnIE.length = 0;
15464 }
15465#ifdef FEATURE_WLAN_ESE
15466 if (eWNI_SME_JOIN_REQ == messageType)
15467 csr_join_req->cckmIE.length = 0;
15468 else if (eWNI_SME_REASSOC_REQ == messageType) {
15469 /* cckmIE */
15470 if (csr_is_profile_ese(pProfile)) {
15471 /* Insert the CCKM IE into the join request */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015472 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015473 qdf_mem_copy((void *)(wpaRsnIE),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015474 pSession->suppCckmIeInfo.cckmIe,
15475 ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015476 } else
15477 ieLen = 0;
15478 /*
15479 * If present, copy the IE into the
15480 * eWNI_SME_REASSOC_REQ message buffer
15481 */
15482 if (ieLen) {
15483 /*
15484 * Copy the CCKM IE over from the temp
15485 * buffer (wpaRsnIE)
15486 */
15487 csr_join_req->cckmIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015488 qdf_mem_copy(&csr_join_req->cckmIE.cckmIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015489 wpaRsnIE, ieLen);
15490 } else
15491 csr_join_req->cckmIE.length = 0;
15492 }
15493#endif /* FEATURE_WLAN_ESE */
15494 /* addIEScan */
15495 if (pProfile->nAddIEScanLength && pProfile->pAddIEScan) {
15496 ieLen = pProfile->nAddIEScanLength;
15497 if (ieLen > pSession->nAddIEScanLength) {
15498 if (pSession->pAddIEScan
15499 && pSession->nAddIEScanLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015500 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015501 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015502 pSession->pAddIEScan = qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015503 if (NULL == pSession->pAddIEScan)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015504 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015505 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015506 status = QDF_STATUS_SUCCESS;
15507 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015508 break;
15509 }
15510 pSession->nAddIEScanLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015511 qdf_mem_copy(pSession->pAddIEScan, pProfile->pAddIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015512 ieLen);
15513 csr_join_req->addIEScan.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015514 qdf_mem_copy(&csr_join_req->addIEScan.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015515 pProfile->pAddIEScan, ieLen);
15516 } else {
15517 pSession->nAddIEScanLength = 0;
15518 if (pSession->pAddIEScan) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015519 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015520 pSession->pAddIEScan = NULL;
15521 }
15522 csr_join_req->addIEScan.length = 0;
15523 }
15524 /* addIEAssoc */
15525 if (pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc) {
15526 ieLen = pProfile->nAddIEAssocLength;
15527 if (ieLen > pSession->nAddIEAssocLength) {
15528 if (pSession->pAddIEAssoc
15529 && pSession->nAddIEAssocLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015530 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015531 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015532 pSession->pAddIEAssoc = qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015533 if (NULL == pSession->pAddIEAssoc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015534 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015535 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015536 status = QDF_STATUS_SUCCESS;
15537 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015538 break;
15539 }
15540 pSession->nAddIEAssocLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015541 qdf_mem_copy(pSession->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015542 pProfile->pAddIEAssoc, ieLen);
15543 csr_join_req->addIEAssoc.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015544 qdf_mem_copy(&csr_join_req->addIEAssoc.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015545 pProfile->pAddIEAssoc, ieLen);
15546 } else {
15547 pSession->nAddIEAssocLength = 0;
15548 if (pSession->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015549 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015550 pSession->pAddIEAssoc = NULL;
15551 }
15552 csr_join_req->addIEAssoc.length = 0;
15553 }
15554
15555 if (eWNI_SME_REASSOC_REQ == messageType) {
15556 /* Unmask any AC in reassoc that is ACM-set */
15557 uapsd_mask = (uint8_t) pProfile->uapsd_mask;
15558 if (uapsd_mask && (NULL != pBssDescription)) {
15559 if (CSR_IS_QOS_BSS(pIes)
15560 && CSR_IS_UAPSD_BSS(pIes))
15561#ifndef WLAN_MDM_CODE_REDUCTION_OPT
15562 acm_mask =
15563 sme_qos_get_acm_mask(pMac,
15564 pBssDescription,
15565 pIes);
15566#endif /* WLAN_MDM_CODE_REDUCTION_OPT */
15567 else
15568 uapsd_mask = 0;
15569 }
15570 }
15571
Kiran Kumar Lokere722dccd2018-02-23 13:23:52 -080015572 if (!CSR_IS_11n_ALLOWED(pProfile->negotiatedUCEncryptionType))
15573 csr_join_req->he_with_wep_tkip =
15574 pMac->roam.configParam.wep_tkip_in_he;
15575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015576 csr_join_req->UCEncryptionType =
15577 csr_translate_encrypt_type_to_ed_type
15578 (pProfile->negotiatedUCEncryptionType);
15579
15580 csr_join_req->MCEncryptionType =
15581 csr_translate_encrypt_type_to_ed_type
15582 (pProfile->negotiatedMCEncryptionType);
Abhishek Singhcfb44482017-03-10 12:42:37 +053015583 csr_set_mgmt_enc_type(pProfile, pIes, csr_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015584#ifdef FEATURE_WLAN_ESE
15585 ese_config = pMac->roam.configParam.isEseIniFeatureEnabled;
15586#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015587 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Abhinav Kumar271f0632018-03-29 16:01:30 +053015588 if (csr_is_profile11r(pMac, pProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015589#ifdef FEATURE_WLAN_ESE
15590 &&
15591 !((pProfile->negotiatedAuthType ==
15592 eCSR_AUTH_TYPE_OPEN_SYSTEM) && (pIes->ESEVersion.present)
15593 && (ese_config))
15594#endif
15595 )
15596 csr_join_req->is11Rconnection = true;
15597 else
15598 csr_join_req->is11Rconnection = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015599#ifdef FEATURE_WLAN_ESE
15600 if (true == ese_config)
15601 csr_join_req->isESEFeatureIniEnabled = true;
15602 else
15603 csr_join_req->isESEFeatureIniEnabled = false;
15604
15605 /* A profile can not be both ESE and 11R. But an 802.11R AP
15606 * may be advertising support for ESE as well. So if we are
15607 * associating Open or explicitly ESE then we will get ESE.
Jeff Johnson698eacd2018-05-12 17:00:03 -070015608 * If we are associating explicitly 11R only then we will get
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015609 * 11R.
15610 */
15611 if ((csr_is_profile_ese(pProfile) ||
15612 ((pIes->ESEVersion.present) &&
15613 (pProfile->negotiatedAuthType ==
15614 eCSR_AUTH_TYPE_OPEN_SYSTEM)))
15615 && (ese_config))
15616 csr_join_req->isESEconnection = true;
15617 else
15618 csr_join_req->isESEconnection = false;
15619
15620 if (eWNI_SME_JOIN_REQ == messageType) {
15621 tESETspecInfo eseTspec;
15622 /*
15623 * ESE-Tspec IEs in the ASSOC request is presently not
15624 * supported. so nullify the TSPEC parameters
15625 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015626 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
15627 qdf_mem_copy(&csr_join_req->eseTspecInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015628 &eseTspec, sizeof(tESETspecInfo));
15629 } else if (eWNI_SME_REASSOC_REQ == messageType) {
15630 if ((csr_is_profile_ese(pProfile) ||
15631 ((pIes->ESEVersion.present)
15632 && (pProfile->negotiatedAuthType ==
15633 eCSR_AUTH_TYPE_OPEN_SYSTEM))) &&
15634 (ese_config)) {
15635 tESETspecInfo eseTspec;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015636
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015637 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015638 0);
15639 eseTspec.numTspecs =
15640 sme_qos_ese_retrieve_tspec_info(pMac,
15641 sessionId,
15642 (tTspecInfo *) &eseTspec.
15643 tspec[0]);
15644 csr_join_req->eseTspecInfo.numTspecs =
15645 eseTspec.numTspecs;
15646 if (eseTspec.numTspecs) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015647 qdf_mem_copy(&csr_join_req->eseTspecInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015648 .tspec[0],
15649 &eseTspec.tspec[0],
15650 (eseTspec.numTspecs *
15651 sizeof(tTspecInfo)));
15652 }
15653 } else {
15654 tESETspecInfo eseTspec;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015655 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015656 * ESE-Tspec IEs in the ASSOC request is
15657 * presently not supported. so nullify the TSPEC
15658 * parameters
15659 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015660 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015661 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015662 qdf_mem_copy(&csr_join_req->eseTspecInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015663 &eseTspec,
15664 sizeof(tESETspecInfo));
15665 }
15666 }
15667#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015668 if (ese_config
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015669 || csr_roam_is_fast_roam_enabled(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015670 csr_join_req->isFastTransitionEnabled = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015671 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015672 csr_join_req->isFastTransitionEnabled = false;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015673
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015674 if (csr_roam_is_fast_roam_enabled(pMac, sessionId))
15675 csr_join_req->isFastRoamIniFeatureEnabled = true;
15676 else
15677 csr_join_req->isFastRoamIniFeatureEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015678
15679 csr_join_req->txLdpcIniFeatureEnabled =
Krunal Sonia2c0e412017-05-04 14:12:41 +053015680 (uint8_t) pMac->roam.configParam.tx_ldpc_enable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015681
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015682 if ((csr_is11h_supported(pMac)) &&
15683 (WLAN_REG_IS_5GHZ_CH(pBssDescription->channelId)) &&
15684 (pIes->Country.present) &&
15685 (!pMac->roam.configParam.
15686 fSupplicantCountryCodeHasPriority)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015687 csr_save_to_channel_power2_g_5_g(pMac,
15688 pIes->Country.num_triplets *
15689 sizeof(tSirMacChanInfo),
15690 (tSirMacChanInfo *)
15691 (&pIes->Country.triplets[0]));
15692 csr_apply_power2_current(pMac);
15693 }
Krunal Soni0193b6f2016-08-15 15:53:43 -070015694 /*
15695 * If RX LDPC has been disabled for 2.4GHz channels and enabled
Krunal Sonid292a6b2016-10-27 17:25:23 -070015696 * for 5Ghz for STA like persona then here is how to handle
15697 * those cases (by now channel has been decided).
Krunal Soni0193b6f2016-08-15 15:53:43 -070015698 */
Krunal Sonid292a6b2016-10-27 17:25:23 -070015699 if (eSIR_INFRASTRUCTURE_MODE == csr_join_req->bsstype ||
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080015700 !policy_mgr_is_dbs_enable(pMac->psoc))
Krunal Soni0193b6f2016-08-15 15:53:43 -070015701 csr_set_ldpc_exception(pMac, pSession,
15702 pBssDescription->channelId,
Krunal Sonia2c0e412017-05-04 14:12:41 +053015703 pMac->roam.configParam.rx_ldpc_enable);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015704 qdf_mem_copy(&csr_join_req->htConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015705 &pSession->htConfig, sizeof(tSirHTConfig));
Sandeep Puligilla98917432016-06-10 13:50:28 -070015706 qdf_mem_copy(&csr_join_req->vht_config, &pSession->vht_config,
15707 sizeof(pSession->vht_config));
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015708 sme_debug("ht capability 0x%x VHT capability 0x%x",
Sandeep Puligilla98917432016-06-10 13:50:28 -070015709 (unsigned int)(*(uint32_t *) &csr_join_req->htConfig),
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015710 (unsigned int)(*(uint32_t *) &csr_join_req->
15711 vht_config));
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -080015712
15713 if (IS_DOT11_MODE_HE(csr_join_req->dot11mode))
15714 csr_join_req_copy_he_cap(csr_join_req, pSession);
15715
Krunal Soni53993f72016-07-08 18:20:03 -070015716 if (wlan_cfg_get_int(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
15717 &value) != eSIR_SUCCESS)
15718 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015719 ("Failed to get SU beamformee capability"));
Krunal Soni53993f72016-07-08 18:20:03 -070015720 if (wlan_cfg_get_int(pMac,
15721 WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED,
15722 &value1) != eSIR_SUCCESS)
15723 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015724 ("Failed to get CSN beamformee capability"));
Krunal Soni53993f72016-07-08 18:20:03 -070015725
15726 csr_join_req->vht_config.su_beam_formee = value;
Abhishek Singhd8162ca2017-04-11 11:54:54 +053015727
Kiran Kumar Lokere9493c722017-12-13 14:42:59 -080015728 if (pIes->VHTCaps.present)
15729 vht_caps = &pIes->VHTCaps;
15730 else if (pIes->vendor_vht_ie.VHTCaps.present)
15731 vht_caps = &pIes->vendor_vht_ie.VHTCaps;
Abhishek Singhd8162ca2017-04-11 11:54:54 +053015732 /* Set BF CSN value only if SU Bformee is enabled */
Kiran Kumar Lokere9493c722017-12-13 14:42:59 -080015733 if (vht_caps && csr_join_req->vht_config.su_beam_formee) {
Prakash Dhavali2aa7f892016-12-02 09:56:09 -080015734 txBFCsnValue = (uint8_t)value1;
Naveen Rawat5b96c3c2017-09-13 16:33:07 -070015735 /*
15736 * Certain commercial AP display a bad behavior when
15737 * CSN value in assoc request is more than AP's CSN.
15738 * Sending absolute self CSN value with such AP leads to
15739 * IOT issues. However this issue is observed only with
15740 * CSN cap of less than 4. To avoid such issues, take a
15741 * min of self and peer CSN while sending ASSOC request.
15742 */
Kiran Kumar Lokere9493c722017-12-13 14:42:59 -080015743 if (pIes->Vendor1IE.present &&
15744 vht_caps->csnofBeamformerAntSup < 4) {
15745 if (vht_caps->csnofBeamformerAntSup)
Naveen Rawat5b96c3c2017-09-13 16:33:07 -070015746 txBFCsnValue = QDF_MIN(txBFCsnValue,
Kiran Kumar Lokere9493c722017-12-13 14:42:59 -080015747 vht_caps->csnofBeamformerAntSup);
Naveen Rawat5b96c3c2017-09-13 16:33:07 -070015748 }
Prakash Dhavali2aa7f892016-12-02 09:56:09 -080015749 }
15750 csr_join_req->vht_config.csnof_beamformer_antSup = txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015751
Krunal Soni53993f72016-07-08 18:20:03 -070015752 if (wlan_cfg_get_int(pMac,
Abhishek Singhd8162ca2017-04-11 11:54:54 +053015753 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &value)
15754 != eSIR_SUCCESS)
15755 sme_err("Failed to get SU beamformer capability");
15756
15757 /*
15758 * Set SU Bformer only if SU Bformer is enabled in INI
15759 * and AP is SU Bformee capable
15760 */
15761 if (value && !((IS_BSS_VHT_CAPABLE(pIes->VHTCaps) &&
15762 pIes->VHTCaps.suBeamformeeCap) ||
15763 (IS_BSS_VHT_CAPABLE(
15764 pIes->vendor_vht_ie.VHTCaps)
15765 && pIes->vendor_vht_ie.VHTCaps.
15766 suBeamformeeCap)))
15767 value = 0;
15768
15769 csr_join_req->vht_config.su_beam_former = value;
15770
15771 /* Set num soundingdim value to 0 if SU Bformer is disabled */
15772 if (!csr_join_req->vht_config.su_beam_former)
15773 csr_join_req->vht_config.num_soundingdim = 0;
15774
15775 if (wlan_cfg_get_int(pMac,
15776 WNI_CFG_VHT_MU_BEAMFORMEE_CAP, &value)
15777 != eSIR_SUCCESS)
15778 sme_err("Failed to get CSN beamformee capability");
15779 /*
15780 * Set MU Bformee only if SU Bformee is enabled and
15781 * MU Bformee is enabled in INI
15782 */
Kiran Kumar Lokered057b722017-09-07 15:32:09 -070015783 if (value && csr_join_req->vht_config.su_beam_formee &&
15784 pIes->VHTCaps.muBeamformerCap)
Abhishek Singhd8162ca2017-04-11 11:54:54 +053015785 csr_join_req->vht_config.mu_beam_formee = 1;
15786 else
15787 csr_join_req->vht_config.mu_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015788
15789 csr_join_req->enableVhtpAid =
15790 (uint8_t) pMac->roam.configParam.enableVhtpAid;
15791
15792 csr_join_req->enableVhtGid =
15793 (uint8_t) pMac->roam.configParam.enableVhtGid;
15794
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015795 csr_join_req->enableAmpduPs =
15796 (uint8_t) pMac->roam.configParam.enableAmpduPs;
15797
15798 csr_join_req->enableHtSmps =
15799 (uint8_t) pMac->roam.configParam.enableHtSmps;
15800
15801 csr_join_req->htSmps = (uint8_t) pMac->roam.configParam.htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -080015802 csr_join_req->send_smps_action =
15803 pMac->roam.configParam.send_smps_action;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015804
Deepak Dhamdhere612392c2016-08-28 02:56:51 -070015805 csr_join_req->max_amsdu_num =
15806 (uint8_t) pMac->roam.configParam.max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015807
15808 if (pMac->roam.roamSession[sessionId].fWMMConnection)
15809 csr_join_req->isWMEenabled = true;
15810 else
15811 csr_join_req->isWMEenabled = false;
15812
15813 if (pMac->roam.roamSession[sessionId].fQOSConnection)
15814 csr_join_req->isQosEnabled = true;
15815 else
15816 csr_join_req->isQosEnabled = false;
15817
15818 if (pProfile->bOSENAssociation)
15819 csr_join_req->isOSENConnection = true;
15820 else
15821 csr_join_req->isOSENConnection = false;
15822
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080015823 /* Fill rrm config parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015824 qdf_mem_copy(&csr_join_req->rrm_config,
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080015825 &pMac->rrm.rrmSmeContext.rrmConfig,
15826 sizeof(struct rrm_config_param));
15827
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015828 pAP_capabilityInfo =
15829 (tSirMacCapabilityInfo *)
15830 &pBssDescription->capabilityInfo;
15831 /*
15832 * tell the target AP my 11H capability only if both AP and STA
15833 * support
15834 * 11H and the channel being used is 11a
15835 */
15836 if (csr_is11h_supported(pMac) && pAP_capabilityInfo->spectrumMgt
15837 && eSIR_11A_NW_TYPE == pBssDescription->nwType) {
Srinivas Girigowda74a66d62017-06-21 23:28:25 -070015838 fTmp = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015839 } else
Srinivas Girigowda74a66d62017-06-21 23:28:25 -070015840 fTmp = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015841
15842 csr_join_req->spectrumMgtIndicator = fTmp;
15843 csr_join_req->powerCap.minTxPower = MIN_TX_PWR_CAP;
15844 /*
15845 * This is required for 11k test VoWiFi Ent: Test 2.
15846 * We need the power capabilities for Assoc Req.
15847 * This macro is provided by the halPhyCfg.h. We pick our
15848 * max and min capability by the halPhy provided macros
Selvaraj, Sridhar94be8ba2017-05-04 17:08:54 +053015849 * Any change in this power cap IE should also be done
15850 * in csr_update_driver_assoc_ies() which would send
15851 * assoc IE's to FW which is used for LFR3 roaming
15852 * ie. used in reassociation requests from FW.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015853 */
15854 pwrLimit = csr_get_cfg_max_tx_power(pMac,
15855 pBssDescription->channelId);
Agrawal Ashish6b48ee22017-02-21 20:54:53 +053015856 if (0 != pwrLimit && pwrLimit < MAX_TX_PWR_CAP)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015857 csr_join_req->powerCap.maxTxPower = pwrLimit;
15858 else
15859 csr_join_req->powerCap.maxTxPower = MAX_TX_PWR_CAP;
15860
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053015861 csr_add_supported_5Ghz_channels(pMac,
15862 csr_join_req->supportedChannels.channelList,
15863 &csr_join_req->supportedChannels.numChnl,
15864 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015865
15866 csr_join_req->uapsdPerAcBitmask = (uint8_t)pProfile->uapsd_mask;
15867 /* Move the entire BssDescription into the join request. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015868 qdf_mem_copy(&csr_join_req->bssDescription, pBssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015869 pBssDescription->length +
15870 sizeof(pBssDescription->length));
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053015871 csr_update_fils_connection_info(pProfile, csr_join_req);
Padma, Santhosh Kumarb8f65d92017-09-14 13:05:42 +053015872 csr_update_sae_config(csr_join_req, pMac, pSession);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015873 /*
15874 * conc_custom_rule1:
15875 * If SAP comes up first and STA comes up later then SAP
15876 * need to follow STA's channel in 2.4Ghz. In following if
15877 * condition we are adding sanity check, just to make sure that
15878 * if this rule is enabled then don't allow STA to connect on
15879 * 5gz channel and also by this time SAP's channel should be the
15880 * same as STA's channel.
15881 */
15882 if (pMac->roam.configParam.conc_custom_rule1) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015883 if ((0 == pMac->roam.configParam.
15884 is_sta_connection_in_5gz_enabled) &&
15885 WLAN_REG_IS_5GHZ_CH(pBssDescription->
15886 channelId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053015887 QDF_TRACE(QDF_MODULE_ID_SME,
15888 QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015889 "STA-conn on 5G isn't allowed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015890 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015891 break;
15892 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015893 if (!WLAN_REG_IS_5GHZ_CH(pBssDescription->channelId) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015894 (false == csr_is_conn_allow_2g_band(pMac,
15895 pBssDescription->channelId))) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015896 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015897 break;
15898 }
15899 }
15900
15901 /*
15902 * conc_custom_rule2:
15903 * If P2PGO comes up first and STA comes up later then P2PGO
15904 * need to follow STA's channel in 5Ghz. In following if
15905 * condition we are just adding sanity check to make sure that
15906 * by this time P2PGO's channel is same as STA's channel.
15907 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070015908 if (pMac->roam.configParam.conc_custom_rule2 &&
15909 !WLAN_REG_IS_24GHZ_CH(pBssDescription->channelId) &&
15910 (!csr_is_conn_allow_5g_band(pMac,
15911 pBssDescription->channelId))) {
15912 status = QDF_STATUS_E_FAILURE;
15913 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015914 }
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +053015915
15916 if (pSession->pCurRoamProfile->csrPersona == QDF_STA_MODE)
15917 csr_join_req->enable_bcast_probe_rsp =
15918 pMac->roam.configParam.enable_bcast_probe_rsp;
15919
Rajeev Kumard138ac52017-01-30 18:38:37 -080015920 status = umac_send_mb_message_to_mac(csr_join_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015921 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015922 /*
Rajeev Kumard138ac52017-01-30 18:38:37 -080015923 * umac_send_mb_message_to_mac would've released the mem
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015924 * allocated by csr_join_req. Let's make it defensive by
15925 * assigning NULL to the pointer.
15926 */
15927 csr_join_req = NULL;
15928 break;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015929 }
15930
15931 if (pProfile->csrPersona == QDF_STA_MODE) {
15932 sme_debug("Invoking packetdump register API");
15933 wlan_register_txrx_packetdump();
15934 packetdump_timer_status = qdf_mc_timer_start(
15935 &pMac->roam.packetdump_timer,
15936 (PKT_DUMP_TIMER_DURATION *
15937 QDF_MC_TIMER_TO_SEC_UNIT)/
15938 QDF_MC_TIMER_TO_MS_UNIT);
15939 if (!QDF_IS_STATUS_SUCCESS(packetdump_timer_status))
15940 sme_err("cannot start packetdump timer status: %d",
15941 packetdump_timer_status);
15942 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015943#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015944 if (eWNI_SME_JOIN_REQ == messageType) {
15945 /* Notify QoS module that join happening */
15946 pSession->join_bssid_count++;
15947 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
15948 "BSSID Count: %d", pSession->join_bssid_count);
15949 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015950 SME_QOS_CSR_JOIN_REQ, NULL);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015951 } else if (eWNI_SME_REASSOC_REQ == messageType)
15952 /* Notify QoS module that reassoc happening */
15953 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015954 SME_QOS_CSR_REASSOC_REQ,
15955 NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015956#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015957 } while (0);
15958
15959 /* Clean up the memory in case of any failure */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015960 if (!QDF_IS_STATUS_SUCCESS(status) && (NULL != csr_join_req))
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015961 qdf_mem_free(csr_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015962
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +053015963 if (wpaRsnIE)
15964 qdf_mem_free(wpaRsnIE);
15965
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015966 return status;
15967}
15968
15969/* */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015970QDF_STATUS csr_send_mb_disassoc_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015971 tSirMacAddr bssId, uint16_t reasonCode)
15972{
15973 tSirSmeDisassocReq *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053015974 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015975
15976 if (!CSR_IS_SESSION_VALID(pMac, sessionId))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015977 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015978
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015979 pMsg = qdf_mem_malloc(sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015980 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015981 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015983 pMsg->messageType = eWNI_SME_DISASSOC_REQ;
15984 pMsg->length = sizeof(tSirSmeDisassocReq);
15985 pMsg->sessionId = sessionId;
15986 pMsg->transactionId = 0;
15987 if ((pSession->pCurRoamProfile != NULL)
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070015988 && (CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015989 qdf_mem_copy(&pMsg->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015990 &pSession->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015991 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015992 qdf_mem_copy(&pMsg->peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015993 bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015994 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015995 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015996 qdf_mem_copy(&pMsg->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015997 bssId, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015998 qdf_mem_copy(&pMsg->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015999 bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016000 }
16001 pMsg->reasonCode = reasonCode;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -070016002 pMsg->process_ho_fail = (pSession->disconnect_reason ==
16003 eCSR_DISCONNECT_REASON_ROAM_HO_FAIL) ? true : false;
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053016004
16005 /* Update the disconnect stats */
16006 pSession->disconnect_stats.disconnection_cnt++;
16007 pSession->disconnect_stats.disconnection_by_app++;
16008
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016009 /*
16010 * The state will be DISASSOC_HANDOFF only when we are doing
16011 * handoff. Here we should not send the disassoc over the air
16012 * to the AP
16013 */
Selvaraj, Sridhar0ab68622017-04-24 14:21:27 +053016014 if ((CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
16015 && csr_roam_is11r_assoc(pMac, sessionId)) ||
16016 pMsg->process_ho_fail) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016017 /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
16018 pMsg->doNotSendOverTheAir = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR;
16019 }
Rajeev Kumard138ac52017-01-30 18:38:37 -080016020 return umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016021}
16022
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016023QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016024csr_send_mb_get_associated_stas_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016025 QDF_MODULE_ID modId,
16026 struct qdf_mac_addr bssid,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016027 void *pUsrContext,
16028 void *pfnSapEventCallback,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016029 uint8_t *pAssocStasBuf)
16030{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016031 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016032 tSirSmeGetAssocSTAsReq *pMsg;
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016033
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016034 pMsg = qdf_mem_malloc(sizeof(*pMsg));
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016035 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016036 return QDF_STATUS_E_NOMEM;
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016037
16038 pMsg->messageType = eWNI_SME_GET_ASSOC_STAS_REQ;
Anurag Chouhanc5548422016-02-24 18:33:27 +053016039 qdf_copy_macaddr(&pMsg->bssid, &bssid);
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016040 pMsg->modId = modId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016041 qdf_mem_copy(pMsg->pUsrContext, pUsrContext, sizeof(void *));
16042 qdf_mem_copy(pMsg->pSapEventCallback,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016043 pfnSapEventCallback, sizeof(void *));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016044 qdf_mem_copy(pMsg->pAssocStasArray, pAssocStasBuf, sizeof(void *));
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016045 pMsg->length = sizeof(*pMsg);
Rajeev Kumard138ac52017-01-30 18:38:37 -080016046 status = umac_send_mb_message_to_mac(pMsg);
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080016047
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016048 return status;
16049}
16050
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016051QDF_STATUS csr_send_chng_mcc_beacon_interval(tpAniSirGlobal pMac,
16052 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016053{
16054 tpSirChangeBIParams pMsg;
16055 uint16_t len = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016056 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016057 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016058
16059 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016060 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016061 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016062 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016063 /* NO need to update the Beacon Params if update beacon parameter flag
16064 * is not set
16065 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016066 if (!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016067 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016068
16069 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval =
16070 false;
16071
16072 /* Create the message and send to lim */
16073 len = sizeof(tSirChangeBIParams);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016074 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016075 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016076 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016077 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016078 status = QDF_STATUS_SUCCESS;
16079 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016080 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
16081 pMsg->length = len;
16082
Anurag Chouhanc5548422016-02-24 18:33:27 +053016083 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016084 sme_debug(
16085 "CSR Attempting to change BI for Bssid= "
16086 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMsg->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016087 pMsg->sessionId = sessionId;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016088 sme_debug("session %d BeaconInterval %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016089 sessionId,
16090 pMac->roam.roamSession[sessionId].bssParams.
16091 beaconInterval);
16092 pMsg->beaconInterval =
16093 pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
Rajeev Kumard138ac52017-01-30 18:38:37 -080016094 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016095 }
16096 return status;
16097}
16098
16099#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016100QDF_STATUS csr_set_ht2040_mode(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016101 ePhyChanBondState cbMode, bool obssEnabled)
16102{
16103 tpSirSetHT2040Mode pMsg;
16104 uint16_t len = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016105 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016106 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016107
16108 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016109 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016110 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016111 }
16112
16113 /* Create the message and send to lim */
16114 len = sizeof(tSirSetHT2040Mode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016115 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016116 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016117 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016118 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016119 status = QDF_STATUS_SUCCESS;
16120 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016121 qdf_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016122 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
16123 pMsg->length = len;
16124
Anurag Chouhanc5548422016-02-24 18:33:27 +053016125 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016126 sme_debug(
16127 "CSR Attempting to set HT20/40 mode for Bssid= "
16128 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMsg->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016129 pMsg->sessionId = sessionId;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016130 sme_debug(" session %d HT20/40 mode %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016131 sessionId, cbMode);
16132 pMsg->cbMode = cbMode;
16133 pMsg->obssEnabled = obssEnabled;
Rajeev Kumard138ac52017-01-30 18:38:37 -080016134 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016135 }
16136 return status;
16137}
16138#endif
16139
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016140QDF_STATUS csr_send_mb_deauth_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016141 tSirMacAddr bssId, uint16_t reasonCode)
16142{
16143 tSirSmeDeauthReq *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016144 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016145
16146 if (!CSR_IS_SESSION_VALID(pMac, sessionId))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016147 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016148
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016149 pMsg = qdf_mem_malloc(sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016150 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016151 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016152
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016153 qdf_mem_set(pMsg, sizeof(tSirSmeDeauthReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016154 pMsg->messageType = eWNI_SME_DEAUTH_REQ;
16155 pMsg->length = sizeof(tSirSmeDeauthReq);
16156 pMsg->sessionId = sessionId;
16157 pMsg->transactionId = 0;
16158
16159 if ((pSession->pCurRoamProfile != NULL)
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070016160 && (CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016161 qdf_mem_copy(&pMsg->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016162 &pSession->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016163 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016164 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016165 qdf_mem_copy(&pMsg->bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016166 bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016167 }
16168
16169 /* Set the peer MAC address before sending the message to LIM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016170 qdf_mem_copy(&pMsg->peer_macaddr.bytes, bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016171 pMsg->reasonCode = reasonCode;
16172
Vignesh Viswanathan66c951d2017-09-06 12:23:42 +053016173 /* Update the disconnect stats */
16174 pSession->disconnect_stats.disconnection_cnt++;
16175 pSession->disconnect_stats.disconnection_by_app++;
16176
Rajeev Kumard138ac52017-01-30 18:38:37 -080016177 return umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016178}
16179
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016180QDF_STATUS csr_send_mb_disassoc_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016181 tpSirSmeDisassocInd pDisassocInd)
16182{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016183 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016184 tSirSmeDisassocCnf *pMsg;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016185
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016186 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016187 pMsg = qdf_mem_malloc(sizeof(tSirSmeDisassocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016188 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016189 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016190 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016191 status = QDF_STATUS_SUCCESS;
16192 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016193 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016194 pMsg->messageType = eWNI_SME_DISASSOC_CNF;
16195 pMsg->statusCode = eSIR_SME_SUCCESS;
16196 pMsg->length = sizeof(tSirSmeDisassocCnf);
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +053016197 pMsg->sme_session_id = pDisassocInd->sessionId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053016198 qdf_copy_macaddr(&pMsg->peer_macaddr,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080016199 &pDisassocInd->peer_macaddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016200 status = QDF_STATUS_SUCCESS;
16201 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016202 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016203 break;
16204 }
16205
Anurag Chouhanc5548422016-02-24 18:33:27 +053016206 qdf_copy_macaddr(&pMsg->bssid, &pDisassocInd->bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016207 status = QDF_STATUS_SUCCESS;
16208 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016209 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016210 break;
16211 }
16212
Rajeev Kumard138ac52017-01-30 18:38:37 -080016213 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016214 } while (0);
16215 return status;
16216}
16217
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016218QDF_STATUS csr_send_mb_deauth_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016219 tpSirSmeDeauthInd pDeauthInd)
16220{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016221 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016222 tSirSmeDeauthCnf *pMsg;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016223
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016224 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016225 pMsg = qdf_mem_malloc(sizeof(tSirSmeDeauthCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016226 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016227 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016228 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016229 status = QDF_STATUS_SUCCESS;
16230 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016231 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016232 pMsg->messageType = eWNI_SME_DEAUTH_CNF;
16233 pMsg->statusCode = eSIR_SME_SUCCESS;
16234 pMsg->length = sizeof(tSirSmeDeauthCnf);
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +053016235 pMsg->sme_session_id = pDeauthInd->sessionId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053016236 qdf_copy_macaddr(&pMsg->bssid, &pDeauthInd->bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016237 status = QDF_STATUS_SUCCESS;
16238 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016239 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016240 break;
16241 }
Anurag Chouhanc5548422016-02-24 18:33:27 +053016242 qdf_copy_macaddr(&pMsg->peer_macaddr,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -080016243 &pDeauthInd->peer_macaddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016244 status = QDF_STATUS_SUCCESS;
16245 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016246 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016247 break;
16248 }
Rajeev Kumard138ac52017-01-30 18:38:37 -080016249 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016250 } while (0);
16251 return status;
16252}
16253
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016254QDF_STATUS csr_send_assoc_cnf_msg(tpAniSirGlobal pMac, tpSirSmeAssocInd
16255 pAssocInd, QDF_STATUS Halstatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016256{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016257 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016258 tSirSmeAssocCnf *pMsg;
Sandeep Puligilla1426d612017-04-12 18:22:06 -070016259 struct scheduler_msg msg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016260
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016261 sme_debug("Posting eWNI_SME_ASSOC_CNF to LIM.HalStatus: %d", Halstatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016262 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016263 pMsg = qdf_mem_malloc(sizeof(tSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016264 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016265 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016266 pMsg->messageType = eWNI_SME_ASSOC_CNF;
16267 pMsg->length = sizeof(tSirSmeAssocCnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016268 if (QDF_IS_STATUS_SUCCESS(Halstatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016269 pMsg->statusCode = eSIR_SME_SUCCESS;
16270 else
16271 pMsg->statusCode = eSIR_SME_ASSOC_REFUSED;
16272 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016273 qdf_mem_copy(pMsg->bssid.bytes, pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016274 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016275 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016276 qdf_mem_copy(pMsg->peer_macaddr.bytes, pAssocInd->peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016277 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016278 /* aid */
16279 pMsg->aid = pAssocInd->aid;
16280 /* alternateBssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016281 qdf_mem_copy(pMsg->alternate_bssid.bytes, pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016282 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016283 /* alternateChannelId */
16284 pMsg->alternateChannelId = 11;
Sandeep Puligilla1426d612017-04-12 18:22:06 -070016285
16286 msg.type = pMsg->messageType;
16287 msg.bodyval = 0;
16288 msg.bodyptr = pMsg;
Rajeev Kumard138ac52017-01-30 18:38:37 -080016289 /* pMsg is freed by umac_send_mb_message_to_mac in anycase*/
Sandeep Puligilla1426d612017-04-12 18:22:06 -070016290 status = scheduler_post_msg_by_priority(QDF_MODULE_ID_PE, &msg,
16291 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016292 } while (0);
16293 return status;
16294}
16295
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016296QDF_STATUS csr_send_assoc_ind_to_upper_layer_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016297 tpSirSmeAssocInd pAssocInd,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016298 QDF_STATUS Halstatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016299 uint8_t sessionId)
16300{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070016301 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016302 tSirSmeAssocIndToUpperLayerCnf *pMsg;
16303 uint8_t *pBuf;
16304 tSirResultCodes statusCode;
16305 uint16_t wTmp;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016306
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016307 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016308 pMsg = qdf_mem_malloc(sizeof(tSirSmeAssocIndToUpperLayerCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016309 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016310 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016311
16312 pMsg->messageType = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
16313 pMsg->length = sizeof(tSirSmeAssocIndToUpperLayerCnf);
16314
16315 pMsg->sessionId = sessionId;
16316
16317 pBuf = (uint8_t *) &pMsg->statusCode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016318 if (QDF_IS_STATUS_SUCCESS(Halstatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016319 statusCode = eSIR_SME_SUCCESS;
16320 else
16321 statusCode = eSIR_SME_ASSOC_REFUSED;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016322 qdf_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016323 /* bssId */
Will Huang558f8082017-05-31 16:22:24 +080016324 pBuf = (uint8_t *)&pMsg->bssId;
16325 qdf_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId,
16326 sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016327 /* peerMacAddr */
Will Huang558f8082017-05-31 16:22:24 +080016328 pBuf = (uint8_t *)&pMsg->peerMacAddr;
16329 qdf_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
16330 sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016331 /* StaId */
Will Huang558f8082017-05-31 16:22:24 +080016332 pBuf = (uint8_t *)&pMsg->aid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016333 wTmp = pAssocInd->staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016334 qdf_mem_copy(pBuf, &wTmp, sizeof(uint16_t));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016335 /* alternateBssId */
Will Huang558f8082017-05-31 16:22:24 +080016336 pBuf = (uint8_t *)&pMsg->alternateBssId;
16337 qdf_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId,
16338 sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016339 /* alternateChannelId */
Will Huang558f8082017-05-31 16:22:24 +080016340 pBuf = (uint8_t *)&pMsg->alternateChannelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016341 *pBuf = 11;
Will Huang558f8082017-05-31 16:22:24 +080016342 /*
16343 * Instead of copying roam Info,just copy WmmEnabled,
16344 * RsnIE information.
16345 * Wmm
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016346 */
Will Huang558f8082017-05-31 16:22:24 +080016347 pBuf = (uint8_t *)&pMsg->wmmEnabledSta;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016348 *pBuf = pAssocInd->wmmEnabledSta;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016349 /* RSN IE */
Will Huang558f8082017-05-31 16:22:24 +080016350 pBuf = (uint8_t *)&pMsg->rsnIE;
16351 qdf_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE,
16352 sizeof(tSirRSNie));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016353#ifdef FEATURE_WLAN_WAPI
16354 /* WAPI IE */
Will Huang558f8082017-05-31 16:22:24 +080016355 pBuf = (uint8_t *)&pMsg->wapiIE;
16356 qdf_mem_copy((tSirWAPIie *)pBuf, &pAssocInd->wapiIE,
16357 sizeof(tSirWAPIie));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016358#endif
16359 /* Additional IE */
Will Huang558f8082017-05-31 16:22:24 +080016360 pBuf = (uint8_t *)&pMsg->addIE;
16361 qdf_mem_copy((tSirAddie *)pBuf, &pAssocInd->addIE,
16362 sizeof(tSirAddie));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016363 /* reassocReq */
Will Huang558f8082017-05-31 16:22:24 +080016364 pBuf = (uint8_t *)&pMsg->reassocReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016365 *pBuf = pAssocInd->reassocReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016366 /* timingMeasCap */
Will Huang558f8082017-05-31 16:22:24 +080016367 pBuf = (uint8_t *)&pMsg->timingMeasCap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016368 *pBuf = pAssocInd->timingMeasCap;
Will Huang558f8082017-05-31 16:22:24 +080016369 /* chan_info */
16370 pBuf = (uint8_t *)&pMsg->chan_info;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016371 qdf_mem_copy((void *)pBuf, &pAssocInd->chan_info,
Will Huang558f8082017-05-31 16:22:24 +080016372 sizeof(tSirSmeChanInfo));
16373 /* ampdu */
16374 pBuf = (uint8_t *)&pMsg->ampdu;
16375 *((bool *)pBuf) = pAssocInd->ampdu;
16376 /* sgi_enable */
16377 pBuf = (uint8_t *)&pMsg->sgi_enable;
16378 *((bool *)pBuf) = pAssocInd->sgi_enable;
16379 /* tx stbc */
16380 pBuf = (uint8_t *)&pMsg->tx_stbc;
16381 *((bool *)pBuf) = pAssocInd->tx_stbc;
16382 /* ch_width */
16383 pBuf = (uint8_t *)&pMsg->ch_width;
16384 *((tSirMacHTChannelWidth *)pBuf) = pAssocInd->ch_width;
16385 /* mode */
16386 pBuf = (uint8_t *)&pMsg->mode;
16387 *((enum sir_sme_phy_mode *)pBuf) = pAssocInd->mode;
16388 /* rx stbc */
16389 pBuf = (uint8_t *)&pMsg->rx_stbc;
16390 *((bool *)pBuf) = pAssocInd->rx_stbc;
16391 /* max supported idx */
16392 pBuf = (uint8_t *)&pMsg->max_supp_idx;
16393 *pBuf = pAssocInd->max_supp_idx;
16394 /* max extended idx */
16395 pBuf = (uint8_t *)&pMsg->max_ext_idx;
16396 *pBuf = pAssocInd->max_ext_idx;
16397 /* max ht mcs idx */
16398 pBuf = (uint8_t *)&pMsg->max_mcs_idx;
16399 *pBuf = pAssocInd->max_mcs_idx;
16400 /* vht rx mcs map */
16401 pBuf = (uint8_t *)&pMsg->rx_mcs_map;
16402 *pBuf = pAssocInd->rx_mcs_map;
16403 /* vht tx mcs map */
16404 pBuf = (uint8_t *)&pMsg->tx_mcs_map;
16405 *pBuf = pAssocInd->tx_mcs_map;
16406
gaolez7bb1e742017-03-21 16:37:38 +080016407 pBuf = (uint8_t *)&pMsg->ecsa_capable;
16408 *pBuf = pAssocInd->ecsa_capable;
16409
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +053016410 if (pAssocInd->HTCaps.present)
16411 pMsg->ht_caps = pAssocInd->HTCaps;
16412 if (pAssocInd->VHTCaps.present)
16413 pMsg->vht_caps = pAssocInd->VHTCaps;
16414
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016415 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
16416 msgQ.bodyptr = pMsg;
16417 msgQ.bodyval = 0;
16418 sys_process_mmh_msg(pMac, &msgQ);
16419 } while (0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016420 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016421}
16422
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016423QDF_STATUS csr_send_mb_set_context_req_msg(tpAniSirGlobal pMac,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080016424 uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016425 struct qdf_mac_addr peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080016426 uint8_t numKeys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016427 tAniEdType edType, bool fUnicast,
16428 tAniKeyDirection aniKeyDirection,
16429 uint8_t keyId, uint8_t keyLength,
16430 uint8_t *pKey, uint8_t paeRole,
16431 uint8_t *pKeyRsc)
16432{
16433 tSirSmeSetContextReq *pMsg;
Abhishek Singh154637a2017-06-19 18:02:11 +053016434 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016435 uint16_t msgLen;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016436 QDF_STATUS status = QDF_STATUS_E_FAILURE;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016437 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016438
16439 sme_debug("keylength: %d Encry type: %d", keyLength, edType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016440 do {
16441 if ((1 != numKeys) && (0 != numKeys))
16442 break;
16443 /*
16444 * All of these fields appear in every SET_CONTEXT message.
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016445 * Below we'll add in the size for each key set. Since we only
16446 * support up to one key, we always allocate memory for 1 key.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016447 */
16448 msgLen = sizeof(struct sSirSmeSetContextReq);
16449
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016450 pMsg = qdf_mem_malloc(msgLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016451 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016452 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016453 pMsg->messageType = eWNI_SME_SETCONTEXT_REQ;
16454 pMsg->length = msgLen;
16455 pMsg->sessionId = (uint8_t) sessionId;
16456 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053016457 qdf_copy_macaddr(&pMsg->peer_macaddr, &peer_macaddr);
16458 qdf_copy_macaddr(&pMsg->bssid,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080016459 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016460
16461 /**
16462 * Set the pMsg->keyMaterial.length field
16463 * (this length is defined as all data that follows the
16464 * edType field in the tSirKeyMaterial keyMaterial; field).
16465 *
16466 * NOTE: This keyMaterial.length contains the length of a
16467 * MAX size key, though the keyLength can be shorter than this
16468 * max size. Is LIM interpreting this ok ?
16469 */
16470 pMsg->keyMaterial.length =
16471 sizeof(pMsg->keyMaterial.numKeys) +
16472 (numKeys * sizeof(pMsg->keyMaterial.key));
16473 pMsg->keyMaterial.edType = edType;
16474 pMsg->keyMaterial.numKeys = numKeys;
16475 pMsg->keyMaterial.key[0].keyId = keyId;
16476 pMsg->keyMaterial.key[0].unicast = fUnicast;
16477 pMsg->keyMaterial.key[0].keyDirection = aniKeyDirection;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016478 qdf_mem_copy(pMsg->keyMaterial.key[0].keyRsc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016479 pKeyRsc, CSR_MAX_RSC_LEN);
16480 /* 0 is Supplicant */
16481 pMsg->keyMaterial.key[0].paeRole = paeRole;
16482 pMsg->keyMaterial.key[0].keyLength = keyLength;
Sreelakshmi Konamki66ddf3a2017-02-28 17:29:43 +053016483 if (keyLength && pKey)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016484 qdf_mem_copy(pMsg->keyMaterial.key[0].key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016485 pKey, keyLength);
Abhishek Singh154637a2017-06-19 18:02:11 +053016486
16487 msg.type = eWNI_SME_SETCONTEXT_REQ;
16488 msg.bodyptr = pMsg;
16489 status = scheduler_post_msg_by_priority(QDF_MODULE_ID_PE, &msg, true);
16490 if (QDF_IS_STATUS_ERROR(status))
16491 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016492 } while (0);
16493 return status;
16494}
16495
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016496QDF_STATUS csr_send_mb_start_bss_req_msg(tpAniSirGlobal pMac, uint32_t
16497 sessionId, eCsrRoamBssType bssType,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016498 struct csr_roamstart_bssparams *pParam,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016499 tSirBssDescription *pBssDesc)
16500{
16501 tSirSmeStartBssReq *pMsg;
16502 uint16_t wTmp;
Krunal Soni53993f72016-07-08 18:20:03 -070016503 uint32_t value = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016504 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016505
16506 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016507 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016508 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016509 }
16510
16511 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
16512 pSession->joinFailStatusCode.reasonCode = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016513 pMsg = qdf_mem_malloc(sizeof(tSirSmeStartBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016514 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016515 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016516
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016517 pMsg->messageType = eWNI_SME_START_BSS_REQ;
16518 pMsg->sessionId = sessionId;
16519 pMsg->length = sizeof(tSirSmeStartBssReq);
16520 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053016521 qdf_copy_macaddr(&pMsg->bssid, &pParam->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016522 /* selfMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053016523 qdf_copy_macaddr(&pMsg->self_macaddr, &pSession->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016524 /* beaconInterval */
16525 if (pBssDesc && pBssDesc->beaconInterval)
16526 wTmp = pBssDesc->beaconInterval;
16527 else if (pParam->beaconInterval)
16528 wTmp = pParam->beaconInterval;
16529 else
16530 wTmp = WNI_CFG_BEACON_INTERVAL_STADEF;
16531
Krunal Sonicbda8552016-07-14 19:39:02 -070016532 csr_validate_mcc_beacon_interval(pMac, pParam->operationChn,
16533 &wTmp, sessionId, pParam->bssPersona);
16534 /* Update the beacon Interval */
16535 pParam->beaconInterval = wTmp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016536 pMsg->beaconInterval = wTmp;
16537 pMsg->dot11mode =
16538 csr_translate_to_wni_cfg_dot11_mode(pMac,
16539 pParam->uCfgDot11Mode);
16540#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
16541 pMsg->cc_switch_mode = pMac->roam.configParam.cc_switch_mode;
16542#endif
16543 pMsg->bssType = csr_translate_bsstype_to_mac_type(bssType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016544 qdf_mem_copy(&pMsg->ssId, &pParam->ssId, sizeof(pParam->ssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016545 pMsg->channelId = pParam->operationChn;
16546 /* What should we really do for the cbmode. */
16547 pMsg->cbMode = (ePhyChanBondState) pParam->cbMode;
16548 pMsg->vht_channel_width = pParam->ch_params.ch_width;
16549 pMsg->center_freq_seg0 = pParam->ch_params.center_freq_seg0;
16550 pMsg->center_freq_seg1 = pParam->ch_params.center_freq_seg1;
16551 pMsg->sec_ch_offset = pParam->ch_params.sec_ch_offset;
16552 pMsg->privacy = pParam->privacy;
16553 pMsg->apUapsdEnable = pParam->ApUapsdEnable;
16554 pMsg->ssidHidden = pParam->ssidHidden;
16555 pMsg->fwdWPSPBCProbeReq = (uint8_t) pParam->fwdWPSPBCProbeReq;
16556 pMsg->protEnabled = (uint8_t) pParam->protEnabled;
16557 pMsg->obssProtEnabled = (uint8_t) pParam->obssProtEnabled;
16558 /* set cfg related to protection */
16559 pMsg->ht_capab = pParam->ht_protection;
16560 pMsg->authType = pParam->authType;
16561 pMsg->dtimPeriod = pParam->dtimPeriod;
16562 pMsg->wps_state = pParam->wps_state;
16563 pMsg->isCoalesingInIBSSAllowed = pMac->isCoalesingInIBSSAllowed;
16564 pMsg->bssPersona = pParam->bssPersona;
Krunal Sonia2c0e412017-05-04 14:12:41 +053016565 pMsg->txLdpcIniFeatureEnabled = pMac->roam.configParam.tx_ldpc_enable;
Krunal Soni53993f72016-07-08 18:20:03 -070016566
jiad4a7a33c2017-08-08 15:32:24 +080016567 /*
16568 * If RX LDPC has been disabled for 2.4GHz channels and enabled
16569 * for 5Ghz for STA like persona then here is how to handle
16570 * those cases (by now channel has been decided).
16571 */
16572 if (eSIR_IBSS_MODE == pMsg->bssType ||
16573 !policy_mgr_is_dbs_enable(pMac->psoc))
16574 csr_set_ldpc_exception(pMac, pSession,
16575 pMsg->channelId,
16576 pMac->roam.configParam.rx_ldpc_enable);
16577
Kiran Kumar Lokere26d05482017-05-17 12:47:49 -070016578 qdf_mem_copy(&pMsg->vht_config,
16579 &pSession->vht_config,
16580 sizeof(pSession->vht_config));
16581 qdf_mem_copy(&pMsg->htConfig,
16582 &pSession->htConfig,
16583 sizeof(tSirHTConfig));
16584
Krunal Soni53993f72016-07-08 18:20:03 -070016585 if (wlan_cfg_get_int(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP, &value)
16586 != eSIR_SUCCESS)
16587 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016588 "could not get SU beam formee capability");
Krunal Soni53993f72016-07-08 18:20:03 -070016589 pMsg->vht_config.su_beam_formee =
16590 (uint8_t)value &&
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -080016591 (uint8_t)pMac->roam.configParam.enable_txbf_sap_mode;
Krunal Soni53993f72016-07-08 18:20:03 -070016592 if (wlan_cfg_get_int(pMac,
16593 WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED,
16594 &value) != eSIR_SUCCESS)
16595 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016596 ("Failed to get CSN beamformee capability"));
Krunal Soni53993f72016-07-08 18:20:03 -070016597 pMsg->vht_config.csnof_beamformer_antSup = (uint8_t)value;
Kiran Kumar Lokere26d05482017-05-17 12:47:49 -070016598 pMsg->vht_config.mu_beam_formee = 0;
Krunal Soni53993f72016-07-08 18:20:03 -070016599
Kiran Kumar Lokere26d05482017-05-17 12:47:49 -070016600 sme_debug("ht capability 0x%x VHT capability 0x%x",
16601 (uint32_t)(*(uint32_t *) &pMsg->htConfig),
16602 (uint32_t)(*(uint32_t *) &pMsg->vht_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016603#ifdef WLAN_FEATURE_11W
16604 pMsg->pmfCapable = pParam->mfpCapable;
16605 pMsg->pmfRequired = pParam->mfpRequired;
16606#endif
16607
16608 if (pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016609 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016610 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016611 }
16612 pMsg->rsnIE.length = pParam->nRSNIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016613 qdf_mem_copy(pMsg->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016614 pParam->pRSNIE,
16615 pParam->nRSNIELength);
16616 pMsg->nwType = (tSirNwType)pParam->sirNwType;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016617 qdf_mem_copy(&pMsg->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016618 &pParam->operationalRateSet,
16619 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016620 qdf_mem_copy(&pMsg->extendedRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016621 &pParam->extendedRateSet,
16622 sizeof(tSirMacRateSet));
jiad4a7a33c2017-08-08 15:32:24 +080016623
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -080016624 if (IS_DOT11_MODE_HE(pMsg->dot11mode))
16625 csr_start_bss_copy_he_cap(pMsg, pSession);
16626
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016627 qdf_mem_copy(&pMsg->addIeParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016628 &pParam->addIeParams,
16629 sizeof(pParam->addIeParams));
16630 pMsg->obssEnabled = pMac->roam.configParam.obssEnabled;
16631 pMsg->sap_dot11mc = pParam->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +053016632 pMsg->vendor_vht_sap =
16633 pMac->roam.configParam.vendor_vht_sap;
Arif Hussain671a1902017-03-17 09:08:32 -070016634 pMsg->cac_duration_ms = pParam->cac_duration_ms;
16635 pMsg->dfs_regdomain = pParam->dfs_regdomain;
Jiachao Wu712d4fd2017-08-23 16:52:34 +080016636 pMsg->beacon_tx_rate = pParam->beacon_tx_rate;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016637
Rajeev Kumard138ac52017-01-30 18:38:37 -080016638 return umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016639}
16640
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016641QDF_STATUS csr_send_mb_stop_bss_req_msg(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016642{
16643 tSirSmeStopBssReq *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016644 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016645
16646 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016647 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016648 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016649 }
16650
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016651 pMsg = qdf_mem_malloc(sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016652 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016653 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016654 pMsg->messageType = eWNI_SME_STOP_BSS_REQ;
16655 pMsg->sessionId = sessionId;
16656 pMsg->length = sizeof(tSirSmeStopBssReq);
16657 pMsg->transactionId = 0;
16658 pMsg->reasonCode = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053016659 qdf_copy_macaddr(&pMsg->bssid, &pSession->connectedProfile.bssid);
Rajeev Kumard138ac52017-01-30 18:38:37 -080016660 return umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016661}
16662
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016663QDF_STATUS csr_reassoc(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016664 tCsrRoamModifyProfileFields *pModProfileFields,
16665 uint32_t *pRoamId, bool fForce)
16666{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016667 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016668 uint32_t roamId = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016669 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016670
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016671 if ((csr_is_conn_state_connected(pMac, sessionId)) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016672 (fForce || (qdf_mem_cmp(&pModProfileFields,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016673 &pSession->connectedProfile.
16674 modifyProfileFields,
16675 sizeof(tCsrRoamModifyProfileFields))))) {
16676 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016677 if (pRoamId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016678 *pRoamId = roamId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016679
16680 status =
16681 csr_roam_issue_reassoc(pMac, sessionId, NULL,
16682 pModProfileFields,
16683 eCsrSmeIssuedReassocToSameAP,
16684 roamId, false);
16685 }
16686 return status;
16687}
16688
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016689static QDF_STATUS csr_roam_session_opened(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016690 uint32_t sessionId)
16691{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016692 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson172237b2017-11-07 15:32:59 -080016693 struct csr_roam_info roamInfo;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016694
Jeff Johnson172237b2017-11-07 15:32:59 -080016695 qdf_mem_set(&roamInfo, sizeof(struct csr_roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016696 status = csr_roam_call_callback(pMac, sessionId, &roamInfo, 0,
16697 eCSR_ROAM_SESSION_OPENED,
16698 eCSR_ROAM_RESULT_NONE);
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -070016699
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016700 return status;
16701}
16702
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016703QDF_STATUS csr_process_add_sta_session_rsp(tpAniSirGlobal pMac, uint8_t *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016704{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016705 struct add_sta_self_params *rsp;
16706 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016707 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016708
16709 if (pMsg == NULL) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016710 sme_err("in %s msg ptr is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016711 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016712 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016713 rsp = (struct add_sta_self_params *) pMsg;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016714 sme_debug("Add Sta self rsp status = %d", rsp->status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016715
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016716 if (QDF_STATUS_SUCCESS == rsp->status &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016717 (WMI_VDEV_TYPE_STA == rsp->type ||
16718 (WMI_VDEV_TYPE_AP == rsp->type &&
16719 WMI_UNIFIED_VDEV_SUBTYPE_P2P_DEVICE == rsp->sub_type))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016720 sme_debug("send SET IE msg to PE");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016721 msg = qdf_mem_malloc(sizeof(*msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016722 if (NULL == msg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016723 sme_err("Memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016724 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016725 }
16726
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016727 msg->msg_type = eWNI_SME_SET_IE_REQ;
16728 msg->session_id = rsp->session_id;
16729 msg->length = sizeof(*msg);
Rajeev Kumard138ac52017-01-30 18:38:37 -080016730 status = umac_send_mb_message_to_mac(msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016731 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016732 sme_err("Failed to send down the set IE req ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016733 }
16734
Krunal Soni985b8132017-02-10 18:49:08 -080016735 csr_roam_session_opened(pMac, rsp->session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016736 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016737}
16738
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070016739/**
16740 * csr_get_vdev_type_nss() - gets the nss value based on vdev type
16741 * @mac_ctx: Pointer to Global MAC structure
16742 * @dev_mode: current device operating mode.
16743 * @nss2g: Pointer to the 2G Nss parameter.
16744 * @nss5g: Pointer to the 5G Nss parameter.
16745 *
16746 * Fills the 2G and 5G Nss values based on device mode.
16747 *
16748 * Return: None
16749 */
16750void csr_get_vdev_type_nss(tpAniSirGlobal mac_ctx,
Jeff Johnsonc1e62782017-11-09 09:50:17 -080016751 enum QDF_OPMODE dev_mode,
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070016752 uint8_t *nss_2g, uint8_t *nss_5g)
16753{
16754 switch (dev_mode) {
16755 case QDF_STA_MODE:
16756 *nss_2g = mac_ctx->vdev_type_nss_2g.sta;
16757 *nss_5g = mac_ctx->vdev_type_nss_5g.sta;
16758 break;
16759 case QDF_SAP_MODE:
16760 *nss_2g = mac_ctx->vdev_type_nss_2g.sap;
16761 *nss_5g = mac_ctx->vdev_type_nss_5g.sap;
16762 break;
16763 case QDF_P2P_CLIENT_MODE:
16764 *nss_2g = mac_ctx->vdev_type_nss_2g.p2p_cli;
16765 *nss_5g = mac_ctx->vdev_type_nss_5g.p2p_cli;
16766 break;
16767 case QDF_P2P_GO_MODE:
16768 *nss_2g = mac_ctx->vdev_type_nss_2g.p2p_go;
16769 *nss_5g = mac_ctx->vdev_type_nss_5g.p2p_go;
16770 break;
16771 case QDF_P2P_DEVICE_MODE:
16772 *nss_2g = mac_ctx->vdev_type_nss_2g.p2p_dev;
16773 *nss_5g = mac_ctx->vdev_type_nss_5g.p2p_dev;
16774 break;
16775 case QDF_IBSS_MODE:
16776 *nss_2g = mac_ctx->vdev_type_nss_2g.ibss;
16777 *nss_5g = mac_ctx->vdev_type_nss_5g.ibss;
16778 break;
16779 case QDF_OCB_MODE:
16780 *nss_2g = mac_ctx->vdev_type_nss_2g.ocb;
16781 *nss_5g = mac_ctx->vdev_type_nss_5g.ocb;
16782 break;
16783 default:
16784 *nss_2g = 1;
16785 *nss_5g = 1;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016786 sme_err("Unknown device mode");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070016787 break;
16788 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016789 sme_debug("mode - %d: nss_2g - %d, 5g - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070016790 dev_mode, *nss_2g, *nss_5g);
16791}
Jeff Johnson29e2ca12016-10-14 12:50:38 -070016792
16793static
16794QDF_STATUS csr_issue_add_sta_for_session_req(tpAniSirGlobal pMac,
16795 uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016796 tSirMacAddr sessionMacAddr,
16797 uint32_t type, uint32_t subType)
16798{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016799 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016800 struct add_sta_self_params *add_sta_self_req;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070016801 uint8_t nss_2g;
16802 uint8_t nss_5g;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070016803 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016804
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016805 add_sta_self_req = qdf_mem_malloc(sizeof(struct add_sta_self_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016806 if (NULL == add_sta_self_req) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016807 sme_err("Unable to allocate memory for tAddSelfStaParams");
Dustin Brownd28772b2017-03-17 14:16:07 -070016808 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016809 }
16810
Krunal Soni985b8132017-02-10 18:49:08 -080016811 csr_get_vdev_type_nss(pMac, pMac->sme.currDeviceMode,
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070016812 &nss_2g, &nss_5g);
Krunal Soni985b8132017-02-10 18:49:08 -080016813 qdf_mem_copy(add_sta_self_req->self_mac_addr, sessionMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016814 sizeof(tSirMacAddr));
Krunal Soni985b8132017-02-10 18:49:08 -080016815 add_sta_self_req->curr_device_mode = pMac->sme.currDeviceMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016816 add_sta_self_req->session_id = sessionId;
Krunal Soni985b8132017-02-10 18:49:08 -080016817 add_sta_self_req->type = type;
16818 add_sta_self_req->sub_type = subType;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070016819 add_sta_self_req->nss_2g = nss_2g;
16820 add_sta_self_req->nss_5g = nss_5g;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +053016821 add_sta_self_req->tx_aggregation_size =
16822 pMac->roam.configParam.tx_aggregation_size;
Paul Zhangee09f8e2018-04-23 16:11:32 +080016823 add_sta_self_req->tx_aggregation_size_be =
16824 pMac->roam.configParam.tx_aggregation_size_be;
16825 add_sta_self_req->tx_aggregation_size_bk =
16826 pMac->roam.configParam.tx_aggregation_size_bk;
16827 add_sta_self_req->tx_aggregation_size_vi =
16828 pMac->roam.configParam.tx_aggregation_size_vi;
16829 add_sta_self_req->tx_aggregation_size_vo =
16830 pMac->roam.configParam.tx_aggregation_size_vo;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +053016831 add_sta_self_req->rx_aggregation_size =
16832 pMac->roam.configParam.rx_aggregation_size;
Selvaraj, Sridhar4f684bb2017-01-19 15:59:23 +053016833 add_sta_self_req->enable_bcast_probe_rsp =
16834 pMac->roam.configParam.enable_bcast_probe_rsp;
Selvaraj, Sridhar97ce6582017-01-20 17:06:34 +053016835 add_sta_self_req->fils_max_chan_guard_time =
16836 pMac->roam.configParam.fils_max_chan_guard_time;
Naveen Rawat2b6e3c92017-03-20 13:59:07 -070016837 add_sta_self_req->pkt_err_disconn_th =
16838 pMac->roam.configParam.pkt_err_disconn_th;
Yeshwanth Sriram Guntuka2ba6fe92017-10-04 14:40:45 +053016839 add_sta_self_req->oce_feature_bitmap =
16840 pMac->roam.configParam.oce_feature_bitmap;
Paul Zhang33fae272018-04-23 16:19:00 +080016841 add_sta_self_req->tx_aggr_sw_retry_threshold_be =
16842 pMac->roam.configParam.tx_aggr_sw_retry_threshold_be;
16843 add_sta_self_req->tx_aggr_sw_retry_threshold_bk =
16844 pMac->roam.configParam.tx_aggr_sw_retry_threshold_bk;
16845 add_sta_self_req->tx_aggr_sw_retry_threshold_vi =
16846 pMac->roam.configParam.tx_aggr_sw_retry_threshold_vi;
16847 add_sta_self_req->tx_aggr_sw_retry_threshold_vo =
16848 pMac->roam.configParam.tx_aggr_sw_retry_threshold_vo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016849 msg.type = WMA_ADD_STA_SELF_REQ;
16850 msg.reserved = 0;
16851 msg.bodyptr = add_sta_self_req;
16852 msg.bodyval = 0;
16853
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016854 sme_debug(
16855 "Send WMA_ADD_STA_SELF_REQ for selfMac=" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016856 MAC_ADDR_ARRAY(add_sta_self_req->self_mac_addr));
Tushnim Bhattacharyya647f93e2018-03-27 15:50:42 -070016857 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016858
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016859 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016860 sme_err("wma_post_ctrl_msg failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016861 qdf_mem_free(add_sta_self_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016862 add_sta_self_req = NULL;
16863 }
16864 return status;
16865}
16866
Sandeep Puligillaba71da42016-10-04 17:36:32 -070016867QDF_STATUS csr_roam_open_session(tpAniSirGlobal mac_ctx,
Krunal Soni8d184fa2017-11-20 21:52:05 -080016868 struct sme_session_params *session_param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016869{
Dustin Brownd28772b2017-03-17 14:16:07 -070016870 QDF_STATUS status;
16871 uint32_t existing_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016872 union {
16873 uint16_t nCfgValue16;
16874 tSirMacHTCapabilityInfo htCapInfo;
16875 } uHTCapabilityInfo;
Dustin Brownd28772b2017-03-17 14:16:07 -070016876 uint32_t nCfgValue;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053016877 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016878
Dustin Brownd28772b2017-03-17 14:16:07 -070016879 /* check to see if the mac address already belongs to a session */
16880 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Krunal Soni8d184fa2017-11-20 21:52:05 -080016881 (struct qdf_mac_addr *)session_param->self_mac_addr,
16882 &existing_session_id);
Dustin Brownd28772b2017-03-17 14:16:07 -070016883 if (QDF_IS_STATUS_SUCCESS(status)) {
Krunal Soni8d184fa2017-11-20 21:52:05 -080016884 sme_err("Session %d exists with mac address " MAC_ADDRESS_STR,
16885 existing_session_id,
16886 MAC_ADDR_ARRAY(session_param->self_mac_addr));
Sandeep Puligillaba71da42016-10-04 17:36:32 -070016887 return QDF_STATUS_E_FAILURE;
16888 }
16889
Dustin Brownd28772b2017-03-17 14:16:07 -070016890 /* attempt to retrieve session for Id */
Krunal Soni8d184fa2017-11-20 21:52:05 -080016891 session = CSR_GET_SESSION(mac_ctx, session_param->sme_session_id);
Dustin Brownd28772b2017-03-17 14:16:07 -070016892 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016893 sme_err("Session does not exist for interface %d",
Krunal Soni8d184fa2017-11-20 21:52:05 -080016894 session_param->sme_session_id);
Dustin Brownd28772b2017-03-17 14:16:07 -070016895 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016896 }
Dustin Brownd28772b2017-03-17 14:16:07 -070016897
16898 /* check to see if the session is already active */
16899 if (session->sessionActive) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016900 sme_err("Cannot re-open active session with Id %d",
Krunal Soni8d184fa2017-11-20 21:52:05 -080016901 session_param->sme_session_id);
Dustin Brownd28772b2017-03-17 14:16:07 -070016902 return QDF_STATUS_E_FAILURE;
16903 }
16904
16905 session->sessionActive = true;
Krunal Soni8d184fa2017-11-20 21:52:05 -080016906 session->sessionId = session_param->sme_session_id;
Dustin Brownd28772b2017-03-17 14:16:07 -070016907
16908 /* Initialize FT related data structures only in STA mode */
16909 sme_ft_open(mac_ctx, session->sessionId);
16910
Krunal Soni8d184fa2017-11-20 21:52:05 -080016911 session->session_open_cb = session_param->session_open_cb;
16912 session->session_close_cb = session_param->session_close_cb;
16913 session->callback = session_param->callback;
16914 session->pContext = session_param->callback_ctx;
16915
16916 qdf_mem_copy(&session->selfMacAddr, session_param->self_mac_addr,
Dustin Brownd28772b2017-03-17 14:16:07 -070016917 sizeof(struct qdf_mac_addr));
16918 status = qdf_mc_timer_init(&session->hTimerRoaming,
16919 QDF_TIMER_TYPE_SW,
16920 csr_roam_roaming_timer_handler,
16921 &session->roamingTimerInfo);
16922 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016923 sme_err("cannot allocate memory for Roaming timer");
Dustin Brownd28772b2017-03-17 14:16:07 -070016924 return status;
16925 }
16926
16927 status = qdf_mc_timer_init(&session->roaming_offload_timer,
16928 QDF_TIMER_TYPE_SW,
16929 csr_roam_roaming_offload_timeout_handler,
16930 &session->roamingTimerInfo);
16931 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016932 sme_err("mem fail for roaming timer");
Dustin Brownd28772b2017-03-17 14:16:07 -070016933 return status;
16934 }
16935
16936 /* get the HT capability info */
16937 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_HT_CAP_INFO, &nCfgValue) !=
16938 eSIR_SUCCESS) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016939 sme_err("could not get HT capability info");
Dustin Brownd28772b2017-03-17 14:16:07 -070016940 return QDF_STATUS_SUCCESS;
16941 }
16942
16943 uHTCapabilityInfo.nCfgValue16 = 0xFFFF & nCfgValue;
16944 session->htConfig.ht_rx_ldpc = uHTCapabilityInfo.htCapInfo.advCodingCap;
16945 session->htConfig.ht_tx_stbc = uHTCapabilityInfo.htCapInfo.txSTBC;
16946 session->htConfig.ht_rx_stbc = uHTCapabilityInfo.htCapInfo.rxSTBC;
16947 session->htConfig.ht_sgi20 = uHTCapabilityInfo.htCapInfo.shortGI20MHz;
16948 session->htConfig.ht_sgi40 = uHTCapabilityInfo.htCapInfo.shortGI40MHz;
16949
16950#ifdef FEATURE_WLAN_BTAMP_UT_RF
16951 status = qdf_mc_timer_init(&session->hTimerJoinRetry, QDF_TIMER_TYPE_SW,
16952 csr_roam_join_retry_timer_handler,
16953 &session->joinRetryTimerInfo);
16954 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016955 sme_err("cannot allocate memory for join retry timer");
Dustin Brownd28772b2017-03-17 14:16:07 -070016956 return status;
16957 }
16958#endif /* FEATURE_WLAN_BTAMP_UT_RF */
16959
16960 nCfgValue = 0;
16961 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_MAX_MPDU_LENGTH, &nCfgValue);
16962 session->vht_config.max_mpdu_len = nCfgValue;
16963
16964 nCfgValue = 0;
16965 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET,
16966 &nCfgValue);
16967 session->vht_config.supported_channel_widthset = nCfgValue;
16968
16969 nCfgValue = 0;
16970 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_LDPC_CODING_CAP, &nCfgValue);
16971 session->vht_config.ldpc_coding = nCfgValue;
16972
16973 nCfgValue = 0;
16974 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SHORT_GI_80MHZ, &nCfgValue);
16975 session->vht_config.shortgi80 = nCfgValue;
16976
16977 nCfgValue = 0;
16978 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ,
16979 &nCfgValue);
16980 session->vht_config.shortgi160and80plus80 = nCfgValue;
16981
16982 nCfgValue = 0;
16983 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_TXSTBC, &nCfgValue);
16984 session->vht_config.tx_stbc = nCfgValue;
16985
16986 nCfgValue = 0;
16987 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_RXSTBC, &nCfgValue);
16988 session->vht_config.rx_stbc = nCfgValue;
16989
16990 nCfgValue = 0;
16991 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMER_CAP, &nCfgValue);
16992 session->vht_config.su_beam_former = nCfgValue;
16993
16994 nCfgValue = 0;
16995 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP, &nCfgValue);
16996 session->vht_config.su_beam_formee = nCfgValue;
16997
16998 nCfgValue = 0;
16999 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED,
17000 &nCfgValue);
17001 session->vht_config.csnof_beamformer_antSup = nCfgValue;
17002
17003 nCfgValue = 0;
17004 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_NUM_SOUNDING_DIMENSIONS,
17005 &nCfgValue);
17006 session->vht_config.num_soundingdim = nCfgValue;
17007
17008 nCfgValue = 0;
17009 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_MU_BEAMFORMER_CAP, &nCfgValue);
17010 session->vht_config.mu_beam_former = nCfgValue;
17011
17012 nCfgValue = 0;
17013 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, &nCfgValue);
17014 session->vht_config.mu_beam_formee = nCfgValue;
17015
17016 nCfgValue = 0;
17017 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_TXOP_PS, &nCfgValue);
17018 session->vht_config.vht_txops = nCfgValue;
17019
17020 nCfgValue = 0;
17021 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_HTC_VHTC_CAP, &nCfgValue);
17022 session->vht_config.htc_vhtcap = nCfgValue;
17023
17024 nCfgValue = 0;
17025 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_RX_ANT_PATTERN, &nCfgValue);
17026 session->vht_config.rx_antpattern = nCfgValue;
17027
17028 nCfgValue = 0;
17029 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_TX_ANT_PATTERN, &nCfgValue);
17030 session->vht_config.tx_antpattern = nCfgValue;
17031
17032 nCfgValue = 0;
17033 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, &nCfgValue);
17034 session->vht_config.max_ampdu_lenexp = nCfgValue;
17035
17036 csr_update_session_he_cap(mac_ctx, session);
17037
Krunal Soni8d184fa2017-11-20 21:52:05 -080017038 return csr_issue_add_sta_for_session_req(mac_ctx,
17039 session_param->sme_session_id,
17040 session_param->self_mac_addr,
17041 session_param->type_of_persona,
17042 session_param->subtype_of_persona);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017043}
17044
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017045QDF_STATUS csr_process_del_sta_session_rsp(tpAniSirGlobal pMac, uint8_t *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017046{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017047 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017048 struct del_sta_self_params *rsp;
17049 uint8_t sessionId;
17050
17051 if (pMsg == NULL) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017052 sme_err("msg ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017053 return status;
17054 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017055 rsp = (struct del_sta_self_params *) pMsg;
Krunal Soni985b8132017-02-10 18:49:08 -080017056 sessionId = rsp->session_id;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017057 sme_debug("Del Sta rsp status = %d", rsp->status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017058 /* This session is done. */
17059 csr_cleanup_session(pMac, sessionId);
Krunal Soni985b8132017-02-10 18:49:08 -080017060 if (rsp->sme_callback) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017061 status = sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017062 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017063 sme_debug("Failed to Release Lock");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017064 else {
Krunal Soni8d184fa2017-11-20 21:52:05 -080017065 rsp->sme_callback(rsp->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017066 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017067 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017068 sme_debug("Failed to get Lock");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017069 return status;
17070 }
17071 }
17072 }
Krunal Soni985b8132017-02-10 18:49:08 -080017073
17074 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017075}
17076
17077
Jeff Johnson29e2ca12016-10-14 12:50:38 -070017078static QDF_STATUS
17079csr_issue_del_sta_for_session_req(tpAniSirGlobal pMac, uint32_t sessionId,
17080 tSirMacAddr sessionMacAddr,
Krunal Soni8d184fa2017-11-20 21:52:05 -080017081 csr_session_close_cb callback,
Jeff Johnson29e2ca12016-10-14 12:50:38 -070017082 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017083{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017084 struct del_sta_self_params *del_sta_self_req;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070017085 struct scheduler_msg msg = {0};
Min Liu22202b72018-02-12 14:01:24 +080017086 tp_wma_handle wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070017087 tSirRetStatus status;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017088
Min Liu22202b72018-02-12 14:01:24 +080017089 if (!wma_handle) {
17090 sme_err("wma handle is NULL");
17091 return QDF_STATUS_E_INVAL;
17092 }
17093
17094 /* Need to wait for all peer delete command sent to FW
17095 * before sending VDEV delete command
17096 * otherwise it will cause FW assert
17097 * Need to do this before sending to scheduler queue
17098 * otherwise the scheduler thread will be blocked
17099 * and fail to handle the VDEV stop timeout callback
17100 * in which peer delete command will also be sent
17101 */
17102 wma_vdev_wait_for_peer_delete_completion(wma_handle, sessionId);
17103
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017104 del_sta_self_req = qdf_mem_malloc(sizeof(struct del_sta_self_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017105 if (NULL == del_sta_self_req) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017106 sme_err(" mem alloc failed for tDelStaSelfParams");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017107 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017108 }
17109
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017110 qdf_mem_copy(del_sta_self_req->self_mac_addr,
Krunal Soni985b8132017-02-10 18:49:08 -080017111 sessionMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017112
Krunal Soni985b8132017-02-10 18:49:08 -080017113 del_sta_self_req->session_id = sessionId;
17114 del_sta_self_req->sme_callback = callback;
17115 del_sta_self_req->sme_ctx = pContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017116 msg.type = WMA_DEL_STA_SELF_REQ;
17117 msg.reserved = 0;
17118 msg.bodyptr = del_sta_self_req;
17119 msg.bodyval = 0;
17120
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017121 sme_debug("sending WMA_DEL_STA_SELF_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017122 status = wma_post_ctrl_msg(pMac, &msg);
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070017123 if (status != eSIR_SUCCESS) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017124 sme_err("wma_post_ctrl_msg failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017125 qdf_mem_free(del_sta_self_req);
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070017126 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017127 }
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070017128 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017129}
17130
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017131void csr_cleanup_session(tpAniSirGlobal pMac, uint32_t sessionId)
17132{
17133 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017134 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac,
17135 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017136
17137 csr_roam_stop(pMac, sessionId);
17138
17139 /* Clean up FT related data structures */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017140 sme_ft_close(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017141 csr_free_connect_bss_desc(pMac, sessionId);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -080017142 csr_roam_free_connect_profile(&pSession->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017143 csr_roam_free_connected_info(pMac, &pSession->connectedInfo);
Anurag Chouhan210db072016-02-22 18:42:15 +053017144 qdf_mc_timer_destroy(&pSession->hTimerRoaming);
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070017145 qdf_mc_timer_destroy(&pSession->roaming_offload_timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017146#ifdef FEATURE_WLAN_BTAMP_UT_RF
Anurag Chouhan210db072016-02-22 18:42:15 +053017147 qdf_mc_timer_destroy(&pSession->hTimerJoinRetry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017148#endif
Krunal Soni72dba662017-02-15 20:13:17 -080017149 purge_sme_session_pending_cmd_list(pMac, sessionId);
Krunal Soni81f068c2017-02-23 19:51:55 -080017150 purge_sme_session_pending_scan_cmd_list(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017151 csr_init_session(pMac, sessionId);
17152 }
17153}
17154
Krunal Soni8d184fa2017-11-20 21:52:05 -080017155QDF_STATUS csr_roam_close_session(tpAniSirGlobal mac_ctx,
17156 uint32_t session_id, bool sync)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017157{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017158 QDF_STATUS status = QDF_STATUS_SUCCESS;
Krunal Soni8d184fa2017-11-20 21:52:05 -080017159 struct csr_roam_session *session;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017160
Krunal Soni8d184fa2017-11-20 21:52:05 -080017161 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
17162 sme_err("session %d not found", session_id);
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -070017163 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017164 }
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -070017165
Krunal Soni8d184fa2017-11-20 21:52:05 -080017166 session = CSR_GET_SESSION(mac_ctx, session_id);
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -070017167 /* Vdev going down stop roaming */
Krunal Soni8d184fa2017-11-20 21:52:05 -080017168 session->fCancelRoaming = true;
17169 if (sync) {
17170 csr_cleanup_session(mac_ctx, session_id);
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -070017171 return status;
17172 }
17173
Krunal Soni8d184fa2017-11-20 21:52:05 -080017174 purge_sme_session_pending_cmd_list(mac_ctx, session_id);
17175 purge_sme_session_active_cmd_list(mac_ctx, session_id);
17176 purge_sme_session_pending_scan_cmd_list(mac_ctx, session_id);
17177 purge_sme_session_active_scan_cmd_list(mac_ctx, session_id);
17178 if (!session->session_close_cb) {
17179 sme_err("no close session callback registered");
17180 return QDF_STATUS_E_FAILURE;
17181 }
17182 status = csr_issue_del_sta_for_session_req(mac_ctx,
17183 session_id, session->selfMacAddr.bytes,
17184 session->session_close_cb, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017185 return status;
17186}
17187
17188static void csr_init_session(tpAniSirGlobal pMac, uint32_t sessionId)
17189{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017190 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017191
17192 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017193 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017194 return;
17195 }
17196
17197 pSession->sessionActive = false;
17198 pSession->sessionId = CSR_SESSION_ID_INVALID;
17199 pSession->callback = NULL;
17200 pSession->pContext = NULL;
17201 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
wadesongd5477662018-04-25 17:00:47 +080017202 csr_saved_scan_cmd_free_fields(pMac, pSession);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017203 csr_free_roam_profile(pMac, sessionId);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -080017204 csr_roam_free_connect_profile(&pSession->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017205 csr_roam_free_connected_info(pMac, &pSession->connectedInfo);
17206 csr_free_connect_bss_desc(pMac, sessionId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017207 qdf_mem_set(&pSession->selfMacAddr, sizeof(struct qdf_mac_addr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017208 if (pSession->pWpaRsnReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017209 qdf_mem_free(pSession->pWpaRsnReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017210 pSession->pWpaRsnReqIE = NULL;
17211 }
17212 pSession->nWpaRsnReqIeLength = 0;
17213 if (pSession->pWpaRsnRspIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017214 qdf_mem_free(pSession->pWpaRsnRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017215 pSession->pWpaRsnRspIE = NULL;
17216 }
17217 pSession->nWpaRsnRspIeLength = 0;
17218#ifdef FEATURE_WLAN_WAPI
17219 if (pSession->pWapiReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017220 qdf_mem_free(pSession->pWapiReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017221 pSession->pWapiReqIE = NULL;
17222 }
17223 pSession->nWapiReqIeLength = 0;
17224 if (pSession->pWapiRspIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017225 qdf_mem_free(pSession->pWapiRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017226 pSession->pWapiRspIE = NULL;
17227 }
17228 pSession->nWapiRspIeLength = 0;
17229#endif /* FEATURE_WLAN_WAPI */
17230 if (pSession->pAddIEScan) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017231 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017232 pSession->pAddIEScan = NULL;
17233 }
17234 pSession->nAddIEScanLength = 0;
17235 if (pSession->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017236 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017237 pSession->pAddIEAssoc = NULL;
17238 }
17239 pSession->nAddIEAssocLength = 0;
17240}
17241
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017242QDF_STATUS csr_roam_get_session_id_from_bssid(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +053017243 struct qdf_mac_addr *bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017244 uint32_t *pSessionId)
17245{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017246 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017247 uint32_t i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017248
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017249 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
17250 if (CSR_IS_SESSION_VALID(pMac, i)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053017251 if (qdf_is_macaddr_equal(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017252 &pMac->roam.roamSession[i].connectedProfile.
17253 bssid)) {
17254 /* Found it */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017255 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017256 *pSessionId = i;
17257 break;
17258 }
17259 }
17260 }
17261 return status;
17262}
17263
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017264/* This function assumes that we only support one IBSS session.
17265 * We cannot use BSSID to identify session because for IBSS,
17266 * the bssid changes.
17267 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017268static uint32_t csr_find_ibss_session(tpAniSirGlobal pMac)
17269{
17270 uint32_t i, nRet = CSR_SESSION_ID_INVALID;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017271 struct csr_roam_session *pSession;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017272
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017273 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
17274 if (CSR_IS_SESSION_VALID(pMac, i)) {
17275 pSession = CSR_GET_SESSION(pMac, i);
17276 if (pSession->pCurRoamProfile
17277 &&
17278 (csr_is_bss_type_ibss
17279 (pSession->connectedProfile.BSSType))) {
17280 /* Found it */
17281 nRet = i;
17282 break;
17283 }
17284 }
17285 }
17286 return nRet;
17287}
17288
Anurag Chouhan6d760662016-02-20 16:05:43 +053017289static void csr_roam_link_up(tpAniSirGlobal pMac, struct qdf_mac_addr bssid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017290{
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080017291 uint32_t sessionId = 0;
17292
17293 /*
17294 * Update the current BSS info in ho control block based on connected
17295 * profile info from pmac global structure
17296 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017297
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017298 sme_debug(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017299 " csr_roam_link_up: WLAN link UP with AP= " MAC_ADDRESS_STR,
17300 MAC_ADDR_ARRAY(bssid.bytes));
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080017301 /* Check for user misconfig of RSSI trigger threshold */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017302 pMac->roam.configParam.vccRssiThreshold =
17303 (0 == pMac->roam.configParam.vccRssiThreshold) ?
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080017304 CSR_VCC_RSSI_THRESHOLD :
17305 pMac->roam.configParam.vccRssiThreshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017306 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080017307 /* Check for user misconfig of UL MAC Loss trigger threshold */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017308 pMac->roam.configParam.vccUlMacLossThreshold =
17309 (0 == pMac->roam.configParam.vccUlMacLossThreshold) ?
17310 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.
17311 vccUlMacLossThreshold;
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080017312 /* Indicate the neighbor roal algorithm about the connect indication */
17313 csr_roam_get_session_id_from_bssid(pMac, &bssid,
17314 &sessionId);
17315 csr_neighbor_roam_indicate_connect(pMac, sessionId,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017316 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017317}
17318
17319static void csr_roam_link_down(tpAniSirGlobal pMac, uint32_t sessionId)
17320{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017321 struct csr_roam_session *pSession = CSR_GET_SESSION(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017322
17323 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017324 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017325 return;
17326 }
17327 /* Only to handle the case for Handover on infra link */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017328 if (eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017329 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017330 /*
17331 * Incase of station mode, immediately stop data transmission whenever
17332 * link down is detected.
17333 */
17334 if (csr_roam_is_sta_mode(pMac, sessionId)
17335 && !CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -080017336 && !csr_roam_is11r_assoc(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017337 sme_debug("Inform Link lost for session %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017338 sessionId);
17339 csr_roam_call_callback(pMac, sessionId, NULL, 0,
17340 eCSR_ROAM_LOSTLINK,
17341 eCSR_ROAM_RESULT_LOSTLINK);
17342 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017343 /* deregister the clients requesting stats from PE/TL & also stop the
17344 * corresponding timers
17345 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017346 csr_roam_dereg_statistics_req(pMac);
17347 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017348 /* Indicate the neighbor roal algorithm about the disconnect
17349 * indication
17350 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017351 csr_neighbor_roam_indicate_disconnect(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017352
17353 /* Remove this code once SLM_Sessionization is supported */
17354 /* BMPS_WORKAROUND_NOT_NEEDED */
17355 if (!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
17356 csr_is_infra_ap_started(pMac) &&
17357 pMac->roam.configParam.doBMPSWorkaround) {
17358 pMac->roam.configParam.doBMPSWorkaround = 0;
17359 }
17360
17361}
17362
Naveen Rawatfa2a1002018-05-17 16:06:37 -070017363#ifndef QCA_SUPPORT_CP_STATS
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017364QDF_STATUS csr_send_mb_stats_req_msg(tpAniSirGlobal pMac, uint32_t statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017365 uint8_t staId, uint8_t sessionId)
17366{
17367 tAniGetPEStatsReq *pMsg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017368 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017369
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017370 pMsg = qdf_mem_malloc(sizeof(tAniGetPEStatsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017371 if (NULL == pMsg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017372 sme_err("Failed to allocate mem for stats req ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017373 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017374 }
17375 /* need to initiate a stats request to PE */
17376 pMsg->msgType = eWNI_SME_GET_STATISTICS_REQ;
17377 pMsg->msgLen = (uint16_t) sizeof(tAniGetPEStatsReq);
17378 pMsg->staId = staId;
17379 pMsg->statsMask = statsMask;
17380 pMsg->sessionId = sessionId;
Rajeev Kumard138ac52017-01-30 18:38:37 -080017381 status = umac_send_mb_message_to_mac(pMsg);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017382 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017383 sme_debug("Failed to send down the stats req ");
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017384
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017385 return status;
17386}
17387
17388/**
17389 * csr_update_stats() - updates correct stats struct in mac_ctx
17390 * @mac: mac global context
17391 * @stats_type: stats type
17392 * @sme_stats_rsp: stats rsp msg packet
17393 * @stats: input stats data buffer to fill in mac_ctx struct
17394 * @length: out param - stats length
17395 *
17396 * This function fills corresponding stats struct in mac_cts based on stats type
17397 * passed
17398 *
17399 * Return: void
17400 */
17401static void
17402csr_update_stats(tpAniSirGlobal mac, uint8_t stats_type,
17403 tAniGetPEStatsRsp *sme_stats_rsp,
17404 uint8_t **stats, uint32_t *length)
17405{
17406 switch (stats_type) {
17407 case eCsrSummaryStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017408 sme_debug("summary stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017409 qdf_mem_copy((uint8_t *) &mac->roam.summaryStatsInfo, *stats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017410 sizeof(tCsrSummaryStatsInfo));
17411 *stats += sizeof(tCsrSummaryStatsInfo);
17412 *length -= sizeof(tCsrSummaryStatsInfo);
17413 break;
17414 case eCsrGlobalClassAStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017415 sme_debug("ClassA stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017416 qdf_mem_copy((uint8_t *) &mac->roam.classAStatsInfo, *stats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017417 sizeof(tCsrGlobalClassAStatsInfo));
17418 *stats += sizeof(tCsrGlobalClassAStatsInfo);
17419 *length -= sizeof(tCsrGlobalClassAStatsInfo);
17420 break;
Himanshu Agarwal37e42412016-07-21 14:35:09 +053017421 case csr_per_chain_rssi_stats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017422 sme_debug("csrRoamStatsRspProcessor:Per Chain RSSI stats");
Himanshu Agarwal37e42412016-07-21 14:35:09 +053017423 qdf_mem_copy((uint8_t *)&mac->roam.per_chain_rssi_stats,
17424 *stats, sizeof(struct csr_per_chain_rssi_stats_info));
17425 *stats += sizeof(struct csr_per_chain_rssi_stats_info);
17426 *length -= sizeof(struct csr_per_chain_rssi_stats_info);
17427 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017428 default:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017429 sme_warn("unknown stats type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017430 break;
17431 }
17432}
17433
17434/**
17435 * csr_roam_stats_rsp_processor() - processes stats rsp msg
17436 * @pMac mac global context
17437 * @pSirMsg: incoming message
17438 *
17439 * Return: void
17440 */
17441void csr_roam_stats_rsp_processor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
17442{
17443 tAniGetPEStatsRsp *pSmeStatsRsp;
17444 tListElem *pEntry = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017445 struct csr_statsclient_reqinfo *pTempStaEntry = NULL;
17446 struct csr_pestats_reqinfo *pPeStaEntry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017447 uint32_t tempMask = 0;
17448 uint8_t counter = 0;
17449 uint8_t *pStats = NULL;
17450 uint32_t length = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017451 int8_t rssi = 0, snr = 0;
17452 uint32_t *pRssi = NULL, *pSnr = NULL;
17453 uint32_t linkCapacity;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017454
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017455 pSmeStatsRsp = (tAniGetPEStatsRsp *) pSirMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017456 if (pSmeStatsRsp->rc) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017457 sme_warn("stats rsp from PE shows failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017458 goto post_update;
17459 }
17460 tempMask = pSmeStatsRsp->statsMask;
17461 pStats = ((uint8_t *) &pSmeStatsRsp->statsMask) +
17462 sizeof(pSmeStatsRsp->statsMask);
17463 /*
17464 * subtract all statistics from this length, and after processing the
17465 * entire 'stat' part of the message, if the length is not zero, then
17466 * rssi is piggy packed in this 'stats' message.
17467 */
17468 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
17469 /* new stats info from PE, fill up the stats strucutres in PMAC */
17470 while (tempMask) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017471 if (tempMask & 1)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017472 csr_update_stats(pMac, counter, pSmeStatsRsp,
17473 &pStats, &length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017474 tempMask >>= 1;
17475 counter++;
17476 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017477 if (length != 0) {
17478 pRssi = (uint32_t *) pStats;
17479 rssi = (int8_t) *pRssi;
17480 pStats += sizeof(uint32_t);
17481 length -= sizeof(uint32_t);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017482 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017483 /* If riva is not sending rssi, continue to use the hack */
17484 rssi = RSSI_HACK_BMPS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017485
17486 if (length != 0) {
17487 linkCapacity = *(uint32_t *) pStats;
17488 pStats += sizeof(uint32_t);
17489 length -= sizeof(uint32_t);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017490 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017491 linkCapacity = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017492
17493 if (length != 0) {
17494 pSnr = (uint32_t *) pStats;
17495 snr = (int8_t) *pSnr;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017496 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017497 snr = SNR_HACK_BMPS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017498
17499post_update:
17500 /* make sure to update the pe stats req list */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017501 pEntry = csr_roam_find_in_pe_stats_req_list(pMac,
17502 pSmeStatsRsp->statsMask);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017503 if (pEntry) {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017504 pPeStaEntry = GET_BASE_ADDR(pEntry,
17505 struct csr_pestats_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017506 pPeStaEntry->rspPending = false;
17507
17508 }
17509 /* check the one timer cases */
17510 pEntry = csr_roam_check_client_req_list(pMac, pSmeStatsRsp->statsMask);
17511 if (pEntry) {
17512 pTempStaEntry =
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017513 GET_BASE_ADDR(pEntry,
17514 struct csr_statsclient_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017515 if (pTempStaEntry->timerExpired) {
17516 /* send up the stats report */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017517 csr_roam_report_statistics(pMac,
17518 pTempStaEntry->statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017519 pTempStaEntry->callback,
17520 pTempStaEntry->staId,
17521 pTempStaEntry->pContext);
17522 /* also remove from the client list */
17523 csr_roam_remove_stat_list_entry(pMac, pEntry);
17524 pTempStaEntry = NULL;
17525 }
17526 }
17527}
17528
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017529tListElem *csr_roam_find_in_pe_stats_req_list(
17530 tpAniSirGlobal pMac, uint32_t statsMask)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017531{
17532 tListElem *pEntry = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017533 struct csr_pestats_reqinfo *pTempStaEntry = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017534
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017535 pEntry = csr_ll_peek_head(&pMac->roam.peStatsReqList, LL_ACCESS_LOCK);
17536 if (!pEntry) {
17537 /* list empty */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017538 sme_debug("csr_roam_find_in_pe_stats_req_list: List empty, no request to PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017539 return NULL;
17540 }
17541 while (pEntry) {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017542 pTempStaEntry = GET_BASE_ADDR(pEntry, struct csr_pestats_reqinfo, link);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017543 if (pTempStaEntry->statsMask == statsMask)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017544 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017545 pEntry =
17546 csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
17547 LL_ACCESS_NOLOCK);
17548 }
17549 return pEntry;
17550}
17551
Jeff Johnson29e2ca12016-10-14 12:50:38 -070017552static
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017553tListElem *csr_roam_checkn_update_client_req_list(
17554tpAniSirGlobal pMac, struct csr_statsclient_reqinfo *pStaEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017555 bool update)
17556{
17557 tListElem *pEntry;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017558 struct csr_statsclient_reqinfo *pTempStaEntry;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017559
17560 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList,
17561 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017562 if (!pEntry) {
17563 /* list empty */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017564 sme_debug("List empty, no request from upper layer client(s)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017565 return NULL;
17566 }
17567 while (pEntry) {
17568 pTempStaEntry =
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017569 GET_BASE_ADDR(pEntry,
17570 struct csr_statsclient_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017571 if ((pTempStaEntry->requesterId == pStaEntry->requesterId)
17572 && (pTempStaEntry->statsMask == pStaEntry->statsMask)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017573 if (update) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017574 pTempStaEntry->callback = pStaEntry->callback;
17575 pTempStaEntry->pContext = pStaEntry->pContext;
17576 }
17577 break;
17578 }
17579 pEntry =
17580 csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
17581 LL_ACCESS_NOLOCK);
17582 }
17583 return pEntry;
17584}
17585
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017586tListElem *csr_roam_check_client_req_list(tpAniSirGlobal pMac,
17587 uint32_t statsMask)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017588{
17589 tListElem *pEntry;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017590 struct csr_statsclient_reqinfo *pTempStaEntry;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017591
17592 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList,
17593 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017594 if (!pEntry) {
17595 /* list empty */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017596 sme_debug("List empty, no request from upper layer client(s)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017597 return NULL;
17598 }
17599 while (pEntry) {
17600 pTempStaEntry =
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017601 GET_BASE_ADDR(pEntry,
17602 struct csr_statsclient_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017603 if ((pTempStaEntry->
17604 statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017605 break;
17606 }
17607 pEntry =
17608 csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
17609 LL_ACCESS_NOLOCK);
17610 }
17611 return pEntry;
17612}
17613
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017614struct csr_statsclient_reqinfo *csr_roam_insert_entry_into_list(
17615 tpAniSirGlobal pMac, tDblLinkList *pStaList,
17616 struct csr_statsclient_reqinfo *
17617 pStaEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017618{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017619 struct csr_statsclient_reqinfo *pNewStaEntry = NULL;
Naveen Rawatd0ca4412017-06-16 14:19:19 -070017620 /*
17621 * if same entity requested for same set of stats with different
17622 * callback update it
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017623 */
17624 if (NULL == csr_roam_checkn_update_client_req_list(pMac, pStaEntry,
17625 true)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017626
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017627 pNewStaEntry = qdf_mem_malloc(sizeof(struct csr_statsclient_reqinfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017628 if (NULL == pNewStaEntry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017629 sme_err("couldn't allocate memory for the entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017630 return NULL;
17631 }
17632
17633 pNewStaEntry->callback = pStaEntry->callback;
17634 pNewStaEntry->pContext = pStaEntry->pContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017635 pNewStaEntry->requesterId = pStaEntry->requesterId;
17636 pNewStaEntry->statsMask = pStaEntry->statsMask;
17637 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
17638 pNewStaEntry->pMac = pStaEntry->pMac;
17639 pNewStaEntry->staId = pStaEntry->staId;
17640 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
17641
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017642 csr_ll_insert_tail(pStaList, &pNewStaEntry->link,
17643 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017644 }
17645 return pNewStaEntry;
17646}
Naveen Rawatfa2a1002018-05-17 16:06:37 -070017647#endif /* QCA_SUPPORT_CP_STATS */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017648
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017649QDF_STATUS csr_get_rssi(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017650 tCsrRssiCallback callback,
17651 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053017652 struct qdf_mac_addr bssId,
Jeff Johnson8bd23352017-09-26 11:39:24 -070017653 int8_t lastRSSI, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017654{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017655 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070017656 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017657 uint32_t sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017658 tAniGetRssiReq *pMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017659
17660 status = csr_roam_get_session_id_from_bssid(pMac, &bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017661 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017662 callback(lastRSSI, staId, pContext);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017663 sme_err("Failed to get SessionId");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017664 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017665 }
17666
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017667 pMsg = qdf_mem_malloc(sizeof(tAniGetRssiReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017668 if (NULL == pMsg) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017669 sme_err("csr_get_rssi: failed to allocate mem for req ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017670 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017671 }
17672
17673 pMsg->msgType = eWNI_SME_GET_RSSI_REQ;
17674 pMsg->msgLen = (uint16_t) sizeof(tAniGetRssiReq);
17675 pMsg->sessionId = sessionId;
17676 pMsg->staId = staId;
17677 pMsg->rssiCallback = callback;
17678 pMsg->pDevContext = pContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017679 /*
17680 * store RSSI at time of calling, so that if RSSI request cannot
17681 * be sent to firmware, this value can be used to return immediately
17682 */
17683 pMsg->lastRSSI = lastRSSI;
17684 msg.type = eWNI_SME_GET_RSSI_REQ;
17685 msg.bodyptr = pMsg;
17686 msg.reserved = 0;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080017687 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_SME,
Krunal Soni66c113f2016-12-21 16:46:47 -080017688 &msg)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017689 sme_err("scheduler_post_msg failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017690 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017691 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017692 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017693 return status;
17694}
17695
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017696QDF_STATUS csr_get_snr(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017697 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +053017698 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017699{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017700 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070017701 struct scheduler_msg msg = {0};
Yuanyuan Liu889167d2017-05-31 16:56:26 -070017702 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017703 tAniGetSnrReq *pMsg;
17704
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017705 pMsg = (tAniGetSnrReq *) qdf_mem_malloc(sizeof(tAniGetSnrReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017706 if (NULL == pMsg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017707 sme_err("failed to allocate mem for req");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017708 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017709 }
17710
Tushnim Bhattacharyya85bedb92017-05-17 13:23:14 -070017711 status = csr_roam_get_session_id_from_bssid(pMac, &bssId, &sessionId);
17712 if (!QDF_IS_STATUS_SUCCESS(status)) {
Houston Hoffman77bf4072017-07-17 01:01:18 -070017713 qdf_mem_free(pMsg);
Srinivas Girigowdaaf0173e2017-06-01 11:50:41 -070017714 sme_err("Couldn't find session_id for given BSSID");
17715 return status;
Tushnim Bhattacharyya85bedb92017-05-17 13:23:14 -070017716 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017717
17718 pMsg->msgType = eWNI_SME_GET_SNR_REQ;
17719 pMsg->msgLen = (uint16_t) sizeof(tAniGetSnrReq);
17720 pMsg->sessionId = sessionId;
17721 pMsg->staId = staId;
17722 pMsg->snrCallback = callback;
17723 pMsg->pDevContext = pContext;
17724 msg.type = eWNI_SME_GET_SNR_REQ;
17725 msg.bodyptr = pMsg;
17726 msg.reserved = 0;
17727
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080017728 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_SME,
Krunal Soni66c113f2016-12-21 16:46:47 -080017729 &msg)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017730 sme_err("failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017731 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017732 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017733 }
17734
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017735 return status;
17736}
17737
Naveen Rawatfa2a1002018-05-17 16:06:37 -070017738#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017739/**
17740 * csr_deregister_client_request() - deregisters a get stats request
17741 * @mac_ctx: mac global context
17742 * @sta_entry: stats request entry
17743 *
17744 * Return: status of operation
17745 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017746static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017747csr_deregister_client_request(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017748 struct csr_statsclient_reqinfo *sta_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017749{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017750 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017751 tListElem *entry = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017752 struct csr_statsclient_reqinfo *ptr_sta_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017753
17754 entry = csr_roam_checkn_update_client_req_list(mac_ctx, sta_entry,
17755 false);
17756 if (!entry) {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017757 sme_err("callback is empty in the request & couldn't find any existing request in statsClientReqList");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017758 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017759 }
17760 /* clean up & return */
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017761 ptr_sta_entry = GET_BASE_ADDR(entry,
17762 struct csr_statsclient_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017763 if (NULL != ptr_sta_entry->pPeStaEntry) {
17764 ptr_sta_entry->pPeStaEntry->numClient--;
17765 /* check if we need to delete the entry from peStatsReqList */
17766 if (!ptr_sta_entry->pPeStaEntry->numClient)
17767 csr_roam_remove_entry_from_pe_stats_req_list(mac_ctx,
17768 ptr_sta_entry->pPeStaEntry);
17769 }
17770 /* check if we need to stop the tl stats timer too */
17771 mac_ctx->roam.tlStatsReqInfo.numClient--;
Anurag Chouhan210db072016-02-22 18:42:15 +053017772 qdf_mc_timer_stop(&ptr_sta_entry->timer);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053017773 /* Destroy the qdf timer... */
Anurag Chouhan210db072016-02-22 18:42:15 +053017774 status = qdf_mc_timer_destroy(&ptr_sta_entry->timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017775 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017776 sme_err(
17777 "failed to destroy Client req timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017778
17779 csr_roam_remove_stat_list_entry(mac_ctx, entry);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017780 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017781}
17782
17783/**
17784 * csr_insert_stats_request_to_list() - inserts request to existing list
17785 * @mac_ctx: mac global context
17786 * @sta_entry: stats request entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017787 *
17788 * Return: status of operation
17789 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017790static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017791csr_insert_stats_request_to_list(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017792 struct csr_statsclient_reqinfo *sta_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017793{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017794struct csr_statsclient_reqinfo *ptr_sta_entry = csr_roam_insert_entry_into_list(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017795 mac_ctx, &mac_ctx->roam.statsClientReqList,
17796 sta_entry);
17797 if (!ptr_sta_entry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017798 sme_err("Failed to insert req in statsClientReqList");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017799 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017800 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017801 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017802}
17803
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017804QDF_STATUS csr_get_statistics(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017805 eCsrStatsRequesterType requesterId,
17806 uint32_t statsMask,
17807 tCsrStatsCallback callback,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017808 uint8_t staId,
17809 void *pContext,
17810 uint8_t sessionId)
17811{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017812 struct csr_statsclient_reqinfo staEntry;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017813 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017814 bool insertInClientList = false;
17815 uint32_t temp_mask = 0;
17816
17817 if (csr_is_all_session_disconnected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017818 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017819
17820 if (csr_neighbor_middle_of_roaming(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017821 sme_debug("in the middle of roaming states");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017822 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017823 }
17824
17825 if ((!statsMask) && (!callback)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017826 sme_err("statsMask & callback empty in the request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017827 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017828 }
17829 /* for the search list method for deregister */
17830 staEntry.requesterId = requesterId;
17831 staEntry.statsMask = statsMask;
17832 /* requester wants to deregister or just an error */
17833 if ((statsMask) && (!callback))
17834 return csr_deregister_client_request(pMac, &staEntry);
17835
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017836 /* add the request in the client req list */
17837 staEntry.callback = callback;
17838 staEntry.pContext = pContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017839 staEntry.pPeStaEntry = NULL;
17840 staEntry.staId = staId;
17841 staEntry.pMac = pMac;
17842 staEntry.timerExpired = false;
17843 staEntry.sessionId = sessionId;
17844
Naveen Rawatd0ca4412017-06-16 14:19:19 -070017845 temp_mask = statsMask & ~(1 << eCsrGlobalClassDStats);
17846 if (temp_mask) {
17847 /* send down a req */
17848 status = csr_send_mb_stats_req_msg(pMac,
17849 temp_mask, staId, sessionId);
17850 if (!QDF_IS_STATUS_SUCCESS(status))
17851 sme_err("failed to send down stats req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017852 /*
Naveen Rawatd0ca4412017-06-16 14:19:19 -070017853 * so that when the stats rsp comes back from PE we
17854 * respond to upper layer right away
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017855 */
Naveen Rawatd0ca4412017-06-16 14:19:19 -070017856 staEntry.timerExpired = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017857 insertInClientList = true;
17858 }
Naveen Rawatd0ca4412017-06-16 14:19:19 -070017859 /* if looking for stats from TL only */
17860 if (!insertInClientList) {
17861 /* return the stats */
17862 csr_roam_report_statistics(pMac, statsMask, callback,
17863 staId, pContext);
17864 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017865 }
17866 if (insertInClientList)
Naveen Rawatd0ca4412017-06-16 14:19:19 -070017867 return csr_insert_stats_request_to_list(pMac, &staEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017868
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017869 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017870}
Naveen Rawatfa2a1002018-05-17 16:06:37 -070017871#endif /* QCA_SUPPORT_CP_STATS */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017872
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080017873#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070017874/**
17875 * csr_roam_set_key_mgmt_offload() - enable/disable key mgmt offload
17876 * @mac_ctx: mac context.
17877 * @session_id: Session Identifier
17878 * @roam_key_mgmt_offload_enabled: key mgmt enable/disable flag
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080017879 * @pmkid_modes: PMKID modes of PMKSA caching and OKC
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070017880 *
17881 * Return: QDF_STATUS_SUCCESS - CSR updated config successfully.
17882 * Other status means CSR is failed to update.
17883 */
17884
17885QDF_STATUS csr_roam_set_key_mgmt_offload(tpAniSirGlobal mac_ctx,
17886 uint32_t session_id,
17887 bool roam_key_mgmt_offload_enabled,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080017888 struct pmkid_mode_bits *pmkid_modes)
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080017889{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017890 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017891
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070017892 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017893 sme_err("session %d not found", session_id);
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080017894 return QDF_STATUS_E_FAILURE;
17895 }
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070017896 session->RoamKeyMgmtOffloadEnabled = roam_key_mgmt_offload_enabled;
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080017897 session->pmkid_modes.fw_okc = pmkid_modes->fw_okc;
17898 session->pmkid_modes.fw_pmksa_cache = pmkid_modes->fw_pmksa_cache;
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080017899 return QDF_STATUS_SUCCESS;
17900}
17901
17902/**
17903 * csr_update_roam_scan_offload_request() - updates req msg with roam offload
Jeff Johnson60ed45a2018-05-06 15:28:49 -070017904 * parameters
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080017905 * @pMac: mac global context
17906 * @req_buf: out param, roam offload scan request packet
17907 * @session: roam session
17908 *
17909 * Return: void
17910 */
17911static void
17912csr_update_roam_scan_offload_request(tpAniSirGlobal mac_ctx,
17913 tSirRoamOffloadScanReq *req_buf,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053017914 struct csr_roam_session *session)
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080017915{
17916 qdf_mem_copy(req_buf->PSK_PMK, session->psk_pmk,
17917 sizeof(req_buf->PSK_PMK));
17918 req_buf->pmk_len = session->pmk_len;
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080017919 req_buf->R0KH_ID_Length = session->ftSmeContext.r0kh_id_len;
17920 qdf_mem_copy(req_buf->R0KH_ID,
17921 session->ftSmeContext.r0kh_id,
17922 req_buf->R0KH_ID_Length);
17923 req_buf->Prefer5GHz = mac_ctx->roam.configParam.nRoamPrefer5GHz;
17924 req_buf->RoamRssiCatGap = mac_ctx->roam.configParam.bCatRssiOffset;
17925 req_buf->Select5GHzMargin = mac_ctx->roam.configParam.nSelect5GHzMargin;
Abhinav Kumara083f212018-04-05 18:49:45 +053017926 req_buf->ho_delay_for_rx = mac_ctx->roam.configParam.ho_delay_for_rx;
Abhinav Kumara95af7c2018-04-06 17:08:00 +053017927 req_buf->min_delay_btw_roam_scans =
17928 mac_ctx->roam.configParam.min_delay_btw_roam_scans;
17929 req_buf->roam_trigger_reason_bitmask =
17930 mac_ctx->roam.configParam.roam_trigger_reason_bitmask;
Abhinav Kumaredd1d372018-05-11 15:33:35 +053017931 req_buf->roam_force_rssi_trigger =
17932 mac_ctx->roam.configParam.roam_force_rssi_trigger;
17933
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080017934 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
17935 (uint32_t *) &req_buf->ReassocFailureTimeout)
17936 != eSIR_SUCCESS) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017937 sme_err(
17938 "could not retrieve ReassocFailureTimeout value");
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080017939 req_buf->ReassocFailureTimeout =
17940 DEFAULT_REASSOC_FAILURE_TIMEOUT;
17941 }
17942#ifdef FEATURE_WLAN_ESE
17943 if (csr_is_auth_type_ese(req_buf->ConnectedNetwork.authentication)) {
17944 qdf_mem_copy(req_buf->KRK, session->eseCckmInfo.krk,
17945 SIR_KRK_KEY_LEN);
17946 qdf_mem_copy(req_buf->BTK, session->eseCckmInfo.btk,
17947 SIR_BTK_KEY_LEN);
17948 }
17949#endif
Naveen Rawatcd118312016-11-22 10:46:21 -080017950 req_buf->AcUapsd.acbe_uapsd = SIR_UAPSD_GET(ACBE, session->uapsd_mask);
17951 req_buf->AcUapsd.acbk_uapsd = SIR_UAPSD_GET(ACBK, session->uapsd_mask);
17952 req_buf->AcUapsd.acvi_uapsd = SIR_UAPSD_GET(ACVI, session->uapsd_mask);
17953 req_buf->AcUapsd.acvo_uapsd = SIR_UAPSD_GET(ACVO, session->uapsd_mask);
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080017954}
17955#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
17956
17957#if defined(WLAN_FEATURE_HOST_ROAM) || defined(WLAN_FEATURE_ROAM_OFFLOAD)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017958/**
17959 * csr_check_band_channel_match() - check if passed band and channel match
Jeff Johnson60ed45a2018-05-06 15:28:49 -070017960 * parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017961 * @band: band to match with channel
17962 * @channel: channel to match with band
17963 *
17964 * Return: bool if match else false
17965 */
17966static bool
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080017967csr_check_band_channel_match(enum band_info band, uint8_t channel)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017968{
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080017969 if (BAND_ALL == band)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017970 return true;
17971
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080017972 if (BAND_2G == band && WLAN_REG_IS_24GHZ_CH(channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017973 return true;
17974
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080017975 if (BAND_5G == band && WLAN_REG_IS_5GHZ_CH(channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017976 return true;
17977
17978 return false;
17979}
17980
17981/**
17982 * csr_fetch_ch_lst_from_ini() - fetch channel list from ini and update req msg
Jeff Johnson60ed45a2018-05-06 15:28:49 -070017983 * parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017984 * @mac_ctx: global mac ctx
17985 * @roam_info: roam info struct
17986 * @req_buf: out param, roam offload scan request packet
17987 *
17988 * Return: result of operation
17989 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017990static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017991csr_fetch_ch_lst_from_ini(tpAniSirGlobal mac_ctx,
17992 tpCsrNeighborRoamControlInfo roam_info,
17993 tSirRoamOffloadScanReq *req_buf)
17994{
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080017995 enum band_info band;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017996 uint8_t i = 0;
17997 uint8_t num_channels = 0;
17998 uint8_t *ch_lst = roam_info->cfgParams.channelInfo.ChannelList;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053017999 uint16_t unsafe_chan[NUM_CHANNELS];
18000 uint16_t unsafe_chan_cnt = 0;
18001 uint16_t cnt = 0;
18002 bool is_unsafe_chan;
18003 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
18004
18005 if (!qdf_ctx) {
18006 cds_err("qdf_ctx is NULL");
18007 return QDF_STATUS_E_FAILURE;
18008 }
18009
18010 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
18011 &unsafe_chan_cnt,
18012 sizeof(unsafe_chan));
18013
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018014 /*
18015 * The INI channels need to be filtered with respect to the current band
18016 * that is supported.
18017 */
18018 band = mac_ctx->roam.configParam.bandCapability;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080018019 if ((BAND_2G != band) && (BAND_5G != band)
18020 && (BAND_ALL != band)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018021 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018022 "Invalid band(%d), roam scan offload req aborted",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018023 band);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018024 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018025 }
18026
18027 for (i = 0; i < roam_info->cfgParams.channelInfo.numOfChannels; i++) {
18028 if (!csr_check_band_channel_match(band, *ch_lst))
18029 continue;
18030 /* Allow DFS channels only if the DFS roaming is enabled */
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018031 if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
18032 (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
18033 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070018034 (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018035 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
18036 ("ignoring dfs channel %d"), *ch_lst);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018037 ch_lst++;
18038 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018039 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018040
18041 if (mac_ctx->roam.configParam.sta_roam_policy.
18042 skip_unsafe_channels &&
18043 unsafe_chan_cnt) {
18044 is_unsafe_chan = false;
18045 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
18046 if (unsafe_chan[cnt] == *ch_lst) {
18047 is_unsafe_chan = true;
18048 break;
18049 }
18050 }
18051 if (is_unsafe_chan) {
18052 QDF_TRACE(QDF_MODULE_ID_SME,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018053 QDF_TRACE_LEVEL_DEBUG,
18054 ("ignoring unsafe channel %d"),
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018055 *ch_lst);
18056 ch_lst++;
18057 continue;
18058 }
18059 }
18060 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
18061 *ch_lst;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018062 ch_lst++;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018063
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018064 }
18065 req_buf->ConnectedNetwork.ChannelCount = num_channels;
18066 req_buf->ChannelCacheType = CHANNEL_LIST_STATIC;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018067 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018068}
18069
18070/**
18071 * csr_fetch_ch_lst_from_occupied_lst() - fetch channel list from occupied list
18072 * and update req msg
Jeff Johnson60ed45a2018-05-06 15:28:49 -070018073 * parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018074 * @mac_ctx: global mac ctx
18075 * @session_id: session id
18076 * @reason: reason to roam
18077 * @req_buf: out param, roam offload scan request packet
18078 * @roam_info: roam info struct
18079 *
18080 * Return: void
18081 */
18082static void
18083csr_fetch_ch_lst_from_occupied_lst(tpAniSirGlobal mac_ctx,
18084 uint8_t session_id,
18085 uint8_t reason,
18086 tSirRoamOffloadScanReq *req_buf,
18087 tpCsrNeighborRoamControlInfo roam_info)
18088{
18089 uint8_t i = 0;
18090 uint8_t num_channels = 0;
18091 uint8_t *ch_lst =
18092 mac_ctx->scan.occupiedChannels[session_id].channelList;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018093 uint16_t unsafe_chan[NUM_CHANNELS];
18094 uint16_t unsafe_chan_cnt = 0;
18095 uint16_t cnt = 0;
18096 bool is_unsafe_chan;
18097 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
18098
18099 if (!qdf_ctx) {
18100 cds_err("qdf_ctx is NULL");
18101 return;
18102 }
18103
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018104 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018105 "Num of channels before filtering=%d",
18106 mac_ctx->scan.occupiedChannels[session_id].numChannels);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018107 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
18108 &unsafe_chan_cnt,
18109 sizeof(unsafe_chan));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018110 for (i = 0; i < mac_ctx->scan.occupiedChannels[session_id].numChannels;
18111 i++) {
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018112 if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
18113 (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
18114 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070018115 (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018116 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
18117 ("ignoring dfs channel %d"), *ch_lst);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018118 ch_lst++;
18119 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018120 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018121
18122 if (mac_ctx->roam.configParam.sta_roam_policy.
18123 skip_unsafe_channels &&
18124 unsafe_chan_cnt) {
18125 is_unsafe_chan = false;
18126 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
18127 if (unsafe_chan[cnt] == *ch_lst) {
18128 is_unsafe_chan = true;
18129 break;
18130 }
18131 }
18132 if (is_unsafe_chan) {
18133 QDF_TRACE(QDF_MODULE_ID_SME,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018134 QDF_TRACE_LEVEL_DEBUG,
18135 ("ignoring unsafe channel %d"),
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018136 *ch_lst);
18137 ch_lst++;
18138 continue;
18139 }
18140 }
18141 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
18142 *ch_lst;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018143 if (*ch_lst)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018144 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018145 "DFSRoam=%d, ChnlState=%d, Chnl=%d, num_ch=%d",
18146 mac_ctx->roam.configParam.allowDFSChannelRoam,
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070018147 wlan_reg_get_channel_state(mac_ctx->pdev,
18148 *ch_lst),
18149 *ch_lst,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018150 num_channels);
18151 ch_lst++;
18152 }
18153 req_buf->ConnectedNetwork.ChannelCount = num_channels;
18154 /*
18155 * If the profile changes as to what it was earlier, inform the FW
18156 * through FLUSH as ChannelCacheType in which case, the FW will flush
18157 * the occupied channels for the earlier profile and try to learn them
18158 * afresh
18159 */
18160 if (reason == REASON_FLUSH_CHANNEL_LIST)
18161 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
18162 else {
18163 if (csr_neighbor_roam_is_new_connected_profile(mac_ctx,
18164 session_id))
18165 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
18166 else
18167 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
18168 }
18169}
18170
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018171/**
18172 * csr_fetch_valid_ch_lst() - fetch channel list from valid channel list and
18173 * update req msg
Jeff Johnson60ed45a2018-05-06 15:28:49 -070018174 * parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018175 * @mac_ctx: global mac ctx
18176 * @req_buf: out param, roam offload scan request packet
18177 *
18178 * Return: void
18179 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018180static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018181csr_fetch_valid_ch_lst(tpAniSirGlobal mac_ctx,
Vignesh Viswanathanc56e6572017-10-17 20:59:06 +053018182 tSirRoamOffloadScanReq *req_buf,
18183 uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018184{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018185 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018186 uint32_t host_channels = 0;
18187 uint8_t *ch_lst = NULL;
18188 uint8_t i = 0, num_channels = 0;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018189 uint16_t unsafe_chan[NUM_CHANNELS];
18190 uint16_t unsafe_chan_cnt = 0;
18191 uint16_t cnt = 0;
18192 bool is_unsafe_chan;
18193 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -080018194 enum band_info band = BAND_ALL;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018195
18196 if (!qdf_ctx) {
18197 cds_err("qdf_ctx is NULL");
18198 return QDF_STATUS_E_FAILURE;
18199 }
18200
18201 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
18202 &unsafe_chan_cnt,
18203 sizeof(unsafe_chan));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018204
18205 host_channels = sizeof(mac_ctx->roam.validChannelList);
18206 status = csr_get_cfg_valid_channels(mac_ctx,
18207 mac_ctx->roam.validChannelList,
18208 &host_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018209 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018210 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018211 "Failed to get the valid channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018212 return status;
18213 }
Vignesh Viswanathanc56e6572017-10-17 20:59:06 +053018214
18215 if (CSR_IS_ROAM_INTRA_BAND_ENABLED(mac_ctx)) {
18216 band = csr_get_rf_band(mac_ctx->roam.roamSession[session_id].
18217 connectedProfile.operationChannel);
18218 sme_debug("updated band %d operational ch %d", band,
18219 mac_ctx->roam.roamSession[session_id].
18220 connectedProfile.operationChannel);
18221 }
18222
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018223 ch_lst = mac_ctx->roam.validChannelList;
18224 mac_ctx->roam.numValidChannels = host_channels;
Vignesh Viswanathanc56e6572017-10-17 20:59:06 +053018225
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018226 for (i = 0; i < mac_ctx->roam.numValidChannels; i++) {
Vignesh Viswanathanc56e6572017-10-17 20:59:06 +053018227 if (!csr_check_band_channel_match(band, *ch_lst)) {
18228 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
18229 ("ignoring non-intra band channel %d"),
18230 *ch_lst);
18231 ch_lst++;
18232 continue;
18233 }
18234
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018235 if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
18236 (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
18237 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070018238 (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018239 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
18240 ("ignoring dfs channel %d"), *ch_lst);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018241 ch_lst++;
18242 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018243 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018244
18245 if (mac_ctx->roam.configParam.
18246 sta_roam_policy.skip_unsafe_channels &&
18247 unsafe_chan_cnt) {
18248 is_unsafe_chan = false;
18249 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
18250 if (unsafe_chan[cnt] == *ch_lst) {
18251 is_unsafe_chan = true;
18252 break;
18253 }
18254 }
18255 if (is_unsafe_chan) {
18256 QDF_TRACE(QDF_MODULE_ID_SME,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018257 QDF_TRACE_LEVEL_DEBUG,
18258 ("ignoring unsafe channel %d"),
Agrawal Ashish21ba2572016-09-03 16:40:10 +053018259 *ch_lst);
18260 ch_lst++;
18261 continue;
18262 }
18263 }
18264 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
18265 *ch_lst;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018266 ch_lst++;
18267 }
18268 req_buf->ValidChannelCount = num_channels;
Vignesh Viswanathanc56e6572017-10-17 20:59:06 +053018269
Abhinav Kumaredd1d372018-05-11 15:33:35 +053018270 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
18271 req_buf->ConnectedNetwork.ChannelCount = num_channels;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018272 return status;
18273}
18274
18275/**
18276 * csr_create_roam_scan_offload_request() - init roam offload scan request
18277 *
Jeff Johnson60ed45a2018-05-06 15:28:49 -070018278 * parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018279 * @mac_ctx: global mac ctx
18280 * @command: roam scan offload command input
18281 * @session_id: session id
18282 * @reason: reason to roam
18283 * @session: roam session
18284 * @roam_info: roam info struct
18285 *
18286 * Return: roam offload scan request packet buffer
18287 */
18288static tSirRoamOffloadScanReq *
18289csr_create_roam_scan_offload_request(tpAniSirGlobal mac_ctx,
18290 uint8_t command,
18291 uint8_t session_id,
18292 uint8_t reason,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018293 struct csr_roam_session *session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018294 tpCsrNeighborRoamControlInfo roam_info)
18295{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018296 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018297 uint8_t i, j, dot11_mode;
18298 bool ese_neighbor_list_recvd = false;
18299 uint8_t ch_cache_str[128] = { 0 };
18300 tSirRoamOffloadScanReq *req_buf = NULL;
18301 tpCsrChannelInfo curr_ch_lst_info =
18302 &roam_info->roamChannelInfo.currentChannelListInfo;
18303#ifdef FEATURE_WLAN_ESE
18304 /*
18305 * this flag will be true if connection is ESE and no neighbor
18306 * list received or if the connection is not ESE
18307 */
18308 ese_neighbor_list_recvd = ((roam_info->isESEAssoc)
18309 && (roam_info->roamChannelInfo.IAPPNeighborListReceived
18310 == false))
18311 || (roam_info->isESEAssoc == false);
18312#endif /* FEATURE_WLAN_ESE */
18313
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018314 req_buf = qdf_mem_malloc(sizeof(tSirRoamOffloadScanReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018315 if (NULL == req_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018316 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018317 "Mem alloc for roam scan offload req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018318 return NULL;
18319 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018320 req_buf->Command = command;
18321 /*
18322 * If command is STOP, then pass down ScanOffloadEnabled as Zero. This
18323 * will handle the case of host driver reloads, but Riva still up and
18324 * running
18325 */
18326 if (command == ROAM_SCAN_OFFLOAD_STOP) {
18327 /*
18328 * clear the roaming parameters that are per connection.
18329 * For a new connection, they have to be programmed again.
18330 */
18331 if (csr_neighbor_middle_of_roaming((tHalHandle)mac_ctx,
18332 session_id))
18333 req_buf->middle_of_roaming = 1;
18334 else
18335 csr_roam_reset_roam_params(mac_ctx);
18336 req_buf->RoamScanOffloadEnabled = 0;
18337 } else {
18338 req_buf->RoamScanOffloadEnabled =
18339 mac_ctx->roam.configParam.isRoamOffloadScanEnabled;
18340 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018341 qdf_mem_copy(req_buf->ConnectedNetwork.currAPbssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053018342 roam_info->currAPbssid.bytes, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018343 req_buf->ConnectedNetwork.ssId.length =
18344 mac_ctx->roam.roamSession[session_id].
18345 connectedProfile.SSID.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018346 qdf_mem_copy(req_buf->ConnectedNetwork.ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018347 mac_ctx->roam.roamSession[session_id].
18348 connectedProfile.SSID.ssId,
18349 req_buf->ConnectedNetwork.ssId.length);
18350 req_buf->ConnectedNetwork.authentication =
18351 mac_ctx->roam.roamSession[session_id].connectedProfile.AuthType;
18352 req_buf->ConnectedNetwork.encryption =
18353 mac_ctx->roam.roamSession[session_id].
18354 connectedProfile.EncryptionType;
18355 req_buf->ConnectedNetwork.mcencryption =
18356 mac_ctx->roam.roamSession[session_id].
18357 connectedProfile.mcEncryptionType;
gaurank kathpaliac63859d2018-05-03 18:48:41 +053018358 /* Copy the RSN capabilities in roam offload request from session*/
18359 req_buf->rsn_caps = session->rsn_caps;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018360#ifdef WLAN_FEATURE_11W
18361 req_buf->ConnectedNetwork.mfp_enabled =
18362 mac_ctx->roam.roamSession[session_id].connectedProfile.MFPEnabled;
18363#endif
18364 req_buf->delay_before_vdev_stop =
18365 roam_info->cfgParams.delay_before_vdev_stop;
18366 req_buf->OpportunisticScanThresholdDiff =
18367 roam_info->cfgParams.nOpportunisticThresholdDiff;
18368 req_buf->RoamRescanRssiDiff =
18369 roam_info->cfgParams.nRoamRescanRssiDiff;
18370 req_buf->RoamRssiDiff = mac_ctx->roam.configParam.RoamRssiDiff;
Abhishek Singh34c0e632017-09-28 14:39:29 +053018371 req_buf->rssi_abs_thresh = mac_ctx->roam.configParam.rssi_abs_thresh;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018372 req_buf->reason = reason;
18373 req_buf->NeighborScanTimerPeriod =
18374 roam_info->cfgParams.neighborScanPeriod;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +053018375 req_buf->neighbor_scan_min_timer_period =
18376 roam_info->cfgParams.neighbor_scan_min_period;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018377 req_buf->NeighborRoamScanRefreshPeriod =
18378 roam_info->cfgParams.neighborResultsRefreshPeriod;
18379 req_buf->NeighborScanChannelMinTime =
18380 roam_info->cfgParams.minChannelScanTime;
18381 req_buf->NeighborScanChannelMaxTime =
18382 roam_info->cfgParams.maxChannelScanTime;
18383 req_buf->EmptyRefreshScanPeriod =
18384 roam_info->cfgParams.emptyScanRefreshPeriod;
18385 req_buf->RoamBmissFirstBcnt =
18386 roam_info->cfgParams.nRoamBmissFirstBcnt;
18387 req_buf->RoamBmissFinalBcnt =
18388 roam_info->cfgParams.nRoamBmissFinalBcnt;
18389 req_buf->RoamBeaconRssiWeight =
18390 roam_info->cfgParams.nRoamBeaconRssiWeight;
Varun Reddy Yeturu061d4d62017-07-20 09:39:32 -070018391 qdf_mem_copy(&req_buf->mawc_roam_params,
18392 &mac_ctx->roam.configParam.csr_mawc_config,
18393 sizeof(req_buf->mawc_roam_params));
18394 sme_debug("MAWC:global=%d,roam=%d,traffic=%d,ap_rssi=%d,high=%d,low=%d",
18395 req_buf->mawc_roam_params.mawc_enabled,
18396 req_buf->mawc_roam_params.mawc_roam_enabled,
18397 req_buf->mawc_roam_params.mawc_roam_traffic_threshold,
18398 req_buf->mawc_roam_params.mawc_roam_ap_rssi_threshold,
18399 req_buf->mawc_roam_params.mawc_roam_rssi_high_adjust,
18400 req_buf->mawc_roam_params.mawc_roam_rssi_low_adjust);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018401#ifdef FEATURE_WLAN_ESE
18402 req_buf->IsESEAssoc =
Srinivas Girigowda18dcf3d2015-12-16 18:11:48 -080018403 csr_roam_is_ese_assoc(mac_ctx, session_id) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018404 ((req_buf->ConnectedNetwork.authentication ==
18405 eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
18406 (csr_is_auth_type_ese(req_buf->
18407 ConnectedNetwork.authentication)));
Abhinav Kumar271f0632018-03-29 16:01:30 +053018408 req_buf->is_11r_assoc = roam_info->is11rAssoc;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018409 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Abhinav Kumar271f0632018-03-29 16:01:30 +053018410 "IsEseAssoc: %d is_11r_assoc: %d middle of roaming: %d ese_neighbor_list_recvd: %d cur no of chan: %d",
18411 req_buf->IsESEAssoc, req_buf->is_11r_assoc,
Selvaraj, Sridhar8fe6c672017-01-10 11:37:29 +053018412 req_buf->middle_of_roaming,
18413 ese_neighbor_list_recvd,
18414 curr_ch_lst_info->numOfChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018415#endif
Selvaraj, Sridhar38101832017-05-12 14:23:07 +053018416
Vignesh Viswanathanc56e6572017-10-17 20:59:06 +053018417 if (!CSR_IS_ROAM_INTRA_BAND_ENABLED(mac_ctx)) {
18418 if (ese_neighbor_list_recvd ||
18419 curr_ch_lst_info->numOfChannels == 0) {
18420 /*
18421 * Retrieve the Channel Cache either from ini or from
18422 * the occupied channels list.
18423 * Give Preference to INI Channels
18424 */
18425 if (roam_info->cfgParams.channelInfo.numOfChannels) {
18426 status = csr_fetch_ch_lst_from_ini(mac_ctx,
18427 roam_info,
18428 req_buf);
18429 if (!QDF_IS_STATUS_SUCCESS(status)) {
18430 QDF_TRACE(QDF_MODULE_ID_SME,
18431 QDF_TRACE_LEVEL_DEBUG,
18432 "Fetch channel list from ini failed");
18433 qdf_mem_free(req_buf);
18434 return NULL;
18435 }
18436 } else {
18437 csr_fetch_ch_lst_from_occupied_lst(mac_ctx,
18438 session_id, reason, req_buf,
18439 roam_info);
18440 }
18441 }
18442#ifdef FEATURE_WLAN_ESE
18443 else {
18444 /*
18445 * If ESE is enabled, and a neighbor Report is received,
18446 * then Ignore the INI Channels or the Occupied Channel
18447 * List. Consider the channels in the neighbor list sent
18448 * by the ESE AP
18449 */
18450 csr_fetch_ch_lst_from_received_list(mac_ctx, roam_info,
18451 curr_ch_lst_info, req_buf);
18452 }
18453#endif
18454 }
Selvaraj, Sridhar38101832017-05-12 14:23:07 +053018455 if (req_buf->ConnectedNetwork.ChannelCount == 0) {
18456 /* Maintain the Valid Channels List */
Vignesh Viswanathanc56e6572017-10-17 20:59:06 +053018457 status = csr_fetch_valid_ch_lst(mac_ctx, req_buf, session_id);
Selvaraj, Sridhar38101832017-05-12 14:23:07 +053018458 if (!QDF_IS_STATUS_SUCCESS(status)) {
18459 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
18460 "Fetch channel list fail");
18461 qdf_mem_free(req_buf);
18462 return NULL;
18463 }
18464 }
18465
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018466 for (i = 0, j = 0; i < req_buf->ConnectedNetwork.ChannelCount; i++) {
18467 if (j < sizeof(ch_cache_str)) {
18468 j += snprintf(ch_cache_str + j,
18469 sizeof(ch_cache_str) - j, " %d",
18470 req_buf->ConnectedNetwork.
18471 ChannelCache[i]);
18472 } else
18473 break;
18474 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018475 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018476 FL("ChnlCacheType:%d, No of Chnls:%d,Channels: %s"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018477 req_buf->ChannelCacheType,
18478 req_buf->ConnectedNetwork.ChannelCount, ch_cache_str);
18479
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018480 req_buf->MDID.mdiePresent =
18481 mac_ctx->roam.roamSession[session_id].
18482 connectedProfile.MDID.mdiePresent;
18483 req_buf->MDID.mobilityDomain =
18484 mac_ctx->roam.roamSession[session_id].
18485 connectedProfile.MDID.mobilityDomain;
18486 req_buf->sessionId = session_id;
18487 req_buf->nProbes = mac_ctx->roam.configParam.nProbes;
18488 req_buf->HomeAwayTime = mac_ctx->roam.configParam.nRoamScanHomeAwayTime;
18489
18490 /*
18491 * Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
18492 * where RFS is the RF Switching time. It is twice RFS to consider the
18493 * time to go off channel and return to the home channel.
18494 */
18495 if (req_buf->HomeAwayTime < (req_buf->NeighborScanChannelMaxTime +
18496 (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018497 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
18498 "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 -080018499 req_buf->HomeAwayTime,
18500 (req_buf->NeighborScanChannelMaxTime +
18501 (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
18502 req_buf->HomeAwayTime = 0;
18503 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018504
18505 /*Prepare a probe request for 2.4GHz band and one for 5GHz band */
18506 dot11_mode = (uint8_t) csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
18507 csr_find_best_phy_mode(mac_ctx,
18508 mac_ctx->roam.configParam.phyMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018509 req_buf->allowDFSChannelRoam =
18510 mac_ctx->roam.configParam.allowDFSChannelRoam;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -070018511 req_buf->early_stop_scan_enable =
18512 mac_ctx->roam.configParam.early_stop_scan_enable;
18513 req_buf->early_stop_scan_min_threshold =
18514 mac_ctx->roam.configParam.early_stop_scan_min_threshold;
18515 req_buf->early_stop_scan_max_threshold =
18516 mac_ctx->roam.configParam.early_stop_scan_max_threshold;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053018517 req_buf->roamscan_adaptive_dwell_mode =
18518 mac_ctx->roam.configParam.roamscan_adaptive_dwell_mode;
Selvaraj, Sridhar57ce4df2017-05-29 18:30:49 +053018519 req_buf->lca_config_params.disallow_duration =
18520 mac_ctx->roam.configParam.disallow_duration;
18521 req_buf->lca_config_params.rssi_channel_penalization =
18522 mac_ctx->roam.configParam.rssi_channel_penalization;
18523 req_buf->lca_config_params.num_disallowed_aps =
18524 mac_ctx->roam.configParam.num_disallowed_aps;
Vignesh Viswanathana3d5c272018-06-04 19:36:02 +053018525
18526 /* For RSO Stop, we need to notify FW to deinit BTM */
18527 if (command == ROAM_SCAN_OFFLOAD_STOP)
18528 req_buf->btm_offload_config = 0;
18529 else
18530 req_buf->btm_offload_config =
18531 mac_ctx->roam.configParam.btm_offload_config;
18532
Jiachao Wu84bb2ea2018-01-08 16:17:33 +080018533 req_buf->btm_solicited_timeout =
18534 mac_ctx->roam.configParam.btm_solicited_timeout;
18535 req_buf->btm_max_attempt_cnt =
18536 mac_ctx->roam.configParam.btm_max_attempt_cnt;
18537 req_buf->btm_sticky_time =
18538 mac_ctx->roam.configParam.btm_sticky_time;
Selvaraj, Sridhar57ce4df2017-05-29 18:30:49 +053018539
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018540#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Selvaraj, Sridhar57ce4df2017-05-29 18:30:49 +053018541 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
18542 FL("HomeAwayTime=%d EarlyStopFeature Enable=%d, MinThresh=%d, MaxThresh=%d PMK len=%d disallow_dur=%d rssi_chan_pen=%d num_disallowed_aps=%d"),
18543 req_buf->HomeAwayTime,
18544 req_buf->early_stop_scan_enable,
18545 req_buf->early_stop_scan_min_threshold,
18546 req_buf->early_stop_scan_max_threshold,
18547 req_buf->pmk_len,
18548 req_buf->lca_config_params.disallow_duration,
18549 req_buf->lca_config_params.rssi_channel_penalization,
18550 req_buf->lca_config_params.num_disallowed_aps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018551 req_buf->RoamOffloadEnabled = csr_roamIsRoamOffloadEnabled(mac_ctx);
18552 req_buf->RoamKeyMgmtOffloadEnabled = session->RoamKeyMgmtOffloadEnabled;
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080018553 req_buf->pmkid_modes = session->pmkid_modes;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018554 /* Roam Offload piggybacks upon the Roam Scan offload command. */
18555 if (req_buf->RoamOffloadEnabled)
18556 csr_update_roam_scan_offload_request(mac_ctx, req_buf, session);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018557 qdf_mem_copy(&req_buf->roam_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018558 &mac_ctx->roam.configParam.roam_params,
18559 sizeof(req_buf->roam_params));
18560#endif
18561 return req_buf;
18562}
Vignesh Viswanathanfb9d0752018-02-06 16:19:00 +053018563
18564/**
18565 * csr_update_11k_offload_params - Update 11K offload params
18566 * @mac_ctx: MAC context
18567 * @session: Pointer to the CSR Roam Session
18568 * @req_buffer: Pointer to the RSO Request buffer
Vignesh Viswanathane25af782018-03-23 14:49:50 +053018569 * @enabled: 11k offload enabled/disabled.
Vignesh Viswanathanfb9d0752018-02-06 16:19:00 +053018570 *
18571 * API to update 11k offload params to Roam Scan Offload request buffer
18572 *
18573 * Return: none
18574 */
18575static void csr_update_11k_offload_params(tpAniSirGlobal mac_ctx,
18576 struct csr_roam_session *session,
Vignesh Viswanathane25af782018-03-23 14:49:50 +053018577 tSirRoamOffloadScanReq *req_buffer,
18578 bool enabled)
Vignesh Viswanathanfb9d0752018-02-06 16:19:00 +053018579{
18580 struct wmi_11k_offload_params *params = &req_buffer->offload_11k_params;
18581 struct csr_config *csr_config = &mac_ctx->roam.configParam;
18582 struct csr_neighbor_report_offload_params *neighbor_report_offload =
18583 &csr_config->neighbor_report_offload;
18584
18585 params->vdev_id = session->sessionId;
Vignesh Viswanathane25af782018-03-23 14:49:50 +053018586
18587 if (enabled) {
18588 params->offload_11k_bitmask =
18589 csr_config->offload_11k_enable_bitmask;
18590 } else {
18591 params->offload_11k_bitmask = 0;
18592 sme_debug("11k offload disabled in RSO");
18593 return;
18594 }
Vignesh Viswanathanfb9d0752018-02-06 16:19:00 +053018595
18596 /*
18597 * If none of the parameters are enabled, then set the
18598 * offload_11k_bitmask to 0, so that we don't send the command
18599 * to the FW and drop it in WMA
18600 */
18601 if ((neighbor_report_offload->params_bitmask &
18602 NEIGHBOR_REPORT_PARAMS_ALL) == 0) {
18603 sme_err("No valid neighbor report offload params %x",
18604 neighbor_report_offload->params_bitmask);
18605 params->offload_11k_bitmask = 0;
Vignesh Viswanathane25af782018-03-23 14:49:50 +053018606 return;
Vignesh Viswanathanfb9d0752018-02-06 16:19:00 +053018607 }
18608
18609 /*
18610 * First initialize all params to NEIGHBOR_REPORT_PARAM_INVALID
18611 * Then set the values that are enabled
18612 */
18613 params->neighbor_report_params.time_offset =
18614 NEIGHBOR_REPORT_PARAM_INVALID;
18615 params->neighbor_report_params.low_rssi_offset =
18616 NEIGHBOR_REPORT_PARAM_INVALID;
18617 params->neighbor_report_params.bmiss_count_trigger =
18618 NEIGHBOR_REPORT_PARAM_INVALID;
18619 params->neighbor_report_params.per_threshold_offset =
18620 NEIGHBOR_REPORT_PARAM_INVALID;
18621 params->neighbor_report_params.neighbor_report_cache_timeout =
18622 NEIGHBOR_REPORT_PARAM_INVALID;
18623 params->neighbor_report_params.max_neighbor_report_req_cap =
18624 NEIGHBOR_REPORT_PARAM_INVALID;
18625
18626 if (neighbor_report_offload->params_bitmask &
18627 NEIGHBOR_REPORT_PARAMS_TIME_OFFSET)
18628 params->neighbor_report_params.time_offset =
18629 neighbor_report_offload->time_offset;
18630
18631 if (neighbor_report_offload->params_bitmask &
18632 NEIGHBOR_REPORT_PARAMS_LOW_RSSI_OFFSET)
18633 params->neighbor_report_params.low_rssi_offset =
18634 neighbor_report_offload->low_rssi_offset;
18635
18636 if (neighbor_report_offload->params_bitmask &
18637 NEIGHBOR_REPORT_PARAMS_BMISS_COUNT_TRIGGER)
18638 params->neighbor_report_params.bmiss_count_trigger =
18639 neighbor_report_offload->bmiss_count_trigger;
18640
18641 if (neighbor_report_offload->params_bitmask &
18642 NEIGHBOR_REPORT_PARAMS_PER_THRESHOLD_OFFSET)
18643 params->neighbor_report_params.per_threshold_offset =
18644 neighbor_report_offload->per_threshold_offset;
18645
18646 if (neighbor_report_offload->params_bitmask &
18647 NEIGHBOR_REPORT_PARAMS_CACHE_TIMEOUT)
18648 params->neighbor_report_params.neighbor_report_cache_timeout =
18649 neighbor_report_offload->neighbor_report_cache_timeout;
18650
18651 if (neighbor_report_offload->params_bitmask &
18652 NEIGHBOR_REPORT_PARAMS_MAX_REQ_CAP)
18653 params->neighbor_report_params.max_neighbor_report_req_cap =
18654 neighbor_report_offload->max_neighbor_report_req_cap;
18655
18656 params->neighbor_report_params.ssid.length =
18657 session->connectedProfile.SSID.length;
18658 qdf_mem_copy(params->neighbor_report_params.ssid.mac_ssid,
18659 session->connectedProfile.SSID.ssId,
18660 session->connectedProfile.SSID.length);
18661
18662 sme_debug("Updated 11k offload params to RSO");
18663}
18664
18665QDF_STATUS csr_invoke_neighbor_report_request(uint8_t session_id,
18666 struct sRrmNeighborReq *neighbor_report_req,
18667 bool send_resp_to_host)
18668{
18669 struct wmi_invoke_neighbor_report_params *invoke_params;
18670 struct scheduler_msg msg = {0};
18671
18672 if (!neighbor_report_req) {
18673 sme_err("Invalid params");
18674 return QDF_STATUS_E_INVAL;
18675 }
18676
18677 invoke_params = qdf_mem_malloc(sizeof(*invoke_params));
18678 if (!invoke_params) {
18679 sme_err("Memory allocation failure");
18680 return QDF_STATUS_E_NOMEM;
18681 }
18682
18683 invoke_params->vdev_id = session_id;
18684 invoke_params->send_resp_to_host = send_resp_to_host;
18685
18686 if (!neighbor_report_req->no_ssid) {
18687 invoke_params->ssid.length = neighbor_report_req->ssid.length;
18688 qdf_mem_copy(invoke_params->ssid.mac_ssid,
18689 neighbor_report_req->ssid.ssId,
18690 neighbor_report_req->ssid.length);
18691 } else {
18692 invoke_params->ssid.length = 0;
18693 }
18694
18695 sme_debug("Sending SIR_HAL_INVOKE_NEIGHBOR_REPORT");
18696
18697 msg.type = SIR_HAL_INVOKE_NEIGHBOR_REPORT;
18698 msg.reserved = 0;
18699 msg.bodyptr = invoke_params;
18700
18701 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA, &msg)) {
18702 sme_err("Not able to post message to WMA");
18703 qdf_mem_free(invoke_params);
18704 return QDF_STATUS_E_FAILURE;
18705 }
18706
18707 return QDF_STATUS_SUCCESS;
18708}
18709
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018710/**
18711 * check_allowed_ssid_list() - Check the WhiteList
18712 * @req_buffer: Buffer which contains the connected profile SSID.
18713 * @roam_params: Buffer which contains the whitelist SSID's.
18714 *
18715 * Check if the connected profile SSID exists in the whitelist.
18716 * It is assumed that the framework provides this also in the whitelist.
18717 * If it exists there is no issue. Otherwise add it to the list.
18718 *
18719 * Return: None
18720 */
18721static void check_allowed_ssid_list(tSirRoamOffloadScanReq *req_buffer,
18722 struct roam_ext_params *roam_params)
18723{
18724 int i = 0;
18725 bool match = false;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018726
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018727 for (i = 0; i < roam_params->num_ssid_allowed_list; i++) {
18728 if ((roam_params->ssid_allowed_list[i].length ==
18729 req_buffer->ConnectedNetwork.ssId.length) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018730 (!qdf_mem_cmp(roam_params->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018731 req_buffer->ConnectedNetwork.ssId.ssId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018732 roam_params->ssid_allowed_list[i].length))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018733 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018734 "Whitelist contains connected profile SSID");
18735 match = true;
18736 break;
18737 }
18738 }
18739 if (!match) {
18740 if (roam_params->num_ssid_allowed_list >=
18741 MAX_SSID_ALLOWED_LIST) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018742 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018743 "Whitelist is FULL. Cannot Add another entry");
18744 return;
18745 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018746 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018747 "Adding Connected profile SSID to whitelist");
18748 /* i is the next available index to add the entry.*/
18749 i = roam_params->num_ssid_allowed_list;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018750 qdf_mem_copy(roam_params->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018751 req_buffer->ConnectedNetwork.ssId.ssId,
18752 req_buffer->ConnectedNetwork.ssId.length);
18753 roam_params->ssid_allowed_list[i].length =
18754 req_buffer->ConnectedNetwork.ssId.length;
18755 roam_params->num_ssid_allowed_list++;
18756 }
18757}
18758
Abhishek Singh4db8c152017-07-18 10:40:08 +053018759/**
18760 * csr_add_rssi_reject_ap_list() - add rssi reject AP list to the
18761 * roam params
18762 * @mac_ctx: mac ctx.
18763 * @roam_params: roam params in which reject AP list needs
18764 * to be populated.
18765 *
18766 * Return: None
18767 */
18768static void csr_add_rssi_reject_ap_list(tpAniSirGlobal mac_ctx,
18769 struct roam_ext_params *roam_params)
18770{
18771 int i = 0;
18772 struct sir_rssi_disallow_lst *cur_node;
18773 qdf_list_node_t *cur_list = NULL;
18774 qdf_list_node_t *next_list = NULL;
18775 struct rssi_disallow_bssid *rssi_rejection_ap;
18776 qdf_list_t *list = &mac_ctx->roam.rssi_disallow_bssid;
18777 qdf_time_t cur_time =
18778 qdf_do_div(qdf_get_monotonic_boottime(),
18779 QDF_MC_TIMER_TO_MS_UNIT);
18780
18781 roam_params->num_rssi_rejection_ap = qdf_list_size(list);
18782
18783 if (!qdf_list_size(list))
18784 return;
18785
18786 if (roam_params->num_rssi_rejection_ap > MAX_RSSI_AVOID_BSSID_LIST)
18787 roam_params->num_rssi_rejection_ap = MAX_RSSI_AVOID_BSSID_LIST;
18788
18789 qdf_list_peek_front(list, &cur_list);
18790 while (cur_list) {
18791 int32_t rem_time;
18792
18793 rssi_rejection_ap = &roam_params->rssi_rejection_ap[i];
18794 cur_node = qdf_container_of(cur_list,
18795 struct sir_rssi_disallow_lst, node);
18796 rem_time = cur_node->retry_delay -
18797 (cur_time - cur_node->time_during_rejection);
18798
18799 if (rem_time > 0) {
18800 qdf_copy_macaddr(&rssi_rejection_ap->bssid,
18801 &cur_node->bssid);
18802 rssi_rejection_ap->expected_rssi =
18803 cur_node->expected_rssi;
18804 rssi_rejection_ap->remaining_duration = rem_time;
18805 i++;
18806 }
18807 qdf_list_peek_next(list, cur_list, &next_list);
18808 cur_list = next_list;
18809 next_list = NULL;
18810
18811 if (i >= MAX_RSSI_AVOID_BSSID_LIST)
18812 break;
18813 }
18814 for (i = 0; i < roam_params->num_rssi_rejection_ap; i++) {
18815 sme_debug("BSSID %pM expected rssi %d remaining duration %d",
18816 roam_params->rssi_rejection_ap[i].bssid.bytes,
18817 roam_params->rssi_rejection_ap[i].expected_rssi,
18818 roam_params->rssi_rejection_ap[i].remaining_duration);
18819 }
18820}
18821
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018822/*
18823 * Below Table describe whether RSO command can be send down to fimrware or not.
18824 * Host check it on the basis of previous RSO command sent down to firmware.
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070018825 * ||=========================================================================||
18826 * || New cmd | LAST SENT COMMAND ---> ||
18827 * ||====|====================================================================||
18828 * || V | START | STOP | RESTART | UPDATE_CFG| ABORT_SCAN ||
18829 * || ------------------------------------------------------------------------||
18830 * || RSO_START | NO | YES | NO | YES | NO ||
18831 * || RSO_STOP | YES | YES | YES | YES | YES ||
18832 * || RSO_RESTART | YES | YES | NO | YES | YES ||
18833 * || RSO_UPDATE_CFG | YES | NO | YES | YES | YES ||
18834 * || RSO_ABORT_SCAN | YES | NO | YES | YES | YES ||
18835 * ||=========================================================================||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018836 **/
18837#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
18838#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
18839#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
18840#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080018841#define RSO_ABORT_SCAN_BIT (1<<ROAM_SCAN_OFFLOAD_ABORT_SCAN)
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070018842#define RSO_START_ALLOW_MASK (RSO_STOP_BIT | RSO_UPDATE_CFG_BIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018843#define RSO_STOP_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080018844 RSO_STOP_BIT | RSO_START_BIT | RSO_ABORT_SCAN_BIT)
18845#define RSO_RESTART_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_START_BIT | \
18846 RSO_ABORT_SCAN_BIT | RSO_RESTART_BIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018847#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_STOP_BIT | \
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080018848 RSO_START_BIT | RSO_ABORT_SCAN_BIT)
18849#define RSO_ABORT_SCAN_ALLOW_MASK (RSO_START_BIT | RSO_RESTART_BIT | \
18850 RSO_UPDATE_CFG_BIT | RSO_ABORT_SCAN_BIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018851
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018852static bool csr_is_RSO_cmd_allowed(tpAniSirGlobal mac_ctx,
18853 uint8_t command, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018854{
18855 tpCsrNeighborRoamControlInfo neigh_roam_info =
18856 &mac_ctx->roam.neighborRoamInfo[session_id];
18857 uint8_t desiredMask = 0;
18858 bool ret_val;
18859
18860 switch (command) {
18861 case ROAM_SCAN_OFFLOAD_START:
18862 desiredMask = RSO_START_ALLOW_MASK;
18863 break;
18864 case ROAM_SCAN_OFFLOAD_STOP:
18865 desiredMask = RSO_STOP_ALLOW_MASK;
18866 break;
18867 case ROAM_SCAN_OFFLOAD_RESTART:
18868 desiredMask = RSO_RESTART_ALLOW_MASK;
18869 break;
18870 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
18871 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
18872 break;
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080018873 case ROAM_SCAN_OFFLOAD_ABORT_SCAN:
18874 desiredMask = RSO_ABORT_SCAN_ALLOW_MASK;
18875 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018876 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018877 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018878 ("Wrong RSO command %d, not allowed"), command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018879 return 0;/*Cmd Not allowed*/
18880 }
18881 ret_val = desiredMask & (1 << neigh_roam_info->last_sent_cmd);
18882 return ret_val;
18883}
18884
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053018885/*
18886 * csr_roam_send_rso_cmd() - API to send RSO command to PE
18887 * @mac_ctx: Pointer to global MAC structure
18888 * @session_id: Session ID
18889 * @request_buf: Pointer to tSirRoamOffloadScanReq
18890 *
18891 * Return: QDF_STATUS
18892 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -070018893static QDF_STATUS csr_roam_send_rso_cmd(tpAniSirGlobal mac_ctx,
18894 uint8_t session_id,
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053018895 tSirRoamOffloadScanReq *request_buf)
18896{
18897 QDF_STATUS status;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018898
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053018899 request_buf->message_type = eWNI_SME_ROAM_SCAN_OFFLOAD_REQ;
18900 request_buf->length = sizeof(*request_buf);
18901
Rajeev Kumard138ac52017-01-30 18:38:37 -080018902 status = umac_send_mb_message_to_mac(request_buf);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053018903 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018904 sme_err("Send RSO from CSR failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053018905 return status;
18906 }
18907 return QDF_STATUS_SUCCESS;
18908}
18909
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018910/**
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053018911 * csr_append_assoc_ies() - Append specific IE to assoc IE's buffer
18912 * @mac_ctx: Pointer to global mac context
18913 * @req_buf: Pointer to Roam offload scan request
18914 * @ie_id: IE ID to be appended
18915 * @ie_len: IE length to be appended
18916 * @ie_data: IE data to be appended
18917 *
18918 * Return: None
18919 */
18920static void csr_append_assoc_ies(tpAniSirGlobal mac_ctx,
18921 tSirRoamOffloadScanReq *req_buf, uint8_t ie_id,
18922 uint8_t ie_len, uint8_t *ie_data)
18923{
18924 tSirAddie *assoc_ie = &req_buf->assoc_ie;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018925
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053018926 if ((SIR_MAC_MAX_ADD_IE_LENGTH - assoc_ie->length) < ie_len) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018927 sme_err("Appending IE id: %d fails", ie_id);
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053018928 return;
18929 }
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053018930 assoc_ie->addIEdata[assoc_ie->length] = ie_id;
18931 assoc_ie->addIEdata[assoc_ie->length + 1] = ie_len;
18932 qdf_mem_copy(&assoc_ie->addIEdata[assoc_ie->length + 2],
18933 ie_data, ie_len);
18934 assoc_ie->length += (ie_len + 2);
18935}
18936
yeshwanth sriram guntuka27e4ffc2016-12-01 18:00:17 +053018937#ifdef FEATURE_WLAN_ESE
18938/**
18939 * ese_populate_addtional_ies() - add IEs to reassoc frame
18940 * @mac_ctx: Pointer to global mac structure
18941 * @session: pointer to CSR session
18942 * @req_buf: Pointer to Roam offload scan request
18943 *
18944 * This function populates the TSPEC ie and appends the info
18945 * to assoc buffer.
18946 *
18947 * Return: None
18948 */
18949static void ese_populate_addtional_ies(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018950 struct csr_roam_session *session,
yeshwanth sriram guntuka27e4ffc2016-12-01 18:00:17 +053018951 tSirRoamOffloadScanReq *req_buf) {
18952
18953 uint8_t tspec_ie_hdr[SIR_MAC_OUI_WME_HDR_MIN]
18954 = { 0x00, 0x50, 0xf2, 0x02, 0x02, 0x01 };
18955 uint8_t tspec_ie_buf[DOT11F_IE_WMMTSPEC_MAX_LEN], j;
18956 ese_wmm_tspec_ie *tspec_ie;
18957 tESETspecInfo ese_tspec;
18958
18959 tspec_ie = (ese_wmm_tspec_ie *)(tspec_ie_buf + SIR_MAC_OUI_WME_HDR_MIN);
18960 if (csr_is_wmm_supported(mac_ctx) &&
18961 mac_ctx->roam.configParam.isEseIniFeatureEnabled &&
18962 csr_roam_is_ese_assoc(mac_ctx, session->sessionId)) {
18963 ese_tspec.numTspecs = sme_qos_ese_retrieve_tspec_info(mac_ctx,
18964 session->sessionId,
18965 (tTspecInfo *) &ese_tspec.tspec[0]);
18966 qdf_mem_copy(tspec_ie_buf, tspec_ie_hdr,
18967 SIR_MAC_OUI_WME_HDR_MIN);
18968 for (j = 0; j < ese_tspec.numTspecs; j++) {
18969 /* Populate the tspec_ie */
18970 ese_populate_wmm_tspec(&ese_tspec.tspec[j].tspec,
18971 tspec_ie);
18972 csr_append_assoc_ies(mac_ctx, req_buf,
18973 IEEE80211_ELEMID_VENDOR,
18974 DOT11F_IE_WMMTSPEC_MAX_LEN,
18975 tspec_ie_buf);
18976 }
18977 }
18978
18979}
18980#else
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018981static inline void ese_populate_addtional_ies(
18982 tpAniSirGlobal mac_ctx,
18983 struct csr_roam_session *session, tSirRoamOffloadScanReq *req_buf) {
yeshwanth sriram guntuka27e4ffc2016-12-01 18:00:17 +053018984}
18985#endif
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053018986/**
18987 * csr_update_driver_assoc_ies() - Append driver built IE's to assoc IE's
18988 * @mac_ctx: Pointer to global mac structure
18989 * @session: pointer to CSR session
18990 * @req_buf: Pointer to Roam offload scan request
18991 *
18992 * Return: None
18993 */
18994static void csr_update_driver_assoc_ies(tpAniSirGlobal mac_ctx,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053018995 struct csr_roam_session *session,
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053018996 tSirRoamOffloadScanReq *req_buf)
18997{
18998 bool power_caps_populated = false;
18999 uint32_t csr_11henable = WNI_CFG_11H_ENABLED_STADEF;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019000
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019001 uint8_t *rrm_cap_ie_data
19002 = (uint8_t *) &mac_ctx->rrm.rrmPEContext.rrmEnabledCaps;
19003 uint8_t power_cap_ie_data[DOT11F_IE_POWERCAPS_MAX_LEN]
19004 = {MIN_TX_PWR_CAP, MAX_TX_PWR_CAP};
Naveen Rawat224ae9c2016-10-24 15:36:56 -070019005 uint8_t max_tx_pwr_cap = 0;
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053019006 uint8_t supp_chan_ie[DOT11F_IE_SUPPCHANNELS_MAX_LEN], supp_chan_ie_len;
Yu Wang0477ee32017-02-10 20:02:03 +080019007
19008#ifdef FEATURE_WLAN_ESE
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053019009 uint8_t ese_ie[DOT11F_IE_ESEVERSION_MAX_LEN]
19010 = { 0x0, 0x40, 0x96, 0x3, ESE_VERSION_SUPPORTED};
Yu Wang0477ee32017-02-10 20:02:03 +080019011#endif
Selvaraj, Sridharced57062017-01-30 15:19:07 +053019012 uint8_t qcn_ie[DOT11F_IE_QCN_IE_MAX_LEN]
19013 = {0x8C, 0xFD, 0xF0, 0x1, QCN_IE_VERSION_SUBATTR_ID,
19014 QCN_IE_VERSION_SUBATTR_DATA_LEN,
19015 QCN_IE_VERSION_SUPPORTED,
19016 QCN_IE_SUBVERSION_SUPPORTED};
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053019017
Naveen Rawat224ae9c2016-10-24 15:36:56 -070019018 if (session->pConnectBssDesc)
19019 max_tx_pwr_cap = csr_get_cfg_max_tx_power(mac_ctx,
19020 session->pConnectBssDesc->channelId);
Selvaraj, Sridhar94be8ba2017-05-04 17:08:54 +053019021
19022 if (max_tx_pwr_cap && max_tx_pwr_cap < MAX_TX_PWR_CAP)
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019023 power_cap_ie_data[1] = max_tx_pwr_cap;
Selvaraj, Sridhar94be8ba2017-05-04 17:08:54 +053019024 else
19025 power_cap_ie_data[1] = MAX_TX_PWR_CAP;
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019026
19027 wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &csr_11henable);
19028
19029 if (csr_11henable && csr_is11h_supported(mac_ctx)) {
19030 /* Append power cap IE */
19031 csr_append_assoc_ies(mac_ctx, req_buf, IEEE80211_ELEMID_PWRCAP,
19032 DOT11F_IE_POWERCAPS_MAX_LEN,
19033 power_cap_ie_data);
19034 power_caps_populated = true;
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053019035
19036 /* Append Supported channels IE */
19037 csr_add_supported_5Ghz_channels(mac_ctx, supp_chan_ie,
19038 &supp_chan_ie_len, true);
19039
19040 csr_append_assoc_ies(mac_ctx, req_buf,
19041 IEEE80211_ELEMID_SUPPCHAN,
19042 supp_chan_ie_len, supp_chan_ie);
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019043 }
19044
Yu Wang0477ee32017-02-10 20:02:03 +080019045#ifdef FEATURE_WLAN_ESE
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053019046 /* Append ESE version IE if isEseIniFeatureEnabled INI is enabled */
19047 if (mac_ctx->roam.configParam.isEseIniFeatureEnabled)
19048 csr_append_assoc_ies(mac_ctx, req_buf, IEEE80211_ELEMID_VENDOR,
19049 DOT11F_IE_ESEVERSION_MAX_LEN,
19050 ese_ie);
Yu Wang0477ee32017-02-10 20:02:03 +080019051#endif
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053019052
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019053 if (mac_ctx->rrm.rrmPEContext.rrmEnable) {
19054 /* Append RRM IE */
19055 csr_append_assoc_ies(mac_ctx, req_buf, IEEE80211_ELEMID_RRM,
19056 DOT11F_IE_RRMENABLEDCAP_MAX_LEN,
19057 rrm_cap_ie_data);
19058 if (!power_caps_populated)
19059 /* Append Power cap IE if not appended already */
19060 csr_append_assoc_ies(mac_ctx, req_buf,
19061 IEEE80211_ELEMID_PWRCAP,
19062 DOT11F_IE_POWERCAPS_MAX_LEN,
19063 power_cap_ie_data);
19064 }
yeshwanth sriram guntuka27e4ffc2016-12-01 18:00:17 +053019065 ese_populate_addtional_ies(mac_ctx, session, req_buf);
19066
Selvaraj, Sridharced57062017-01-30 15:19:07 +053019067 /* Append QCN IE if g_support_qcn_ie INI is enabled */
19068 if (mac_ctx->roam.configParam.qcn_ie_support)
19069 csr_append_assoc_ies(mac_ctx, req_buf, IEEE80211_ELEMID_VENDOR,
19070 DOT11F_IE_QCN_IE_MAX_LEN,
19071 qcn_ie);
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019072}
19073
19074/**
Kapil Gupta5cda2252016-12-29 18:44:26 +053019075 * csr_create_per_roam_request() - create PER roam offload scan request
19076 *
19077 * parameters
19078 * @mac_ctx: global mac ctx
19079 * @session_id: session id
19080 *
19081 * Return: per roam config request packet buffer
19082 */
19083static struct wmi_per_roam_config_req *
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019084csr_create_per_roam_request(tpAniSirGlobal mac_ctx,
19085 uint8_t session_id)
Kapil Gupta5cda2252016-12-29 18:44:26 +053019086{
19087 struct wmi_per_roam_config_req *req_buf = NULL;
19088
19089 req_buf = qdf_mem_malloc(sizeof(struct wmi_per_roam_config_req));
19090 if (!req_buf) {
19091 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019092 "Mem alloc for per roam req failed");
Kapil Gupta5cda2252016-12-29 18:44:26 +053019093 return NULL;
19094 }
19095 req_buf->vdev_id = session_id;
19096 req_buf->per_config.enable =
19097 mac_ctx->roam.configParam.per_roam_config.enable;
19098 req_buf->per_config.tx_high_rate_thresh =
19099 mac_ctx->roam.configParam.per_roam_config.tx_high_rate_thresh;
19100 req_buf->per_config.rx_high_rate_thresh =
19101 mac_ctx->roam.configParam.per_roam_config.rx_high_rate_thresh;
19102 req_buf->per_config.tx_low_rate_thresh =
19103 mac_ctx->roam.configParam.per_roam_config.tx_low_rate_thresh;
19104 req_buf->per_config.rx_low_rate_thresh =
19105 mac_ctx->roam.configParam.per_roam_config.rx_low_rate_thresh;
19106 req_buf->per_config.per_rest_time =
19107 mac_ctx->roam.configParam.per_roam_config.per_rest_time;
Kapil Gupta957827b2017-02-13 15:47:04 +053019108 req_buf->per_config.tx_per_mon_time =
19109 mac_ctx->roam.configParam.per_roam_config.tx_per_mon_time;
19110 req_buf->per_config.rx_per_mon_time =
19111 mac_ctx->roam.configParam.per_roam_config.rx_per_mon_time;
Kapil Gupta5cda2252016-12-29 18:44:26 +053019112 req_buf->per_config.tx_rate_thresh_percnt =
19113 mac_ctx->roam.configParam.per_roam_config.tx_rate_thresh_percnt;
19114 req_buf->per_config.rx_rate_thresh_percnt =
19115 mac_ctx->roam.configParam.per_roam_config.rx_rate_thresh_percnt;
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +053019116 req_buf->per_config.min_candidate_rssi =
19117 mac_ctx->roam.configParam.per_roam_config.min_candidate_rssi;
Kapil Gupta5cda2252016-12-29 18:44:26 +053019118
19119 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +053019120 "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 +053019121 req_buf->per_config.enable, session_id,
19122 req_buf->per_config.tx_high_rate_thresh,
19123 req_buf->per_config.tx_low_rate_thresh,
19124 req_buf->per_config.tx_rate_thresh_percnt,
Kapil Gupta957827b2017-02-13 15:47:04 +053019125 req_buf->per_config.per_rest_time,
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +053019126 req_buf->per_config.tx_per_mon_time,
19127 req_buf->per_config.min_candidate_rssi);
Kapil Gupta5cda2252016-12-29 18:44:26 +053019128 return req_buf;
19129}
19130
19131/**
19132 * csr_roam_offload_per_scan() - populates roam offload scan request and sends
19133 * to WMA
19134 *
19135 * parameters
19136 * @mac_ctx: global mac ctx
19137 * @session_id: session id
19138 *
19139 * Return: result of operation
19140 */
19141static QDF_STATUS
19142csr_roam_offload_per_scan(tpAniSirGlobal mac_ctx, uint8_t session_id)
19143{
19144 tpCsrNeighborRoamControlInfo roam_info =
19145 &mac_ctx->roam.neighborRoamInfo[session_id];
19146 struct wmi_per_roam_config_req *req_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070019147 struct scheduler_msg msg = {0};
Kapil Gupta5cda2252016-12-29 18:44:26 +053019148
19149 /*
19150 * No need to update in case of stop command, FW takes care of stopping
19151 * this internally
19152 */
19153 if (roam_info->last_sent_cmd == ROAM_SCAN_OFFLOAD_STOP)
19154 return QDF_STATUS_SUCCESS;
19155
19156 if (!mac_ctx->roam.configParam.per_roam_config.enable) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019157 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
19158 "PER based roaming is disabled in configuration");
Kapil Gupta5cda2252016-12-29 18:44:26 +053019159 return QDF_STATUS_SUCCESS;
19160 }
19161
19162 req_buf = csr_create_per_roam_request(mac_ctx, session_id);
19163 if (!req_buf) {
19164 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019165 "Failed to create req packet");
Kapil Gupta5cda2252016-12-29 18:44:26 +053019166 return QDF_STATUS_E_FAILURE;
19167 }
19168 msg.type = WMA_SET_PER_ROAM_CONFIG_CMD;
19169 msg.reserved = 0;
19170 msg.bodyptr = req_buf;
19171 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
19172 &msg))) {
19173 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
19174 "%s: Unable to post WMA_SET_PER_ROAM_CONFIG_CMD to WMA",
19175 __func__);
19176 qdf_mem_free(req_buf);
19177 }
19178 return QDF_STATUS_SUCCESS;
19179}
19180
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019181#if defined(WLAN_FEATURE_FILS_SK)
19182QDF_STATUS csr_update_fils_config(tpAniSirGlobal mac, uint8_t session_id,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070019183 struct csr_roam_profile *src_profile)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019184{
19185 struct csr_roam_session *session = CSR_GET_SESSION(mac, session_id);
Jeff Johnson66ee8a92018-03-17 15:24:26 -070019186 struct csr_roam_profile *dst_profile = NULL;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019187
19188 if (!session) {
19189 sme_err("session NULL");
19190 return QDF_STATUS_E_FAILURE;
19191 }
19192
19193 dst_profile = session->pCurRoamProfile;
19194
19195 if (!dst_profile) {
19196 sme_err("Current Roam profile of SME session NULL");
19197 return QDF_STATUS_E_FAILURE;
19198 }
19199 update_profile_fils_info(dst_profile, src_profile);
19200 return QDF_STATUS_SUCCESS;
19201}
19202
19203/**
19204 * copy_all_before_char() - API to copy all character before a particular char
19205 * @str: Source string
Arif Hussain80a328a2018-03-02 00:12:48 -080019206 * @str_len: Source string legnth
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019207 * @dst: Destination string
Arif Hussain80a328a2018-03-02 00:12:48 -080019208 * @dst_len: Destination string legnth
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019209 * @c: Character before which all characters need to be copied
19210 *
19211 * Return: length of the copied string, if success. zero otherwise.
19212 */
Arif Hussain80a328a2018-03-02 00:12:48 -080019213static uint32_t copy_all_before_char(char *str, uint32_t str_len,
19214 char *dst, uint32_t dst_len, char c)
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019215{
19216 uint32_t len = 0;
19217
19218 if (!str)
19219 return len;
19220
Arif Hussain80a328a2018-03-02 00:12:48 -080019221 while ((len < str_len) && (len < dst_len) &&
19222 (*str != '\0') && (*str != c)) {
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019223 *dst++ = *str++;
19224 len++;
19225 }
Arif Hussain80a328a2018-03-02 00:12:48 -080019226
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019227 return len;
19228}
19229
19230/**
19231 * csr_update_fils_params_rso() - API to update FILS params in RSO
19232 * @mac: Mac context
19233 * @session: CSR Roam Session
19234 * @req_buffer: RSO request buffer
19235 *
19236 * Return: None
19237 */
19238static void csr_update_fils_params_rso(tpAniSirGlobal mac,
19239 struct csr_roam_session *session,
19240 tSirRoamOffloadScanReq *req_buffer)
19241{
19242 struct roam_fils_params *roam_fils_params;
19243 struct cds_fils_connection_info *fils_info;
Arif Hussaina216f672018-04-04 07:16:58 -070019244 uint32_t usr_name_len;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019245
19246 if (!session->pCurRoamProfile)
19247 return;
19248
19249 fils_info = session->pCurRoamProfile->fils_con_info;
19250 if (!fils_info || !req_buffer)
19251 return;
19252
Vignesh Viswanathan925db8c2018-01-09 17:20:19 +053019253 if (!fils_info->key_nai_length) {
Vignesh Viswanathan04f87952017-11-04 00:46:10 +053019254 sme_debug("key_nai_length is NULL");
19255 return;
19256 }
19257
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019258 roam_fils_params = &req_buffer->roam_fils_params;
19259 if ((fils_info->key_nai_length > FILS_MAX_KEYNAME_NAI_LENGTH) ||
19260 (fils_info->r_rk_length > FILS_MAX_RRK_LENGTH)) {
19261 sme_err("Fils info len error: keyname nai len(%d) rrk len(%d)",
19262 fils_info->key_nai_length, fils_info->r_rk_length);
19263 return;
19264 }
19265
Arif Hussaina216f672018-04-04 07:16:58 -070019266 usr_name_len = copy_all_before_char(fils_info->keyname_nai,
19267 sizeof(fils_info->keyname_nai),
19268 roam_fils_params->username,
19269 sizeof(roam_fils_params->username),
19270 '@');
19271 if (fils_info->key_nai_length <= usr_name_len) {
19272 sme_err("Fils info len error: key nai len %d, user name len %d",
19273 fils_info->key_nai_length, usr_name_len);
19274 return;
19275 }
19276
19277 roam_fils_params->username_length = usr_name_len;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019278 req_buffer->is_fils_connection = true;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019279
19280 roam_fils_params->next_erp_seq_num =
19281 (fils_info->sequence_number + 1);
19282
19283 roam_fils_params->rrk_length = fils_info->r_rk_length;
19284 qdf_mem_copy(roam_fils_params->rrk, fils_info->r_rk,
19285 roam_fils_params->rrk_length);
19286
19287 /* REALM info */
19288 roam_fils_params->realm_len = fils_info->key_nai_length
19289 - roam_fils_params->username_length - 1;
19290 qdf_mem_copy(roam_fils_params->realm, fils_info->keyname_nai
19291 + roam_fils_params->username_length + 1,
19292 roam_fils_params->realm_len);
19293}
19294#else
19295static inline void csr_update_fils_params_rso(tpAniSirGlobal mac,
19296 struct csr_roam_session *session,
19297 tSirRoamOffloadScanReq *req_buffer)
19298{}
19299#endif
19300
Kapil Gupta5cda2252016-12-29 18:44:26 +053019301/**
Himanshu Agarwal8bcec572017-09-28 11:54:37 +053019302 * csr_update_score_params() - API to update Score params in RSO
19303 * @mac_ctx: Mac context
19304 * @req_buffer: RSO request buffer
19305 *
19306 * Return: None
19307 */
19308static void csr_update_score_params(tpAniSirGlobal mac_ctx,
19309 tSirRoamOffloadScanReq *req_buffer)
19310{
19311 struct scoring_param *req_score_params;
19312 struct rssi_scoring *req_rssi_score;
19313 struct sir_score_config *bss_score_params;
19314 struct sir_weight_config *weight_config;
19315 struct sir_rssi_cfg_score *rssi_score;
19316
19317 req_score_params = &req_buffer->score_params;
19318 req_rssi_score = &req_score_params->rssi_scoring;
19319
19320 bss_score_params = &mac_ctx->roam.configParam.bss_score_params;
19321 weight_config = &bss_score_params->weight_cfg;
19322 rssi_score = &bss_score_params->rssi_score;
19323
19324 if (!bss_score_params->enable_scoring_for_roam)
19325 req_score_params->disable_bitmap =
19326 WLAN_ROAM_SCORING_DISABLE_ALL;
19327
19328 req_score_params->rssi_weightage = weight_config->rssi_weightage;
19329 req_score_params->ht_weightage = weight_config->ht_caps_weightage;
19330 req_score_params->vht_weightage = weight_config->vht_caps_weightage;
19331 req_score_params->he_weightage = weight_config->he_caps_weightage;
19332 req_score_params->bw_weightage = weight_config->chan_width_weightage;
19333 req_score_params->band_weightage = weight_config->chan_band_weightage;
19334 req_score_params->nss_weightage = weight_config->nss_weightage;
19335 req_score_params->esp_qbss_weightage =
19336 weight_config->channel_congestion_weightage;
19337 req_score_params->beamforming_weightage =
19338 weight_config->beamforming_cap_weightage;
19339 req_score_params->pcl_weightage =
19340 weight_config->pcl_weightage;
19341 req_score_params->oce_wan_weightage = weight_config->oce_wan_weightage;
19342
19343 req_score_params->bw_index_score =
19344 bss_score_params->bandwidth_weight_per_index;
19345 req_score_params->band_index_score =
19346 bss_score_params->band_weight_per_index;
19347 req_score_params->nss_index_score =
19348 bss_score_params->nss_weight_per_index;
19349
19350 req_rssi_score->best_rssi_threshold = rssi_score->best_rssi_threshold;
19351 req_rssi_score->good_rssi_threshold = rssi_score->good_rssi_threshold;
19352 req_rssi_score->bad_rssi_threshold = rssi_score->bad_rssi_threshold;
19353 req_rssi_score->good_rssi_pcnt = rssi_score->good_rssi_pcnt;
19354 req_rssi_score->bad_rssi_pcnt = rssi_score->bad_rssi_pcnt;
19355 req_rssi_score->good_bucket_size = rssi_score->good_rssi_bucket_size;
19356 req_rssi_score->bad_bucket_size = rssi_score->bad_rssi_bucket_size;
19357 req_rssi_score->rssi_pref_5g_rssi_thresh =
19358 rssi_score->rssi_pref_5g_rssi_thresh;
19359
19360 req_score_params->esp_qbss_scoring.num_slot =
19361 bss_score_params->esp_qbss_scoring.num_slot;
19362 req_score_params->esp_qbss_scoring.score_pcnt3_to_0 =
19363 bss_score_params->esp_qbss_scoring.score_pcnt3_to_0;
19364 req_score_params->esp_qbss_scoring.score_pcnt7_to_4 =
19365 bss_score_params->esp_qbss_scoring.score_pcnt7_to_4;
19366 req_score_params->esp_qbss_scoring.score_pcnt11_to_8 =
19367 bss_score_params->esp_qbss_scoring.score_pcnt11_to_8;
19368 req_score_params->esp_qbss_scoring.score_pcnt15_to_12 =
19369 bss_score_params->esp_qbss_scoring.score_pcnt15_to_12;
19370
19371 req_score_params->oce_wan_scoring.num_slot =
19372 bss_score_params->oce_wan_scoring.num_slot;
19373 req_score_params->oce_wan_scoring.score_pcnt3_to_0 =
19374 bss_score_params->oce_wan_scoring.score_pcnt3_to_0;
19375 req_score_params->oce_wan_scoring.score_pcnt7_to_4 =
19376 bss_score_params->oce_wan_scoring.score_pcnt7_to_4;
19377 req_score_params->oce_wan_scoring.score_pcnt11_to_8 =
19378 bss_score_params->oce_wan_scoring.score_pcnt11_to_8;
19379 req_score_params->oce_wan_scoring.score_pcnt15_to_12 =
19380 bss_score_params->oce_wan_scoring.score_pcnt15_to_12;
19381}
19382
Abhishek Singh1f217ec2017-12-22 11:48:27 +053019383uint8_t csr_get_roam_enabled_sta_sessionid(tpAniSirGlobal mac_ctx)
19384{
19385 struct csr_roam_session *session;
19386 tpCsrNeighborRoamControlInfo roam_info;
19387 uint8_t i;
19388
19389 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
19390 session = CSR_GET_SESSION(mac_ctx, i);
19391 if (!session || !CSR_IS_SESSION_VALID(mac_ctx, i))
19392 continue;
19393 if (!session->pCurRoamProfile ||
19394 session->pCurRoamProfile->csrPersona != QDF_STA_MODE)
19395 continue;
19396 roam_info = &mac_ctx->roam.neighborRoamInfo[i];
19397 if (roam_info->b_roam_scan_offload_started) {
19398 sme_debug("Roaming enabled on iface, session: %d", i);
19399 return i;
19400 }
19401 }
19402
19403 return CSR_SESSION_ID_INVALID;
19404}
19405
Himanshu Agarwal8bcec572017-09-28 11:54:37 +053019406/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019407 * csr_roam_offload_scan() - populates roam offload scan request and sends to
19408 * WMA
19409 *
Jeff Johnson60ed45a2018-05-06 15:28:49 -070019410 * parameters
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019411 * @mac_ctx: global mac ctx
19412 * @session_id: session id
19413 * @command: roam scan offload command input
19414 * @reason: reason to roam
19415 *
19416 * Return: result of operation
19417 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019418QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019419csr_roam_offload_scan(tpAniSirGlobal mac_ctx, uint8_t session_id,
19420 uint8_t command, uint8_t reason)
19421{
19422 uint8_t *state = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019423 tSirRoamOffloadScanReq *req_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019424 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019425 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019426 tpCsrNeighborRoamControlInfo roam_info =
19427 &mac_ctx->roam.neighborRoamInfo[session_id];
19428 struct roam_ext_params *roam_params_dst;
19429 struct roam_ext_params *roam_params_src;
Abhishek Singh1f217ec2017-12-22 11:48:27 +053019430 uint8_t i, temp_session_id;
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080019431 uint8_t op_channel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019432
Abhishek Singh1f217ec2017-12-22 11:48:27 +053019433 sme_debug("RSO Command %d, Session id %d, Reason %d", command,
19434 session_id, reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019435 if (NULL == session) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019436 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019437 "session is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019438 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019439 }
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +053019440
Abhishek Singh1f217ec2017-12-22 11:48:27 +053019441 temp_session_id = csr_get_roam_enabled_sta_sessionid(mac_ctx);
19442 if ((temp_session_id != CSR_SESSION_ID_INVALID) &&
19443 (session_id != temp_session_id)) {
19444 sme_debug("Roam cmd not for session %d on which roaming is enabled",
19445 temp_session_id);
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -070019446 return QDF_STATUS_E_FAILURE;
19447 }
19448
Selvaraj, Sridhar50566502017-05-15 18:26:47 +053019449 if ((ROAM_SCAN_OFFLOAD_START == command &&
Varun Reddy Yeturue5a35d12017-10-20 11:26:57 -070019450 REASON_CTX_INIT != reason) &&
19451 (session->pCurRoamProfile &&
19452 session->pCurRoamProfile->supplicant_disabled_roaming)) {
Selvaraj, Sridhar50566502017-05-15 18:26:47 +053019453 sme_debug("Supplicant disabled driver roaming");
19454 return QDF_STATUS_E_FAILURE;
19455 }
19456
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019457 if (0 == csr_roam_is_roam_offload_scan_enabled(mac_ctx)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019458 sme_err("isRoamOffloadScanEnabled not set");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019459 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019460 }
19461 if (!csr_is_RSO_cmd_allowed(mac_ctx, command, session_id) &&
19462 reason != REASON_ROAM_SET_BLACKLIST_BSSID) {
Srinivas Girigowda6598eea2017-07-06 19:26:19 -070019463 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019464 ("RSO out-of-sync command %d lastSentCmd %d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019465 command, roam_info->last_sent_cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019466 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019467 }
19468
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070019469 if ((true == roam_info->b_roam_scan_offload_started)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019470 && (ROAM_SCAN_OFFLOAD_START == command)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019471 sme_err("Roam Scan Offload is already started");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019472 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019473 }
Vignesh Viswanathan731186f2017-09-18 13:47:37 +053019474
19475 /* Roaming is not supported currently for FILS akm */
19476 if (session->pCurRoamProfile && CSR_IS_AUTH_TYPE_FILS(
19477 session->pCurRoamProfile->AuthType.authType[0]) &&
19478 !mac_ctx->is_fils_roaming_supported) {
19479 sme_info("FILS Roaming not suppprted by fw");
19480 return QDF_STATUS_SUCCESS;
19481 }
19482
Padma, Santhosh Kumar9d896c22017-11-10 15:33:52 +053019483 /* Roaming is not supported currently for OWE akm */
19484 if (session->pCurRoamProfile &&
19485 (session->pCurRoamProfile->AuthType.authType[0] ==
19486 eCSR_AUTH_TYPE_OWE)) {
19487 sme_info("OWE Roaming not suppprted by fw");
19488 return QDF_STATUS_SUCCESS;
19489 }
19490
Padma, Santhosh Kumar2b1e57e2017-09-14 14:42:43 +053019491 /* Roaming is not supported currently for SAE authentication */
19492 if (session->pCurRoamProfile &&
19493 CSR_IS_AUTH_TYPE_SAE(
19494 session->pCurRoamProfile->AuthType.authType[0])) {
19495 sme_info("Roaming not suppprted for SAE connection");
19496 return QDF_STATUS_SUCCESS;
19497 }
19498
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019499 /*
19500 * The Dynamic Config Items Update may happen even if the state is in
19501 * INIT. It is important to ensure that the command is passed down to
Naveen Rawat224ae9c2016-10-24 15:36:56 -070019502 * the FW only if the Infra Station is in a connected state. A connected
19503 * station could also be in a PREAUTH or REASSOC states.
19504 * 1) Block all CMDs that are not STOP in INIT State. For STOP always
19505 * inform firmware irrespective of state.
19506 * 2) Block update cfg CMD if its for REASON_ROAM_SET_BLACKLIST_BSSID,
19507 * because we need to inform firmware of blacklisted AP for PNO in
19508 * all states.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019509 */
19510
19511 if ((roam_info->neighborRoamState ==
19512 eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
19513 (command != ROAM_SCAN_OFFLOAD_STOP) &&
19514 (reason != REASON_ROAM_SET_BLACKLIST_BSSID)) {
19515 state = mac_trace_get_neighbour_roam_state(
19516 roam_info->neighborRoamState);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019517 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019518 FL("Scan Command not sent to FW state=%s and cmd=%d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019519 state, command);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019520 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019521 }
19522
19523 req_buf = csr_create_roam_scan_offload_request(mac_ctx, command,
19524 session_id, reason,
19525 session, roam_info);
19526 if (!req_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019527 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019528 "Failed to create req packet");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019529 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019530 }
19531 roam_params_dst = &req_buf->roam_params;
19532 roam_params_src = &mac_ctx->roam.configParam.roam_params;
19533 if (reason == REASON_ROAM_SET_SSID_ALLOWED)
19534 check_allowed_ssid_list(req_buf, roam_params_src);
Abhishek Singh4db8c152017-07-18 10:40:08 +053019535
19536 /*
19537 * For CTX INT cmd if rssi disallow bssid list have any member
19538 * fill it and send it to firmware so that firmware does not
Jeff Johnson7fa88f72018-05-10 14:52:20 -070019539 * try to roam to these BSS until RSSI OR time condition are
Abhishek Singh4db8c152017-07-18 10:40:08 +053019540 * matched.
19541 */
19542 if (reason == REASON_CTX_INIT)
19543 csr_add_rssi_reject_ap_list(mac_ctx, roam_params_src);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019544 /*
19545 * Configure the lookup threshold either from INI or from framework.
19546 * If both are present, give higher priority to the one from framework.
19547 */
19548 if (roam_params_src->alert_rssi_threshold)
19549 req_buf->LookupThreshold =
19550 roam_params_src->alert_rssi_threshold;
19551 else
19552 req_buf->LookupThreshold =
19553 (int8_t)roam_info->cfgParams.neighborLookupThreshold *
19554 (-1);
Varun Reddy Yeturu168134f2017-06-26 13:46:05 -070019555 req_buf->rssi_thresh_offset_5g =
19556 roam_info->cfgParams.rssi_thresh_offset_5g;
19557 sme_debug("5g offset threshold: %d", req_buf->rssi_thresh_offset_5g);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019558 qdf_mem_copy(roam_params_dst, roam_params_src,
Varun Reddy Yeturufaad37e2017-07-26 10:54:13 -070019559 sizeof(*roam_params_dst));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019560 /*
19561 * rssi_diff which is updated via framework is equivalent to the
19562 * INI RoamRssiDiff parameter and hence should be updated.
19563 */
19564 if (roam_params_src->rssi_diff)
19565 req_buf->RoamRssiDiff = roam_params_src->rssi_diff;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019566 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019567 "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 -080019568 roam_params_dst->num_bssid_avoid_list,
19569 roam_params_dst->num_ssid_allowed_list,
19570 roam_params_dst->num_bssid_favored,
19571 roam_params_dst->raise_rssi_thresh_5g,
19572 roam_params_dst->drop_rssi_thresh_5g,
19573 roam_params_dst->raise_rssi_type_5g,
19574 roam_params_dst->raise_factor_5g,
19575 roam_params_dst->drop_rssi_type_5g,
19576 roam_params_dst->drop_factor_5g,
19577 roam_params_dst->max_raise_rssi_5g,
19578 roam_params_dst->max_drop_rssi_5g,
19579 req_buf->RoamRssiDiff, roam_params_dst->alert_rssi_threshold);
19580
Gupta, Kapil71221252016-06-28 15:35:02 +053019581 /* Set initial dense roam status */
Kapil Gupta0a2477b2016-08-23 18:00:34 +053019582 if (mac_ctx->scan.roam_candidate_count[session_id] >
Gupta, Kapil71221252016-06-28 15:35:02 +053019583 roam_params_dst->dense_min_aps_cnt)
19584 roam_params_dst->initial_dense_status = true;
19585
Kapil Gupta0a2477b2016-08-23 18:00:34 +053019586 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Selvaraj, Sridhard1225e62017-03-17 12:56:58 +053019587 "dense_rssi_thresh_offset: %d, dense_min_aps_cnt:%d, traffic_threshold:%d, "
19588 "initial_dense_status:%d, candidate count:%d",
19589 roam_params_dst->dense_rssi_thresh_offset,
19590 roam_params_dst->dense_min_aps_cnt,
19591 roam_params_dst->traffic_threshold,
19592 roam_params_dst->initial_dense_status,
19593 mac_ctx->scan.roam_candidate_count[session_id]);
Vignesh Viswanathanc018e982017-09-07 18:49:19 +053019594 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 -070019595 roam_params_dst->bg_scan_bad_rssi_thresh,
Vignesh Viswanathanc018e982017-09-07 18:49:19 +053019596 roam_params_dst->bg_scan_client_bitmap,
19597 roam_params_dst->roam_bad_rssi_thresh_offset_2g);
Kapil Gupta0a2477b2016-08-23 18:00:34 +053019598
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019599 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019600 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019601 "Blacklist Bssid:"MAC_ADDRESS_STR")",
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019602 MAC_ADDR_ARRAY(roam_params_dst->bssid_avoid_list[i].
19603 bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019604 }
19605 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019606 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019607 "Whitelist: %.*s",
19608 roam_params_dst->ssid_allowed_list[i].length,
19609 roam_params_dst->ssid_allowed_list[i].ssId);
19610 }
19611 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019612 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019613 "Preferred Bssid:"MAC_ADDRESS_STR") score: %d",
Srinivas Girigowdab0532392015-11-24 11:50:16 -080019614 MAC_ADDR_ARRAY(roam_params_dst->bssid_favored[i].bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019615 roam_params_dst->bssid_favored_factor[i]);
19616 }
19617
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080019618 op_channel = session->connectedProfile.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019619 req_buf->hi_rssi_scan_max_count =
19620 roam_info->cfgParams.hi_rssi_scan_max_count;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019621 req_buf->hi_rssi_scan_delay =
19622 roam_info->cfgParams.hi_rssi_scan_delay;
19623 req_buf->hi_rssi_scan_rssi_ub =
19624 roam_info->cfgParams.hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080019625 /*
19626 * If the current operation channel is 5G frequency band, then
19627 * there is no need to enable the HI_RSSI feature. This feature
19628 * is useful only if we are connected to a 2.4 GHz AP and we wish
19629 * to connect to a better 5GHz AP is available.
19630 */
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070019631 if (session->disable_hi_rssi)
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080019632 req_buf->hi_rssi_scan_rssi_delta = 0;
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070019633 else
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080019634 req_buf->hi_rssi_scan_rssi_delta =
19635 roam_info->cfgParams.hi_rssi_scan_rssi_delta;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019636 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080019637 "hi_rssi:delta=%d, max_count=%d, delay=%d, ub=%d",
19638 req_buf->hi_rssi_scan_rssi_delta,
19639 req_buf->hi_rssi_scan_max_count,
19640 req_buf->hi_rssi_scan_delay,
19641 req_buf->hi_rssi_scan_rssi_ub);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019642
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053019643 if (command != ROAM_SCAN_OFFLOAD_STOP) {
Naveen Rawatf311a5a2016-11-15 23:38:10 -080019644 req_buf->assoc_ie.length = session->nAddIEAssocLength;
Selvaraj, Sridhara7fc7632016-09-04 13:13:38 +053019645 qdf_mem_copy(req_buf->assoc_ie.addIEdata,
19646 session->pAddIEAssoc,
19647 session->nAddIEAssocLength);
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053019648 csr_update_driver_assoc_ies(mac_ctx, session, req_buf);
Himanshu Agarwal8bcec572017-09-28 11:54:37 +053019649 csr_update_score_params(mac_ctx, req_buf);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053019650 csr_update_fils_params_rso(mac_ctx, session, req_buf);
Selvaraj, Sridhara7fc7632016-09-04 13:13:38 +053019651 }
19652
Vignesh Viswanathane25af782018-03-23 14:49:50 +053019653 /*
19654 * 11k offload is enabled during RSO Start after connect indication and
19655 * 11k offload is disabled during RSO Stop after disconnect indication
19656 */
19657 if (command == ROAM_SCAN_OFFLOAD_START &&
19658 reason == REASON_CTX_INIT)
19659 csr_update_11k_offload_params(mac_ctx, session, req_buf, TRUE);
19660 else if (command == ROAM_SCAN_OFFLOAD_STOP &&
19661 reason == REASON_DISCONNECTED)
19662 csr_update_11k_offload_params(mac_ctx, session, req_buf, FALSE);
19663
Selvaraj, Sridhard1225e62017-03-17 12:56:58 +053019664 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
19665 "Assoc IE buffer:");
19666 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
19667 req_buf->assoc_ie.addIEdata, req_buf->assoc_ie.length);
19668
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053019669 if (!QDF_IS_STATUS_SUCCESS(
19670 csr_roam_send_rso_cmd(mac_ctx, session_id, req_buf))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019671 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053019672 "%s: Not able to post message to PE",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019673 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019674 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019675 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019676 if (ROAM_SCAN_OFFLOAD_START == command)
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070019677 roam_info->b_roam_scan_offload_started = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019678 else if (ROAM_SCAN_OFFLOAD_STOP == command)
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070019679 roam_info->b_roam_scan_offload_started = false;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019681 /* update the last sent cmd */
19682 roam_info->last_sent_cmd = command;
19683
Kapil Gupta5cda2252016-12-29 18:44:26 +053019684 /* Update PER config to FW after sending the command */
19685 csr_roam_offload_per_scan(mac_ctx, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019686 return status;
19687}
19688
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019689QDF_STATUS csr_roam_offload_scan_rsp_hdlr(tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019690 tpSirRoamOffloadScanRsp
19691 scanOffloadRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019692{
19693 switch (scanOffloadRsp->reason) {
19694 case 0:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019695 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019696 "Rsp for Roam Scan Offload with failure status");
19697 break;
19698 case REASON_OS_REQUESTED_ROAMING_NOW:
19699 csr_neighbor_roam_proceed_with_handoff_req(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019700 scanOffloadRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019701 break;
19702
19703 default:
Abhishek Singh245182f2017-08-10 17:41:09 +053019704 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019705 "Rsp for Roam Scan Offload with reason %d",
19706 scanOffloadRsp->reason);
19707 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019708 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019709}
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080019710#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019711
Naveen Rawatfa2a1002018-05-17 16:06:37 -070019712#ifndef QCA_SUPPORT_CP_STATS
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019713/* pStaEntry is no longer invalid upon the return of this function. */
19714static void csr_roam_remove_stat_list_entry(tpAniSirGlobal pMac,
19715 tListElem *pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019716{
19717 if (pEntry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019718 if (csr_ll_remove_entry(&pMac->roam.statsClientReqList,
19719 pEntry, LL_ACCESS_LOCK))
19720 qdf_mem_free(GET_BASE_ADDR(pEntry,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019721 struct csr_statsclient_reqinfo, link));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019722 }
19723}
19724
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019725static void csr_roam_remove_entry_from_pe_stats_req_list(
19726tpAniSirGlobal pMac, struct csr_pestats_reqinfo *pPeStaEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019727{
19728 tListElem *pEntry;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019729 struct csr_pestats_reqinfo *pTempStaEntry;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019730
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019731 pEntry = csr_ll_peek_head(&pMac->roam.peStatsReqList, LL_ACCESS_LOCK);
19732 if (!pEntry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019733 sme_err("List empty, no stats req for PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019734 return;
19735 }
19736 while (pEntry) {
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019737 pTempStaEntry = GET_BASE_ADDR(pEntry,
19738 struct csr_pestats_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019739 if (NULL == pTempStaEntry
19740 || (pTempStaEntry->statsMask !=
19741 pPeStaEntry->statsMask)) {
19742 pEntry = csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
19743 LL_ACCESS_NOLOCK);
19744 continue;
19745 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019746 sme_debug("Match found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019747 if (csr_ll_remove_entry(&pMac->roam.peStatsReqList, pEntry,
19748 LL_ACCESS_LOCK)) {
Naveen Rawatd0ca4412017-06-16 14:19:19 -070019749 qdf_mem_free(pTempStaEntry);
19750 pTempStaEntry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019751 break;
19752 }
19753 pEntry = csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
19754 LL_ACCESS_NOLOCK);
19755 } /* end of while loop */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019756}
19757
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019758static void csr_roam_report_statistics(tpAniSirGlobal pMac,
19759 uint32_t statsMask,
19760 tCsrStatsCallback callback, uint8_t staId,
19761 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019762{
19763 uint8_t stats[500];
19764 uint8_t *pStats = NULL;
19765 uint32_t tempMask = 0;
19766 uint8_t counter = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019767
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019768 if (!callback) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019769 sme_err("Cannot report callback NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019770 return;
19771 }
19772 if (!statsMask) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019773 sme_err("Cannot report statsMask is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019774 return;
19775 }
19776 pStats = stats;
19777 tempMask = statsMask;
19778 while (tempMask) {
19779 if (tempMask & 1) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019780 /* new stats info from PE, fill up the stats
19781 * strucutres in PMAC
19782 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019783 switch (counter) {
19784 case eCsrSummaryStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019785 sme_debug("Summary stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019786 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019787 (uint8_t *) &pMac->roam.
19788 summaryStatsInfo,
19789 sizeof(tCsrSummaryStatsInfo));
19790 pStats += sizeof(tCsrSummaryStatsInfo);
19791 break;
19792 case eCsrGlobalClassAStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019793 sme_debug("ClassA stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019794 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019795 (uint8_t *) &pMac->roam.
19796 classAStatsInfo,
19797 sizeof(tCsrGlobalClassAStatsInfo));
19798 pStats += sizeof(tCsrGlobalClassAStatsInfo);
19799 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019800 case eCsrGlobalClassDStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019801 sme_debug("ClassD stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019802 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019803 (uint8_t *) &pMac->roam.
19804 classDStatsInfo,
19805 sizeof(tCsrGlobalClassDStatsInfo));
19806 pStats += sizeof(tCsrGlobalClassDStatsInfo);
19807 break;
Himanshu Agarwal37e42412016-07-21 14:35:09 +053019808 case csr_per_chain_rssi_stats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019809 sme_debug("Per Chain RSSI stats");
Himanshu Agarwal37e42412016-07-21 14:35:09 +053019810 qdf_mem_copy(pStats,
19811 (uint8_t *)&pMac->roam.per_chain_rssi_stats,
19812 sizeof(struct csr_per_chain_rssi_stats_info));
19813 pStats += sizeof(
19814 struct csr_per_chain_rssi_stats_info);
19815 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019816 default:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019817 sme_err(
19818 "Unknown stats type and counter %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019819 counter);
19820 break;
19821 }
19822 }
19823 tempMask >>= 1;
19824 counter++;
19825 }
19826 callback(stats, pContext);
19827}
19828
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019829static QDF_STATUS csr_roam_dereg_statistics_req(
19830 tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019831{
19832 tListElem *pEntry = NULL;
19833 tListElem *pPrevEntry = NULL;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019834 struct csr_statsclient_reqinfo *pTempStaEntry = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019835 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019836
19837 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList,
19838 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019839 if (!pEntry) {
19840 /* list empty */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019841 sme_debug("List empty, no request from upper layer client(s)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019842 return status;
19843 }
19844 while (pEntry) {
19845 if (pPrevEntry) {
19846 pTempStaEntry =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019847 GET_BASE_ADDR(pPrevEntry,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019848 struct csr_statsclient_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019849 /* send up the stats report */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019850 csr_roam_report_statistics(pMac,
19851 pTempStaEntry->statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019852 pTempStaEntry->callback,
19853 pTempStaEntry->staId,
19854 pTempStaEntry->pContext);
19855 csr_roam_remove_stat_list_entry(pMac, pPrevEntry);
19856 }
19857 pTempStaEntry =
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019858 GET_BASE_ADDR(pEntry, struct csr_statsclient_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019859 if (pTempStaEntry->pPeStaEntry) {
19860 /* pPeStaEntry can be NULL */
19861 pTempStaEntry->pPeStaEntry->numClient--;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019862 /* check if we need to delete the entry from
19863 * peStatsReqList too
19864 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019865 if (!pTempStaEntry->pPeStaEntry->numClient) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019866 csr_roam_remove_entry_from_pe_stats_req_list(
19867 pMac,
19868 pTempStaEntry->
19869 pPeStaEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019870 }
19871 }
19872 /* check if we need to stop the tl stats timer too */
19873 pMac->roam.tlStatsReqInfo.numClient--;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019874 pPrevEntry = pEntry;
Naveen Rawatd0ca4412017-06-16 14:19:19 -070019875 pEntry = csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
19876 LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019877 }
19878 /* the last one */
19879 if (pPrevEntry) {
19880 pTempStaEntry =
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019881 GET_BASE_ADDR(pPrevEntry, struct csr_statsclient_reqinfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019882 /* send up the stats report */
19883 csr_roam_report_statistics(pMac, pTempStaEntry->statsMask,
19884 pTempStaEntry->callback,
19885 pTempStaEntry->staId,
19886 pTempStaEntry->pContext);
19887 csr_roam_remove_stat_list_entry(pMac, pPrevEntry);
19888 }
19889 return status;
19890
19891}
Naveen Rawatfa2a1002018-05-17 16:06:37 -070019892#endif /* QCA_SUPPORT_CP_STATS */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019893
19894tSmeCmd *csr_get_command_buffer(tpAniSirGlobal pMac)
19895{
19896 tSmeCmd *pCmd = sme_get_command_buffer(pMac);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019897
19898 if (pCmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019899 pMac->roam.sPendingCommands++;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019900
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019901 return pCmd;
19902}
19903
Krunal Sonidea45952017-02-15 11:58:15 -080019904static void csr_free_cmd_memory(tpAniSirGlobal pMac, tSmeCmd *pCommand)
19905{
19906 if (!pCommand) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070019907 sme_err("pCommand is NULL");
Krunal Sonidea45952017-02-15 11:58:15 -080019908 return;
19909 }
19910 switch (pCommand->command) {
Krunal Sonidea45952017-02-15 11:58:15 -080019911 case eSmeCommandRoam:
19912 csr_release_command_roam(pMac, pCommand);
19913 break;
19914 case eSmeCommandWmStatusChange:
19915 csr_release_command_wm_status_change(pMac, pCommand);
19916 break;
Krunal Sonidea45952017-02-15 11:58:15 -080019917 default:
19918 break;
19919 }
19920}
19921
Krunal Sonia8270f52017-02-23 19:51:25 -080019922void csr_release_command_buffer(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019923{
19924 if (pMac->roam.sPendingCommands > 0) {
Krunal Sonidea45952017-02-15 11:58:15 -080019925 /*
19926 * All command allocated through csr_get_command_buffer
19927 * need to decrement the pending count when releasing
19928 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019929 pMac->roam.sPendingCommands--;
Krunal Sonidea45952017-02-15 11:58:15 -080019930 csr_free_cmd_memory(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019931 sme_release_command(pMac, pCommand);
19932 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019933 sme_err("no pending commands");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019934 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019935 }
19936}
19937
Krunal Sonia8270f52017-02-23 19:51:25 -080019938void csr_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019939{
Krunal Sonia8270f52017-02-23 19:51:25 -080019940 struct wlan_serialization_queued_cmd_info cmd_info;
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080019941 struct wlan_serialization_command cmd;
Krunal Sonic3c8b8b2017-06-19 13:52:37 -070019942 struct wlan_objmgr_vdev *vdev;
Krunal Sonia8270f52017-02-23 19:51:25 -080019943
19944 if (!sme_cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019945 sme_err("sme_cmd is NULL");
Krunal Sonia8270f52017-02-23 19:51:25 -080019946 return;
19947 }
Krunal Sonic3c8b8b2017-06-19 13:52:37 -070019948 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
19949 sme_cmd->sessionId, WLAN_LEGACY_SME_ID);
19950 if (!vdev) {
19951 sme_err("Invalid vdev");
19952 return;
19953 }
Krunal Soni81f068c2017-02-23 19:51:55 -080019954 qdf_mem_zero(&cmd_info,
19955 sizeof(struct wlan_serialization_queued_cmd_info));
Abhinav Kumarf9989582018-02-06 17:42:22 +053019956
19957 sme_debug("filled cmd_id = 0");
19958 cmd_info.cmd_id = 0;
19959 cmd_info.req_type = WLAN_SER_CANCEL_NON_SCAN_CMD;
Krunal Soni81f068c2017-02-23 19:51:55 -080019960 cmd_info.cmd_type = csr_get_cmd_type(sme_cmd);
Krunal Sonic3c8b8b2017-06-19 13:52:37 -070019961 cmd_info.vdev = vdev;
19962 qdf_mem_zero(&cmd, sizeof(struct wlan_serialization_command));
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080019963 cmd.cmd_id = cmd_info.cmd_id;
19964 cmd.cmd_type = cmd_info.cmd_type;
19965 cmd.vdev = cmd_info.vdev;
Krunal Soni81f068c2017-02-23 19:51:55 -080019966 if (wlan_serialization_is_cmd_present_in_active_queue(
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080019967 mac_ctx->psoc, &cmd)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019968 sme_debug("Releasing active cmd_id[%d] cmd_type[%d]",
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080019969 cmd_info.cmd_id, cmd_info.cmd_type);
Krunal Soni81f068c2017-02-23 19:51:55 -080019970 wlan_serialization_remove_cmd(&cmd_info);
19971 } else if (wlan_serialization_is_cmd_present_in_pending_queue(
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080019972 mac_ctx->psoc, &cmd)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019973 sme_debug("Releasing pending cmd_id[%d] cmd_type[%d]",
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080019974 cmd_info.cmd_id, cmd_info.cmd_type);
Krunal Soni81f068c2017-02-23 19:51:55 -080019975 wlan_serialization_cancel_request(&cmd_info);
19976 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019977 sme_debug("can't find cmd_id[%d] cmd_type[%d]",
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080019978 cmd_info.cmd_id, cmd_info.cmd_type);
Krunal Sonia8270f52017-02-23 19:51:25 -080019979 }
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080019980 if (cmd_info.vdev)
19981 wlan_objmgr_vdev_release_ref(cmd_info.vdev, WLAN_LEGACY_SME_ID);
Krunal Sonia8270f52017-02-23 19:51:25 -080019982}
19983
Krunal Sonia8270f52017-02-23 19:51:25 -080019984
gaurank kathpalia14e2f912017-08-31 14:51:45 +053019985static enum wlan_serialization_cmd_type csr_get_roam_cmd_type(
19986 tSmeCmd *sme_cmd)
Krunal Sonia8270f52017-02-23 19:51:25 -080019987{
19988 enum wlan_serialization_cmd_type cmd_type = WLAN_SER_CMD_MAX;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -070019989
Krunal Sonia8270f52017-02-23 19:51:25 -080019990 switch (sme_cmd->u.roamCmd.roamReason) {
19991 case eCsrForcedDisassoc:
19992 cmd_type = WLAN_SER_CMD_FORCE_DISASSOC;
19993 break;
19994 case eCsrHddIssued:
19995 cmd_type = WLAN_SER_CMD_HDD_ISSUED;
19996 break;
19997 case eCsrLostLink1:
19998 cmd_type = WLAN_SER_CMD_LOST_LINK1;
19999 break;
20000 case eCsrLostLink2:
20001 cmd_type = WLAN_SER_CMD_LOST_LINK2;
20002 break;
20003 case eCsrLostLink3:
20004 cmd_type = WLAN_SER_CMD_LOST_LINK3;
20005 break;
20006 case eCsrForcedDisassocMICFailure:
20007 cmd_type = WLAN_SER_CMD_FORCE_DISASSOC_MIC_FAIL;
20008 break;
20009 case eCsrHddIssuedReassocToSameAP:
20010 cmd_type = WLAN_SER_CMD_HDD_ISSUE_REASSOC_SAME_AP;
20011 break;
20012 case eCsrSmeIssuedReassocToSameAP:
20013 cmd_type = WLAN_SER_CMD_SME_ISSUE_REASSOC_SAME_AP;
20014 break;
Krunal Sonia8270f52017-02-23 19:51:25 -080020015 case eCsrForcedDeauth:
20016 cmd_type = WLAN_SER_CMD_FORCE_DEAUTH;
20017 break;
20018 case eCsrSmeIssuedDisassocForHandoff:
20019 cmd_type =
20020 WLAN_SER_CMD_SME_ISSUE_DISASSOC_FOR_HANDOFF;
20021 break;
20022 case eCsrSmeIssuedAssocToSimilarAP:
20023 cmd_type =
20024 WLAN_SER_CMD_SME_ISSUE_ASSOC_TO_SIMILAR_AP;
20025 break;
20026 case eCsrSmeIssuedIbssJoinFailure:
20027 cmd_type = WLAN_SER_CMD_SME_ISSUE_IBSS_JOIN_FAIL;
20028 break;
20029 case eCsrForcedIbssLeave:
20030 cmd_type = WLAN_SER_CMD_FORCE_IBSS_LEAVE;
20031 break;
20032 case eCsrStopBss:
20033 cmd_type = WLAN_SER_CMD_STOP_BSS;
20034 break;
20035 case eCsrSmeIssuedFTReassoc:
20036 cmd_type = WLAN_SER_CMD_SME_ISSUE_FT_REASSOC;
20037 break;
20038 case eCsrForcedDisassocSta:
20039 cmd_type = WLAN_SER_CMD_FORCE_DISASSOC_STA;
20040 break;
20041 case eCsrForcedDeauthSta:
20042 cmd_type = WLAN_SER_CMD_FORCE_DEAUTH_STA;
20043 break;
20044 case eCsrPerformPreauth:
20045 cmd_type = WLAN_SER_CMD_PERFORM_PRE_AUTH;
20046 break;
Krunal Sonia8270f52017-02-23 19:51:25 -080020047 default:
20048 break;
20049 }
20050
20051 return cmd_type;
20052}
20053
20054enum wlan_serialization_cmd_type csr_get_cmd_type(tSmeCmd *sme_cmd)
20055{
20056 enum wlan_serialization_cmd_type cmd_type = WLAN_SER_CMD_MAX;
20057
20058 switch (sme_cmd->command) {
Krunal Sonia8270f52017-02-23 19:51:25 -080020059 case eSmeCommandRoam:
20060 cmd_type = csr_get_roam_cmd_type(sme_cmd);
20061 break;
20062 case eSmeCommandWmStatusChange:
20063 cmd_type = WLAN_SER_CMD_WM_STATUS_CHANGE;
20064 break;
Krunal Sonia8270f52017-02-23 19:51:25 -080020065 case eSmeCommandAddTs:
20066 cmd_type = WLAN_SER_CMD_ADDTS;
20067 break;
20068 case eSmeCommandDelTs:
20069 cmd_type = WLAN_SER_CMD_DELTS;
20070 break;
20071 case eSmeCommandTdlsSendMgmt:
20072 cmd_type = WLAN_SER_CMD_TDLS_SEND_MGMT;
20073 break;
20074 case eSmeCommandTdlsAddPeer:
20075 cmd_type = WLAN_SER_CMD_TDLS_ADD_PEER;
20076 break;
20077 case eSmeCommandTdlsDelPeer:
20078 cmd_type = WLAN_SER_CMD_TDLS_DEL_PEER;
20079 break;
20080 case eSmeCommandTdlsLinkEstablish:
20081 cmd_type = WLAN_SER_CMD_TDLS_LINK_EST;
20082 break;
20083 case e_sme_command_set_hw_mode:
20084 cmd_type = WLAN_SER_CMD_SET_HW_MODE;
20085 break;
20086 case e_sme_command_nss_update:
20087 cmd_type = WLAN_SER_CMD_NSS_UPDATE;
20088 break;
20089 case e_sme_command_set_dual_mac_config:
20090 cmd_type = WLAN_SER_CMD_SET_DUAL_MAC_CONFIG;
20091 break;
20092 case e_sme_command_set_antenna_mode:
20093 cmd_type = WLAN_SER_CMD_SET_ANTENNA_MODE;
20094 break;
Krunal Sonia8270f52017-02-23 19:51:25 -080020095 case eSmeCommandEnterBmps:
20096 cmd_type = WLAN_SER_CMD_ENTER_BMPS;
20097 break;
20098 case eSmeCommandExitBmps:
20099 cmd_type = WLAN_SER_CMD_EXIT_BMPS;
20100 break;
20101 case eSmeCommandEnterUapsd:
20102 cmd_type = WLAN_SER_CMD_ENTER_UAPSD;
20103 break;
20104 case eSmeCommandExitUapsd:
20105 cmd_type = WLAN_SER_CMD_EXIT_UAPSD;
20106 break;
20107 case eSmeCommandExitWowl:
20108 cmd_type = WLAN_SER_CMD_EXIT_WOWL;
20109 break;
20110 default:
20111 break;
20112 }
20113
20114 return cmd_type;
20115}
20116
20117QDF_STATUS csr_set_serialization_params_to_cmd(tpAniSirGlobal mac_ctx,
20118 tSmeCmd *sme_cmd, struct wlan_serialization_command *cmd,
20119 uint8_t high_priority)
20120{
20121 QDF_STATUS status = QDF_STATUS_E_FAILURE;
20122
20123 if (!sme_cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020124 sme_err("Invalid sme_cmd");
Krunal Sonia8270f52017-02-23 19:51:25 -080020125 return status;
20126 }
20127 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020128 sme_err("Invalid serialization_cmd");
Krunal Sonia8270f52017-02-23 19:51:25 -080020129 return status;
20130 }
20131
20132 /*
20133 * no need to fill command id for non-scan as they will be
20134 * zero always
20135 */
Abhinav Kumarf9989582018-02-06 17:42:22 +053020136 sme_debug("cmd_id = 0");
20137 cmd->cmd_id = 0;
20138
Krunal Sonia8270f52017-02-23 19:51:25 -080020139 cmd->cmd_type = csr_get_cmd_type(sme_cmd);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020140 sme_debug("filled cmd_type[%d] cmd_id[%d]",
Krunal Soni81f068c2017-02-23 19:51:55 -080020141 cmd->cmd_type, cmd->cmd_id);
Krunal Sonia8270f52017-02-23 19:51:25 -080020142 if (cmd->cmd_type == WLAN_SER_CMD_MAX) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070020143 sme_err("serialization enum not found");
Krunal Sonia8270f52017-02-23 19:51:25 -080020144 return status;
20145 }
20146 cmd->vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
20147 sme_cmd->sessionId, WLAN_LEGACY_SME_ID);
Krunal Soni45ec4392017-10-20 11:44:22 -070020148 if (!cmd->vdev) {
20149 sme_err("vdev is NULL for sme_session:%d", sme_cmd->sessionId);
20150 return status;
20151 }
Krunal Sonia8270f52017-02-23 19:51:25 -080020152 cmd->umac_cmd = sme_cmd;
20153 cmd->cmd_timeout_duration = SME_DEFAULT_CMD_TIMEOUT;
20154 cmd->cmd_cb = sme_ser_cmd_callback;
20155 cmd->is_high_priority = high_priority;
20156 return QDF_STATUS_SUCCESS;
20157}
20158
20159QDF_STATUS csr_queue_sme_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd,
20160 bool high_priority)
20161{
20162 struct wlan_serialization_command cmd;
Krunal Soniaa179db2017-10-13 19:28:17 -070020163 struct wlan_objmgr_vdev *vdev = NULL;
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020164 QDF_STATUS status;
Krunal Sonia8270f52017-02-23 19:51:25 -080020165
20166 if (!SME_IS_START(mac_ctx)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020167 sme_err("Sme in stop state");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020168 QDF_ASSERT(0);
Krunal Soniaa179db2017-10-13 19:28:17 -070020169 goto error;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020170 }
20171
Krunal Soni81f068c2017-02-23 19:51:55 -080020172 if (CSR_IS_WAIT_FOR_KEY(mac_ctx, sme_cmd->sessionId)) {
Krunal Sonid3676732017-05-10 14:12:18 -070020173 if (!CSR_IS_DISCONNECT_COMMAND(sme_cmd)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020174 sme_err("Can't process cmd(%d), waiting for key",
Krunal Soni81f068c2017-02-23 19:51:55 -080020175 sme_cmd->command);
Krunal Soniaa179db2017-10-13 19:28:17 -070020176 goto error;
Krunal Soni81f068c2017-02-23 19:51:55 -080020177 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020178 }
Krunal Soni81f068c2017-02-23 19:51:55 -080020179
Krunal Sonia8270f52017-02-23 19:51:25 -080020180 qdf_mem_zero(&cmd, sizeof(struct wlan_serialization_command));
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020181 status = csr_set_serialization_params_to_cmd(mac_ctx, sme_cmd,
20182 &cmd, high_priority);
20183 if (QDF_STATUS_SUCCESS == status) {
Krunal Soniaa179db2017-10-13 19:28:17 -070020184 vdev = cmd.vdev;
Krunal Sonia8270f52017-02-23 19:51:25 -080020185 if (WLAN_SER_CMD_DENIED_UNSPECIFIED ==
Krunal Soniaa179db2017-10-13 19:28:17 -070020186 wlan_serialization_request(&cmd))
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020187 status = QDF_STATUS_E_FAILURE;
Krunal Soniaa179db2017-10-13 19:28:17 -070020188 if (vdev)
20189 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_SME_ID);
20190 if (status == QDF_STATUS_E_FAILURE)
20191 goto error;
Krunal Sonia8270f52017-02-23 19:51:25 -080020192 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070020193 sme_err("failed to set ser params");
Krunal Soniaa179db2017-10-13 19:28:17 -070020194 goto error;
Krunal Sonia8270f52017-02-23 19:51:25 -080020195 }
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080020196 return status;
Krunal Soniaa179db2017-10-13 19:28:17 -070020197
20198error:
20199 csr_release_command_buffer(mac_ctx, sme_cmd);
20200 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020201}
20202
Naveen Rawat8029a402017-06-01 10:54:19 -070020203QDF_STATUS csr_roam_update_config(tpAniSirGlobal mac_ctx, uint8_t session_id,
20204 uint16_t capab, uint32_t value)
20205{
20206 struct update_config *msg;
20207 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020208 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Naveen Rawat8029a402017-06-01 10:54:19 -070020209
20210 sme_debug("update HT config requested");
20211 if (NULL == session) {
20212 sme_err("Session does not exist for session id %d", session_id);
20213 return QDF_STATUS_E_FAILURE;
20214 }
20215
20216 msg = qdf_mem_malloc(sizeof(*msg));
20217 if (NULL == msg) {
20218 sme_err("malloc failed");
20219 return QDF_STATUS_E_NOMEM;
20220 }
20221
20222 msg->messageType = eWNI_SME_UPDATE_CONFIG;
20223 msg->sme_session_id = session_id;
20224 msg->capab = capab;
20225 msg->value = value;
20226 msg->length = sizeof(*msg);
20227 status = umac_send_mb_message_to_mac(msg);
20228
20229 return status;
20230}
20231
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020232/*
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020233 * pBuf points to the beginning of the message
20234 * LIM packs disassoc rsp as below,
20235 * messageType - 2 bytes
20236 * messageLength - 2 bytes
20237 * sessionId - 1 byte
20238 * transactionId - 2 bytes (uint16_t)
20239 * reasonCode - 4 bytes (sizeof(tSirResultCodes))
20240 * peerMacAddr - 6 bytes
20241 * The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP)
20242 * and not used
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020243 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020244static void csr_ser_des_unpack_diassoc_rsp(uint8_t *pBuf, tSirSmeDisassocRsp
20245 *pRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020246{
20247 if (pBuf && pRsp) {
20248 pBuf += 4; /* skip type and length */
20249 pRsp->sessionId = *pBuf++;
Anurag Chouhanc5548422016-02-24 18:33:27 +053020250 qdf_get_u16(pBuf, (uint16_t *) &pRsp->transactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020251 pBuf += 2;
Anurag Chouhanc5548422016-02-24 18:33:27 +053020252 qdf_get_u32(pBuf, (uint32_t *) &pRsp->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020253 pBuf += 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020254 qdf_mem_copy(pRsp->peer_macaddr.bytes, pBuf, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020255 }
20256}
20257
Anurag Chouhan6d760662016-02-20 16:05:43 +053020258/* Returns whether a session is in QDF_STA_MODE...or not */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020259bool csr_roam_is_sta_mode(tpAniSirGlobal pMac, uint32_t sessionId)
20260{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020261 struct csr_roam_session *pSession = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020262
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020263 pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020264
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020265 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020266 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020267 return false;
20268 }
20269 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020270 sme_err("Inactive session_id: %d", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020271 return false;
20272 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020273 if (eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020274 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020275 /* There is a possibility that the above check may fail,because
20276 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
20277 * when it is connected.So,we may sneak through the above check even
20278 * if we are not a STA mode INFRA station. So, if we sneak through
20279 * the above condition, we can use the following check if we are
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020280 * really in STA Mode.
20281 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020282
20283 if (NULL != pSession->pCurRoamProfile) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020284 if (pSession->pCurRoamProfile->csrPersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020285 return true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020286 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020287 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020288 }
20289
20290 return false;
20291}
20292
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020293QDF_STATUS csr_handoff_request(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020294 uint8_t sessionId,
20295 tCsrHandoffRequest *pHandoffInfo)
20296{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020297 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070020298 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020299
20300 tAniHandoffReq *pMsg;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020301
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020302 pMsg = qdf_mem_malloc(sizeof(tAniHandoffReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020303 if (NULL == pMsg) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020304 sme_err("csr_handoff_request: failed to allocate mem for req ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020305 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020306 }
20307 pMsg->msgType = eWNI_SME_HANDOFF_REQ;
20308 pMsg->msgLen = (uint16_t) sizeof(tAniHandoffReq);
20309 pMsg->sessionId = sessionId;
20310 pMsg->channel = pHandoffInfo->channel;
20311 pMsg->handoff_src = pHandoffInfo->src;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020312 qdf_mem_copy(pMsg->bssid, pHandoffInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020313 msg.type = eWNI_SME_HANDOFF_REQ;
20314 msg.bodyptr = pMsg;
20315 msg.reserved = 0;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080020316 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_SME,
Krunal Soni66c113f2016-12-21 16:46:47 -080020317 &msg)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020318 sme_err("scheduler_post_msg failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020319 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020320 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020321 }
20322 return status;
20323}
20324
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080020325/**
20326 * csr_roam_channel_change_req() - Post channel change request to LIM
20327 * @pMac: mac context
20328 * @bssid: SAP bssid
20329 * @ch_params: channel information
20330 * @profile: CSR profile
20331 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -080020332 * This API is primarily used to post Channel Change Req for SAP
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080020333 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020334 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020335 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020336QDF_STATUS csr_roam_channel_change_req(tpAniSirGlobal pMac,
Amar Singhale4f28ee2015-10-21 14:36:56 -070020337 struct qdf_mac_addr bssid,
Amar Singhal5cccafe2017-02-15 12:42:58 -080020338 struct ch_params *ch_params,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070020339 struct csr_roam_profile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020340{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020341 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020342 tSirChanChangeRequest *pMsg;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020343 struct csr_roamstart_bssparams param;
hqu16d6e082017-09-04 10:52:31 +080020344 bool skip_hostapd_rate = !profile->chan_switch_hostapd_rate_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020345
Krunal Soni8f8507c2016-12-20 13:54:34 -080020346 /*
20347 * while changing the channel, use basic rates given by driver
20348 * and not by hostapd as there is a chance that hostapd might
20349 * give us rates based on original channel which may not be
20350 * suitable for new channel
20351 */
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020352 qdf_mem_zero(&param, sizeof(struct csr_roamstart_bssparams));
Ravi Joshib398c852017-07-18 17:55:21 -070020353
hqu16d6e082017-09-04 10:52:31 +080020354 csr_roam_get_bss_start_parms(pMac, profile, &param, skip_hostapd_rate);
Ravi Joshib398c852017-07-18 17:55:21 -070020355
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020356 pMsg = qdf_mem_malloc(sizeof(tSirChanChangeRequest));
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020357 if (!pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020358 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020359
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020360 pMsg->messageType = eWNI_SME_CHANNEL_CHANGE_REQ;
20361 pMsg->messageLen = sizeof(tSirChanChangeRequest);
20362 pMsg->targetChannel = profile->ChannelInfo.ChannelList[0];
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080020363 pMsg->sec_ch_offset = ch_params->sec_ch_offset;
20364 pMsg->ch_width = profile->ch_params.ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020365 pMsg->dot11mode = csr_translate_to_wni_cfg_dot11_mode(pMac,
Himanshu Agarwalf5c5b102018-05-22 20:13:57 +053020366 param.uCfgDot11Mode);
Gupta, Kapil76ed25e2016-04-22 15:13:55 +053020367 if (IS_24G_CH(pMsg->targetChannel) &&
20368 (false == pMac->roam.configParam.enableVhtFor24GHz) &&
20369 (WNI_CFG_DOT11_MODE_11AC == pMsg->dot11mode ||
20370 WNI_CFG_DOT11_MODE_11AC_ONLY == pMsg->dot11mode))
20371 pMsg->dot11mode = WNI_CFG_DOT11_MODE_11N;
20372
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080020373 pMsg->center_freq_seg_0 = ch_params->center_freq_seg0;
20374 pMsg->center_freq_seg_1 = ch_params->center_freq_seg1;
Arif Hussain671a1902017-03-17 09:08:32 -070020375 pMsg->cac_duration_ms = profile->cac_duration_ms;
20376 pMsg->dfs_regdomain = profile->dfs_regdomain;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020377 qdf_mem_copy(pMsg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
20378 qdf_mem_copy(&pMsg->operational_rateset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020379 &param.operationalRateSet, sizeof(pMsg->operational_rateset));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020380 qdf_mem_copy(&pMsg->extended_rateset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020381 &param.extendedRateSet, sizeof(pMsg->extended_rateset));
Rajeev Kumard138ac52017-01-30 18:38:37 -080020382 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020383
20384 return status;
20385}
20386
20387/*
20388 * Post Beacon Tx Start request to LIM
20389 * immediately after SAP CAC WAIT is
20390 * completed without any RADAR indications.
20391 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020392QDF_STATUS csr_roam_start_beacon_req(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +053020393 struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020394 uint8_t dfsCacWaitStatus)
20395{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020396 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020397 tSirStartBeaconIndication *pMsg;
20398
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020399 pMsg = qdf_mem_malloc(sizeof(tSirStartBeaconIndication));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020400
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020401 if (!pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020402 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020403
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020404 pMsg->messageType = eWNI_SME_START_BEACON_REQ;
20405 pMsg->messageLen = sizeof(tSirStartBeaconIndication);
20406 pMsg->beaconStartStatus = dfsCacWaitStatus;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020407 qdf_mem_copy(pMsg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020408
Rajeev Kumard138ac52017-01-30 18:38:37 -080020409 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020410
20411 return status;
20412}
20413
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020414/*
20415 * csr_roam_modify_add_ies -
20416 * This function sends msg to modify the additional IE buffers in PE
20417 *
20418 * @pMac: pMac global structure
20419 * @pModifyIE: pointer to tSirModifyIE structure
20420 * @updateType: Type of buffer
20421 *
20422 *
20423 * Return: QDF_STATUS - Success or failure
20424 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020425QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020426csr_roam_modify_add_ies(tpAniSirGlobal pMac,
20427 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
20428{
20429 tpSirModifyIEsInd pModifyAddIEInd = NULL;
20430 uint8_t *pLocalBuffer = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020431 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020432
20433 /* following buffer will be freed by consumer (PE) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020434 pLocalBuffer = qdf_mem_malloc(pModifyIE->ieBufferlength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020435
20436 if (NULL == pLocalBuffer) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020437 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020438 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020439 }
20440
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020441 pModifyAddIEInd = qdf_mem_malloc(sizeof(tSirModifyIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020442 if (NULL == pModifyAddIEInd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020443 sme_err("Memory Allocation Failure!!!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020444 qdf_mem_free(pLocalBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020445 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020446 }
20447
20448 /*copy the IE buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020449 qdf_mem_copy(pLocalBuffer, pModifyIE->pIEBuffer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020450 pModifyIE->ieBufferlength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020451 qdf_mem_zero(pModifyAddIEInd, sizeof(tSirModifyIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020452
20453 pModifyAddIEInd->msgType = eWNI_SME_MODIFY_ADDITIONAL_IES;
20454 pModifyAddIEInd->msgLen = sizeof(tSirModifyIEsInd);
20455
Anurag Chouhanc5548422016-02-24 18:33:27 +053020456 qdf_copy_macaddr(&pModifyAddIEInd->modifyIE.bssid, &pModifyIE->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020457
20458 pModifyAddIEInd->modifyIE.smeSessionId = pModifyIE->smeSessionId;
20459 pModifyAddIEInd->modifyIE.notify = pModifyIE->notify;
20460 pModifyAddIEInd->modifyIE.ieID = pModifyIE->ieID;
20461 pModifyAddIEInd->modifyIE.ieIDLen = pModifyIE->ieIDLen;
20462 pModifyAddIEInd->modifyIE.pIEBuffer = pLocalBuffer;
20463 pModifyAddIEInd->modifyIE.ieBufferlength = pModifyIE->ieBufferlength;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080020464 pModifyAddIEInd->modifyIE.oui_length = pModifyIE->oui_length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020465
20466 pModifyAddIEInd->updateType = updateType;
20467
Rajeev Kumard138ac52017-01-30 18:38:37 -080020468 status = umac_send_mb_message_to_mac(pModifyAddIEInd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020469 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020470 sme_err("Failed to send eWNI_SME_UPDATE_ADDTIONAL_IES msg status %d",
20471 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020472 qdf_mem_free(pLocalBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020473 }
20474 return status;
20475}
20476
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020477/*
20478 * csr_roam_update_add_ies -
20479 * This function sends msg to updates the additional IE buffers in PE
20480 *
20481 * @pMac: pMac global structure
20482 * @sessionId: SME session id
20483 * @bssid: BSSID
20484 * @additionIEBuffer: buffer containing addition IE from hostapd
20485 * @length: length of buffer
20486 * @updateType: Type of buffer
20487 * @append: append or replace completely
20488 *
20489 *
20490 * Return: QDF_STATUS - Success or failure
20491 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020492QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020493csr_roam_update_add_ies(tpAniSirGlobal pMac,
20494 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
20495{
20496 tpSirUpdateIEsInd pUpdateAddIEs = NULL;
20497 uint8_t *pLocalBuffer = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020498 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020499
20500 if (pUpdateIE->ieBufferlength != 0) {
20501 /* Following buffer will be freed by consumer (PE) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020502 pLocalBuffer = qdf_mem_malloc(pUpdateIE->ieBufferlength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020503 if (NULL == pLocalBuffer) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020504 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020505 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020506 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020507 qdf_mem_copy(pLocalBuffer, pUpdateIE->pAdditionIEBuffer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020508 pUpdateIE->ieBufferlength);
20509 }
20510
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020511 pUpdateAddIEs = qdf_mem_malloc(sizeof(tSirUpdateIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020512 if (NULL == pUpdateAddIEs) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020513 sme_err("Memory Allocation Failure!!!");
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020514 if (pLocalBuffer != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020515 qdf_mem_free(pLocalBuffer);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020516
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020517 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020518 }
20519
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020520 pUpdateAddIEs->msgType = eWNI_SME_UPDATE_ADDITIONAL_IES;
20521 pUpdateAddIEs->msgLen = sizeof(tSirUpdateIEsInd);
20522
Anurag Chouhanc5548422016-02-24 18:33:27 +053020523 qdf_copy_macaddr(&pUpdateAddIEs->updateIE.bssid, &pUpdateIE->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020524
20525 pUpdateAddIEs->updateIE.smeSessionId = pUpdateIE->smeSessionId;
20526 pUpdateAddIEs->updateIE.append = pUpdateIE->append;
20527 pUpdateAddIEs->updateIE.notify = pUpdateIE->notify;
20528 pUpdateAddIEs->updateIE.ieBufferlength = pUpdateIE->ieBufferlength;
20529 pUpdateAddIEs->updateIE.pAdditionIEBuffer = pLocalBuffer;
20530
20531 pUpdateAddIEs->updateType = updateType;
20532
Rajeev Kumard138ac52017-01-30 18:38:37 -080020533 status = umac_send_mb_message_to_mac(pUpdateAddIEs);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020534 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020535 sme_err("Failed to send eWNI_SME_UPDATE_ADDTIONAL_IES msg status %d",
20536 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020537 qdf_mem_free(pLocalBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020538 }
20539 return status;
20540}
20541
20542/**
Abhishek Singh518323d2015-10-19 17:42:01 +053020543 * csr_send_ext_change_channel()- function to post send ECSA
20544 * action frame to lim.
20545 * @mac_ctx: pointer to global mac structure
20546 * @channel: new channel to switch
20547 * @session_id: senssion it should be sent on.
20548 *
20549 * This function is called to post ECSA frame to lim.
20550 *
20551 * Return: success if msg posted to LIM else return failure
20552 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020553QDF_STATUS csr_send_ext_change_channel(tpAniSirGlobal mac_ctx, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +053020554 uint8_t session_id)
20555{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020556 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +053020557 struct sir_sme_ext_cng_chan_req *msg;
20558
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020559 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh518323d2015-10-19 17:42:01 +053020560 if (NULL == msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020561 return QDF_STATUS_E_NOMEM;
Abhishek Singh518323d2015-10-19 17:42:01 +053020562
Abhishek Singh518323d2015-10-19 17:42:01 +053020563 msg->message_type = eWNI_SME_EXT_CHANGE_CHANNEL;
20564 msg->length = sizeof(*msg);
20565 msg->new_channel = channel;
20566 msg->session_id = session_id;
Rajeev Kumard138ac52017-01-30 18:38:37 -080020567 status = umac_send_mb_message_to_mac(msg);
Abhishek Singh518323d2015-10-19 17:42:01 +053020568 return status;
20569}
20570
20571/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020572 * csr_roam_send_chan_sw_ie_request() - Request to transmit CSA IE
20573 * @mac_ctx: Global MAC context
20574 * @bssid: BSSID
20575 * @target_channel: Channel on which to send the IE
20576 * @csa_ie_reqd: Include/Exclude CSA IE.
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080020577 * @ch_params: operating Channel related information
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020578 *
20579 * This function sends request to transmit channel switch announcement
20580 * IE to lower layers
20581 *
20582 * Return: success or failure
20583 **/
Amar Singhale4f28ee2015-10-21 14:36:56 -070020584QDF_STATUS csr_roam_send_chan_sw_ie_request(tpAniSirGlobal mac_ctx,
20585 struct qdf_mac_addr bssid,
20586 uint8_t target_channel,
20587 uint8_t csa_ie_reqd,
Amar Singhal5cccafe2017-02-15 12:42:58 -080020588 struct ch_params *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020589{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020590 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020591 tSirDfsCsaIeRequest *msg;
20592
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020593 msg = qdf_mem_malloc(sizeof(tSirDfsCsaIeRequest));
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020594 if (!msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020595 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020597 msg->msgType = eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ;
20598 msg->msgLen = sizeof(tSirDfsCsaIeRequest);
20599
20600 msg->targetChannel = target_channel;
20601 msg->csaIeRequired = csa_ie_reqd;
gaoleze2920bd2017-03-21 17:38:42 +080020602 msg->ch_switch_beacon_cnt =
20603 mac_ctx->sap.SapDfsInfo.sap_ch_switch_beacon_cnt;
gaolez76d2a162017-03-21 19:23:58 +080020604 msg->ch_switch_mode = mac_ctx->sap.SapDfsInfo.sap_ch_switch_mode;
20605 msg->dfs_ch_switch_disable =
20606 mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020607 qdf_mem_copy(msg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
Amar Singhal5cccafe2017-02-15 12:42:58 -080020608 qdf_mem_copy(&msg->ch_params, ch_params, sizeof(struct ch_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020609
Rajeev Kumard138ac52017-01-30 18:38:37 -080020610 status = umac_send_mb_message_to_mac(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020611
20612 return status;
20613}
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080020614#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
20615/**
20616 * csr_roaming_report_diag_event() - Diag events for LFR3
20617 * @mac_ctx: MAC context
20618 * @roam_synch_ind_ptr: Roam Synch Indication Pointer
20619 * @reason: Reason for this event to happen
20620 *
20621 * The major events in the host for LFR3 roaming such as
20622 * roam synch indication, roam synch completion and
20623 * roam synch handoff fail will be indicated to the
20624 * diag framework using this API.
20625 *
20626 * Return: None
20627 */
20628void csr_roaming_report_diag_event(tpAniSirGlobal mac_ctx,
20629 roam_offload_synch_ind *roam_synch_ind_ptr,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020630 enum csr_diagwlan_status_eventreason reason)
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080020631{
20632 WLAN_HOST_DIAG_EVENT_DEF(roam_connection,
20633 host_event_wlan_status_payload_type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020634 qdf_mem_set(&roam_connection,
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080020635 sizeof(host_event_wlan_status_payload_type), 0);
20636 switch (reason) {
20637 case eCSR_REASON_ROAM_SYNCH_IND:
20638 roam_connection.eventId = eCSR_WLAN_STATUS_CONNECT;
20639 if (roam_synch_ind_ptr) {
20640 roam_connection.rssi = roam_synch_ind_ptr->rssi;
20641 roam_connection.channel =
20642 cds_freq_to_chan(roam_synch_ind_ptr->chan_freq);
20643 }
20644 break;
20645 case eCSR_REASON_ROAM_SYNCH_CNF:
20646 roam_connection.eventId = eCSR_WLAN_STATUS_CONNECT;
20647 break;
20648 case eCSR_REASON_ROAM_HO_FAIL:
20649 roam_connection.eventId = eCSR_WLAN_STATUS_DISCONNECT;
20650 break;
20651 default:
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020652 sme_err("LFR3: Unsupported reason %d", reason);
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080020653 return;
20654 }
20655 roam_connection.reason = reason;
Abhishek Singh7a995582016-04-27 13:53:36 +053020656 WLAN_HOST_DIAG_EVENT_REPORT(&roam_connection, EVENT_WLAN_STATUS_V2);
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080020657}
20658#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020659
20660#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020661/*
20662 * fn csr_process_ho_fail_ind
20663 * brief This function will process the Hand Off Failure indication
20664 * received from the firmware. It will trigger a disconnect on
20665 * the session which the firmware reported a hand off failure
20666 * param pMac global structure
20667 * param pMsgBuf - Contains the session ID for which the handler should apply
20668 */
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080020669void csr_process_ho_fail_ind(tpAniSirGlobal mac_ctx, void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020670{
20671 tSirSmeHOFailureInd *pSmeHOFailInd = (tSirSmeHOFailureInd *) pMsgBuf;
20672 uint32_t sessionId;
20673
20674 if (pSmeHOFailInd)
20675 sessionId = pSmeHOFailInd->sessionId;
20676 else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020677 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020678 "LFR3: Hand-Off Failure Ind is NULL");
20679 return;
20680 }
20681 /* Roaming is supported only on Infra STA Mode. */
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080020682 if (!csr_roam_is_sta_mode(mac_ctx, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020683 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020684 "LFR3:HO Fail cannot be handled for session %d",
20685 sessionId);
20686 return;
20687 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080020688 mac_ctx->sme.set_connection_info_cb(false);
20689 csr_roam_roaming_offload_timer_action(mac_ctx, 0, sessionId,
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070020690 ROAMING_OFFLOAD_TIMER_STOP);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080020691 csr_roam_call_callback(mac_ctx, sessionId, NULL, 0,
Abhishek Singh533c9da2017-05-04 10:23:34 +053020692 eCSR_ROAM_NAPI_OFF, eCSR_ROAM_RESULT_FAILURE);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080020693 csr_roam_synch_clean_up(mac_ctx, sessionId);
20694 csr_roaming_report_diag_event(mac_ctx, NULL,
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080020695 eCSR_REASON_ROAM_HO_FAIL);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020696 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020697 "LFR3:Issue Disconnect on session %d", sessionId);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080020698 csr_roam_disconnect(mac_ctx, sessionId,
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -070020699 eCSR_DISCONNECT_REASON_ROAM_HO_FAIL);
Agrawal Ashishc416da62017-04-10 15:12:46 +053020700 if (mac_ctx->roam.configParam.enable_fatal_event)
Agrawal Ashish87ec5d42017-06-15 15:22:19 +053020701 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
Agrawal Ashishc416da62017-04-10 15:12:46 +053020702 WLAN_LOG_INDICATOR_HOST_DRIVER,
20703 WLAN_LOG_REASON_ROAM_HO_FAILURE,
20704 true, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020705}
20706#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
20707
20708/**
20709 * csr_update_op_class_array() - update op class for each band
20710 * @mac_ctx: mac global context
20711 * @op_classes: out param, operating class array to update
20712 * @channel_info: channel info
20713 * @ch_name: channel band name to display in debug messages
20714 * @i: out param, stores number of operating classes
20715 *
20716 * Return: void
20717 */
20718static void
20719csr_update_op_class_array(tpAniSirGlobal mac_ctx,
20720 uint8_t *op_classes,
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020721 struct csr_channel *channel_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020722 char *ch_name,
20723 uint8_t *i)
20724{
20725 uint8_t j = 0, idx = 0, class = 0;
20726 bool found = false;
20727 uint8_t num_channels = channel_info->numChannels;
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053020728 uint8_t ch_bandwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020729
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020730 sme_debug("Num of %s channels, %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020731 ch_name, num_channels);
20732
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070020733 for (idx = 0; idx < num_channels &&
20734 *i < (REG_MAX_SUPP_OPER_CLASSES - 1); idx++) {
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053020735 for (ch_bandwidth = BW20; ch_bandwidth < BWALL;
20736 ch_bandwidth++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070020737 class = wlan_reg_dmn_get_opclass_from_channel(
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053020738 mac_ctx->scan.countryCodeCurrent,
20739 channel_info->channelList[idx],
20740 ch_bandwidth);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020741 sme_debug("for chan %d, op class: %d",
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053020742 channel_info->channelList[idx], class);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020743
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053020744 found = false;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070020745 for (j = 0; j < REG_MAX_SUPP_OPER_CLASSES - 1;
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053020746 j++) {
20747 if (op_classes[j] == class) {
20748 found = true;
20749 break;
20750 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020751 }
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053020752
20753 if (!found) {
20754 op_classes[*i] = class;
20755 *i = *i + 1;
20756 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020757 }
20758 }
20759}
20760
20761/**
20762 * csr_update_op_class_array() - update op class for all bands
20763 * @hHal: global hal context
20764 *
20765 * Return: void
20766 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020767static void csr_init_operating_classes(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020768{
20769 uint8_t i = 0;
20770 uint8_t j = 0;
20771 uint8_t swap = 0;
20772 uint8_t numClasses = 0;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070020773 uint8_t opClasses[REG_MAX_SUPP_OPER_CLASSES] = {0,};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020774 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
20775
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020776 sme_debug("Current Country = %c%c",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020777 pMac->scan.countryCodeCurrent[0],
20778 pMac->scan.countryCodeCurrent[1]);
20779
20780 csr_update_op_class_array(pMac, opClasses,
20781 &pMac->scan.base_channels, "20MHz", &i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020782 numClasses = i;
20783
20784 /* As per spec the operating classes should be in ascending order.
20785 * Bubble sort is fine since we don't have many classes
20786 */
20787 for (i = 0; i < (numClasses - 1); i++) {
20788 for (j = 0; j < (numClasses - i - 1); j++) {
20789 /* For decreasing order use < */
20790 if (opClasses[j] > opClasses[j + 1]) {
20791 swap = opClasses[j];
20792 opClasses[j] = opClasses[j + 1];
20793 opClasses[j + 1] = swap;
20794 }
20795 }
20796 }
20797
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020798 sme_debug("Number of unique supported op classes %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020799 numClasses);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020800 for (i = 0; i < numClasses; i++)
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020801 sme_debug("supported opClasses[%d] = %d", i, opClasses[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020802
20803 /* Set the ordered list of op classes in regdomain
20804 * for use by other modules
20805 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070020806 wlan_reg_dmn_set_curr_opclasses(numClasses, &opClasses[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020807}
20808
20809/**
20810 * csr_find_session_by_type() - This function will find given session type from
20811 * all sessions.
20812 * @mac_ctx: pointer to mac context.
20813 * @type: session type
20814 *
20815 * Return: session id for give session type.
20816 **/
20817static uint32_t
Jeff Johnsonc1e62782017-11-09 09:50:17 -080020818csr_find_session_by_type(tpAniSirGlobal mac_ctx, enum QDF_OPMODE type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020819{
20820 uint32_t i, session_id = CSR_SESSION_ID_INVALID;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020821 struct csr_roam_session *session_ptr;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020822
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020823 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
20824 if (!CSR_IS_SESSION_VALID(mac_ctx, i))
20825 continue;
20826
20827 session_ptr = CSR_GET_SESSION(mac_ctx, i);
20828 if (type == session_ptr->bssParams.bssPersona) {
20829 session_id = i;
20830 break;
20831 }
20832 }
20833 return session_id;
20834}
20835/**
20836 * csr_is_conn_allow_2g_band() - This function will check if station's conn
20837 * is allowed in 2.4Ghz band.
20838 * @mac_ctx: pointer to mac context.
20839 * @chnl: station's channel.
20840 *
20841 * This function will check if station's connection is allowed in 5Ghz band
20842 * after comparing it with SAP's operating channel. If SAP's operating
20843 * channel and Station's channel is different than this function will return
20844 * false else true.
20845 *
20846 * Return: true or false.
20847 **/
20848static bool csr_is_conn_allow_2g_band(tpAniSirGlobal mac_ctx, uint32_t chnl)
20849{
20850 uint32_t sap_session_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020851 struct csr_roam_session *sap_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020852
20853 if (0 == chnl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020854 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020855 FL("channel is zero, connection not allowed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020856
20857 return false;
20858 }
20859
Anurag Chouhan6d760662016-02-20 16:05:43 +053020860 sap_session_id = csr_find_session_by_type(mac_ctx, QDF_SAP_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020861 if (CSR_SESSION_ID_INVALID != sap_session_id) {
20862 sap_session = CSR_GET_SESSION(mac_ctx, sap_session_id);
20863 if ((0 != sap_session->bssParams.operationChn) &&
20864 (sap_session->bssParams.operationChn != chnl)) {
20865
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020866 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020867 "Can't allow STA to connect, chnls not same");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020868 return false;
20869 }
20870 }
20871 return true;
20872}
20873
20874/**
20875 * csr_is_conn_allow_5g_band() - This function will check if station's conn
20876 * is allowed in 5Ghz band.
20877 * @mac_ctx: pointer to mac context.
20878 * @chnl: station's channel.
20879 *
20880 * This function will check if station's connection is allowed in 5Ghz band
20881 * after comparing it with P2PGO's operating channel. If P2PGO's operating
20882 * channel and Station's channel is different than this function will return
20883 * false else true.
20884 *
20885 * Return: true or false.
20886 **/
20887static bool csr_is_conn_allow_5g_band(tpAniSirGlobal mac_ctx, uint32_t chnl)
20888{
20889 uint32_t p2pgo_session_id;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020890 struct csr_roam_session *p2pgo_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020891
20892 if (0 == chnl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020893 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020894 FL("channel is zero, connection not allowed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020895 return false;
20896 }
20897
Anurag Chouhan6d760662016-02-20 16:05:43 +053020898 p2pgo_session_id = csr_find_session_by_type(mac_ctx, QDF_P2P_GO_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020899 if (CSR_SESSION_ID_INVALID != p2pgo_session_id) {
20900 p2pgo_session = CSR_GET_SESSION(mac_ctx, p2pgo_session_id);
20901 if ((0 != p2pgo_session->bssParams.operationChn) &&
20902 (eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED !=
20903 p2pgo_session->connectState) &&
20904 (p2pgo_session->bssParams.operationChn !=
20905 chnl)) {
20906
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020907 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053020908 "Can't allow STA to connect, chnls not same");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020909 return false;
20910 }
20911 }
20912 return true;
20913}
20914
20915/**
20916 * csr_clear_joinreq_param() - This function will clear station's params
20917 * for stored join request to csr.
20918 * @hal_handle: pointer to hal context.
20919 * @session_id: station's session id.
20920 *
20921 * This function will clear station's allocated memory for cached join
20922 * request.
20923 *
20924 * Return: true or false based on function's overall success.
20925 **/
20926bool csr_clear_joinreq_param(tpAniSirGlobal mac_ctx,
20927 uint32_t session_id)
20928{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020929 struct csr_roam_session *sta_session;
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053020930 struct scan_result_list *bss_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020931
20932 if (NULL == mac_ctx)
20933 return false;
20934
20935 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
20936 if (NULL == sta_session)
20937 return false;
20938
20939 /* Release the memory allocated by previous join request */
20940 bss_list =
Yeshwanth Sriram Guntuka36c09902017-09-26 11:34:26 +053020941 (struct scan_result_list *)&sta_session->stored_roam_profile.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020942 bsslist_handle;
20943 if (NULL != bss_list) {
20944 csr_scan_result_purge(mac_ctx,
20945 sta_session->stored_roam_profile.bsslist_handle);
Abhishek Singh245182f2017-08-10 17:41:09 +053020946 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020947 FL("bss list is released for session %d"), session_id);
20948 sta_session->stored_roam_profile.bsslist_handle = NULL;
20949 }
20950 sta_session->stored_roam_profile.bsslist_handle = NULL;
20951 csr_release_profile(mac_ctx, &sta_session->stored_roam_profile.profile);
20952 sta_session->stored_roam_profile.reason = 0;
20953 sta_session->stored_roam_profile.roam_id = 0;
20954 sta_session->stored_roam_profile.imediate_flag = false;
20955 sta_session->stored_roam_profile.clear_flag = false;
20956 return true;
20957}
20958
20959/**
20960 * csr_store_joinreq_param() - This function will store station's join
20961 * request to that station's session.
20962 * @mac_ctx: pointer to mac context.
20963 * @profile: pointer to station's roam profile.
20964 * @scan_cache: pointer to station's scan cache.
20965 * @roam_id: reference to roam_id variable being passed.
20966 * @session_id: station's session id.
20967 *
20968 * This function will store station's join request to one of the
20969 * csr structure and add it to station's session.
20970 *
20971 * Return: true or false based on function's overall success.
20972 **/
20973bool csr_store_joinreq_param(tpAniSirGlobal mac_ctx,
Jeff Johnson66ee8a92018-03-17 15:24:26 -070020974 struct csr_roam_profile *profile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020975 tScanResultHandle scan_cache,
20976 uint32_t *roam_id,
20977 uint32_t session_id)
20978{
gaurank kathpalia14e2f912017-08-31 14:51:45 +053020979 struct csr_roam_session *sta_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020980
20981 if (NULL == mac_ctx)
20982 return false;
20983
20984 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
20985 if (NULL == sta_session)
20986 return false;
20987
20988 sta_session->stored_roam_profile.session_id = session_id;
20989 csr_roam_copy_profile(mac_ctx,
20990 &sta_session->stored_roam_profile.profile, profile);
20991 /* new bsslist_handle's memory will be relased later */
20992 sta_session->stored_roam_profile.bsslist_handle = scan_cache;
20993 sta_session->stored_roam_profile.reason = eCsrHddIssued;
20994 sta_session->stored_roam_profile.roam_id = *roam_id;
20995 sta_session->stored_roam_profile.imediate_flag = false;
20996 sta_session->stored_roam_profile.clear_flag = false;
20997
20998 return true;
20999}
21000
21001/**
21002 * csr_issue_stored_joinreq() - This function will issues station's stored
21003 * the join request.
21004 * @mac_ctx: pointer to mac context.
21005 * @roam_id: reference to roam_id variable being passed.
21006 * @session_id: station's session id.
21007 *
21008 * This function will issue station's stored join request, from this point
21009 * onwards the flow will be just like normal connect request.
21010 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021011 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021012 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021013QDF_STATUS csr_issue_stored_joinreq(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021014 uint32_t *roam_id,
21015 uint32_t session_id)
21016{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021017 QDF_STATUS status = QDF_STATUS_SUCCESS;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053021018 struct csr_roam_session *sta_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021019 uint32_t new_roam_id;
21020
21021 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
21022 if (NULL == sta_session)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021023 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021024 new_roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
21025 *roam_id = new_roam_id;
21026 status = csr_roam_issue_connect(mac_ctx,
21027 sta_session->stored_roam_profile.session_id,
21028 &sta_session->stored_roam_profile.profile,
21029 sta_session->stored_roam_profile.bsslist_handle,
21030 sta_session->stored_roam_profile.reason,
21031 new_roam_id,
21032 sta_session->stored_roam_profile.imediate_flag,
21033 sta_session->stored_roam_profile.clear_flag);
Will Huang8e8d3002018-05-11 10:48:03 +080021034
21035 sta_session->stored_roam_profile.bsslist_handle =
21036 CSR_INVALID_SCANRESULT_HANDLE;
21037
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021038 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053021039 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021040 FL
21041 ("CSR failed issuing connect cmd with status = 0x%08X"),
21042 status);
21043 csr_clear_joinreq_param(mac_ctx, session_id);
21044 }
21045 return status;
21046}
21047
21048/**
21049 * csr_process_set_hw_mode() - Set HW mode command to PE
21050 * @mac: Globacl MAC pointer
21051 * @command: Command received from SME
21052 *
21053 * Posts the set HW mode command to PE. This message passing
21054 * through PE is required for PE's internal management
21055 *
21056 * Return: None
21057 */
21058void csr_process_set_hw_mode(tpAniSirGlobal mac, tSmeCmd *command)
21059{
21060 uint32_t len;
yeshwanth sriram guntukad4b482a2017-03-27 12:51:46 +053021061 struct s_sir_set_hw_mode *cmd = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021062 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070021063 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021064 struct sir_set_hw_mode_resp *param;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021065 enum policy_mgr_hw_mode_change hw_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021066
21067 /* Setting HW mode is for the entire system.
21068 * So, no need to check session
21069 */
21070
21071 if (!command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021072 sme_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021073 goto fail;
21074 }
21075
21076 len = sizeof(*cmd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021077 cmd = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021078 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021079 sme_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021080 /* Probably the fail response will also fail during malloc.
21081 * Still proceeding to send response!
21082 */
21083 goto fail;
21084 }
21085
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053021086 /* For hidden SSID case, if there is any scan command pending
21087 * it needs to be cleared before issuing set HW mode
21088 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021089 if (command->u.set_hw_mode_cmd.reason ==
21090 POLICY_MGR_UPDATE_REASON_HIDDEN_STA) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021091 sme_err("clear any pending scan command");
Abhishek Singh9fabbbb2018-01-29 17:38:36 +053021092 status = csr_scan_abort_mac_scan(mac,
21093 command->u.set_hw_mode_cmd.session_id, INVAL_SCAN_ID);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021094 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021095 sme_err("Failed to clear scan cmd");
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053021096 goto fail;
21097 }
21098 }
21099
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021100 if ((POLICY_MGR_UPDATE_REASON_OPPORTUNISTIC ==
21101 command->u.set_hw_mode_cmd.reason) &&
21102 (true == mac->sme.get_connection_info_cb(NULL, NULL))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021103 sme_err("Set HW mode refused: conn in progress");
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021104 policy_mgr_restart_opportunistic_timer(mac->psoc, false);
Nitesh Shaha3dfea32017-02-09 19:18:57 +053021105 goto fail;
21106 }
21107
Tushnim Bhattacharyya356d46e2018-02-14 10:56:58 -080021108 if ((POLICY_MGR_UPDATE_REASON_OPPORTUNISTIC ==
21109 command->u.set_hw_mode_cmd.reason) &&
21110 (!command->u.set_hw_mode_cmd.hw_mode_index &&
21111 !policy_mgr_need_opportunistic_upgrade(mac->psoc))) {
21112 sme_err("Set HW mode to SMM not needed anymore");
21113 goto fail;
21114 }
21115
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021116 hw_mode = policy_mgr_get_hw_mode_change_from_hw_mode_index(
21117 mac->psoc, command->u.set_hw_mode_cmd.hw_mode_index);
Nitesh Shaha3dfea32017-02-09 19:18:57 +053021118
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021119 if (POLICY_MGR_HW_MODE_NOT_IN_PROGRESS == hw_mode) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070021120 sme_err("hw_mode %d, failing", hw_mode);
Nitesh Shaha3dfea32017-02-09 19:18:57 +053021121 goto fail;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021122 }
Nitesh Shaha3dfea32017-02-09 19:18:57 +053021123
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021124 policy_mgr_set_hw_mode_change_in_progress(mac->psoc, hw_mode);
Nitesh Shaha3dfea32017-02-09 19:18:57 +053021125
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021126 cmd->messageType = eWNI_SME_SET_HW_MODE_REQ;
21127 cmd->length = len;
21128 cmd->set_hw.hw_mode_index = command->u.set_hw_mode_cmd.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053021129 cmd->set_hw.reason = command->u.set_hw_mode_cmd.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021130 /*
21131 * Below callback and context info are not needed for PE as of now.
21132 * Storing the passed value in the same s_sir_set_hw_mode format.
21133 */
21134 cmd->set_hw.set_hw_mode_cb = command->u.set_hw_mode_cmd.set_hw_mode_cb;
21135
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021136 sme_debug(
21137 "Posting set hw mode req to PE session:%d reason:%d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053021138 command->u.set_hw_mode_cmd.session_id,
21139 command->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021140
Rajeev Kumard138ac52017-01-30 18:38:37 -080021141 status = umac_send_mb_message_to_mac(cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021142 if (QDF_STATUS_SUCCESS != status) {
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021143 policy_mgr_set_hw_mode_change_in_progress(mac->psoc,
21144 POLICY_MGR_HW_MODE_NOT_IN_PROGRESS);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021145 sme_err("Posting to PE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021146 return;
21147 }
21148 return;
21149fail:
yeshwanth sriram guntukad4b482a2017-03-27 12:51:46 +053021150 if (cmd)
21151 qdf_mem_free(cmd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021152 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021153 if (!param) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021154 sme_err(
21155 "Malloc fail: Fail to send response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021156 return;
21157 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021158 sme_err("Sending set HW fail response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021159 param->status = SET_HW_MODE_STATUS_ECANCELED;
21160 param->cfgd_hw_mode_index = 0;
21161 param->num_vdev_mac_entries = 0;
21162 msg.type = eWNI_SME_SET_HW_MODE_RESP;
21163 msg.bodyptr = param;
21164 msg.bodyval = 0;
21165 sys_process_mmh_msg(mac, &msg);
21166}
21167
21168/**
21169 * csr_process_set_dual_mac_config() - Set HW mode command to PE
21170 * @mac: Global MAC pointer
21171 * @command: Command received from SME
21172 *
21173 * Posts the set dual mac config command to PE.
21174 *
21175 * Return: None
21176 */
21177void csr_process_set_dual_mac_config(tpAniSirGlobal mac, tSmeCmd *command)
21178{
21179 uint32_t len;
21180 struct sir_set_dual_mac_cfg *cmd;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021181 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070021182 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021183 struct sir_dual_mac_config_resp *param;
21184
21185 /* Setting MAC configuration is for the entire system.
21186 * So, no need to check session
21187 */
21188
21189 if (!command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021190 sme_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021191 goto fail;
21192 }
21193
21194 len = sizeof(*cmd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021195 cmd = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021196 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021197 sme_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021198 /* Probably the fail response will also fail during malloc.
21199 * Still proceeding to send response!
21200 */
21201 goto fail;
21202 }
21203
21204 cmd->message_type = eWNI_SME_SET_DUAL_MAC_CFG_REQ;
21205 cmd->length = len;
21206 cmd->set_dual_mac.scan_config = command->u.set_dual_mac_cmd.scan_config;
21207 cmd->set_dual_mac.fw_mode_config =
21208 command->u.set_dual_mac_cmd.fw_mode_config;
21209 /*
21210 * Below callback and context info are not needed for PE as of now.
21211 * Storing the passed value in the same sir_set_dual_mac_cfg format.
21212 */
21213 cmd->set_dual_mac.set_dual_mac_cb =
21214 command->u.set_dual_mac_cmd.set_dual_mac_cb;
21215
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021216 sme_debug(
21217 "Posting eWNI_SME_SET_DUAL_MAC_CFG_REQ to PE: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021218 cmd->set_dual_mac.scan_config,
21219 cmd->set_dual_mac.fw_mode_config);
21220
Rajeev Kumard138ac52017-01-30 18:38:37 -080021221 status = umac_send_mb_message_to_mac(cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021222 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021223 sme_err("Posting to PE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021224 return;
21225 }
21226 return;
21227fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021228 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021229 if (!param) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021230 sme_err(
21231 "Malloc fail: Fail to send response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021232 return;
21233 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021234 sme_err("Sending set dual mac fail response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021235 param->status = SET_HW_MODE_STATUS_ECANCELED;
21236 msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
21237 msg.bodyptr = param;
21238 msg.bodyval = 0;
21239 sys_process_mmh_msg(mac, &msg);
21240}
21241
21242/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021243 * csr_process_set_antenna_mode() - Set antenna mode command to
21244 * PE
21245 * @mac: Global MAC pointer
21246 * @command: Command received from SME
21247 *
21248 * Posts the set dual mac config command to PE.
21249 *
21250 * Return: None
21251 */
21252void csr_process_set_antenna_mode(tpAniSirGlobal mac, tSmeCmd *command)
21253{
21254 uint32_t len;
21255 struct sir_set_antenna_mode *cmd;
21256 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070021257 struct scheduler_msg msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021258 struct sir_antenna_mode_resp *param;
21259
21260 /* Setting MAC configuration is for the entire system.
21261 * So, no need to check session
21262 */
21263
21264 if (!command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021265 sme_err("Set antenna mode param is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021266 goto fail;
21267 }
21268
21269 len = sizeof(*cmd);
21270 cmd = qdf_mem_malloc(len);
21271 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021272 sme_err("Memory allocation failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021273 goto fail;
21274 }
21275
21276 cmd->message_type = eWNI_SME_SET_ANTENNA_MODE_REQ;
21277 cmd->length = len;
21278 cmd->set_antenna_mode = command->u.set_antenna_mode_cmd;
21279
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021280 sme_debug(
21281 "Posting eWNI_SME_SET_ANTENNA_MODE_REQ to PE: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021282 cmd->set_antenna_mode.num_rx_chains,
21283 cmd->set_antenna_mode.num_tx_chains);
21284
Rajeev Kumard138ac52017-01-30 18:38:37 -080021285 status = umac_send_mb_message_to_mac(cmd);
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021286 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021287 sme_err("Posting to PE failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021288 /*
Rajeev Kumard138ac52017-01-30 18:38:37 -080021289 * umac_send_mb_message_to_mac would've released the mem
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021290 * allocated by cmd.
21291 */
21292 goto fail;
21293 }
21294
21295 return;
21296fail:
21297 param = qdf_mem_malloc(sizeof(*param));
21298 if (!param) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021299 sme_err(
21300 "Malloc fail: Fail to send response to SME");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021301 return;
21302 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021303 sme_err("Sending set dual mac fail response to SME");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080021304 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
21305 msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
21306 msg.bodyptr = param;
21307 msg.bodyval = 0;
21308 sys_process_mmh_msg(mac, &msg);
21309}
21310
21311/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021312 * csr_process_nss_update_req() - Update nss command to PE
21313 * @mac: Globacl MAC pointer
21314 * @command: Command received from SME
21315 *
21316 * Posts the nss update command to PE. This message passing
21317 * through PE is required for PE's internal management
21318 *
21319 * Return: None
21320 */
21321void csr_process_nss_update_req(tpAniSirGlobal mac, tSmeCmd *command)
21322{
21323 uint32_t len;
21324 struct sir_nss_update_request *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021325 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070021326 struct scheduler_msg msg_return = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021327 struct sir_beacon_tx_complete_rsp *param;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053021328 struct csr_roam_session *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021329
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021330
Naveen Rawat7ecf53d2016-06-27 15:31:48 -070021331 if (!CSR_IS_SESSION_VALID(mac, command->sessionId)) {
Varun Reddy Yeturu84c497b2017-09-19 15:36:22 -070021332 sme_err("Invalid session id %d", command->sessionId);
21333 goto fail;
Naveen Rawat7ecf53d2016-06-27 15:31:48 -070021334 }
21335 session = CSR_GET_SESSION(mac, command->sessionId);
21336
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021337 len = sizeof(*msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021338 msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021339 if (!msg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021340 sme_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021341 /* Probably the fail response is also fail during malloc.
21342 * Still proceeding to send response!
21343 */
21344 goto fail;
21345 }
21346
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021347 msg->msgType = eWNI_SME_NSS_UPDATE_REQ;
21348 msg->msgLen = sizeof(*msg);
21349
21350 msg->new_nss = command->u.nss_update_cmd.new_nss;
21351 msg->vdev_id = command->u.nss_update_cmd.session_id;
21352
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021353 sme_debug("Posting eWNI_SME_NSS_UPDATE_REQ to PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021354
Rajeev Kumard138ac52017-01-30 18:38:37 -080021355 status = umac_send_mb_message_to_mac(msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021356 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021357 sme_err("Posting to PE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021358 return;
21359 }
21360 return;
21361fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021362 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021363 if (!param) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021364 sme_err(
21365 "Malloc fail: Fail to send response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021366 return;
21367 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021368 sme_err("Sending nss update fail response to SME");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021369 param->tx_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080021370 param->session_id = command->u.nss_update_cmd.session_id;
21371 msg_return.type = eWNI_SME_NSS_UPDATE_RSP;
21372 msg_return.bodyptr = param;
21373 msg_return.bodyval = 0;
21374 sys_process_mmh_msg(mac, &msg_return);
21375}
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021376#ifdef FEATURE_WLAN_TDLS
21377/**
21378 * csr_roam_fill_tdls_info() - Fill TDLS information
21379 * @roam_info: Roaming information buffer
21380 * @join_rsp: Join response which has TDLS info
21381 *
21382 * Return: None
21383 */
Jeff Johnson172237b2017-11-07 15:32:59 -080021384void csr_roam_fill_tdls_info(tpAniSirGlobal mac_ctx,
21385 struct csr_roam_info *roam_info,
21386 tpSirSmeJoinRsp join_rsp)
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021387{
21388 roam_info->tdls_prohibited = join_rsp->tdls_prohibited;
21389 roam_info->tdls_chan_swit_prohibited =
21390 join_rsp->tdls_chan_swit_prohibited;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021391 sme_debug(
21392 "tdls:prohibit: %d, chan_swit_prohibit: %d",
Kabilan Kannan32eb5022016-10-04 12:24:50 -070021393 roam_info->tdls_prohibited,
21394 roam_info->tdls_chan_swit_prohibited);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021395}
21396#endif
21397
Sridhar Selvaraje5260442017-08-19 10:12:03 +053021398#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Jeff Johnson172237b2017-11-07 15:32:59 -080021399static void csr_copy_fils_join_rsp_roam_info(struct csr_roam_info *roam_info,
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053021400 roam_offload_synch_ind *roam_synch_data)
21401{
21402 struct fils_join_rsp_params *roam_fils_info;
21403
21404 roam_info->fils_join_rsp = qdf_mem_malloc(sizeof(*roam_fils_info));
21405 if (!roam_info->fils_join_rsp) {
21406 sme_err("fils_join_rsp malloc fails!");
21407 return;
21408 }
21409
21410 roam_fils_info = roam_info->fils_join_rsp;
21411 cds_copy_hlp_info(&roam_synch_data->dst_mac,
21412 &roam_synch_data->src_mac,
21413 roam_synch_data->hlp_data_len,
21414 roam_synch_data->hlp_data,
21415 &roam_fils_info->dst_mac,
21416 &roam_fils_info->src_mac,
21417 &roam_fils_info->hlp_data_len,
21418 roam_fils_info->hlp_data);
21419}
21420#else
Jeff Johnson172237b2017-11-07 15:32:59 -080021421static inline
21422void csr_copy_fils_join_rsp_roam_info(struct csr_roam_info *roam_info,
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053021423 roam_offload_synch_ind *roam_synch_data)
21424{}
21425#endif
21426
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080021427#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Naveen Rawat257386f2017-05-17 11:42:18 -070021428static QDF_STATUS csr_process_roam_sync_callback(tpAniSirGlobal mac_ctx,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021429 roam_offload_synch_ind *roam_synch_data,
Naveen Rawat257386f2017-05-17 11:42:18 -070021430 tpSirBssDescription bss_desc, enum sir_roam_op_code reason)
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021431{
21432 uint8_t session_id = roam_synch_data->roamedVdevId;
gaurank kathpalia14e2f912017-08-31 14:51:45 +053021433 struct csr_roam_session *session = CSR_GET_SESSION(mac_ctx, session_id);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021434 tDot11fBeaconIEs *ies_local = NULL;
21435 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
Jeff Johnson172237b2017-11-07 15:32:59 -080021436 struct csr_roam_info *roam_info;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021437 tCsrRoamConnectedProfile *conn_profile = NULL;
21438 sme_QosAssocInfo assoc_info;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021439 tpAddBssParams add_bss_params;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021440 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -070021441 uint16_t len;
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +053021442#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
21443 tSirSmeHTProfile *src_profile = NULL;
21444 tCsrRoamHTProfile *dst_profile = NULL;
21445#endif
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021446
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021447 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021448 sme_err("LFR3: Session not found");
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021449 return QDF_STATUS_E_FAILURE;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021450 }
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +053021451
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021452 sme_debug("LFR3: reason: %d", reason);
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070021453 switch (reason) {
21454 case SIR_ROAMING_DEREGISTER_STA:
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070021455 /*
21456 * The following is the first thing done in CSR
21457 * after receiving RSI. Hence stopping the timer here.
21458 */
21459 csr_roam_roaming_offload_timer_action(mac_ctx,
21460 0, session_id, ROAMING_OFFLOAD_TIMER_STOP);
Abhishek Singhd5686472017-09-20 15:18:50 +053021461 if (session->discon_in_progress ||
21462 !CSR_IS_ROAM_JOINED(mac_ctx, session_id)) {
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021463 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhd5686472017-09-20 15:18:50 +053021464 FL("LFR3: Session not in connected state or disconnect is in progress %d"),
21465 session->discon_in_progress);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021466 return QDF_STATUS_E_FAILURE;
21467 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021468 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070021469 eCSR_ROAM_FT_START, eCSR_ROAM_RESULT_SUCCESS);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021470 return status;
Naveen Rawat8cc23b02016-07-14 12:22:56 -070021471 case SIR_ROAMING_START:
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070021472 csr_roam_roaming_offload_timer_action(mac_ctx,
21473 CSR_ROAMING_OFFLOAD_TIMEOUT_PERIOD, session_id,
21474 ROAMING_OFFLOAD_TIMER_START);
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070021475 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070021476 eCSR_ROAM_START, eCSR_ROAM_RESULT_SUCCESS);
Varun Reddy Yeturu85090c92018-01-26 15:06:02 -080021477 wlan_abort_scan(mac_ctx->pdev, INVAL_PDEV_ID,
21478 session_id, INVAL_SCAN_ID, false);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021479 return status;
Naveen Rawat8cc23b02016-07-14 12:22:56 -070021480 case SIR_ROAMING_ABORT:
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070021481 csr_roam_roaming_offload_timer_action(mac_ctx,
21482 0, session_id, ROAMING_OFFLOAD_TIMER_STOP);
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070021483 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070021484 eCSR_ROAM_ABORT, eCSR_ROAM_RESULT_SUCCESS);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021485 return status;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -070021486 case SIR_ROAM_SYNCH_NAPI_OFF:
21487 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070021488 eCSR_ROAM_NAPI_OFF, eCSR_ROAM_RESULT_SUCCESS);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021489 return status;
Arif Hussain43354e62017-05-24 11:24:25 -070021490 case SIR_ROAMING_INVOKE_FAIL:
Arif Hussain43354e62017-05-24 11:24:25 -070021491 /* Userspace roam request failed, disconnect with current AP */
21492 sme_debug("LFR3: roam invoke from user-space fail, dis cur AP");
21493 csr_roam_disconnect(mac_ctx, session_id,
21494 eCSR_DISCONNECT_REASON_DEAUTH);
21495 return status;
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070021496 case SIR_ROAM_SYNCH_PROPAGATION:
21497 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -070021498 case SIR_ROAM_SYNCH_COMPLETE:
21499 /*
21500 * Following operations need to be done once roam sync
21501 * completion is sent to FW, hence called here:
21502 * 1) Firmware has already updated DBS policy. Update connection
21503 * table in the host driver.
21504 * 2) Force SCC switch if needed
21505 * 3) Set connection in progress = false
21506 */
21507 /* first update connection info from wma interface */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021508 policy_mgr_update_connection_info(mac_ctx->psoc, session_id);
Naveen Rawat8cc23b02016-07-14 12:22:56 -070021509 /* then update remaining parameters from roam sync ctx */
Srinivas Girigowda6598eea2017-07-06 19:26:19 -070021510 sme_debug("Update DBS hw mode");
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021511 policy_mgr_hw_mode_transition_cb(
Naveen Rawat8cc23b02016-07-14 12:22:56 -070021512 roam_synch_data->hw_mode_trans_ind.old_hw_mode_index,
21513 roam_synch_data->hw_mode_trans_ind.new_hw_mode_index,
21514 roam_synch_data->hw_mode_trans_ind.num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021515 roam_synch_data->hw_mode_trans_ind.vdev_mac_map,
21516 mac_ctx->psoc);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080021517 mac_ctx->sme.set_connection_info_cb(false);
Naveen Rawat8cc23b02016-07-14 12:22:56 -070021518 session->roam_synch_in_progress = false;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080021519 policy_mgr_check_concurrent_intf_and_restart_sap(mac_ctx->psoc);
Selvaraj, Sridhar50566502017-05-15 18:26:47 +053021520 csr_roam_offload_scan(mac_ctx, session_id,
21521 ROAM_SCAN_OFFLOAD_START,
21522 REASON_CONNECT);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021523 return status;
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070021524 default:
Srinivas Girigowda6598eea2017-07-06 19:26:19 -070021525 sme_debug("LFR3: callback reason %d", reason);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021526 return QDF_STATUS_E_FAILURE;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021527 }
Arif Hussain557920f2016-09-07 16:03:46 -070021528 session->roam_synch_in_progress = true;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021529 session->roam_synch_data = roam_synch_data;
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021530 status = csr_get_parsed_bss_description_ies(
21531 mac_ctx, bss_desc, &ies_local);
21532 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021533 sme_err("LFR3: fail to parse IEs");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021534 session->roam_synch_in_progress = false;
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021535 return status;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021536 }
21537 conn_profile = &session->connectedProfile;
21538 csr_roam_stop_network(mac_ctx, session_id,
21539 session->pCurRoamProfile,
21540 bss_desc,
21541 ies_local);
21542 ps_global_info->remain_in_power_active_till_dhcp = false;
21543 session->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
Jeff Johnson172237b2017-11-07 15:32:59 -080021544 roam_info = qdf_mem_malloc(sizeof(struct csr_roam_info));
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021545 if (NULL == roam_info) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053021546 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021547 FL("LFR3: Mem Alloc failed for roam info"));
21548 session->roam_synch_in_progress = false;
Yeshwanth Sriram Guntuka6f8b8752016-12-08 17:33:10 +053021549 qdf_mem_free(ies_local);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021550 return QDF_STATUS_E_NOMEM;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021551 }
21552 csr_scan_save_roam_offload_ap_to_scan_cache(mac_ctx, roam_synch_data,
21553 bss_desc);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021554 roam_info->sessionId = session_id;
Frank Liud1a28462017-09-06 22:55:48 +080021555 tgt_tdls_peers_deleted_notification(mac_ctx->psoc, session_id);
21556
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021557 qdf_mem_copy(&roam_info->bssid.bytes, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053021558 sizeof(struct qdf_mac_addr));
Jeff Johnson536249f2018-05-12 16:48:38 -070021559 csr_roam_save_connected_information(mac_ctx, session_id,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021560 session->pCurRoamProfile,
21561 bss_desc,
21562 ies_local);
21563 csr_roam_save_security_rsp_ie(mac_ctx, session_id,
21564 session->pCurRoamProfile->negotiatedAuthType,
21565 bss_desc, ies_local);
Yu Wang0477ee32017-02-10 20:02:03 +080021566
21567#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021568 roam_info->isESEAssoc = conn_profile->isESEAssoc;
Yu Wang0477ee32017-02-10 20:02:03 +080021569#endif
Prakash Dhavalif3287ef2016-11-28 17:56:33 -080021570
21571 /*
21572 * Encryption keys for new connection are obtained as follows:
21573 * authStatus = CSR_ROAM_AUTH_STATUS_AUTHENTICATED
21574 * Open - No keys required.
21575 * Static WEP - Firmware copies keys from old AP to new AP.
21576 * Fast roaming authentications e.g. PSK, FT, CCKM - firmware
21577 * supplicant obtains them through 4-way handshake.
21578 *
21579 * authStatus = CSR_ROAM_AUTH_STATUS_CONNECTED
21580 * All other authentications - Host supplicant performs EAPOL
21581 * with AP after this point and sends new keys to the driver.
21582 * Driver starts wait_for_key timer for that purpose.
21583 */
Srinivas Girigowdaf326dfe2017-08-03 11:28:32 -070021584 if (roam_synch_data->authStatus
21585 == CSR_ROAM_AUTH_STATUS_AUTHENTICATED) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053021586 QDF_TRACE(QDF_MODULE_ID_SME,
21587 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021588 FL("LFR3:Don't start waitforkey timer"));
21589 csr_roam_substate_change(mac_ctx,
21590 eCSR_ROAM_SUBSTATE_NONE, session_id);
21591 } else {
21592 roam_info->fAuthRequired = true;
21593 csr_roam_substate_change(mac_ctx,
21594 eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY,
21595 session_id);
21596
21597 ps_global_info->remain_in_power_active_till_dhcp = true;
21598 mac_ctx->roam.WaitForKeyTimerInfo.sessionId = session_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053021599 if (!QDF_IS_STATUS_SUCCESS(csr_roam_start_wait_for_key_timer(
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021600 mac_ctx, CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD))
21601 ) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021602 sme_err("Failed wait for key timer start");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021603 csr_roam_substate_change(mac_ctx,
21604 eCSR_ROAM_SUBSTATE_NONE,
21605 session_id);
21606 }
21607 }
21608 roam_info->nBeaconLength = 0;
21609 roam_info->nAssocReqLength = roam_synch_data->reassoc_req_length -
21610 SIR_MAC_HDR_LEN_3A - SIR_MAC_REASSOC_SSID_OFFSET;
21611 roam_info->nAssocRspLength = roam_synch_data->reassocRespLength -
21612 SIR_MAC_HDR_LEN_3A;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021613 roam_info->pbFrames = qdf_mem_malloc(roam_info->nBeaconLength +
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021614 roam_info->nAssocReqLength + roam_info->nAssocRspLength);
21615 if (NULL == roam_info->pbFrames) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021616 sme_err("no memory available");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021617 session->roam_synch_in_progress = false;
21618 if (roam_info)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021619 qdf_mem_free(roam_info);
Yeshwanth Sriram Guntuka6f8b8752016-12-08 17:33:10 +053021620 qdf_mem_free(ies_local);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021621 return QDF_STATUS_E_NOMEM;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021622 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021623 qdf_mem_copy(roam_info->pbFrames,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021624 (uint8_t *)roam_synch_data +
21625 roam_synch_data->reassoc_req_offset +
21626 SIR_MAC_HDR_LEN_3A + SIR_MAC_REASSOC_SSID_OFFSET,
21627 roam_info->nAssocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021628 qdf_mem_copy(roam_info->pbFrames + roam_info->nAssocReqLength,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021629 (uint8_t *)roam_synch_data +
21630 roam_synch_data->reassocRespOffset +
21631 SIR_MAC_HDR_LEN_3A,
21632 roam_info->nAssocRspLength);
21633
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053021634 QDF_TRACE(QDF_MODULE_ID_SME,
21635 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021636 FL("LFR3:Clear Connected info"));
21637 csr_roam_free_connected_info(mac_ctx,
21638 &session->connectedInfo);
Yu Wang0477ee32017-02-10 20:02:03 +080021639 len = roam_synch_data->join_rsp->parsedRicRspLen;
21640
21641#ifdef FEATURE_WLAN_ESE
21642 len += roam_synch_data->join_rsp->tspecIeLen;
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -070021643 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yu Wang0477ee32017-02-10 20:02:03 +080021644 FL("LFR3: tspecLen %d"),
Sreelakshmi Konamki0a942d42017-01-24 14:46:55 +053021645 roam_synch_data->join_rsp->tspecIeLen);
Yu Wang0477ee32017-02-10 20:02:03 +080021646#endif
21647
21648 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
21649 FL("LFR3: RIC length - %d"),
21650 roam_synch_data->join_rsp->parsedRicRspLen);
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -070021651 if (len) {
21652 session->connectedInfo.pbFrames =
21653 qdf_mem_malloc(len);
21654 if (session->connectedInfo.pbFrames != NULL) {
21655 qdf_mem_copy(session->connectedInfo.pbFrames,
21656 roam_synch_data->join_rsp->frames, len);
21657 session->connectedInfo.nRICRspLength =
21658 roam_synch_data->join_rsp->parsedRicRspLen;
Yu Wang0477ee32017-02-10 20:02:03 +080021659
21660#ifdef FEATURE_WLAN_ESE
Sreelakshmi Konamki0a942d42017-01-24 14:46:55 +053021661 session->connectedInfo.nTspecIeLength =
21662 roam_synch_data->join_rsp->tspecIeLen;
Yu Wang0477ee32017-02-10 20:02:03 +080021663#endif
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -070021664 }
21665 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021666 conn_profile->vht_channel_width =
21667 roam_synch_data->join_rsp->vht_channel_width;
21668 add_bss_params = (tpAddBssParams)roam_synch_data->add_bss_params;
21669 session->connectedInfo.staId = add_bss_params->staContext.staIdx;
21670 roam_info->staId = session->connectedInfo.staId;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021671 roam_info->timingMeasCap =
21672 roam_synch_data->join_rsp->timingMeasCap;
21673 roam_info->chan_info.nss = roam_synch_data->join_rsp->nss;
21674 roam_info->chan_info.rate_flags =
21675 roam_synch_data->join_rsp->max_rate_flags;
Kabilan Kannan32eb5022016-10-04 12:24:50 -070021676 csr_roam_fill_tdls_info(mac_ctx, roam_info, roam_synch_data->join_rsp);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021677#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
21678 src_profile = &roam_synch_data->join_rsp->HTProfile;
21679 dst_profile = &conn_profile->HTProfile;
21680 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053021681 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021682 csr_roam_copy_ht_profile(dst_profile,
21683 src_profile);
21684#endif
21685 assoc_info.pBssDesc = bss_desc;
21686 roam_info->statusCode = eSIR_SME_SUCCESS;
21687 roam_info->reasonCode = eSIR_SME_SUCCESS;
21688 assoc_info.pProfile = session->pCurRoamProfile;
21689 mac_ctx->roam.roamSession[session_id].connectState =
21690 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
21691 sme_qos_csr_event_ind(mac_ctx, session_id,
21692 SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
21693 sme_qos_csr_event_ind(mac_ctx, session_id,
21694 SME_QOS_CSR_REASSOC_REQ, NULL);
21695 sme_qos_csr_event_ind(mac_ctx, session_id,
21696 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
21697 mac_ctx->roam.roamSession[session_id].connectState =
21698 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
21699 sme_qos_csr_event_ind(mac_ctx, session_id,
21700 SME_QOS_CSR_REASSOC_COMPLETE, &assoc_info);
21701 roam_info->pBssDesc = bss_desc;
21702 conn_profile->acm_mask = sme_qos_get_acm_mask(mac_ctx,
21703 bss_desc, NULL);
21704 if (conn_profile->modifyProfileFields.uapsd_mask) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021705 sme_debug(
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021706 " uapsd_mask (0x%X) set, request UAPSD now",
21707 conn_profile->modifyProfileFields.uapsd_mask);
21708 sme_ps_start_uapsd(mac_ctx, session_id,
21709 NULL, NULL);
21710 }
21711 conn_profile->dot11Mode = session->bssParams.uCfgDot11Mode;
21712 roam_info->u.pConnectedProfile = conn_profile;
21713
Srinivas Girigowda81aef902017-03-17 09:34:19 -070021714 sme_debug(
21715 "vht ch width %d staId %d nss %d rate_flag %d dot11Mode %d",
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +053021716 conn_profile->vht_channel_width,
21717 roam_info->staId,
21718 roam_info->chan_info.nss,
21719 roam_info->chan_info.rate_flags,
21720 conn_profile->dot11Mode);
21721
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021722 if (!IS_FEATURE_SUPPORTED_BY_FW
21723 (SLM_SESSIONIZATION) &&
21724 (csr_is_concurrent_session_running(mac_ctx))) {
21725 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
21726 }
21727 roam_info->roamSynchInProgress = true;
21728 roam_info->synchAuthStatus = roam_synch_data->authStatus;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053021729 roam_info->kek_len = roam_synch_data->kek_len;
21730 roam_info->pmk_len = roam_synch_data->pmk_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021731 qdf_mem_copy(roam_info->kck, roam_synch_data->kck, SIR_KCK_KEY_LEN);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053021732 qdf_mem_copy(roam_info->kek, roam_synch_data->kek, roam_info->kek_len);
21733
21734 if (roam_synch_data->pmk_len)
21735 qdf_mem_copy(roam_info->pmk, roam_synch_data->pmk,
21736 roam_synch_data->pmk_len);
21737
21738 qdf_mem_copy(roam_info->pmkid, roam_synch_data->pmkid, SIR_PMKID_LEN);
21739 roam_info->update_erp_next_seq_num =
21740 roam_synch_data->update_erp_next_seq_num;
21741 roam_info->next_erp_seq_num = roam_synch_data->next_erp_seq_num;
Vignesh Viswanathan8da68cf2017-09-07 14:00:04 +053021742 sme_debug("Update ERP Seq Num : %d, Next ERP Seq Num : %d",
21743 roam_info->update_erp_next_seq_num,
21744 roam_info->next_erp_seq_num);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021745 qdf_mem_copy(roam_info->replay_ctr, roam_synch_data->replay_ctr,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021746 SIR_REPLAY_CTR_LEN);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053021747 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053021748 FL("LFR3: Copy KCK, KEK(len %d) and Replay Ctr"),
21749 roam_info->kek_len);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021750 roam_info->subnet_change_status =
21751 CSR_GET_SUBNET_STATUS(roam_synch_data->roamReason);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053021752
21753 csr_copy_fils_join_rsp_roam_info(roam_info, roam_synch_data);
21754
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021755 csr_roam_call_callback(mac_ctx, session_id, roam_info, 0,
21756 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
21757 csr_reset_pmkid_candidate_list(mac_ctx, session_id);
21758#ifdef FEATURE_WLAN_WAPI
21759 csr_reset_bkid_candidate_list(mac_ctx, session_id);
21760#endif
21761 if (!CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053021762 QDF_TRACE(QDF_MODULE_ID_SME,
21763 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021764 FL
21765 ("NO CSR_IS_WAIT_FOR_KEY -> csr_roam_link_up"));
21766 csr_roam_link_up(mac_ctx, conn_profile->bssid);
21767 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -070021768
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021769 session->fRoaming = false;
21770 session->roam_synch_in_progress = false;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +053021771 sme_free_join_rsp_fils_params(roam_info);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053021772 qdf_mem_free(roam_info->pbFrames);
21773 qdf_mem_free(roam_info);
Yeshwanth Sriram Guntuka6f8b8752016-12-08 17:33:10 +053021774 qdf_mem_free(ies_local);
Naveen Rawat257386f2017-05-17 11:42:18 -070021775
21776 return status;
21777}
21778
21779/**
21780 * csr_roam_synch_callback() - SME level callback for roam synch propagation
21781 * @mac_ctx: MAC Context
21782 * @roam_synch_data: Roam synch data buffer pointer
21783 * @bss_desc: BSS descriptor pointer
21784 * @reason: Reason for calling the callback
21785 *
21786 * This callback is registered with WMA and used after roaming happens in
21787 * firmware and the call to this routine completes the roam synch
21788 * propagation at both CSR and HDD levels. The HDD level propagation
21789 * is achieved through the already defined callback for assoc completion
21790 * handler.
21791 *
21792 * Return: Success or Failure.
21793 */
21794QDF_STATUS csr_roam_synch_callback(tpAniSirGlobal mac_ctx,
21795 roam_offload_synch_ind *roam_synch_data,
21796 tpSirBssDescription bss_desc, enum sir_roam_op_code reason)
21797{
21798 QDF_STATUS status;
21799
21800 status = sme_acquire_global_lock(&mac_ctx->sme);
21801 if (!QDF_IS_STATUS_SUCCESS(status)) {
21802 sme_err("LFR3: Locking failed, bailing out");
21803 return status;
21804 }
21805
21806 status = csr_process_roam_sync_callback(mac_ctx, roam_synch_data,
21807 bss_desc, reason);
21808
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021809 sme_release_global_lock(&mac_ctx->sme);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070021810
21811 return status;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080021812}
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080021813#endif