blob: ab78f4f33f4f1544847cd2e60f8f149051e46515 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Sandeep Puligilla4d976b62017-01-06 17:38:45 -08002 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053028/*
29 * DOC: csr_api_roam.c
30 *
31 * Implementation for the Common Roaming interfaces.
32 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080033#include "ani_global.h" /* for tpAniSirGlobal */
34#include "wma_types.h"
35#include "wma_if.h" /* for STA_INVALID_IDX. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080036#include "csr_inside_api.h"
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +053037#include "sme_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080038#include "sme_qos_internal.h"
39#include "sme_inside.h"
40#include "host_diag_core_event.h"
41#include "host_diag_core_log.h"
42#include "csr_api.h"
43#include "csr_internal.h"
44#include "cds_reg_service.h"
45#include "mac_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080046#include "csr_neighbor_roam.h"
Amar Singhale4f28ee2015-10-21 14:36:56 -070047#include "cds_regdomain.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "cds_utils.h"
49#include "sir_types.h"
50#include "cfg_api.h"
51#include "sme_power_save_api.h"
52#include "wma.h"
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080053#include "wlan_policy_mgr_api.h"
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -070054#include "sme_nan_datapath.h"
Agrawal Ashish21ba2572016-09-03 16:40:10 +053055#include "pld_common.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070056#include "wlan_reg_services_api.h"
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053057#include <wlan_logging_sock_svc.h>
Krunal Sonia8270f52017-02-23 19:51:25 -080058#include "wlan_objmgr_psoc_obj.h"
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080059#include <wlan_scan_ucfg_api.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
Amar Singhal7c1e8982016-05-19 15:08:09 -070061#define MAX_PWR_FCC_CHAN_12 8
62#define MAX_PWR_FCC_CHAN_13 2
63
Sandeep Puligilla80038de2017-05-10 10:43:29 -070064#define CSR_NUM_IBSS_START_CHAN_50 5
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065#define CSR_NUM_IBSS_START_CHANNELS_24 3
Agrawal Ashish71afe142017-04-27 14:38:52 +053066/* 75 seconds, for WPA, WPA2, CCKM */
67#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD (75 * QDF_MC_TIMER_TO_SEC_UNIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068/* 120 seconds, for WPS */
Anurag Chouhan210db072016-02-22 18:42:15 +053069#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD (120 * QDF_MC_TIMER_TO_SEC_UNIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053071/* OBIWAN recommends [8 10]% : pick 9% */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053073/* OBIWAN recommends -85dBm */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080074#define CSR_VCC_RSSI_THRESHOLD 80
75#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 /* ms */
76#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 /* ms */
77#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 /* ms */
78/* Flag to send/do not send disassoc frame over the air */
79#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
80#define RSSI_HACK_BMPS (-40)
81#define MAX_CB_VALUE_IN_INI (2)
82
83#define MAX_SOCIAL_CHANNELS 3
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053084
85/* packet dump timer duration of 60 secs */
86#define PKT_DUMP_TIMER_DURATION 60
87
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088/* Choose the largest possible value that can be accomodates in 8 bit signed */
89/* variable. */
90#define SNR_HACK_BMPS (127)
91
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070092/*
93 * ROAMING_OFFLOAD_TIMER_START - Indicates the action to start the timer
94 * ROAMING_OFFLOAD_TIMER_STOP - Indicates the action to stop the timer
95 * CSR_ROAMING_OFFLOAD_TIMEOUT_PERIOD - Timeout value for roaming offload timer
96 */
97#define ROAMING_OFFLOAD_TIMER_START 1
98#define ROAMING_OFFLOAD_TIMER_STOP 2
99#define CSR_ROAMING_OFFLOAD_TIMEOUT_PERIOD (5 * QDF_MC_TIMER_TO_SEC_UNIT)
100
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530101/* Static Type declarations */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800102static tCsrRoamSession csr_roam_roam_session[CSR_ROAM_SESSION_MAX];
103
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800104#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
105int diag_auth_type_from_csr_type(eCsrAuthType authType)
106{
107 int n = AUTH_OPEN;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530108
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800109 switch (authType) {
110 case eCSR_AUTH_TYPE_SHARED_KEY:
111 n = AUTH_SHARED;
112 break;
113 case eCSR_AUTH_TYPE_WPA:
114 n = AUTH_WPA_EAP;
115 break;
116 case eCSR_AUTH_TYPE_WPA_PSK:
117 n = AUTH_WPA_PSK;
118 break;
119 case eCSR_AUTH_TYPE_RSN:
120#ifdef WLAN_FEATURE_11W
121 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
122#endif
123 n = AUTH_WPA2_EAP;
124 break;
125 case eCSR_AUTH_TYPE_RSN_PSK:
126#ifdef WLAN_FEATURE_11W
127 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
128#endif
129 n = AUTH_WPA2_PSK;
130 break;
131#ifdef FEATURE_WLAN_WAPI
132 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
133 n = AUTH_WAPI_CERT;
134 break;
135 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
136 n = AUTH_WAPI_PSK;
137 break;
138#endif /* FEATURE_WLAN_WAPI */
139 default:
140 break;
141 }
142 return n;
143}
144
145int diag_enc_type_from_csr_type(eCsrEncryptionType encType)
146{
147 int n = ENC_MODE_OPEN;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 switch (encType) {
150 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
151 case eCSR_ENCRYPT_TYPE_WEP40:
152 n = ENC_MODE_WEP40;
153 break;
154 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
155 case eCSR_ENCRYPT_TYPE_WEP104:
156 n = ENC_MODE_WEP104;
157 break;
158 case eCSR_ENCRYPT_TYPE_TKIP:
159 n = ENC_MODE_TKIP;
160 break;
161 case eCSR_ENCRYPT_TYPE_AES:
162 n = ENC_MODE_AES;
163 break;
164#ifdef FEATURE_WLAN_WAPI
165 case eCSR_ENCRYPT_TYPE_WPI:
166 n = ENC_MODE_SMS4;
167 break;
168#endif /* FEATURE_WLAN_WAPI */
169 default:
170 break;
171 }
172 return n;
173}
174#endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */
175static const uint8_t
Sandeep Puligilla80038de2017-05-10 10:43:29 -0700176csr_start_ibss_channels50[CSR_NUM_IBSS_START_CHAN_50] = { 36, 44, 52, 56, 140 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177static const uint8_t
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530178csr_start_ibss_channels24[CSR_NUM_IBSS_START_CHANNELS_24] = { 1, 6, 11 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179static void init_config_param(tpAniSirGlobal pMac);
180static bool csr_roam_process_results(tpAniSirGlobal pMac, tSmeCmd *pCommand,
181 eCsrRoamCompleteResult Result,
182 void *Context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530183static QDF_STATUS csr_roam_start_ibss(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 tCsrRoamProfile *pProfile,
185 bool *pfSameIbss);
186static void csr_roam_update_connected_profile_from_new_bss(tpAniSirGlobal pMac,
187 uint32_t sessionId,
188 tSirSmeNewBssInfo *
189 pNewBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800190static ePhyChanBondState csr_get_cb_mode_from_ies(tpAniSirGlobal pMac,
191 uint8_t primaryChn,
192 tDot11fBeaconIEs *pIes);
193
194static void csr_roaming_state_config_cnf_processor(tpAniSirGlobal pMac,
Krunal Sonia8270f52017-02-23 19:51:25 -0800195 tSmeCmd *pCommand, uint32_t result, uint8_t session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530196static QDF_STATUS csr_roam_open(tpAniSirGlobal pMac);
197static QDF_STATUS csr_roam_close(tpAniSirGlobal pMac);
198static bool csr_roam_is_same_profile_keys(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199 tCsrRoamConnectedProfile *pConnProfile,
200 tCsrRoamProfile *pProfile2);
201
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530202static QDF_STATUS csr_roam_start_roaming_timer(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 uint32_t sessionId,
204 uint32_t interval);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530205static QDF_STATUS csr_roam_stop_roaming_timer(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 uint32_t sessionId);
207static void csr_roam_roaming_timer_handler(void *pv);
Yingying Tang87f01392017-03-22 17:29:54 +0800208#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -0700209static void csr_roam_roaming_offload_timer_action(tpAniSirGlobal mac_ctx,
210 uint32_t interval, uint8_t session_id, uint8_t action);
Yingying Tang87f01392017-03-22 17:29:54 +0800211#endif
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -0700212static void csr_roam_roaming_offload_timeout_handler(void *timer_data);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530213static QDF_STATUS csr_roam_start_wait_for_key_timer(tpAniSirGlobal pMac,
214 uint32_t interval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800215static void csr_roam_wait_for_key_time_out_handler(void *pv);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530216static QDF_STATUS csr_init11d_info(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
217static QDF_STATUS csr_init_channel_power_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800218 tCsr11dinfo *ps11dinfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530219static QDF_STATUS csr_roam_free_connected_info(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220 tCsrRoamConnectedInfo *
221 pConnectedInfo);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530222static QDF_STATUS csr_send_mb_set_context_req_msg(tpAniSirGlobal pMac,
223 uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530224 struct qdf_mac_addr peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -0800225 uint8_t numKeys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226 tAniEdType edType, bool fUnicast,
227 tAniKeyDirection aniKeyDirection,
228 uint8_t keyId, uint8_t keyLength,
229 uint8_t *pKey, uint8_t paeRole,
230 uint8_t *pKeyRsc);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530231static void csr_roam_link_up(tpAniSirGlobal pMac, struct qdf_mac_addr bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232static void csr_roam_link_down(tpAniSirGlobal pMac, uint32_t sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530233static QDF_STATUS csr_send_mb_stats_req_msg(tpAniSirGlobal pMac,
234 uint32_t statsMask, uint8_t staId,
235 uint8_t sessionId);
236/* pStaEntry is no longer invalid upon the return of this function. */
237static void csr_roam_remove_stat_list_entry(tpAniSirGlobal pMac,
238 tListElem *pEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800239static eCsrCfgDot11Mode csr_roam_get_phy_mode_band_for_bss(tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530240 tCsrRoamProfile *pProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241 uint8_t operationChn,
242 eCsrBand *pBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530243static QDF_STATUS csr_roam_get_qos_info_from_bss(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 tSirBssDescription *pBssDesc);
245tCsrStatsClientReqInfo *csr_roam_insert_entry_into_list(tpAniSirGlobal pMac,
246 tDblLinkList *pStaList,
247 tCsrStatsClientReqInfo *
248 pStaEntry);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530249static void csr_roam_report_statistics(tpAniSirGlobal pMac, uint32_t statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 tCsrStatsCallback callback, uint8_t staId,
251 void *pContext);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530252tListElem *csr_roam_check_client_req_list(tpAniSirGlobal pMac,
253 uint32_t statsMask);
254static void csr_roam_remove_entry_from_pe_stats_req_list(tpAniSirGlobal pMac,
255 tCsrPeStatsReqInfo *pPeStaEntry);
256tListElem *csr_roam_find_in_pe_stats_req_list(tpAniSirGlobal pMac,
257 uint32_t statsMask);
258static QDF_STATUS csr_roam_dereg_statistics_req(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800259static uint32_t csr_find_ibss_session(tpAniSirGlobal pMac);
Peng Xuf5d60c82015-10-02 17:17:03 -0700260static uint32_t csr_find_session_by_type(tpAniSirGlobal,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530261 enum tQDF_ADAPTER_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262static bool csr_is_conn_allow_2g_band(tpAniSirGlobal pMac, uint32_t chnl);
263static bool csr_is_conn_allow_5g_band(tpAniSirGlobal pMac, uint32_t chnl);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530264static QDF_STATUS csr_roam_start_wds(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265 tCsrRoamProfile *pProfile,
266 tSirBssDescription *pBssDesc);
267static void csr_init_session(tpAniSirGlobal pMac, uint32_t sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530268static QDF_STATUS csr_roam_issue_set_key_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269 uint32_t sessionId,
270 tCsrRoamSetKey *pSetKey,
271 uint32_t roamId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530272static QDF_STATUS csr_roam_get_qos_info_from_bss(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800273 tSirBssDescription *pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800274static void csr_ser_des_unpack_diassoc_rsp(uint8_t *pBuf,
275 tSirSmeDisassocRsp *pRsp);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530276static void csr_init_operating_classes(tHalHandle hHal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800277
278/* Initialize global variables */
279static void csr_roam_init_globals(tpAniSirGlobal pMac)
280{
281 if (pMac) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530282 qdf_mem_zero(&csr_roam_roam_session,
283 sizeof(csr_roam_roam_session));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 pMac->roam.roamSession = csr_roam_roam_session;
285 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800286}
287
288static void csr_roam_de_init_globals(tpAniSirGlobal pMac)
289{
Naveen Rawat20969542017-01-27 18:01:17 -0800290 uint8_t i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530291
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292 if (pMac) {
Naveen Rawat20969542017-01-27 18:01:17 -0800293 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
294 if (pMac->roam.roamSession[i].pCurRoamProfile)
295 csr_release_profile(pMac,
296 pMac->roam.roamSession[i].
297 pCurRoamProfile);
298 csr_release_profile(pMac,
299 &pMac->roam.roamSession[i].
300 stored_roam_profile.profile);
301 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800302 pMac->roam.roamSession = NULL;
303 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304}
305
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530306QDF_STATUS csr_open(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530308 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309 uint32_t i;
310
311 do {
312 /* Initialize CSR Roam Globals */
313 csr_roam_init_globals(pMac);
314 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
315 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_STOP, i);
316
317 init_config_param(pMac);
318 status = csr_scan_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530319 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320 break;
321 status = csr_roam_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530322 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800323 break;
324 pMac->roam.nextRoamId = 1; /* Must not be 0 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530325 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800326 (csr_ll_open(pMac->hHdd,
327 &pMac->roam.statsClientReqList)))
328 break;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530329 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800330 (csr_ll_open(pMac->hHdd,
331 &pMac->roam.peStatsReqList)))
332 break;
Abhishek Singhf3756fc2017-06-28 16:04:06 +0530333 qdf_list_create(&pMac->roam.rssi_disallow_bssid,
334 MAX_RSSI_AVOID_BSSID_LIST);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800335 } while (0);
336
337 return status;
338}
339
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530340QDF_STATUS csr_init_chan_list(tpAniSirGlobal mac, uint8_t *alpha2)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530342 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343
344 mac->scan.countryCodeDefault[0] = alpha2[0];
345 mac->scan.countryCodeDefault[1] = alpha2[1];
346 mac->scan.countryCodeDefault[2] = alpha2[2];
347
Srinivas Girigowda81aef902017-03-17 09:34:19 -0700348 sme_debug("init time country code %.2s", mac->scan.countryCodeDefault);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800349
Amar Singhale4f28ee2015-10-21 14:36:56 -0700350 mac->scan.domainIdDefault = 0;
351 mac->scan.domainIdCurrent = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530353 qdf_mem_copy(mac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354 mac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530355 qdf_mem_copy(mac->scan.countryCodeElected,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356 mac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
357 status = csr_get_channel_and_power_list(mac);
358 csr_clear_votes_for_country_info(mac);
359 return status;
360}
361
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530362QDF_STATUS csr_set_channels(tHalHandle hHal, tCsrConfigParam *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530364 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
366 uint8_t index = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530367
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530368 qdf_mem_copy(pParam->Csr11dinfo.countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
370 for (index = 0; index < pMac->scan.base_channels.numChannels;
371 index++) {
372 pParam->Csr11dinfo.Channels.channelList[index] =
373 pMac->scan.base_channels.channelList[index];
374 pParam->Csr11dinfo.ChnPower[index].firstChannel =
375 pMac->scan.base_channels.channelList[index];
376 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
377 pParam->Csr11dinfo.ChnPower[index].maxtxPower =
Amar Singhal5cccafe2017-02-15 12:42:58 -0800378 pMac->scan.defaultPowerTable[index].tx_power;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379 }
380 pParam->Csr11dinfo.Channels.numChannels =
381 pMac->scan.base_channels.numChannels;
382
383 return status;
384}
385
Abhishek Singhf3756fc2017-06-28 16:04:06 +0530386/**
387 * csr_assoc_rej_free_rssi_disallow_list() - Free the rssi diallowed
388 * BSSID entries and destroy the list
389 * @list: rssi based disallowed list entry
390 *
391 * Return: void
392 */
393static void csr_assoc_rej_free_rssi_disallow_list(qdf_list_t *list)
394{
395 QDF_STATUS status;
396 struct sir_rssi_disallow_lst *cur_node;
397 qdf_list_node_t *cur_lst = NULL, *next_lst = NULL;
398
399 qdf_list_peek_front(list, &cur_lst);
400 while (cur_lst) {
401 qdf_list_peek_next(list, cur_lst, &next_lst);
402 cur_node = qdf_container_of(cur_lst,
403 struct sir_rssi_disallow_lst, node);
404 status = qdf_list_remove_node(list, cur_lst);
405 if (QDF_IS_STATUS_SUCCESS(status))
406 qdf_mem_free(cur_node);
407 cur_lst = next_lst;
408 next_lst = NULL;
409 }
410 qdf_list_destroy(list);
411}
412
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530413QDF_STATUS csr_close(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800414{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530415 QDF_STATUS status = QDF_STATUS_SUCCESS;
Naveen Rawat90542b32017-01-27 16:54:57 -0800416 tSmeCmd *saved_scan_cmd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417
418 csr_roam_close(pMac);
Abhishek Singhf3756fc2017-06-28 16:04:06 +0530419 csr_assoc_rej_free_rssi_disallow_list(
420 &pMac->roam.rssi_disallow_bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421 csr_scan_close(pMac);
422 csr_ll_close(&pMac->roam.statsClientReqList);
423 csr_ll_close(&pMac->roam.peStatsReqList);
Naveen Rawat90542b32017-01-27 16:54:57 -0800424 saved_scan_cmd = (tSmeCmd *)pMac->sme.saved_scan_cmd;
425 if (saved_scan_cmd) {
426 csr_release_profile(pMac, saved_scan_cmd->u.scanCmd.
427 pToRoamProfile);
428 if (saved_scan_cmd->u.scanCmd.pToRoamProfile) {
429 qdf_mem_free(saved_scan_cmd->u.scanCmd.pToRoamProfile);
430 saved_scan_cmd->u.scanCmd.pToRoamProfile = NULL;
431 }
432 if (saved_scan_cmd->u.scanCmd.u.scanRequest.SSIDs.SSIDList) {
433 qdf_mem_free(saved_scan_cmd->u.scanCmd.u.scanRequest.
434 SSIDs.SSIDList);
435 saved_scan_cmd->u.scanCmd.u.scanRequest.SSIDs.
436 SSIDList = NULL;
437 }
438 if (saved_scan_cmd->u.roamCmd.pRoamBssEntry) {
439 qdf_mem_free(saved_scan_cmd->u.roamCmd.pRoamBssEntry);
440 saved_scan_cmd->u.roamCmd.pRoamBssEntry = NULL;
441 }
442 qdf_mem_free(saved_scan_cmd);
443 saved_scan_cmd = NULL;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530444 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800445 /* DeInit Globals */
446 csr_roam_de_init_globals(pMac);
447 return status;
448}
449
Amar Singhala297bfa2015-10-15 15:07:29 -0700450static int8_t csr_find_channel_pwr(struct channel_power *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800451 pdefaultPowerTable,
452 uint8_t ChannelNum)
453{
454 uint8_t i;
455 /* TODO: if defaultPowerTable is guaranteed to be in ascending */
456 /* order of channel numbers, we can employ binary search */
457 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -0700458 if (pdefaultPowerTable[i].chan_num == ChannelNum)
Amar Singhal5cccafe2017-02-15 12:42:58 -0800459 return pdefaultPowerTable[i].tx_power;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460 }
461 /* could not find the channel list in default list */
462 /* this should not have occured */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530463 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800464 return 0;
465}
Naveen Rawat16b82872015-12-14 17:59:16 -0800466
467/**
468 * csr_roam_arrange_ch_list() - Updates the channel list modified with greedy
469 * order for 5 Ghz preference and DFS channels.
470 * @mac_ctx: pointer to mac context.
471 * @chan_list: channel list updated with greedy channel order.
472 * @num_channel: Number of channels in list
473 *
474 * To allow Early Stop Roaming Scan feature to co-exist with 5G preference,
475 * this function moves 5G channels ahead of 2G channels. This function can
476 * also move 2G channels, ahead of DFS channel or vice versa. Order is
477 * maintained among same category channels
478 *
479 * Return: None
480 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -0700481static void csr_roam_arrange_ch_list(tpAniSirGlobal mac_ctx,
Naveen Rawat16b82872015-12-14 17:59:16 -0800482 tSirUpdateChanParam *chan_list, uint8_t num_channel)
483{
484 bool prefer_5g = CSR_IS_ROAM_PREFER_5GHZ(mac_ctx);
485 bool prefer_dfs = CSR_IS_DFS_CH_ROAM_ALLOWED(mac_ctx);
486 int i, j = 0;
487 tSirUpdateChanParam *tmp_list = NULL;
488
489 if (!prefer_5g)
490 return;
491
492 tmp_list = (tSirUpdateChanParam *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530493 qdf_mem_malloc(sizeof(tSirUpdateChanParam) * num_channel);
Naveen Rawat16b82872015-12-14 17:59:16 -0800494 if (tmp_list == NULL) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -0700495 sme_err("Memory allocation failed");
Naveen Rawat16b82872015-12-14 17:59:16 -0800496 return;
497 }
498
499 /* Fist copy Non-DFS 5g channels */
500 for (i = 0; i < num_channel; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700501 if (WLAN_REG_IS_5GHZ_CH(chan_list[i].chanId) &&
502 !wlan_reg_is_dfs_ch(mac_ctx->pdev,
503 chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530504 qdf_mem_copy(&tmp_list[j++],
Naveen Rawat16b82872015-12-14 17:59:16 -0800505 &chan_list[i], sizeof(tSirUpdateChanParam));
506 chan_list[i].chanId = INVALID_CHANNEL_ID;
507 }
508 }
509 if (prefer_dfs) {
510 /* next copy DFS channels (remaining channels in 5G) */
511 for (i = 0; i < num_channel; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700512 if (WLAN_REG_IS_5GHZ_CH(chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530513 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800514 sizeof(tSirUpdateChanParam));
515 chan_list[i].chanId = INVALID_CHANNEL_ID;
516 }
517 }
518 } else {
519 /* next copy 2G channels */
520 for (i = 0; i < num_channel; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700521 if (WLAN_REG_IS_24GHZ_CH(chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530522 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800523 sizeof(tSirUpdateChanParam));
524 chan_list[i].chanId = INVALID_CHANNEL_ID;
525 }
526 }
527 }
528 /* copy rest of the channels in same order to tmp list */
529 for (i = 0; i < num_channel; i++) {
530 if (chan_list[i].chanId != INVALID_CHANNEL_ID) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530531 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800532 sizeof(tSirUpdateChanParam));
533 chan_list[i].chanId = INVALID_CHANNEL_ID;
534 }
535 }
536 /* copy tmp list to original channel list buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530537 qdf_mem_copy(chan_list, tmp_list,
Naveen Rawat16b82872015-12-14 17:59:16 -0800538 sizeof(tSirUpdateChanParam) * num_channel);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530539 qdf_mem_free(tmp_list);
Naveen Rawat16b82872015-12-14 17:59:16 -0800540}
541
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700542/**
543 * csr_roam_sort_channel_for_early_stop() - Sort the channels
Naveen Rawat16b82872015-12-14 17:59:16 -0800544 * @mac_ctx: mac global context
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700545 * @chan_list: Original channel list from the upper layers
546 * @num_channel: Number of original channels
547 *
548 * For Early stop scan feature, the channel list should be in an order,
549 * where-in there is a maximum chance to detect an AP in the initial
550 * channels in the list so that the scanning can be stopped early as the
551 * feature demands.
552 * Below fixed greedy channel list has been provided
553 * based on most of the enterprise wifi installations across the globe.
554 *
555 * Identify all the greedy channels within the channel list from user space.
556 * Identify all the non-greedy channels in the user space channel list.
557 * Merge greedy channels followed by non-greedy channels back into the
558 * chan_list.
559 *
560 * Return: None
561 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -0700562static void csr_roam_sort_channel_for_early_stop(tpAniSirGlobal mac_ctx,
Naveen Rawat16b82872015-12-14 17:59:16 -0800563 tSirUpdateChanList *chan_list, uint8_t num_channel)
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700564{
565 tSirUpdateChanList *chan_list_greedy, *chan_list_non_greedy;
566 uint8_t i, j;
567 static const uint8_t fixed_greedy_chan_list[] = {1, 6, 11, 36, 48, 40,
568 44, 10, 2, 9, 149, 157, 161, 3, 4, 8, 153, 165, 7, 5, 136, 140,
569 52, 116, 56, 104, 64, 60, 100, 120, 13, 14, 112, 132, 151, 155};
570 uint8_t num_fixed_greedy_chan;
571 uint8_t num_greedy_chan = 0;
572 uint8_t num_non_greedy_chan = 0;
573 uint8_t match_found = false;
574 uint32_t buf_size;
575
576 buf_size = sizeof(tSirUpdateChanList) +
577 (sizeof(tSirUpdateChanParam) * num_channel);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530578 chan_list_greedy = qdf_mem_malloc(buf_size);
579 chan_list_non_greedy = qdf_mem_malloc(buf_size);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700580 if (!chan_list_greedy || !chan_list_non_greedy) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530581 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700582 "Failed to allocate memory for tSirUpdateChanList");
583 return;
584 }
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700585 /*
586 * fixed_greedy_chan_list is an evaluated channel list based on most of
587 * the enterprise wifi deployments and the order of the channels
588 * determines the highest possibility of finding an AP.
589 * chan_list is the channel list provided by upper layers based on the
590 * regulatory domain.
591 */
592 num_fixed_greedy_chan = sizeof(fixed_greedy_chan_list)/sizeof(uint8_t);
593 /*
594 * Browse through the chan_list and put all the non-greedy channels
595 * into a seperate list by name chan_list_non_greedy
596 */
597 for (i = 0; i < num_channel; i++) {
598 for (j = 0; j < num_fixed_greedy_chan; j++) {
599 if (chan_list->chanParam[i].chanId ==
600 fixed_greedy_chan_list[j]) {
601 match_found = true;
602 break;
603 }
604 }
605 if (!match_found) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530606 qdf_mem_copy(
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700607 &chan_list_non_greedy->chanParam[num_non_greedy_chan],
608 &chan_list->chanParam[i],
609 sizeof(tSirUpdateChanParam));
610 num_non_greedy_chan++;
611 } else {
612 match_found = false;
613 }
614 }
615 /*
616 * Browse through the fixed_greedy_chan_list and put all the greedy
617 * channels in the chan_list into a seperate list by name
618 * chan_list_greedy
619 */
620 for (i = 0; i < num_fixed_greedy_chan; i++) {
621 for (j = 0; j < num_channel; j++) {
622 if (fixed_greedy_chan_list[i] ==
623 chan_list->chanParam[j].chanId) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530624 qdf_mem_copy(
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700625 &chan_list_greedy->chanParam[num_greedy_chan],
626 &chan_list->chanParam[j],
627 sizeof(tSirUpdateChanParam));
628 num_greedy_chan++;
629 break;
630 }
631 }
632 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530633 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700634 "greedy=%d, non-greedy=%d, tot=%d",
635 num_greedy_chan, num_non_greedy_chan, num_channel);
636 if ((num_greedy_chan + num_non_greedy_chan) != num_channel) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530637 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700638 "incorrect sorting of channels");
639 goto scan_list_sort_error;
640 }
641 /* Copy the Greedy channels first */
642 i = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530643 qdf_mem_copy(&chan_list->chanParam[i],
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700644 &chan_list_greedy->chanParam[i],
645 num_greedy_chan * sizeof(tSirUpdateChanParam));
646 /* Copy the remaining Non Greedy channels */
647 i = num_greedy_chan;
648 j = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530649 qdf_mem_copy(&chan_list->chanParam[i],
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700650 &chan_list_non_greedy->chanParam[j],
651 num_non_greedy_chan * sizeof(tSirUpdateChanParam));
Naveen Rawat16b82872015-12-14 17:59:16 -0800652
653 /* Update channel list for 5g preference and allow DFS roam */
654 csr_roam_arrange_ch_list(mac_ctx, chan_list->chanParam, num_channel);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700655scan_list_sort_error:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530656 qdf_mem_free(chan_list_greedy);
657 qdf_mem_free(chan_list_non_greedy);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700658}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800659
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -0700660/**
661 * csr_emu_chan_req() - update the required channel list for emulation
662 * @channel: channel number to check
663 *
664 * To reduce scan time during emulation platforms, this function
665 * restricts the scanning to be done on selected channels
666 *
667 * Return: QDF_STATUS enumeration
668 */
669#ifdef QCA_WIFI_NAPIER_EMULATION
Krishna Kumaar Natarajan585f0302017-08-07 18:01:27 -0700670#define SCAN_CHAN_LIST_5G_LEN 6
671#define SCAN_CHAN_LIST_2G_LEN 3
672static const uint8_t
673csr_scan_chan_list_5g[SCAN_CHAN_LIST_5G_LEN] = { 36, 44, 52, 56, 140, 149 };
674static const uint8_t
675csr_scan_chan_list_2g[SCAN_CHAN_LIST_2G_LEN] = { 1, 6, 11 };
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -0700676static QDF_STATUS csr_emu_chan_req(uint32_t channel)
677{
678 int i;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700679 if (WLAN_REG_IS_24GHZ_CH(channel)) {
Krishna Kumaar Natarajan585f0302017-08-07 18:01:27 -0700680 for (i = 0; i < QDF_ARRAY_SIZE(csr_scan_chan_list_2g); i++) {
681 if (csr_scan_chan_list_2g[i] == channel)
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -0700682 return QDF_STATUS_SUCCESS;
683 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700684 } else if (WLAN_REG_IS_5GHZ_CH(channel)) {
Krishna Kumaar Natarajan585f0302017-08-07 18:01:27 -0700685 for (i = 0; i < QDF_ARRAY_SIZE(csr_scan_chan_list_5g); i++) {
686 if (csr_scan_chan_list_5g[i] == channel)
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -0700687 return QDF_STATUS_SUCCESS;
688 }
689 }
690 return QDF_STATUS_E_FAILURE;
691}
692#else
693static QDF_STATUS csr_emu_chan_req(uint32_t channel_num)
694{
695 return QDF_STATUS_SUCCESS;
696}
697#endif
698
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530699QDF_STATUS csr_update_channel_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700{
701 tSirUpdateChanList *pChanList;
702 tCsrScanStruct *pScan = &pMac->scan;
703 uint8_t numChan = pScan->base_channels.numChannels;
704 uint8_t num_channel = 0;
705 uint32_t bufLen;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700706 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800707 uint8_t i, j, social_channel[MAX_SOCIAL_CHANNELS] = { 1, 6, 11 };
708 uint8_t channel_state;
Agrawal Ashish21ba2572016-09-03 16:40:10 +0530709 uint16_t unsafe_chan[NUM_CHANNELS];
710 uint16_t unsafe_chan_cnt = 0;
711 uint16_t cnt = 0;
712 uint8_t channel;
713 bool is_unsafe_chan;
714 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
715
716 if (!qdf_ctx) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -0700717 sme_err("qdf_ctx is NULL");
Agrawal Ashish21ba2572016-09-03 16:40:10 +0530718 return QDF_STATUS_E_FAILURE;
719 }
720
721 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
722 &unsafe_chan_cnt,
723 sizeof(unsafe_chan));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724
725 if (CSR_IS_5G_BAND_ONLY(pMac)) {
726 for (i = 0; i < MAX_SOCIAL_CHANNELS; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700727 if (wlan_reg_get_channel_state(pMac->pdev,
728 social_channel[i])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 == CHANNEL_STATE_ENABLE)
730 numChan++;
731 }
732 }
733
734 bufLen = sizeof(tSirUpdateChanList) +
735 (sizeof(tSirUpdateChanParam) * (numChan));
736
737 csr_init_operating_classes((tHalHandle) pMac);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530738 pChanList = (tSirUpdateChanList *) qdf_mem_malloc(bufLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 if (!pChanList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530740 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 "Failed to allocate memory for tSirUpdateChanList");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530742 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800744
745 for (i = 0; i < pScan->base_channels.numChannels; i++) {
Agrawal, Ashish9f84c402016-11-30 16:19:44 +0530746 struct csr_sta_roam_policy_params *roam_policy =
747 &pMac->roam.configParam.sta_roam_policy;
Krishna Kumaar Natarajand542b8e2016-08-16 17:41:04 -0700748 if (QDF_STATUS_SUCCESS !=
749 csr_emu_chan_req(pScan->base_channels.channelList[i]))
750 continue;
751
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 /* Scan is not performed on DSRC channels*/
Amar Singhal5cccafe2017-02-15 12:42:58 -0800753 if (pScan->base_channels.channelList[i] >=
754 WLAN_REG_MIN_11P_CH_NUM)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 continue;
Amar Singhal5cccafe2017-02-15 12:42:58 -0800756
Agrawal Ashish21ba2572016-09-03 16:40:10 +0530757 channel = pScan->base_channels.channelList[i];
Amar Singhal7c1e8982016-05-19 15:08:09 -0700758
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700759 channel_state = wlan_reg_get_channel_state(pMac->pdev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760 pScan->base_channels.channelList[i]);
761 if ((CHANNEL_STATE_ENABLE == channel_state) ||
762 pMac->scan.fEnableDFSChnlScan) {
Agrawal Ashish21ba2572016-09-03 16:40:10 +0530763 if ((pMac->roam.configParam.sta_roam_policy.dfs_mode ==
764 CSR_STA_ROAM_POLICY_DFS_DISABLED) &&
765 (channel_state == CHANNEL_STATE_DFS)) {
766 QDF_TRACE(QDF_MODULE_ID_SME,
767 QDF_TRACE_LEVEL_INFO,
768 FL("skip dfs channel %d"),
769 channel);
770 continue;
771 }
772 if (pMac->roam.configParam.sta_roam_policy.
773 skip_unsafe_channels &&
774 unsafe_chan_cnt) {
775 is_unsafe_chan = false;
776 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
777 if (unsafe_chan[cnt] == channel) {
778 is_unsafe_chan = true;
779 break;
780 }
781 }
Agrawal, Ashish9f84c402016-11-30 16:19:44 +0530782 if ((is_unsafe_chan) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700783 ((WLAN_REG_IS_24GHZ_CH(channel) &&
Agrawal, Ashish9f84c402016-11-30 16:19:44 +0530784 roam_policy->sap_operating_band ==
785 eCSR_BAND_24) ||
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700786 (WLAN_REG_IS_5GHZ_CH(channel) &&
Agrawal, Ashish9f84c402016-11-30 16:19:44 +0530787 roam_policy->sap_operating_band ==
788 eCSR_BAND_5G))) {
Agrawal Ashish21ba2572016-09-03 16:40:10 +0530789 QDF_TRACE(QDF_MODULE_ID_SME,
790 QDF_TRACE_LEVEL_INFO,
791 FL("ignoring unsafe channel %d"),
792 channel);
793 continue;
794 }
795 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796 pChanList->chanParam[num_channel].chanId =
797 pScan->base_channels.channelList[i];
798 pChanList->chanParam[num_channel].pwr =
799 csr_find_channel_pwr(pScan->defaultPowerTable,
Agrawal Ashish21ba2572016-09-03 16:40:10 +0530800 pChanList->chanParam[num_channel].chanId);
Amar Singhal7c1e8982016-05-19 15:08:09 -0700801
802 if (pScan->fcc_constraint) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530803 if (12 == pChanList->chanParam[num_channel].
804 chanId) {
Amar Singhal7c1e8982016-05-19 15:08:09 -0700805 pChanList->chanParam[num_channel].pwr =
806 MAX_PWR_FCC_CHAN_12;
807 QDF_TRACE(QDF_MODULE_ID_SME,
808 QDF_TRACE_LEVEL_INFO,
Amar Singhal83a047a2016-05-19 15:56:11 -0700809 "txpow for channel 12 is %d",
810 MAX_PWR_FCC_CHAN_12);
Amar Singhal7c1e8982016-05-19 15:08:09 -0700811 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530812 if (13 == pChanList->chanParam[num_channel].
813 chanId) {
Amar Singhal7c1e8982016-05-19 15:08:09 -0700814 pChanList->chanParam[num_channel].pwr =
815 MAX_PWR_FCC_CHAN_13;
816 QDF_TRACE(QDF_MODULE_ID_SME,
817 QDF_TRACE_LEVEL_INFO,
Amar Singhal83a047a2016-05-19 15:56:11 -0700818 "txpow for channel 13 is %d",
819 MAX_PWR_FCC_CHAN_13);
Amar Singhal7c1e8982016-05-19 15:08:09 -0700820 }
821 }
822
823
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824 if (CHANNEL_STATE_ENABLE == channel_state)
825 pChanList->chanParam[num_channel].dfsSet =
826 false;
827 else
828 pChanList->chanParam[num_channel].dfsSet =
829 true;
Naveen Rawat64e477e2016-05-20 10:34:56 -0700830 if (cds_is_5_mhz_enabled())
831 pChanList->chanParam[num_channel].quarter_rate
832 = 1;
833 else if (cds_is_10_mhz_enabled())
834 pChanList->chanParam[num_channel].half_rate = 1;
Abhishek Singh562aad62017-01-05 16:24:23 +0530835 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
836 "channel:%d, pwr=%d, DFS=%d qrate %d hrate %d ",
837 pChanList->chanParam[num_channel].chanId,
838 pChanList->chanParam[num_channel].pwr,
839 pChanList->chanParam[num_channel].dfsSet,
840 pChanList->chanParam[num_channel].quarter_rate,
841 pChanList->chanParam[num_channel].half_rate);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 num_channel++;
843 }
844 }
845
846 if (CSR_IS_5G_BAND_ONLY(pMac)) {
847 for (j = 0; j < MAX_SOCIAL_CHANNELS; j++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -0700848 if (wlan_reg_get_channel_state(pMac->pdev,
849 social_channel[j])
Naveen Rawat64e477e2016-05-20 10:34:56 -0700850 != CHANNEL_STATE_ENABLE)
851 continue;
852 pChanList->chanParam[num_channel].chanId =
853 social_channel[j];
854 pChanList->chanParam[num_channel].pwr =
855 csr_find_channel_pwr(pScan->defaultPowerTable,
856 social_channel[j]);
857 pChanList->chanParam[num_channel].dfsSet = false;
858 if (cds_is_5_mhz_enabled())
859 pChanList->chanParam[num_channel].quarter_rate
860 = 1;
861 else if (cds_is_10_mhz_enabled())
862 pChanList->chanParam[num_channel].half_rate = 1;
863 num_channel++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 }
865 }
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700866 if (pMac->roam.configParam.early_stop_scan_enable)
Naveen Rawat16b82872015-12-14 17:59:16 -0800867 csr_roam_sort_channel_for_early_stop(pMac, pChanList,
868 num_channel);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700869 else
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530870 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700871 FL("Early Stop Scan Feature not supported"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700873 if ((pMac->roam.configParam.uCfgDot11Mode ==
874 eCSR_CFG_DOT11_MODE_AUTO) ||
875 (pMac->roam.configParam.uCfgDot11Mode ==
876 eCSR_CFG_DOT11_MODE_11AC) ||
877 (pMac->roam.configParam.uCfgDot11Mode ==
878 eCSR_CFG_DOT11_MODE_11AC_ONLY)) {
879 pChanList->vht_en = true;
880 if (pMac->roam.configParam.enableVhtFor24GHz)
881 pChanList->vht_24_en = true;
882 }
883 if ((pMac->roam.configParam.uCfgDot11Mode ==
884 eCSR_CFG_DOT11_MODE_AUTO) ||
885 (pMac->roam.configParam.uCfgDot11Mode ==
886 eCSR_CFG_DOT11_MODE_11N) ||
887 (pMac->roam.configParam.uCfgDot11Mode ==
888 eCSR_CFG_DOT11_MODE_11N_ONLY)) {
889 pChanList->ht_en = true;
890 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 msg.type = WMA_UPDATE_CHAN_LIST_REQ;
892 msg.reserved = 0;
893 msg.bodyptr = pChanList;
894 pChanList->numChan = num_channel;
Sreelakshmi Konamki6a065362016-05-31 16:05:01 +0530895 MTRACE(qdf_trace(QDF_MODULE_ID_SME, TRACE_CODE_SME_TX_WMA_MSG,
896 NO_SESSION, msg.type));
Rajeev Kumar8eaedf62017-01-21 11:03:13 -0800897 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -0800898 &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530899 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 "%s: Failed to post msg to WMA", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530901 qdf_mem_free(pChanList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530902 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903 }
904
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530905 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906}
907
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530908QDF_STATUS csr_start(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530910 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800911 uint32_t i;
912
913 do {
914 /* save the global cds context */
915 pMac->roam.g_cds_context = cds_get_global_context();
916 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
917 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_IDLE, i);
918
919 status = csr_roam_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530920 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 break;
922
923 pMac->roam.sPendingCommands = 0;
924 csr_scan_enable(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800925 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
926 status = csr_neighbor_roam_init(pMac, i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927 pMac->roam.tlStatsReqInfo.numClient = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928 /* init the link quality indication also */
929 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530930 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -0700931 sme_warn("csr_start: Couldn't Init HO control blk ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932 break;
933 }
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -0800934 /* Register with scan component */
935 pMac->scan.requester_id = ucfg_scan_register_requester(
936 pMac->psoc,
937 "CSR", csr_scan_callback, pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938 } while (0);
939 return status;
940}
941
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530942QDF_STATUS csr_stop(tpAniSirGlobal pMac, tHalStopType stopType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943{
944 uint32_t sessionId;
945
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530946 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800947 csr_roam_close_session(pMac, sessionId, true, NULL, NULL);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530948
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949 csr_scan_disable(pMac);
950 pMac->scan.fCancelIdleScan = false;
951 pMac->scan.fRestartIdleScan = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
954 csr_neighbor_roam_close(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
956 if (CSR_IS_SESSION_VALID(pMac, sessionId))
957 csr_scan_flush_result(pMac);
958
959 /* Reset the domain back to the deault */
960 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
961
962 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++) {
963 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_STOP, sessionId);
964 pMac->roam.curSubState[sessionId] = eCSR_ROAM_SUBSTATE_NONE;
965 }
966
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530967 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968}
969
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530970QDF_STATUS csr_ready(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530972 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 /* If the gScanAgingTime is set to '0' then scan results aging timeout
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530974 * based on timer feature is not enabled
975 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800976 status = csr_apply_channel_and_power_list(pMac);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530977 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -0700978 sme_err("csr_apply_channel_and_power_list failed during csr_ready with status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 status);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530980
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981 return status;
982}
983
984void csr_set_default_dot11_mode(tpAniSirGlobal pMac)
985{
986 uint32_t wniDot11mode = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +0530987
988 wniDot11mode = csr_translate_to_wni_cfg_dot11_mode(pMac,
989 pMac->roam.configParam.uCfgDot11Mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 cfg_set_int(pMac, WNI_CFG_DOT11_MODE, wniDot11mode);
991}
992
993void csr_set_global_cfgs(tpAniSirGlobal pMac)
994{
995
996 cfg_set_int(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD,
997 csr_get_frag_thresh(pMac));
998 cfg_set_int(pMac, WNI_CFG_RTS_THRESHOLD, csr_get_rts_thresh(pMac));
999 cfg_set_int(pMac, WNI_CFG_11D_ENABLED,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301000 ((pMac->roam.configParam.Is11hSupportEnabled) ?
1001 pMac->roam.configParam.Is11dSupportEnabled :
1002 pMac->roam.configParam.Is11dSupportEnabled));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003 cfg_set_int(pMac, WNI_CFG_11H_ENABLED,
1004 pMac->roam.configParam.Is11hSupportEnabled);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301005 /* For now we will just use the 5GHz CB mode ini parameter to decide
1006 * whether CB supported or not in Probes when there is no session
1007 * Once session is established we will use the session related params
1008 * stored in PE session for CB mode
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009 */
1010 cfg_set_int(pMac, WNI_CFG_CHANNEL_BONDING_MODE,
1011 !!(pMac->roam.configParam.channelBondingMode5GHz));
1012 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
1013 pMac->roam.configParam.HeartbeatThresh24);
1014
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301015 /* Update the operating mode to configured value during
1016 * initialization, So that client can advertise full
1017 * capabilities in Probe request frame.
1018 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001019 csr_set_default_dot11_mode(pMac);
1020}
1021
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301022/**
1023 * csr_packetdump_timer_handler() - packet dump timer
1024 * handler
1025 * @pv: user data
1026 *
1027 * This function is used to handle packet dump timer
1028 *
1029 * Return: None
1030 *
1031 */
1032static void csr_packetdump_timer_handler(void *pv)
1033{
1034 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
1035 "%s Invoking packetdump deregistration API", __func__);
1036 wlan_deregister_txrx_packetdump();
1037}
1038
1039/**
1040 * csr_packetdump_timer_stop() - stops packet dump timer
1041 *
1042 * This function is used to stop packet dump timer
1043 *
1044 * Return: None
1045 *
1046 */
1047void csr_packetdump_timer_stop(void)
1048{
1049 QDF_STATUS status;
1050 tHalHandle hal;
1051 tpAniSirGlobal mac;
1052 v_CONTEXT_t vos_ctx_ptr;
1053
1054 /* get the global voss context */
1055 vos_ctx_ptr = cds_get_global_context();
1056 if (vos_ctx_ptr == NULL) {
1057 QDF_ASSERT(0);
1058 return;
1059 }
1060
1061 hal = cds_get_context(QDF_MODULE_ID_SME);
1062 if (hal == NULL) {
1063 QDF_ASSERT(0);
1064 return;
1065 }
1066
1067 mac = PMAC_STRUCT(hal);
1068 status = qdf_mc_timer_stop(&mac->roam.packetdump_timer);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301069 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001070 sme_err("cannot stop packetdump timer");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301071}
1072
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301073static QDF_STATUS csr_roam_open(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301075 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076 uint32_t i;
1077 tCsrRoamSession *pSession;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301078
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079 do {
1080 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
1081 pSession = CSR_GET_SESSION(pMac, i);
1082 pSession->roamingTimerInfo.pMac = pMac;
1083 pSession->roamingTimerInfo.sessionId =
1084 CSR_SESSION_ID_INVALID;
1085 }
1086 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
1087 pMac->roam.WaitForKeyTimerInfo.sessionId =
1088 CSR_SESSION_ID_INVALID;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301089 status = qdf_mc_timer_init(&pMac->roam.hTimerWaitForKey,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301090 QDF_TIMER_TYPE_SW,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301091 csr_roam_wait_for_key_time_out_handler,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092 &pMac->roam.WaitForKeyTimerInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301093 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001094 sme_err("cannot allocate memory for WaitForKey time out timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001095 break;
1096 }
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301097 status = qdf_mc_timer_init(&pMac->roam.packetdump_timer,
1098 QDF_TIMER_TYPE_SW, csr_packetdump_timer_handler,
1099 pMac);
1100 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001101 sme_err("cannot allocate memory for packetdump timer");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301102 break;
1103 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104 } while (0);
1105 return status;
1106}
1107
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301108static QDF_STATUS csr_roam_close(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001109{
1110 uint32_t sessionId;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301111
1112 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001113 csr_roam_close_session(pMac, sessionId, true, NULL, NULL);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301114
Anurag Chouhan210db072016-02-22 18:42:15 +05301115 qdf_mc_timer_stop(&pMac->roam.hTimerWaitForKey);
1116 qdf_mc_timer_destroy(&pMac->roam.hTimerWaitForKey);
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301117 qdf_mc_timer_stop(&pMac->roam.packetdump_timer);
1118 qdf_mc_timer_destroy(&pMac->roam.packetdump_timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301119 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001120}
1121
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301122QDF_STATUS csr_roam_start(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001123{
1124 (void)pMac;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301125 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001126}
1127
1128void csr_roam_stop(tpAniSirGlobal pMac, uint32_t sessionId)
1129{
1130 csr_roam_stop_roaming_timer(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301131 /* deregister the clients requesting stats from PE/TL & also stop
1132 * the corresponding timers
1133 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134 csr_roam_dereg_statistics_req(pMac);
1135}
1136
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301137QDF_STATUS csr_roam_get_connect_state(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138 eCsrConnectState *pState)
1139{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301140 QDF_STATUS status = QDF_STATUS_E_INVAL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301141
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142 if (CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301143 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144 *pState = pMac->roam.roamSession[sessionId].connectState;
1145 }
1146 return status;
1147}
1148
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301149QDF_STATUS csr_roam_copy_connect_profile(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 uint32_t sessionId, tCsrRoamConnectedProfile *pProfile)
1151{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301152 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153 uint32_t size = 0;
1154 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
1155 tCsrRoamConnectedProfile *connected_prof;
1156
1157 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001158 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301159 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001160 }
1161 if (!pProfile) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001162 sme_err("profile not found");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301163 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164 }
1165
1166 if (pSession->pConnectBssDesc) {
1167 size = pSession->pConnectBssDesc->length +
1168 sizeof(pSession->pConnectBssDesc->length);
1169 if (size) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301170 pProfile->pBssDesc = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171 if (NULL != pProfile->pBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301172 qdf_mem_copy(pProfile->pBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001173 pSession->pConnectBssDesc,
1174 size);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301175 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301177 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001178 }
1179 } else {
1180 pProfile->pBssDesc = NULL;
1181 }
1182 connected_prof = &(pSession->connectedProfile);
1183 pProfile->AuthType = connected_prof->AuthType;
1184 pProfile->EncryptionType = connected_prof->EncryptionType;
1185 pProfile->mcEncryptionType = connected_prof->mcEncryptionType;
1186 pProfile->BSSType = connected_prof->BSSType;
1187 pProfile->operationChannel = connected_prof->operationChannel;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301188 qdf_mem_copy(&pProfile->bssid, &connected_prof->bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301189 sizeof(struct qdf_mac_addr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301190 qdf_mem_copy(&pProfile->SSID, &connected_prof->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001191 sizeof(tSirMacSSid));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192 if (connected_prof->MDID.mdiePresent) {
1193 pProfile->MDID.mdiePresent = 1;
1194 pProfile->MDID.mobilityDomain =
1195 connected_prof->MDID.mobilityDomain;
1196 } else {
1197 pProfile->MDID.mdiePresent = 0;
1198 pProfile->MDID.mobilityDomain = 0;
1199 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001200#ifdef FEATURE_WLAN_ESE
1201 pProfile->isESEAssoc = connected_prof->isESEAssoc;
1202 if (csr_is_auth_type_ese(connected_prof->AuthType)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301203 qdf_mem_copy(pProfile->eseCckmInfo.krk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204 connected_prof->eseCckmInfo.krk,
1205 SIR_KRK_KEY_LEN);
1206#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301207 qdf_mem_copy(pProfile->eseCckmInfo.btk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208 connected_prof->eseCckmInfo.btk,
1209 SIR_BTK_KEY_LEN);
1210#endif
1211 pProfile->eseCckmInfo.reassoc_req_num =
1212 connected_prof->eseCckmInfo.reassoc_req_num;
1213 pProfile->eseCckmInfo.krk_plumbed =
1214 connected_prof->eseCckmInfo.krk_plumbed;
1215 }
1216#endif
Krunal Sonib2f13042015-11-02 18:41:08 -08001217#ifdef WLAN_FEATURE_11W
1218 pProfile->MFPEnabled = connected_prof->MFPEnabled;
1219 pProfile->MFPRequired = connected_prof->MFPRequired;
1220 pProfile->MFPCapable = connected_prof->MFPCapable;
1221#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222 }
1223 return status;
1224}
1225
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301226QDF_STATUS csr_roam_get_connect_profile(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 tCsrRoamConnectedProfile *pProfile)
1228{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301229 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001230
1231 if ((csr_is_conn_state_connected(pMac, sessionId)) ||
1232 (csr_is_conn_state_ibss(pMac, sessionId))) {
1233 if (pProfile) {
1234 status =
1235 csr_roam_copy_connect_profile(pMac, sessionId,
1236 pProfile);
1237 }
1238 }
1239 return status;
1240}
1241
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001242void csr_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243{
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001244 if (profile->pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301245 qdf_mem_free(profile->pBssDesc);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001246 if (profile->pAddIEAssoc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301247 qdf_mem_free(profile->pAddIEAssoc);
1248 qdf_mem_set(profile, sizeof(tCsrRoamConnectedProfile), 0);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001249 profile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250}
1251
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301252static QDF_STATUS csr_roam_free_connected_info(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253 tCsrRoamConnectedInfo *
1254 pConnectedInfo)
1255{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301256 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301257
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 if (pConnectedInfo->pbFrames) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301259 qdf_mem_free(pConnectedInfo->pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260 pConnectedInfo->pbFrames = NULL;
1261 }
1262 pConnectedInfo->nBeaconLength = 0;
1263 pConnectedInfo->nAssocReqLength = 0;
1264 pConnectedInfo->nAssocRspLength = 0;
1265 pConnectedInfo->staId = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001266 pConnectedInfo->nRICRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267#ifdef FEATURE_WLAN_ESE
1268 pConnectedInfo->nTspecIeLength = 0;
1269#endif
1270 return status;
1271}
1272
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001273void csr_release_command_roam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1274{
1275 csr_reinit_roam_cmd(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276}
1277
1278void csr_release_command_scan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1279{
Anurag Chouhan210db072016-02-22 18:42:15 +05301280 qdf_mc_timer_stop(&pCommand->u.scanCmd.csr_scan_timer);
1281 qdf_mc_timer_destroy(&pCommand->u.scanCmd.csr_scan_timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282 csr_reinit_scan_cmd(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283}
1284
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301285void csr_release_command_wm_status_change(tpAniSirGlobal pMac,
1286 tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287{
1288 csr_reinit_wm_status_change_cmd(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289}
1290
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001291/**
1292 * csr_release_roc_req_cmd() - Release the command
1293 * @mac_ctx: Global MAC Context
1294 *
1295 * Release the remain on channel request command from the queue
1296 *
1297 * Return: None
1298 */
Krunal Sonidea45952017-02-15 11:58:15 -08001299void csr_release_roc_req_cmd(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300{
Krunal Sonidea45952017-02-15 11:58:15 -08001301 if (eSmeCommandRemainOnChannel == sme_cmd->command) {
1302 remainOnChanCallback callback =
1303 sme_cmd->u.remainChlCmd.callback;
1304 /* process the msg */
1305 if (callback)
1306 callback(mac_ctx,
1307 sme_cmd->u.remainChlCmd.callbackCtx, 0,
1308 sme_cmd->u.remainChlCmd.scan_id);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001309 sme_err("Remove RoC Request from Active Cmd List");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 }
1311}
1312
Krunal Sonia8270f52017-02-23 19:51:25 -08001313void csr_cancel_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
1314{
1315 switch (sme_cmd->command) {
1316 case eSmeCommandRemainOnChannel:
1317 if (NULL != sme_cmd->u.remainChlCmd.callback) {
1318 remainOnChanCallback callback =
1319 sme_cmd->u.remainChlCmd.callback;
1320 /* process the msg */
1321 if (callback) {
1322 callback(mac_ctx, sme_cmd->u.remainChlCmd.
1323 callbackCtx, eCSR_SCAN_ABORT,
1324 sme_cmd->u.remainChlCmd.scan_id);
1325 }
1326 }
1327 break;
1328 case eSmeCommandScan:
1329 /*
1330 * We need to inform the requester before dropping
1331 * the scan command
1332 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001333 sme_warn("Drop scan reason %d callback %p",
Krunal Sonia8270f52017-02-23 19:51:25 -08001334 sme_cmd->u.scanCmd.reason,
1335 sme_cmd->u.scanCmd.callback);
1336 if (NULL != sme_cmd->u.scanCmd.callback) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001337 sme_warn("callback scan requester");
Krunal Sonia8270f52017-02-23 19:51:25 -08001338 csr_scan_call_callback(mac_ctx, sme_cmd,
1339 eCSR_SCAN_ABORT);
1340 }
1341 break;
1342 default:
1343 break;
1344 }
1345}
1346
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347void csr_roam_substate_change(tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate,
1348 uint32_t sessionId)
1349{
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001350 sme_debug("CSR RoamSubstate: [ %s <== %s ]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351 mac_trace_getcsr_roam_sub_state(NewSubstate),
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301352 mac_trace_getcsr_roam_sub_state(pMac->roam.
1353 curSubState[sessionId]));
1354 if (pMac->roam.curSubState[sessionId] == NewSubstate)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001355 return;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301356
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357 pMac->roam.curSubState[sessionId] = NewSubstate;
1358}
1359
1360eCsrRoamState csr_roam_state_change(tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301361 eCsrRoamState NewRoamState,
1362 uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001363{
1364 eCsrRoamState PreviousState;
1365
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001366 sme_debug("CSR RoamState[%hu]: [ %s <== %s ]", sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367 mac_trace_getcsr_roam_state(NewRoamState),
1368 mac_trace_getcsr_roam_state(pMac->roam.curState[sessionId]));
1369 PreviousState = pMac->roam.curState[sessionId];
1370
1371 if (NewRoamState != pMac->roam.curState[sessionId]) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301372 /* Whenever we transition OUT of the Roaming state,
1373 * clear the Roaming substate.
1374 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375 if (CSR_IS_ROAM_JOINING(pMac, sessionId)) {
1376 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
1377 sessionId);
1378 }
1379
1380 pMac->roam.curState[sessionId] = NewRoamState;
1381 }
1382 return PreviousState;
1383}
1384
1385void csr_assign_rssi_for_category(tpAniSirGlobal pMac, int8_t bestApRssi,
1386 uint8_t catOffset)
1387{
1388 int i;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001389
1390 sme_debug("best AP RSSI: %d cat offset: %d", bestApRssi, catOffset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001391 if (catOffset) {
1392 pMac->roam.configParam.bCatRssiOffset = catOffset;
1393 for (i = 0; i < CSR_NUM_RSSI_CAT; i++) {
1394 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i -
1395 1] =
1396 (int)bestApRssi -
1397 pMac->roam.configParam.nSelect5GHzMargin -
1398 (int)(i * catOffset);
1399 }
1400 }
1401}
1402
1403static void init_config_param(tpAniSirGlobal pMac)
1404{
1405 int i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301406
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
1408 pMac->roam.configParam.channelBondingMode24GHz =
1409 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1410 pMac->roam.configParam.channelBondingMode5GHz =
1411 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
1412
1413 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_AUTO;
1414 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1415 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
1416 pMac->roam.configParam.FragmentationThreshold =
1417 eCSR_DOT11_FRAG_THRESH_DEFAULT;
1418 pMac->roam.configParam.HeartbeatThresh24 = 40;
1419 pMac->roam.configParam.HeartbeatThresh50 = 40;
1420 pMac->roam.configParam.Is11dSupportEnabled = false;
1421 pMac->roam.configParam.Is11dSupportEnabledOriginal = false;
1422 pMac->roam.configParam.Is11eSupportEnabled = true;
1423 pMac->roam.configParam.Is11hSupportEnabled = true;
1424 pMac->roam.configParam.RTSThreshold = 2346;
1425 pMac->roam.configParam.shortSlotTime = true;
1426 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1427 pMac->roam.configParam.ProprietaryRatesEnabled = true;
1428 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301429 for (i = 0; i < CSR_NUM_RSSI_CAT; i++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430 pMac->roam.configParam.BssPreferValue[i] = i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001431 csr_assign_rssi_for_category(pMac, CSR_BEST_RSSI_VALUE,
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08001432 CSR_DEFAULT_RSSI_DB_GAP);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = false;
1434 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1435 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1436 pMac->roam.configParam.nPassiveMaxChnTime =
1437 CSR_PASSIVE_MAX_CHANNEL_TIME;
1438 pMac->roam.configParam.nPassiveMinChnTime =
1439 CSR_PASSIVE_MIN_CHANNEL_TIME;
1440#ifdef WLAN_AP_STA_CONCURRENCY
1441 pMac->roam.configParam.nActiveMaxChnTimeConc =
1442 CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1443 pMac->roam.configParam.nActiveMinChnTimeConc =
1444 CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1445 pMac->roam.configParam.nPassiveMaxChnTimeConc =
1446 CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1447 pMac->roam.configParam.nPassiveMinChnTimeConc =
1448 CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1449 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301450 pMac->roam.configParam.min_rest_time_conc = CSR_MIN_REST_TIME_CONC;
1451 pMac->roam.configParam.idle_time_conc = CSR_IDLE_TIME_CONC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452#endif
1453 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301454 pMac->roam.configParam.allow_tpc_from_ap = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001455 pMac->roam.configParam.statsReqPeriodicity =
1456 CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1457 pMac->roam.configParam.statsReqPeriodicityInPS =
1458 CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1461 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold =
1462 120;
Varun Reddy Yeturu168134f2017-06-26 13:46:05 -07001463 pMac->roam.configParam.neighborRoamConfig.rssi_thresh_offset_5g = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 pMac->roam.configParam.neighborRoamConfig.nOpportunisticThresholdDiff =
1465 30;
1466 pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff = 5;
1467 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1468 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1469 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod =
1470 200;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05301471 pMac->roam.configParam.neighborRoamConfig.
1472 neighbor_scan_min_timer_period = 200;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1474 numChannels = 3;
1475 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1476 channelList[0] = 1;
1477 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1478 channelList[1] = 6;
1479 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1480 channelList[2] = 11;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301481 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod
1482 = 20000; /* 20 seconds */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001483 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
1484 pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt = 10;
1485 pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt = 10;
1486 pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight = 14;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487 pMac->roam.configParam.nVhtChannelWidth =
1488 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489
1490 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1491 pMac->roam.configParam.fScanTwice = false;
1492
1493 /* Remove this code once SLM_Sessionization is supported */
1494 /* BMPS_WORKAROUND_NOT_NEEDED */
1495 pMac->roam.configParam.doBMPSWorkaround = 0;
1496
1497 pMac->roam.configParam.nInitialDwellTime = 0;
1498 pMac->roam.configParam.initial_scan_no_dfs_chnl = 0;
1499}
1500
1501eCsrBand csr_get_current_band(tHalHandle hHal)
1502{
1503 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301504
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 return pMac->roam.configParam.bandCapability;
1506}
1507
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301508/* This function flushes the roam scan cache */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301509QDF_STATUS csr_flush_cfg_bg_scan_roam_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001510 uint8_t sessionId)
1511{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301512 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301513
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
1515 &pMac->roam.neighborRoamInfo[sessionId];
1516
1517 /* Free up the memory first (if required) */
1518 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301519 qdf_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001520 ChannelList);
1521 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
1522 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1523 }
1524 return status;
1525}
1526
1527/*
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301528 * This function flushes the roam scan cache and creates fresh cache
1529 * based on the input channel list
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301531QDF_STATUS csr_create_bg_scan_roam_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532 uint8_t sessionId,
1533 const uint8_t *pChannelList,
1534 const uint8_t numChannels)
1535{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301536 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
1538 &pMac->roam.neighborRoamInfo[sessionId];
1539
1540 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1541
1542 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301543 qdf_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 numOfChannels);
1545
1546 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001547 sme_err("Memory Allocation for CFG Channel List failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301549 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 }
1551
1552 /* Update the roam global structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301553 qdf_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 pChannelList,
1555 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1556 return status;
1557}
1558
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001560#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001561/**
1562 * csr_create_roam_scan_channel_list() - create roam scan channel list
1563 * @pMac: Global mac pointer
1564 * @sessionId: session id
1565 * @pChannelList: pointer to channel list
1566 * @numChannels: number of channels
1567 * @eBand: band enumeration
1568 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001569 * This function modifies the roam scan channel list as per AP neighbor
1570 * report; AP neighbor report may be empty or may include only other AP
1571 * channels; in any case, we merge the channel list with the learned occupied
1572 * channels list.
1573 * if the band is 2.4G, then make sure channel list contains only 2.4G
1574 * valid channels if the band is 5G, then make sure channel list contains
1575 * only 5G valid channels
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001576 *
1577 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301579QDF_STATUS csr_create_roam_scan_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 uint8_t sessionId,
1581 uint8_t *pChannelList,
1582 uint8_t numChannels,
1583 const eCsrBand eBand)
1584{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301585 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301586
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587 tpCsrNeighborRoamControlInfo pNeighborRoamInfo
1588 = &pMac->roam.neighborRoamInfo[sessionId];
1589 uint8_t outNumChannels = 0;
1590 uint8_t inNumChannels = numChannels;
1591 uint8_t *inPtr = pChannelList;
1592 uint8_t i = 0;
1593 uint8_t ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
1594 uint8_t tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
1595 uint8_t mergedOutputNumOfChannels = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 tpCsrChannelInfo currChannelListInfo
1598 = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1599 /*
1600 * Create a Union of occupied channel list learnt by the DUT along
1601 * with the Neighbor report Channels. This increases the chances of
1602 * the DUT to get a candidate AP while roaming even if the Neighbor
1603 * Report is not able to provide sufficient information.
1604 */
1605 if (pMac->scan.occupiedChannels[sessionId].numChannels) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301606 csr_neighbor_roam_merge_channel_lists(pMac, &pMac->scan.
1607 occupiedChannels[sessionId].
1608 channelList[0], pMac->scan.
1609 occupiedChannels[sessionId].
1610 numChannels, inPtr,
1611 inNumChannels,
1612 &mergedOutputNumOfChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 inNumChannels = mergedOutputNumOfChannels;
1614 }
1615 if (eCSR_BAND_24 == eBand) {
1616 for (i = 0; i < inNumChannels; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001617 if (WLAN_REG_IS_24GHZ_CH(inPtr[i])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001618 && csr_roam_is_channel_valid(pMac, inPtr[i])) {
1619 ChannelList[outNumChannels++] = inPtr[i];
1620 }
1621 }
1622 } else if (eCSR_BAND_5G == eBand) {
1623 for (i = 0; i < inNumChannels; i++) {
1624 /* Add 5G Non-DFS channel */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001625 if (WLAN_REG_IS_5GHZ_CH(inPtr[i]) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626 csr_roam_is_channel_valid(pMac, inPtr[i]) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001627 !wlan_reg_is_dfs_ch(pMac->pdev, inPtr[i])) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 ChannelList[outNumChannels++] = inPtr[i];
1629 }
1630 }
1631 } else if (eCSR_BAND_ALL == eBand) {
1632 for (i = 0; i < inNumChannels; i++) {
1633 if (csr_roam_is_channel_valid(pMac, inPtr[i]) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001634 !wlan_reg_is_dfs_ch(pMac->pdev, inPtr[i])) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635 ChannelList[outNumChannels++] = inPtr[i];
1636 }
1637 }
1638 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301639 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 "Invalid band, No operation carried out (Band %d)",
1641 eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301642 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 }
1644 /*
1645 * if roaming within band is enabled, then select only the
1646 * in band channels .
1647 * This is required only if the band capability is set to ALL,
1648 * E.g., if band capability is only 2.4G then all the channels in the
1649 * list are already filtered for 2.4G channels, hence ignore this check
1650 */
1651 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac)) {
1652 csr_neighbor_roam_channels_filter_by_current_band(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301653 sessionId,
1654 ChannelList,
1655 outNumChannels,
1656 tmpChannelList,
1657 &outNumChannels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301658 qdf_mem_copy(ChannelList, tmpChannelList, outNumChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 }
1660 /* Prepare final roam scan channel list */
1661 if (outNumChannels) {
1662 /* Clear the channel list first */
1663 if (NULL != currChannelListInfo->ChannelList) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301664 qdf_mem_free(currChannelListInfo->ChannelList);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665 currChannelListInfo->ChannelList = NULL;
1666 currChannelListInfo->numOfChannels = 0;
1667 }
1668 currChannelListInfo->ChannelList
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301669 = qdf_mem_malloc(outNumChannels * sizeof(uint8_t));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670 if (NULL == currChannelListInfo->ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301671 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672 "Failed to allocate memory for roam scan channel list");
1673 currChannelListInfo->numOfChannels = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301674 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301676 qdf_mem_copy(currChannelListInfo->ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 ChannelList, outNumChannels);
1678 }
1679 return status;
1680}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001681
1682/**
1683 * csr_roam_is_ese_assoc() - is this ese association
1684 * @mac_ctx: Global MAC context
1685 * @session_id: session identifier
1686 *
1687 * Returns whether the current association is a ESE assoc or not.
1688 *
1689 * Return: true if ese association; false otherwise
1690 */
Selvaraj, Sridharbc950df2016-07-05 15:35:47 +05301691bool csr_roam_is_ese_assoc(tpAniSirGlobal mac_ctx, uint32_t session_id)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001692{
Srinivas Girigowda18dcf3d2015-12-16 18:11:48 -08001693 return mac_ctx->roam.neighborRoamInfo[session_id].isESEAssoc;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001694}
1695
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001696
1697/**
1698 * csr_roam_is_ese_ini_feature_enabled() - is ese feature enabled
1699 * @mac_ctx: Global MAC context
1700 *
1701 * Return: true if ese feature is enabled; false otherwise
1702 */
1703bool csr_roam_is_ese_ini_feature_enabled(tpAniSirGlobal pMac)
1704{
1705 return pMac->roam.configParam.isEseIniFeatureEnabled;
1706}
1707
1708/**
1709 * csr_tsm_stats_rsp_processor() - tsm stats response processor
1710 * @pMac: Global MAC context
1711 * @pMsg: Message pointer
1712 *
1713 * Return: None
1714 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -07001715static void csr_tsm_stats_rsp_processor(tpAniSirGlobal pMac, void *pMsg)
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001716{
1717 tAniGetTsmStatsRsp *pTsmStatsRsp = (tAniGetTsmStatsRsp *) pMsg;
1718
1719 if (NULL != pTsmStatsRsp) {
1720 /*
1721 * Get roam Rssi request is backed up and passed back
1722 * to the response, Extract the request message
1723 * to fetch callback.
1724 */
1725 tpAniGetTsmStatsReq reqBkp
1726 = (tAniGetTsmStatsReq *) pTsmStatsRsp->tsmStatsReq;
1727
1728 if (NULL != reqBkp) {
1729 if (NULL != reqBkp->tsmStatsCallback) {
1730 ((tCsrTsmStatsCallback)
1731 (reqBkp->tsmStatsCallback))(pTsmStatsRsp->
1732 tsmMetrics,
1733 pTsmStatsRsp->
1734 staId,
1735 reqBkp->
1736 pDevContext);
1737 reqBkp->tsmStatsCallback = NULL;
1738 }
1739 qdf_mem_free(reqBkp);
1740 pTsmStatsRsp->tsmStatsReq = NULL;
1741 } else {
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001742 if (NULL != reqBkp) {
1743 qdf_mem_free(reqBkp);
1744 pTsmStatsRsp->tsmStatsReq = NULL;
1745 }
1746 }
1747 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001748 sme_err("pTsmStatsRsp is NULL");
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001749 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001750}
1751
1752/**
1753 * csr_send_ese_adjacent_ap_rep_ind() - ese send adjacent ap report
1754 * @pMac: Global MAC context
1755 * @pSession: Session pointer
1756 *
1757 * Return: None
1758 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -07001759static void csr_send_ese_adjacent_ap_rep_ind(tpAniSirGlobal pMac,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001760 tCsrRoamSession *pSession)
1761{
1762 uint32_t roamTS2 = 0;
1763 tCsrRoamInfo roamInfo;
1764 tpPESession pSessionEntry = NULL;
1765 uint8_t sessionId = CSR_SESSION_ID_INVALID;
1766
1767 if (NULL == pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001768 sme_err("pSession is NULL");
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001769 return;
1770 }
1771
1772 roamTS2 = qdf_mc_timer_get_system_time();
1773 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001774 sme_debug("Bssid(" MAC_ADDRESS_STR ") Roaming Delay(%u ms)",
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001775 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid.bytes),
1776 roamInfo.tsmRoamDelay);
1777
1778 pSessionEntry = pe_find_session_by_bssid(pMac,
1779 pSession->connectedProfile.bssid.bytes,
1780 &sessionId);
1781 if (NULL == pSessionEntry) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001782 sme_err("session %d not found", sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001783 return;
1784 }
1785
1786 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly
1787 = roamInfo.tsmRoamDelay;
1788
1789 csr_roam_call_callback(pMac, pSession->sessionId, &roamInfo,
1790 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
1791}
1792
1793/**
1794 * csr_get_tsm_stats() - get tsm stats
1795 * @pMac: Global MAC context
1796 * @callback: TSM stats callback
1797 * @staId: Station id
1798 * @bssId: bssid
1799 * @pContext: pointer to context
1800 * @p_cds_context: cds context
1801 * @tid: traffic id
1802 *
1803 * Return: QDF_STATUS enumeration
1804 */
1805QDF_STATUS csr_get_tsm_stats(tpAniSirGlobal pMac,
1806 tCsrTsmStatsCallback callback,
1807 uint8_t staId,
1808 struct qdf_mac_addr bssId,
1809 void *pContext, void *p_cds_context, uint8_t tid)
1810{
1811 QDF_STATUS status = QDF_STATUS_SUCCESS;
1812 tAniGetTsmStatsReq *pMsg = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301813
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001814 pMsg = qdf_mem_malloc(sizeof(tAniGetTsmStatsReq));
1815 if (!pMsg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001816 sme_err(
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001817 "csr_get_tsm_stats: failed to allocate mem for req");
1818 return QDF_STATUS_E_NOMEM;
1819 }
1820 /* need to initiate a stats request to PE */
1821 pMsg->msgType = eWNI_SME_GET_TSM_STATS_REQ;
1822 pMsg->msgLen = (uint16_t) sizeof(tAniGetTsmStatsReq);
1823 pMsg->staId = staId;
1824 pMsg->tid = tid;
1825 qdf_copy_macaddr(&pMsg->bssId, &bssId);
1826 pMsg->tsmStatsCallback = callback;
1827 pMsg->pDevContext = pContext;
1828 pMsg->p_cds_context = p_cds_context;
Rajeev Kumard138ac52017-01-30 18:38:37 -08001829 status = umac_send_mb_message_to_mac(pMsg);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001830 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001831 sme_debug("csr_get_tsm_stats: failed to send down the rssi req");
1832 /* pMsg is freed by cds_send_mb_message_to_mac */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001833 status = QDF_STATUS_E_FAILURE;
1834 }
1835 return status;
1836}
1837
1838/**
1839 * csr_fetch_ch_lst_from_received_list() - fetch channel list from received list
1840 * and update req msg
1841 * paramters
1842 * @mac_ctx: global mac ctx
1843 * @roam_info: roam info struct
1844 * @curr_ch_lst_info: current channel list info
1845 * @req_buf: out param, roam offload scan request packet
1846 *
1847 * Return: void
1848 */
1849static void
1850csr_fetch_ch_lst_from_received_list(tpAniSirGlobal mac_ctx,
1851 tpCsrNeighborRoamControlInfo roam_info,
1852 tpCsrChannelInfo curr_ch_lst_info,
1853 tSirRoamOffloadScanReq *req_buf)
1854{
1855 uint8_t i = 0;
1856 uint8_t num_channels = 0;
1857 uint8_t *ch_lst = NULL;
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301858 uint16_t unsafe_chan[NUM_CHANNELS];
1859 uint16_t unsafe_chan_cnt = 0;
1860 uint16_t cnt = 0;
1861 bool is_unsafe_chan;
1862 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
1863
1864 if (!qdf_ctx) {
1865 cds_err("qdf_ctx is NULL");
1866 return;
1867 }
1868 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
1869 &unsafe_chan_cnt,
1870 sizeof(unsafe_chan));
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001871
1872 if (curr_ch_lst_info->numOfChannels == 0)
1873 return;
1874
1875 ch_lst = curr_ch_lst_info->ChannelList;
1876 for (i = 0; i < curr_ch_lst_info->numOfChannels; i++) {
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301877 if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
1878 (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
1879 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001880 (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001881 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
1882 ("ignoring dfs channel %d"), *ch_lst);
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301883 ch_lst++;
1884 continue;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001885 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301886
1887 if (mac_ctx->roam.configParam.sta_roam_policy.
1888 skip_unsafe_channels &&
1889 unsafe_chan_cnt) {
1890 is_unsafe_chan = false;
1891 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
1892 if (unsafe_chan[cnt] == *ch_lst) {
1893 is_unsafe_chan = true;
1894 break;
1895 }
1896 }
1897 if (is_unsafe_chan) {
1898 QDF_TRACE(QDF_MODULE_ID_SME,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001899 QDF_TRACE_LEVEL_DEBUG,
1900 ("ignoring unsafe channel %d"),
Agrawal Ashish21ba2572016-09-03 16:40:10 +05301901 *ch_lst);
1902 ch_lst++;
1903 continue;
1904 }
1905 }
1906 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
1907 *ch_lst;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001908 ch_lst++;
1909 }
1910 req_buf->ConnectedNetwork.ChannelCount = num_channels;
1911 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
1912}
1913
1914/**
1915 * csr_set_cckm_ie() - set CCKM IE
1916 * @pMac: Global MAC context
1917 * @sessionId: session identifier
1918 * @pCckmIe: Pointer to input CCKM IE data
1919 * @ccKmIeLen: Length of @pCckmIe
1920 *
1921 * This function stores the CCKM IE passed by the supplicant
1922 * in a place holder data structure and this IE will be packed inside
1923 * reassociation request
1924 *
1925 * Return: QDF_STATUS enumeration
1926 */
1927QDF_STATUS csr_set_cckm_ie(tpAniSirGlobal pMac, const uint8_t sessionId,
1928 const uint8_t *pCckmIe, const uint8_t ccKmIeLen)
1929{
1930 QDF_STATUS status = QDF_STATUS_SUCCESS;
1931 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301932
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001933 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07001934 sme_err("session %d not found", sessionId);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001935 return QDF_STATUS_E_FAILURE;
1936 }
1937 qdf_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
1938 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
1939 return status;
1940}
1941
1942/**
1943 * csr_roam_read_tsf() - read TSF
1944 * @pMac: Global MAC context
1945 * @sessionId: session identifier
1946 * @pTimestamp: output TSF timestamp
1947 *
1948 * This function reads the TSF; and also add the time elapsed since
1949 * last beacon or probe response reception from the hand off AP to arrive at
1950 * the latest TSF value.
1951 *
1952 * Return: QDF_STATUS enumeration
1953 */
1954QDF_STATUS csr_roam_read_tsf(tpAniSirGlobal pMac, uint8_t *pTimestamp,
1955 uint8_t sessionId)
1956{
1957 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridhar258594c2016-07-31 15:17:45 +05301958 tCsrNeighborRoamBSSInfo handoffNode = {{0} };
Arun Khandavalli8a711cb2017-01-03 20:23:56 +05301959 uint64_t timer_diff = 0;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001960 uint32_t timeStamp[2];
1961 tpSirBssDescription pBssDescription = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301962
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001963 csr_neighbor_roam_get_handoff_ap_info(pMac, &handoffNode, sessionId);
1964 pBssDescription = handoffNode.pBssDescription;
Arun Khandavalli8a711cb2017-01-03 20:23:56 +05301965 /* Get the time diff in nano seconds */
1966 timer_diff = (qdf_get_monotonic_boottime_ns() -
1967 pBssDescription->scansystimensec);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001968 /* Convert msec to micro sec timer */
Sarada Prasanna Garnayakf21c2962017-03-08 20:42:38 +05301969 timer_diff = do_div(timer_diff, SYSTEM_TIME_NSEC_TO_USEC);
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001970 timeStamp[0] = pBssDescription->timeStamp[0];
1971 timeStamp[1] = pBssDescription->timeStamp[1];
1972 update_cckmtsf(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
1973 qdf_mem_copy(pTimestamp, (void *)&timeStamp[0], sizeof(uint32_t) * 2);
1974 return status;
1975}
1976
1977#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001978
Mahesh Kumar Kalikot Veetil40575112016-09-09 16:57:08 -07001979/**
1980 * csr_roam_is_roam_offload_scan_enabled() - is roam offload enabled
1981 * @mac_ctx: Global MAC context
1982 *
1983 * Returns whether firmware based background scan is currently enabled or not.
1984 *
1985 * Return: true if roam offload scan enabled; false otherwise
1986 */
1987bool csr_roam_is_roam_offload_scan_enabled(tpAniSirGlobal mac_ctx)
1988{
1989 return mac_ctx->roam.configParam.isRoamOffloadScanEnabled;
1990}
1991
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301992QDF_STATUS csr_set_band(tHalHandle hHal, uint8_t sessionId, eCsrBand eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993{
1994 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301995 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301996
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997 if (CSR_IS_PHY_MODE_A_ONLY(pMac) && (eBand == eCSR_BAND_24)) {
1998 /* DOT11 mode configured to 11a only and received
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05301999 * request to change the band to 2.4 GHz
2000 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302001 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002002 "failed to set band cfg80211 = %u, band = %u",
2003 pMac->roam.configParam.uCfgDot11Mode, eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302004 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002005 }
2006 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
2007 CSR_IS_PHY_MODE_G_ONLY(pMac)) && (eBand == eCSR_BAND_5G)) {
2008 /* DOT11 mode configured to 11b/11g only and received
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302009 * request to change the band to 5 GHz
2010 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302011 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012 "failed to set band dot11mode = %u, band = %u",
2013 pMac->roam.configParam.uCfgDot11Mode, eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302014 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302016 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
2018 pMac->roam.configParam.eBand = eBand;
2019 pMac->roam.configParam.bandCapability = eBand;
2020
2021 status = csr_get_channel_and_power_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302022 if (QDF_STATUS_SUCCESS == status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 csr_apply_channel_and_power_list(pMac);
2024 return status;
2025}
2026
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302027/* The funcns csr_convert_cb_ini_value_to_phy_cb_state and
2028 * csr_convert_phy_cb_state_to_ini_value have been introduced
2029 * to convert the ini value to the ENUM used in csr and MAC for CB state
2030 * Ideally we should have kept the ini value and enum value same and
2031 * representing the same cb values as in 11n standard i.e.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 * Set to 1 (SCA) if the secondary channel is above the primary channel
2033 * Set to 3 (SCB) if the secondary channel is below the primary channel
2034 * Set to 0 (SCN) if no secondary channel is present
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302035 * However, since our driver is already distributed we will keep the ini
2036 * definition as it is which is:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037 * 0 - secondary none
2038 * 1 - secondary LOW
2039 * 2 - secondary HIGH
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302040 * and convert to enum value used within the driver in
2041 * csr_change_default_config_param using this funcn
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 * The enum values are as follows:
2043 * PHY_SINGLE_CHANNEL_CENTERED = 0
2044 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
2045 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
2046 */
2047ePhyChanBondState csr_convert_cb_ini_value_to_phy_cb_state(uint32_t cbIniValue)
2048{
2049
2050 ePhyChanBondState phyCbState;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302051
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052 switch (cbIniValue) {
2053 /* secondary none */
2054 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
2055 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
2056 break;
2057 /* secondary LOW */
2058 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
2059 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
2060 break;
2061 /* secondary HIGH */
2062 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
2063 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
2064 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002065 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
2066 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
2067 break;
2068 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
2069 phyCbState =
2070 PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
2071 break;
2072 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
2073 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
2074 break;
2075 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
2076 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
2077 break;
2078 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
2079 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
2080 break;
2081 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
2082 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
2083 break;
2084 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
2085 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
2086 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087 default:
2088 /* If an invalid value is passed, disable CHANNEL BONDING */
2089 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
2090 break;
2091 }
2092 return phyCbState;
2093}
2094
Jeff Johnson29e2ca12016-10-14 12:50:38 -07002095static
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096uint32_t csr_convert_phy_cb_state_to_ini_value(ePhyChanBondState phyCbState)
2097{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098 uint32_t cbIniValue;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302099
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002100 switch (phyCbState) {
2101 /* secondary none */
2102 case PHY_SINGLE_CHANNEL_CENTERED:
2103 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
2104 break;
2105 /* secondary LOW */
2106 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
2107 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
2108 break;
2109 /* secondary HIGH */
2110 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
2111 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
2112 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
2114 cbIniValue =
2115 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
2116 break;
2117 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
2118 cbIniValue =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302119 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002120 break;
2121 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
2122 cbIniValue =
2123 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
2124 break;
2125 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
2126 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
2127 break;
2128 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
2129 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
2130 break;
2131 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
2132 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
2133 break;
2134 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
2135 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
2136 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 default:
2138 /* return some invalid value */
2139 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
2140 break;
2141 }
2142 return cbIniValue;
2143}
2144
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08002145#ifdef WLAN_FEATURE_11AX
2146/**
2147 * csr_update_he_config_param() - Update MAC context with HE config param
2148 * @mac_ctx: pointer to MAC context
2149 * @param: pointer to CSR config params
2150 *
2151 * Return: None
2152 */
2153static void csr_update_he_config_param(tpAniSirGlobal mac_ctx,
2154 tCsrConfigParam *param)
2155{
2156 mac_ctx->roam.configParam.enable_ul_ofdma = param->enable_ul_ofdma;
2157 mac_ctx->roam.configParam.enable_ul_mimo = param->enable_ul_mimo;
2158}
2159
2160/**
2161 * csr_get_he_config_param() - Get HE config param from MAC context
2162 * @param: pointer to CSR config params
2163 * @mac_ctx: pointer to MAC context
2164 *
2165 * Return: None
2166 */
2167static void csr_get_he_config_param(tCsrConfigParam *param,
2168 tpAniSirGlobal mac_ctx)
2169{
2170 param->enable_ul_ofdma = mac_ctx->roam.configParam.enable_ul_ofdma;
2171 param->enable_ul_mimo = mac_ctx->roam.configParam.enable_ul_mimo;
2172}
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002173
2174
2175/**
2176 * csr_join_req_copy_he_cap() - Copy HE cap into CSR Join Req
2177 * @csr_join_req: pointer to CSR Join Req
2178 * @session: pointer to CSR session
2179 *
2180 * Return: None
2181 */
2182static void csr_join_req_copy_he_cap(tSirSmeJoinReq *csr_join_req,
2183 tCsrRoamSession *session)
2184{
2185 qdf_mem_copy(&csr_join_req->he_config, &session->he_config,
2186 sizeof(session->he_config));
2187}
2188
2189/**
2190 * csr_start_bss_copy_he_cap() - Copy HE cap into CSR Join Req
2191 * @req: pointer to START BSS Req
2192 * @session: pointer to CSR session
2193 *
2194 * Return: None
2195 */
2196static void csr_start_bss_copy_he_cap(tSirSmeStartBssReq *req,
2197 tCsrRoamSession *session)
2198{
2199 qdf_mem_copy(&req->he_config, &session->he_config,
2200 sizeof(session->he_config));
2201}
2202
2203static void csr_update_session_he_cap(tpAniSirGlobal mac_ctx,
2204 tCsrRoamSession *session)
2205{
2206 uint32_t value = 0;
2207 tDot11fIEvendor_he_cap *he_cap = &session->he_config;
2208
2209 he_cap->present = true;
2210
2211 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_CONTROL, &value);
2212 he_cap->htc_he = value;
2213 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TWT_REQUESTOR, &value);
2214 he_cap->twt_request = value;
2215 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TWT_RESPONDER, &value);
2216 he_cap->twt_responder = value;
2217 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_FRAGMENTATION, &value);
2218 he_cap->fragmentation = value;
2219 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MAX_FRAG_MSDU, &value);
2220 he_cap->max_num_frag_msdu = value;
2221 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MIN_FRAG_SIZE, &value);
2222 he_cap->min_frag_size = value;
2223 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_TRIG_PAD, &value);
2224 he_cap->trigger_frm_mac_pad = value;
2225 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MTID_AGGR, &value);
2226 he_cap->multi_tid_aggr = value;
2227 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_LINK_ADAPTATION, &value);
2228 he_cap->he_link_adaptation = value;
2229 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_ALL_ACK, &value);
2230 he_cap->all_ack = value;
2231 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_UL_MU_RSP_SCHEDULING, &value);
2232 he_cap->ul_mu_rsp_sched = value;
2233 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_BUFFER_STATUS_RPT, &value);
2234 he_cap->a_bsr = value;
2235 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_BCAST_TWT, &value);
2236 he_cap->broadcast_twt = value;
2237 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_BA_32BIT, &value);
2238 he_cap->ba_32bit_bitmap = value;
2239 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MU_CASCADING, &value);
2240 he_cap->mu_cascade = value;
2241 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MULTI_TID, &value);
2242 he_cap->ack_enabled_multitid = value;
2243 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_DL_MU_BA, &value);
2244 he_cap->dl_mu_ba = value;
2245 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_OMI, &value);
2246 he_cap->omi_a_ctrl = value;
2247 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_OFDMA_RA, &value);
2248 he_cap->ofdma_ra = value;
2249 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MAX_AMPDU_LEN, &value);
2250 he_cap->max_ampdu_len = value;
2251 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_AMSDU_FRAG, &value);
2252 he_cap->amsdu_frag = value;
2253 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_FLEX_TWT_SCHED, &value);
2254 he_cap->flex_twt_sched = value;
2255 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_RX_CTRL, &value);
2256 he_cap->rx_ctrl_frame = value;
2257 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_BSRP_AMPDU_AGGR, &value);
2258 he_cap->bsrp_ampdu_aggr = value;
2259 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_QTP, &value);
2260 he_cap->qtp = value;
2261 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_A_BQR, &value);
2262 he_cap->a_bqr = value;
2263
2264 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_DUAL_BAND, &value);
2265 he_cap->dual_band = value;
2266 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_CHAN_WIDTH, &value);
2267 he_cap->chan_width = value;
2268 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_RX_PREAM_PUNC, &value);
2269 he_cap->rx_pream_puncturing = value;
2270 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_CLASS_OF_DEVICE, &value);
2271 he_cap->device_class = value;
2272 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_LDPC, &value);
2273 he_cap->ldpc_coding = value;
2274 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_LTF_PPDU, &value);
2275 he_cap->he_ltf_gi_ppdu = value;
2276 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_LTF_NDP, &value);
2277 he_cap->he_ltf_gi_ndp = value;
2278 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_STBC, &value);
2279 he_cap->stbc = value;
2280 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_DOPPLER, &value);
2281 he_cap->doppler = value;
2282 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_UL_MUMIMO, &value);
2283 he_cap->ul_mu = value;
2284 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_DCM_TX, &value);
2285 he_cap->dcm_enc_tx = value;
2286 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_DCM_RX, &value);
2287 he_cap->dcm_enc_rx = value;
2288 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MU_PPDU, &value);
2289 he_cap->ul_he_mu = value;
2290 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_SU_BEAMFORMER, &value);
2291 he_cap->su_beamformer = value;
2292 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_SU_BEAMFORMEE, &value);
2293 he_cap->su_beamformee = value;
2294 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MU_BEAMFORMER, &value);
2295 he_cap->mu_beamformer = value;
2296 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_BFEE_STS_LT80, &value);
2297 he_cap->bfee_sts_lt_80 = value;
2298 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_NSTS_TOT_LT80, &value);
2299 he_cap->nsts_tol_lt_80 = value;
2300 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_BFEE_STS_GT80, &value);
2301 he_cap->bfee_sta_gt_80 = value;
2302 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_NSTS_TOT_GT80, &value);
2303 he_cap->nsts_tot_gt_80 = value;
2304 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_NUM_SOUND_LT80, &value);
2305 he_cap->num_sounding_lt_80 = value;
2306 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_NUM_SOUND_GT80, &value);
2307 he_cap->num_sounding_gt_80 = value;
2308 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_SU_FEED_TONE16, &value);
2309 he_cap->su_feedback_tone16 = value;
2310 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MU_FEED_TONE16, &value);
2311 he_cap->mu_feedback_tone16 = value;
2312 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_CODEBOOK_SU, &value);
2313 he_cap->codebook_su = value;
2314 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_CODEBOOK_MU, &value);
2315 he_cap->codebook_mu = value;
2316 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_BFRM_FEED, &value);
2317 he_cap->beamforming_feedback = value;
2318 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_ER_SU_PPDU, &value);
2319 he_cap->he_er_su_ppdu = value;
2320 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_DL_PART_BW, &value);
2321 he_cap->dl_mu_mimo_part_bw = value;
2322 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_PPET_PRESENT, &value);
2323 he_cap->ppet_present = value;
2324 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_SRP, &value);
2325 he_cap->srp = value;
2326 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_POWER_BOOST, &value);
2327 he_cap->power_boost = value;
2328 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_4x_LTF_GI, &value);
2329 he_cap->he_ltf_gi_4x = value;
2330 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_NSS, &value);
2331 he_cap->nss_supported = value;
2332 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_MCS, &value);
2333 he_cap->mcs_supported = value;
2334
Krishna Kumaar Natarajanbc594592017-04-12 19:02:39 -07002335 if (he_cap->ppet_present) {
2336 value = WNI_CFG_HE_PPET_LEN;
2337 sme_cfg_get_str(mac_ctx, WNI_CFG_HE_PPET,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002338 (void *)&he_cap->ppe_threshold, &value);
Krishna Kumaar Natarajanbc594592017-04-12 19:02:39 -07002339 } else {
2340 he_cap->ppe_threshold.present = false;
2341 }
Manikandan Mohan39accff2017-05-02 16:09:00 -07002342 sme_cfg_get_int(mac_ctx, WNI_CFG_HE_STA_OBSSPD, &value);
2343 session->he_sta_obsspd = value;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002344}
2345
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08002346#else
2347static inline void csr_update_he_config_param(tpAniSirGlobal mac_ctx,
2348 tCsrConfigParam *param)
2349{
2350}
2351
2352static inline void csr_get_he_config_param(tCsrConfigParam *param,
2353 tpAniSirGlobal mac_ctx)
2354{
2355}
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08002356
2357static inline void csr_join_req_copy_he_cap(tSirSmeJoinReq *csr_join_req,
2358 tCsrRoamSession *session)
2359{
2360}
2361
2362static inline void csr_start_bss_copy_he_cap(tSirSmeStartBssReq *req,
2363 tCsrRoamSession *session)
2364{
2365}
2366
2367static inline void csr_update_session_he_cap(tpAniSirGlobal mac_ctx,
2368 tCsrRoamSession *session)
2369{
2370}
2371
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08002372#endif
2373
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302374QDF_STATUS csr_change_default_config_param(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375 tCsrConfigParam *pParam)
2376{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302377 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378
2379 if (pParam) {
Naveen Rawat2b6e3c92017-03-20 13:59:07 -07002380 pMac->roam.configParam.pkt_err_disconn_th =
2381 pParam->pkt_err_disconn_th;
Naveen Rawatb2fc4132017-05-10 20:42:05 -07002382 pMac->roam.configParam.is_force_1x1 =
2383 pParam->is_force_1x1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002384 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
2385 cfg_set_int(pMac, WNI_CFG_WME_ENABLED,
2386 (pParam->WMMSupportMode == eCsrRoamWmmNoQos) ? 0 : 1);
2387 pMac->roam.configParam.Is11eSupportEnabled =
2388 pParam->Is11eSupportEnabled;
2389 pMac->roam.configParam.FragmentationThreshold =
2390 pParam->FragmentationThreshold;
2391 pMac->roam.configParam.Is11dSupportEnabled =
2392 pParam->Is11dSupportEnabled;
2393 pMac->roam.configParam.Is11dSupportEnabledOriginal =
2394 pParam->Is11dSupportEnabled;
2395 pMac->roam.configParam.Is11hSupportEnabled =
2396 pParam->Is11hSupportEnabled;
2397
2398 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
2399 pMac->roam.configParam.mcc_rts_cts_prot_enable =
2400 pParam->mcc_rts_cts_prot_enable;
2401 pMac->roam.configParam.mcc_bcast_prob_resp_enable =
2402 pParam->mcc_bcast_prob_resp_enable;
2403 pMac->roam.configParam.fAllowMCCGODiffBI =
2404 pParam->fAllowMCCGODiffBI;
2405
2406 /* channelBondingMode5GHz plays a dual role right now
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302407 * INFRA STA will use this non zero value as CB enabled
2408 * and SOFTAP will use this non-zero value to determine
2409 * the secondary channel offset. This is how
2410 * channelBondingMode5GHz works now and this is kept intact
2411 * to avoid any cfg.ini change.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302413 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
2414 sme_warn("Invalid CB value from ini in 2.4GHz band %d, CB DISABLED",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415 pParam->channelBondingMode24GHz);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 pMac->roam.configParam.channelBondingMode24GHz =
2417 csr_convert_cb_ini_value_to_phy_cb_state(pParam->
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302418 channelBondingMode24GHz);
2419 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
2420 sme_warn("Invalid CB value from ini in 5GHz band %d, CB DISABLED",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421 pParam->channelBondingMode5GHz);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002422 pMac->roam.configParam.channelBondingMode5GHz =
2423 csr_convert_cb_ini_value_to_phy_cb_state(pParam->
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302424 channelBondingMode5GHz);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
2426 pMac->roam.configParam.phyMode = pParam->phyMode;
2427 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
2428 pMac->roam.configParam.HeartbeatThresh24 =
2429 pParam->HeartbeatThresh24;
2430 pMac->roam.configParam.HeartbeatThresh50 =
2431 pParam->HeartbeatThresh50;
2432 pMac->roam.configParam.ProprietaryRatesEnabled =
2433 pParam->ProprietaryRatesEnabled;
2434 pMac->roam.configParam.TxRate = pParam->TxRate;
2435 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
2436 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
2437 pMac->roam.configParam.bandCapability = pParam->bandCapability;
2438 pMac->roam.configParam.cbChoice = pParam->cbChoice;
2439 pMac->roam.configParam.neighborRoamConfig.
2440 delay_before_vdev_stop =
2441 pParam->neighborRoamConfig.delay_before_vdev_stop;
2442
2443 /* if HDD passed down non zero values then only update, */
2444 /* otherwise keep using the defaults */
2445 if (pParam->initial_scan_no_dfs_chnl) {
2446 pMac->roam.configParam.initial_scan_no_dfs_chnl =
2447 pParam->initial_scan_no_dfs_chnl;
2448 }
2449 if (pParam->nInitialDwellTime) {
2450 pMac->roam.configParam.nInitialDwellTime =
2451 pParam->nInitialDwellTime;
2452 }
2453 if (pParam->nActiveMaxChnTime) {
2454 pMac->roam.configParam.nActiveMaxChnTime =
2455 pParam->nActiveMaxChnTime;
2456 cfg_set_int(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
2457 pParam->nActiveMaxChnTime);
2458 }
2459 if (pParam->nActiveMinChnTime) {
2460 pMac->roam.configParam.nActiveMinChnTime =
2461 pParam->nActiveMinChnTime;
2462 cfg_set_int(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
2463 pParam->nActiveMinChnTime);
2464 }
2465 if (pParam->nPassiveMaxChnTime) {
2466 pMac->roam.configParam.nPassiveMaxChnTime =
2467 pParam->nPassiveMaxChnTime;
2468 cfg_set_int(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
2469 pParam->nPassiveMaxChnTime);
2470 }
2471 if (pParam->nPassiveMinChnTime) {
2472 pMac->roam.configParam.nPassiveMinChnTime =
2473 pParam->nPassiveMinChnTime;
2474 cfg_set_int(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
2475 pParam->nPassiveMinChnTime);
2476 }
2477#ifdef WLAN_AP_STA_CONCURRENCY
2478 if (pParam->nActiveMaxChnTimeConc) {
2479 pMac->roam.configParam.nActiveMaxChnTimeConc =
2480 pParam->nActiveMaxChnTimeConc;
2481 }
2482 if (pParam->nActiveMinChnTimeConc) {
2483 pMac->roam.configParam.nActiveMinChnTimeConc =
2484 pParam->nActiveMinChnTimeConc;
2485 }
2486 if (pParam->nPassiveMaxChnTimeConc) {
2487 pMac->roam.configParam.nPassiveMaxChnTimeConc =
2488 pParam->nPassiveMaxChnTimeConc;
2489 }
2490 if (pParam->nPassiveMinChnTimeConc) {
2491 pMac->roam.configParam.nPassiveMinChnTimeConc =
2492 pParam->nPassiveMinChnTimeConc;
2493 }
Agrawal Ashish17bb3902016-05-05 13:29:40 +05302494 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
2495 pMac->roam.configParam.min_rest_time_conc =
2496 pParam->min_rest_time_conc;
2497 pMac->roam.configParam.idle_time_conc = pParam->idle_time_conc;
2498
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499#endif
2500 pMac->roam.configParam.eBand = pParam->eBand;
2501 pMac->roam.configParam.uCfgDot11Mode =
2502 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302503 pMac->roam.configParam.
2504 phyMode,
2505 pMac->roam.configParam.
2506 ProprietaryRatesEnabled);
2507 /* if HDD passed down non zero values for age params,
2508 * then only update, otherwise keep using the defaults
2509 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002510 if (pParam->nScanResultAgeCount) {
2511 pMac->roam.configParam.agingCount =
2512 pParam->nScanResultAgeCount;
2513 }
Sandeep Puligillae0875662016-02-12 16:09:21 -08002514 if (pParam->obss_width_interval) {
2515 pMac->roam.configParam.obss_width_interval =
2516 pParam->obss_width_interval;
2517 cfg_set_int(pMac,
2518 WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
2519 pParam->obss_width_interval);
2520 }
2521 if (pParam->obss_active_dwelltime) {
2522 pMac->roam.configParam.obss_active_dwelltime =
2523 pParam->obss_active_dwelltime;
2524 cfg_set_int(pMac,
2525 WNI_CFG_OBSS_HT40_SCAN_ACTIVE_DWELL_TIME,
2526 pParam->obss_active_dwelltime);
2527 }
2528 if (pParam->obss_passive_dwelltime) {
2529 pMac->roam.configParam.obss_passive_dwelltime =
2530 pParam->obss_passive_dwelltime;
2531 cfg_set_int(pMac,
2532 WNI_CFG_OBSS_HT40_SCAN_PASSIVE_DWELL_TIME,
2533 pParam->obss_passive_dwelltime);
2534 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002535
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08002536 pMac->first_scan_bucket_threshold =
2537 pParam->first_scan_bucket_threshold;
2538 csr_assign_rssi_for_category(pMac,
2539 pMac->first_scan_bucket_threshold,
2540 pParam->bCatRssiOffset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002541 pMac->roam.configParam.fSupplicantCountryCodeHasPriority =
2542 pParam->fSupplicantCountryCodeHasPriority;
2543 pMac->roam.configParam.vccRssiThreshold =
2544 pParam->vccRssiThreshold;
2545 pMac->roam.configParam.vccUlMacLossThreshold =
2546 pParam->vccUlMacLossThreshold;
2547 pMac->roam.configParam.statsReqPeriodicity =
2548 pParam->statsReqPeriodicity;
2549 pMac->roam.configParam.statsReqPeriodicityInPS =
2550 pParam->statsReqPeriodicityInPS;
2551 /* Assign this before calling csr_init11d_info */
2552 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05302553 pMac->roam.configParam.allow_tpc_from_ap =
2554 pParam->allow_tpc_from_ap;
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07002555 if (wlan_reg_11d_enabled_on_host(pMac->psoc))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 status = csr_init11d_info(pMac, &pParam->Csr11dinfo);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302557 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002559
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302560 /* Initialize the power + channel information if 11h is
2561 * enabled. If 11d is enabled this information has already
2562 * been initialized
2563 */
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07002564 if (csr_is11h_supported(pMac) &&
2565 !wlan_reg_11d_enabled_on_host(pMac->psoc))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002566 csr_init_channel_power_list(pMac, &pParam->Csr11dinfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302568 qdf_mem_copy(&pMac->roam.configParam.csr11rConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 &pParam->csr11rConfig,
2570 sizeof(tCsr11rConfigParams));
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002571 sme_debug("IsFTResourceReqSupp: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002572 pMac->roam.configParam.csr11rConfig.
2573 IsFTResourceReqSupported);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 pMac->roam.configParam.isFastTransitionEnabled =
2575 pParam->isFastTransitionEnabled;
2576 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
2577 pMac->roam.configParam.nRoamPrefer5GHz =
2578 pParam->nRoamPrefer5GHz;
2579 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
2580 pMac->roam.configParam.isWESModeEnabled =
2581 pParam->isWESModeEnabled;
2582 pMac->roam.configParam.nProbes = pParam->nProbes;
2583 pMac->roam.configParam.nRoamScanHomeAwayTime =
2584 pParam->nRoamScanHomeAwayTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585 pMac->roam.configParam.isRoamOffloadScanEnabled =
2586 pParam->isRoamOffloadScanEnabled;
2587 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
2588 pParam->bFastRoamInConIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
2590 pParam->isFastRoamIniFeatureEnabled;
2591 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002592
2593#ifdef FEATURE_WLAN_ESE
2594 pMac->roam.configParam.isEseIniFeatureEnabled =
2595 pParam->isEseIniFeatureEnabled;
2596#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302597 qdf_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598 &pParam->neighborRoamConfig,
2599 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002600 sme_debug("nNeighborScanTimerPerioid: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601 pMac->roam.configParam.neighborRoamConfig.
2602 nNeighborScanTimerPeriod);
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +05302603 sme_debug("neighbor_scan_min_timer_period: %d",
2604 pMac->roam.configParam.neighborRoamConfig.
2605 neighbor_scan_min_timer_period);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002606 sme_debug("nNeighborLookupRssiThreshold: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 pMac->roam.configParam.neighborRoamConfig.
2608 nNeighborLookupRssiThreshold);
Varun Reddy Yeturu168134f2017-06-26 13:46:05 -07002609 sme_debug("rssi_thresh_offset_5g: %d",
2610 pMac->roam.configParam.neighborRoamConfig.rssi_thresh_offset_5g);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002611 sme_debug("nOpportunisticThresholdDiff: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002612 pMac->roam.configParam.neighborRoamConfig.
2613 nOpportunisticThresholdDiff);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002614 sme_debug("nRoamRescanRssiDiff: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002615 pMac->roam.configParam.neighborRoamConfig.
2616 nRoamRescanRssiDiff);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002617 sme_debug("nNeighborScanMinChanTime: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618 pMac->roam.configParam.neighborRoamConfig.
2619 nNeighborScanMinChanTime);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002620 sme_debug("nNeighborScanMaxChanTime: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002621 pMac->roam.configParam.neighborRoamConfig.
2622 nNeighborScanMaxChanTime);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002623 sme_debug("nMaxNeighborRetries: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624 pMac->roam.configParam.neighborRoamConfig.
2625 nMaxNeighborRetries);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002626 sme_debug("nNeighborResultsRefreshPeriod: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627 pMac->roam.configParam.neighborRoamConfig.
2628 nNeighborResultsRefreshPeriod);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002629 sme_debug("nEmptyScanRefreshPeriod: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 pMac->roam.configParam.neighborRoamConfig.
2631 nEmptyScanRefreshPeriod);
2632 {
2633 int i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302634
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002635 sme_debug("Num of Channels in CFG Channel List: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636 pMac->roam.configParam.neighborRoamConfig.
2637 neighborScanChanList.numChannels);
2638 for (i = 0;
2639 i <
2640 pMac->roam.configParam.neighborRoamConfig.
2641 neighborScanChanList.numChannels; i++) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002642 sme_debug("%d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643 pMac->roam.configParam.
2644 neighborRoamConfig.neighborScanChanList.
2645 channelList[i]);
2646 }
2647 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002648 sme_debug("nRoamBmissFirstBcnt: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649 pMac->roam.configParam.neighborRoamConfig.
2650 nRoamBmissFirstBcnt);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002651 sme_debug("nRoamBmissFinalBcnt: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652 pMac->roam.configParam.neighborRoamConfig.
2653 nRoamBmissFinalBcnt);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002654 sme_debug("nRoamBeaconRssiWeight: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655 pMac->roam.configParam.neighborRoamConfig.
2656 nRoamBeaconRssiWeight);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657 pMac->roam.configParam.addTSWhenACMIsOff =
2658 pParam->addTSWhenACMIsOff;
2659 pMac->scan.fValidateList = pParam->fValidateList;
2660 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
2661 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
2662 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
2663 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
2664 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
2665 pMac->scan.max_scan_count = pParam->max_scan_count;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05302666 /* This parameter is not available in cfg and not passed from
2667 * upper layers. Instead it is initialized here This paramtere
2668 * is used in concurrency to determine if there are concurrent
2669 * active sessions. Is used as a temporary fix to disconnect
2670 * all active sessions when BMPS enabled so the active session
2671 * if Infra STA will automatically connect back and resume BMPS
2672 * since resume BMPS is not working when moving from concurrent
2673 * to single session
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674 */
2675 /* Remove this code once SLM_Sessionization is supported */
2676 /* BMPS_WORKAROUND_NOT_NEEDED */
2677 pMac->roam.configParam.doBMPSWorkaround = 0;
2678
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 pMac->roam.configParam.nVhtChannelWidth =
2680 pParam->nVhtChannelWidth;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08002681 pMac->roam.configParam.enable_txbf_sap_mode =
2682 pParam->enable_txbf_sap_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 pMac->roam.configParam.enable2x2 = pParam->enable2x2;
2684 pMac->roam.configParam.enableVhtFor24GHz =
2685 pParam->enableVhtFor24GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686 pMac->roam.configParam.enableVhtpAid = pParam->enableVhtpAid;
2687 pMac->roam.configParam.enableVhtGid = pParam->enableVhtGid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688 pMac->roam.configParam.enableAmpduPs = pParam->enableAmpduPs;
2689 pMac->roam.configParam.enableHtSmps = pParam->enableHtSmps;
2690 pMac->roam.configParam.htSmps = pParam->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002691 pMac->roam.configParam.send_smps_action =
2692 pParam->send_smps_action;
Krunal Sonia2c0e412017-05-04 14:12:41 +05302693 pMac->roam.configParam.tx_ldpc_enable = pParam->enable_tx_ldpc;
2694 pMac->roam.configParam.rx_ldpc_enable = pParam->enable_rx_ldpc;
Krunal Soni158bfe62017-08-02 12:33:08 -07002695 pMac->roam.configParam.disable_high_ht_mcs_2x2 =
2696 pParam->disable_high_ht_mcs_2x2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697 pMac->roam.configParam.ignore_peer_erp_info =
2698 pParam->ignore_peer_erp_info;
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07002699 pMac->roam.configParam.max_amsdu_num =
2700 pParam->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701 pMac->roam.configParam.nSelect5GHzMargin =
2702 pParam->nSelect5GHzMargin;
2703 pMac->roam.configParam.isCoalesingInIBSSAllowed =
2704 pParam->isCoalesingInIBSSAllowed;
2705#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
2706 pMac->roam.configParam.cc_switch_mode = pParam->cc_switch_mode;
2707#endif
2708 pMac->roam.configParam.allowDFSChannelRoam =
2709 pParam->allowDFSChannelRoam;
2710#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2711 pMac->roam.configParam.isRoamOffloadEnabled =
2712 pParam->isRoamOffloadEnabled;
2713#endif
2714 pMac->roam.configParam.obssEnabled = pParam->obssEnabled;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302715 pMac->roam.configParam.vendor_vht_sap =
2716 pParam->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717 pMac->roam.configParam.conc_custom_rule1 =
2718 pParam->conc_custom_rule1;
2719 pMac->roam.configParam.conc_custom_rule2 =
2720 pParam->conc_custom_rule2;
2721 pMac->roam.configParam.is_sta_connection_in_5gz_enabled =
2722 pParam->is_sta_connection_in_5gz_enabled;
2723 pMac->roam.configParam.sendDeauthBeforeCon =
2724 pParam->sendDeauthBeforeCon;
2725
2726 pMac->enable_dot11p = pParam->enable_dot11p;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07002727 pMac->roam.configParam.early_stop_scan_enable =
2728 pParam->early_stop_scan_enable;
2729 pMac->roam.configParam.early_stop_scan_min_threshold =
2730 pParam->early_stop_scan_min_threshold;
2731 pMac->roam.configParam.early_stop_scan_max_threshold =
2732 pParam->early_stop_scan_max_threshold;
Krunal Soni1878d3a2016-01-14 13:00:44 -08002733 pMac->isCoalesingInIBSSAllowed =
2734 pParam->isCoalesingInIBSSAllowed;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07002735
Gupta, Kapilc68ad462016-02-01 19:17:23 +05302736 pMac->roam.configParam.roam_params.dense_rssi_thresh_offset =
2737 pParam->roam_dense_rssi_thresh_offset;
2738 pMac->roam.configParam.roam_params.dense_min_aps_cnt =
2739 pParam->roam_dense_min_aps;
2740 pMac->roam.configParam.roam_params.traffic_threshold =
2741 pParam->roam_dense_traffic_thresh;
2742
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05302743 pMac->roam.configParam.scan_adaptive_dwell_mode =
2744 pParam->scan_adaptive_dwell_mode;
2745 pMac->roam.configParam.roamscan_adaptive_dwell_mode =
2746 pParam->roamscan_adaptive_dwell_mode;
2747
Kapil Gupta5cda2252016-12-29 18:44:26 +05302748 pMac->roam.configParam.per_roam_config.enable =
2749 pParam->per_roam_config.enable;
2750 pMac->roam.configParam.per_roam_config.tx_high_rate_thresh =
2751 pParam->per_roam_config.tx_high_rate_thresh;
2752 pMac->roam.configParam.per_roam_config.rx_high_rate_thresh =
2753 pParam->per_roam_config.rx_high_rate_thresh;
2754 pMac->roam.configParam.per_roam_config.tx_low_rate_thresh =
2755 pParam->per_roam_config.tx_low_rate_thresh;
2756 pMac->roam.configParam.per_roam_config.rx_low_rate_thresh =
2757 pParam->per_roam_config.rx_low_rate_thresh;
2758 pMac->roam.configParam.per_roam_config.tx_rate_thresh_percnt =
2759 pParam->per_roam_config.tx_rate_thresh_percnt;
2760 pMac->roam.configParam.per_roam_config.rx_rate_thresh_percnt =
2761 pParam->per_roam_config.rx_rate_thresh_percnt;
2762 pMac->roam.configParam.per_roam_config.per_rest_time =
2763 pParam->per_roam_config.per_rest_time;
Kapil Gupta957827b2017-02-13 15:47:04 +05302764 pMac->roam.configParam.per_roam_config.tx_per_mon_time =
2765 pParam->per_roam_config.tx_per_mon_time;
2766 pMac->roam.configParam.per_roam_config.rx_per_mon_time =
2767 pParam->per_roam_config.rx_per_mon_time;
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +05302768 pMac->roam.configParam.per_roam_config.min_candidate_rssi =
2769 pParam->per_roam_config.min_candidate_rssi;
Kapil Gupta5cda2252016-12-29 18:44:26 +05302770
Krunal Soni1878d3a2016-01-14 13:00:44 -08002771 pMac->fEnableDebugLog = pParam->fEnableDebugLog;
2772
2773 /* update interface configuration */
2774 pMac->sme.max_intf_count = pParam->max_intf_count;
2775
2776 pMac->enable5gEBT = pParam->enable5gEBT;
2777 pMac->sme.enableSelfRecovery = pParam->enableSelfRecovery;
2778
2779 pMac->f_sta_miracast_mcc_rest_time_val =
2780 pParam->f_sta_miracast_mcc_rest_time_val;
2781#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
2782 pMac->sap.sap_channel_avoidance =
2783 pParam->sap_channel_avoidance;
2784#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
2785
2786 pMac->f_prefer_non_dfs_on_radar =
2787 pParam->f_prefer_non_dfs_on_radar;
2788
2789 pMac->sme.ps_global_info.ps_enabled =
2790 pParam->is_ps_enabled;
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002791 pMac->sme.ps_global_info.auto_bmps_timer_val =
2792 pParam->auto_bmps_timer_val;
Abhishek Singh165bc602016-03-21 12:43:00 +05302793 pMac->roam.configParam.ignore_peer_ht_opmode =
2794 pParam->ignore_peer_ht_opmode;
Krunal Soni1878d3a2016-01-14 13:00:44 -08002795 pMac->fine_time_meas_cap = pParam->fine_time_meas_cap;
2796 pMac->dual_mac_feature_disable =
2797 pParam->dual_mac_feature_disable;
Krunal Soni1878d3a2016-01-14 13:00:44 -08002798 pMac->roam.configParam.early_stop_scan_enable =
2799 pParam->early_stop_scan_enable;
2800 pMac->roam.configParam.early_stop_scan_min_threshold =
2801 pParam->early_stop_scan_min_threshold;
2802 pMac->roam.configParam.early_stop_scan_max_threshold =
2803 pParam->early_stop_scan_max_threshold;
Abhishek Singh10ecf582016-05-04 17:48:59 +05302804 pMac->roam.configParam.enable_edca_params =
2805 pParam->enable_edca_params;
2806 pMac->roam.configParam.edca_vo_cwmin = pParam->edca_vo_cwmin;
2807 pMac->roam.configParam.edca_vi_cwmin = pParam->edca_vi_cwmin;
2808 pMac->roam.configParam.edca_bk_cwmin = pParam->edca_bk_cwmin;
2809 pMac->roam.configParam.edca_be_cwmin = pParam->edca_be_cwmin;
2810
2811 pMac->roam.configParam.edca_vo_cwmax = pParam->edca_vo_cwmax;
2812 pMac->roam.configParam.edca_vi_cwmax = pParam->edca_vi_cwmax;
2813 pMac->roam.configParam.edca_bk_cwmax = pParam->edca_bk_cwmax;
2814 pMac->roam.configParam.edca_be_cwmax = pParam->edca_be_cwmax;
2815
2816 pMac->roam.configParam.edca_vo_aifs = pParam->edca_vo_aifs;
2817 pMac->roam.configParam.edca_vi_aifs = pParam->edca_vi_aifs;
2818 pMac->roam.configParam.edca_bk_aifs = pParam->edca_bk_aifs;
2819 pMac->roam.configParam.edca_be_aifs = pParam->edca_be_aifs;
2820
Abhishek Singh5ea86532016-04-27 14:10:53 +05302821 pMac->roam.configParam.enable_fatal_event =
2822 pParam->enable_fatal_event;
Agrawal Ashish21ba2572016-09-03 16:40:10 +05302823 pMac->roam.configParam.sta_roam_policy.dfs_mode =
2824 pParam->sta_roam_policy_params.dfs_mode;
2825 pMac->roam.configParam.sta_roam_policy.skip_unsafe_channels =
2826 pParam->sta_roam_policy_params.skip_unsafe_channels;
Zhang Qian65e2e8d2017-07-11 11:56:43 +08002827 pMac->roam.configParam.sta_roam_policy.sap_operating_band =
2828 pParam->sta_roam_policy_params.sap_operating_band;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002829
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +05302830 pMac->roam.configParam.tx_aggregation_size =
2831 pParam->tx_aggregation_size;
2832 pMac->roam.configParam.rx_aggregation_size =
2833 pParam->rx_aggregation_size;
Selvaraj, Sridhar4f684bb2017-01-19 15:59:23 +05302834 pMac->roam.configParam.enable_bcast_probe_rsp =
2835 pParam->enable_bcast_probe_rsp;
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05302836 pMac->roam.configParam.qcn_ie_support =
2837 pParam->qcn_ie_support;
Selvaraj, Sridhar97ce6582017-01-20 17:06:34 +05302838 pMac->roam.configParam.fils_max_chan_guard_time =
2839 pParam->fils_max_chan_guard_time;
Selvaraj, Sridhar57ce4df2017-05-29 18:30:49 +05302840 pMac->roam.configParam.disallow_duration =
2841 pParam->disallow_duration;
2842 pMac->roam.configParam.rssi_channel_penalization =
2843 pParam->rssi_channel_penalization;
2844 pMac->roam.configParam.num_disallowed_aps =
2845 pParam->num_disallowed_aps;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +05302846
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08002847 csr_update_he_config_param(pMac, pParam);
Gupta, Kapilc68ad462016-02-01 19:17:23 +05302848 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 return status;
2850}
2851
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302852QDF_STATUS csr_get_config_param(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853{
2854 int i;
2855 tCsrConfig *cfg_params = &pMac->roam.configParam;
2856
2857 if (!pParam)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302858 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002859
Naveen Rawat2b6e3c92017-03-20 13:59:07 -07002860 pParam->pkt_err_disconn_th = cfg_params->pkt_err_disconn_th;
Naveen Rawatb2fc4132017-05-10 20:42:05 -07002861 pParam->is_force_1x1 = cfg_params->is_force_1x1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 pParam->WMMSupportMode = cfg_params->WMMSupportMode;
2863 pParam->Is11eSupportEnabled = cfg_params->Is11eSupportEnabled;
2864 pParam->FragmentationThreshold = cfg_params->FragmentationThreshold;
2865 pParam->Is11dSupportEnabled = cfg_params->Is11dSupportEnabled;
2866 pParam->Is11dSupportEnabledOriginal =
2867 cfg_params->Is11dSupportEnabledOriginal;
2868 pParam->Is11hSupportEnabled = cfg_params->Is11hSupportEnabled;
2869 pParam->channelBondingMode24GHz = csr_convert_phy_cb_state_to_ini_value(
2870 cfg_params->channelBondingMode24GHz);
2871 pParam->channelBondingMode5GHz = csr_convert_phy_cb_state_to_ini_value(
2872 cfg_params->channelBondingMode5GHz);
2873 pParam->RTSThreshold = cfg_params->RTSThreshold;
2874 pParam->phyMode = cfg_params->phyMode;
2875 pParam->shortSlotTime = cfg_params->shortSlotTime;
2876 pParam->HeartbeatThresh24 = cfg_params->HeartbeatThresh24;
2877 pParam->HeartbeatThresh50 = cfg_params->HeartbeatThresh50;
2878 pParam->ProprietaryRatesEnabled = cfg_params->ProprietaryRatesEnabled;
2879 pParam->TxRate = cfg_params->TxRate;
2880 pParam->AdHocChannel24 = cfg_params->AdHocChannel24;
2881 pParam->AdHocChannel5G = cfg_params->AdHocChannel5G;
2882 pParam->bandCapability = cfg_params->bandCapability;
2883 pParam->cbChoice = cfg_params->cbChoice;
2884 pParam->nActiveMaxChnTime = cfg_params->nActiveMaxChnTime;
2885 pParam->nActiveMinChnTime = cfg_params->nActiveMinChnTime;
2886 pParam->nPassiveMaxChnTime = cfg_params->nPassiveMaxChnTime;
2887 pParam->nPassiveMinChnTime = cfg_params->nPassiveMinChnTime;
2888#ifdef WLAN_AP_STA_CONCURRENCY
2889 pParam->nActiveMaxChnTimeConc = cfg_params->nActiveMaxChnTimeConc;
2890 pParam->nActiveMinChnTimeConc = cfg_params->nActiveMinChnTimeConc;
2891 pParam->nPassiveMaxChnTimeConc = cfg_params->nPassiveMaxChnTimeConc;
2892 pParam->nPassiveMinChnTimeConc = cfg_params->nPassiveMinChnTimeConc;
2893 pParam->nRestTimeConc = cfg_params->nRestTimeConc;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05302894 pParam->min_rest_time_conc = cfg_params->min_rest_time_conc;
2895 pParam->idle_time_conc = cfg_params->idle_time_conc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896#endif
2897 pParam->eBand = cfg_params->eBand;
2898 pParam->nScanResultAgeCount = cfg_params->agingCount;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 pParam->bCatRssiOffset = cfg_params->bCatRssiOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 pParam->fSupplicantCountryCodeHasPriority =
2901 cfg_params->fSupplicantCountryCodeHasPriority;
2902 pParam->vccRssiThreshold = cfg_params->vccRssiThreshold;
2903 pParam->vccUlMacLossThreshold = cfg_params->vccUlMacLossThreshold;
2904 pParam->nTxPowerCap = cfg_params->nTxPowerCap;
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05302905 pParam->allow_tpc_from_ap = cfg_params->allow_tpc_from_ap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002906 pParam->statsReqPeriodicity = cfg_params->statsReqPeriodicity;
2907 pParam->statsReqPeriodicityInPS = cfg_params->statsReqPeriodicityInPS;
2908 pParam->addTSWhenACMIsOff = cfg_params->addTSWhenACMIsOff;
2909 pParam->fValidateList = cfg_params->fValidateList;
2910 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
2911 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
2912 pParam->fScanTwice = cfg_params->fScanTwice;
2913 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
2914 pParam->fEnableMCCMode = cfg_params->fenableMCCMode;
2915 pParam->fAllowMCCGODiffBI = cfg_params->fAllowMCCGODiffBI;
2916 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302917 qdf_mem_copy(&pParam->neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918 &cfg_params->neighborRoamConfig,
2919 sizeof(tCsrNeighborRoamConfigParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920 pParam->nVhtChannelWidth = cfg_params->nVhtChannelWidth;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08002921 pParam->enable_txbf_sap_mode =
2922 cfg_params->enable_txbf_sap_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923 pParam->enableVhtFor24GHz = cfg_params->enableVhtFor24GHz;
2924 pParam->ignore_peer_erp_info = cfg_params->ignore_peer_erp_info;
2925 pParam->enable2x2 = cfg_params->enable2x2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302926 qdf_mem_copy(&cfg_params->csr11rConfig, &pParam->csr11rConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927 sizeof(tCsr11rConfigParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928 pParam->isFastTransitionEnabled = cfg_params->isFastTransitionEnabled;
2929 pParam->RoamRssiDiff = cfg_params->RoamRssiDiff;
2930 pParam->nRoamPrefer5GHz = cfg_params->nRoamPrefer5GHz;
2931 pParam->nRoamIntraBand = cfg_params->nRoamIntraBand;
2932 pParam->isWESModeEnabled = cfg_params->isWESModeEnabled;
2933 pParam->nProbes = cfg_params->nProbes;
2934 pParam->nRoamScanHomeAwayTime = cfg_params->nRoamScanHomeAwayTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935 pParam->isRoamOffloadScanEnabled = cfg_params->isRoamOffloadScanEnabled;
2936 pParam->bFastRoamInConIniFeatureEnabled =
2937 cfg_params->bFastRoamInConIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938 pParam->isFastRoamIniFeatureEnabled =
2939 cfg_params->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002940#ifdef FEATURE_WLAN_ESE
2941 pParam->isEseIniFeatureEnabled = cfg_params->isEseIniFeatureEnabled;
2942#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302943 qdf_mem_copy(&pParam->neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002944 &cfg_params->neighborRoamConfig,
2945 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002946 sme_debug("Num of Channels in CFG Channel List: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947 cfg_params->neighborRoamConfig.
2948 neighborScanChanList.numChannels);
2949 for (i = 0; i < cfg_params->neighborRoamConfig.
2950 neighborScanChanList.numChannels; i++) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07002951 sme_debug("%d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952 cfg_params->neighborRoamConfig.
2953 neighborScanChanList.channelList[i]);
2954 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955
2956#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
2957 pParam->cc_switch_mode = cfg_params->cc_switch_mode;
2958#endif
Krunal Sonia2c0e412017-05-04 14:12:41 +05302959 pParam->enable_tx_ldpc = cfg_params->tx_ldpc_enable;
2960 pParam->enable_rx_ldpc = cfg_params->rx_ldpc_enable;
Krunal Soni158bfe62017-08-02 12:33:08 -07002961 pParam->disable_high_ht_mcs_2x2 = cfg_params->disable_high_ht_mcs_2x2;
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07002962 pParam->max_amsdu_num = cfg_params->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963 pParam->nSelect5GHzMargin = cfg_params->nSelect5GHzMargin;
2964 pParam->isCoalesingInIBSSAllowed = cfg_params->isCoalesingInIBSSAllowed;
2965 pParam->allowDFSChannelRoam = cfg_params->allowDFSChannelRoam;
2966 pParam->nInitialDwellTime = cfg_params->nInitialDwellTime;
2967 pParam->initial_scan_no_dfs_chnl = cfg_params->initial_scan_no_dfs_chnl;
2968#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2969 pParam->isRoamOffloadEnabled = cfg_params->isRoamOffloadEnabled;
2970#endif
2971 pParam->enable_dot11p = pMac->enable_dot11p;
2972 csr_set_channels(pMac, pParam);
2973 pParam->obssEnabled = cfg_params->obssEnabled;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302974 pParam->vendor_vht_sap =
2975 pMac->roam.configParam.vendor_vht_sap;
Gupta, Kapilc68ad462016-02-01 19:17:23 +05302976 pParam->roam_dense_rssi_thresh_offset =
Kapil Gupta4b2efbb2016-10-03 13:07:20 +05302977 cfg_params->roam_params.dense_rssi_thresh_offset;
Gupta, Kapilc68ad462016-02-01 19:17:23 +05302978 pParam->roam_dense_min_aps =
2979 cfg_params->roam_params.dense_min_aps_cnt;
2980 pParam->roam_dense_traffic_thresh =
2981 cfg_params->roam_params.traffic_threshold;
2982
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05302983 pParam->scan_adaptive_dwell_mode =
2984 cfg_params->scan_adaptive_dwell_mode;
2985 pParam->roamscan_adaptive_dwell_mode =
2986 cfg_params->roamscan_adaptive_dwell_mode;
Kapil Gupta5cda2252016-12-29 18:44:26 +05302987
2988 pParam->per_roam_config.enable = cfg_params->per_roam_config.enable;
2989 pParam->per_roam_config.tx_high_rate_thresh =
2990 cfg_params->per_roam_config.tx_high_rate_thresh;
2991 pParam->per_roam_config.rx_high_rate_thresh =
2992 cfg_params->per_roam_config.rx_high_rate_thresh;
2993 pParam->per_roam_config.tx_low_rate_thresh =
2994 cfg_params->per_roam_config.tx_low_rate_thresh;
2995 pParam->per_roam_config.rx_low_rate_thresh =
2996 cfg_params->per_roam_config.rx_low_rate_thresh;
2997 pParam->per_roam_config.tx_rate_thresh_percnt =
2998 cfg_params->per_roam_config.tx_rate_thresh_percnt;
2999 pParam->per_roam_config.rx_rate_thresh_percnt =
3000 cfg_params->per_roam_config.rx_rate_thresh_percnt;
3001 pParam->per_roam_config.per_rest_time =
3002 cfg_params->per_roam_config.per_rest_time;
Kapil Gupta957827b2017-02-13 15:47:04 +05303003 pParam->per_roam_config.tx_per_mon_time =
3004 cfg_params->per_roam_config.tx_per_mon_time;
3005 pParam->per_roam_config.rx_per_mon_time =
3006 cfg_params->per_roam_config.rx_per_mon_time;
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +05303007 pParam->per_roam_config.min_candidate_rssi =
3008 cfg_params->per_roam_config.min_candidate_rssi;
Kapil Gupta5cda2252016-12-29 18:44:26 +05303009
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010 pParam->conc_custom_rule1 = cfg_params->conc_custom_rule1;
3011 pParam->conc_custom_rule2 = cfg_params->conc_custom_rule2;
3012 pParam->is_sta_connection_in_5gz_enabled =
3013 cfg_params->is_sta_connection_in_5gz_enabled;
3014 pParam->sendDeauthBeforeCon =
3015 cfg_params->sendDeauthBeforeCon;
3016 pParam->max_scan_count = pMac->scan.max_scan_count;
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08003017 pParam->first_scan_bucket_threshold =
3018 pMac->first_scan_bucket_threshold;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003019#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
3020 pParam->sap_channel_avoidance = pMac->sap.sap_channel_avoidance;
3021#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
3022 pParam->max_intf_count = pMac->sme.max_intf_count;
3023 pParam->enableSelfRecovery = pMac->sme.enableSelfRecovery;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003024 pParam->f_prefer_non_dfs_on_radar =
3025 pMac->f_prefer_non_dfs_on_radar;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003026 pParam->fine_time_meas_cap = pMac->fine_time_meas_cap;
3027 pParam->dual_mac_feature_disable =
3028 pMac->dual_mac_feature_disable;
3029 pParam->is_ps_enabled = pMac->sme.ps_global_info.ps_enabled;
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08003030 pParam->auto_bmps_timer_val =
3031 pMac->sme.ps_global_info.auto_bmps_timer_val;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003032 pParam->fEnableDebugLog = pMac->fEnableDebugLog;
3033 pParam->enable5gEBT = pMac->enable5gEBT;
3034 pParam->f_sta_miracast_mcc_rest_time_val =
3035 pMac->f_sta_miracast_mcc_rest_time_val;
Krunal Soni1878d3a2016-01-14 13:00:44 -08003036 pParam->early_stop_scan_enable =
3037 pMac->roam.configParam.early_stop_scan_enable;
3038 pParam->early_stop_scan_min_threshold =
3039 pMac->roam.configParam.early_stop_scan_min_threshold;
3040 pParam->early_stop_scan_max_threshold =
3041 pMac->roam.configParam.early_stop_scan_max_threshold;
Sandeep Puligillae0875662016-02-12 16:09:21 -08003042 pParam->obss_width_interval =
3043 pMac->roam.configParam.obss_width_interval;
3044 pParam->obss_active_dwelltime =
3045 pMac->roam.configParam.obss_active_dwelltime;
3046 pParam->obss_passive_dwelltime =
3047 pMac->roam.configParam.obss_passive_dwelltime;
Abhishek Singh165bc602016-03-21 12:43:00 +05303048 pParam->ignore_peer_ht_opmode =
3049 pMac->roam.configParam.ignore_peer_ht_opmode;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08003050 pParam->enableHtSmps = pMac->roam.configParam.enableHtSmps;
3051 pParam->htSmps = pMac->roam.configParam.htSmps;
3052 pParam->send_smps_action = pMac->roam.configParam.send_smps_action;
Abhishek Singh10ecf582016-05-04 17:48:59 +05303053
3054 pParam->enable_edca_params =
3055 pMac->roam.configParam.enable_edca_params;
3056 pParam->edca_vo_cwmin = pMac->roam.configParam.edca_vo_cwmin;
3057 pParam->edca_vi_cwmin = pMac->roam.configParam.edca_vi_cwmin;
3058 pParam->edca_bk_cwmin = pMac->roam.configParam.edca_bk_cwmin;
3059 pParam->edca_be_cwmin = pMac->roam.configParam.edca_be_cwmin;
3060
3061 pParam->edca_vo_cwmax = pMac->roam.configParam.edca_vo_cwmax;
3062 pParam->edca_vi_cwmax = pMac->roam.configParam.edca_vi_cwmax;
3063 pParam->edca_bk_cwmax = pMac->roam.configParam.edca_bk_cwmax;
3064 pParam->edca_be_cwmax = pMac->roam.configParam.edca_be_cwmax;
3065
3066 pParam->edca_vo_aifs = pMac->roam.configParam.edca_vo_aifs;
3067 pParam->edca_vi_aifs = pMac->roam.configParam.edca_vi_aifs;
3068 pParam->edca_bk_aifs = pMac->roam.configParam.edca_bk_aifs;
3069 pParam->edca_be_aifs = pMac->roam.configParam.edca_be_aifs;
Abhishek Singh5ea86532016-04-27 14:10:53 +05303070 pParam->enable_fatal_event =
3071 pMac->roam.configParam.enable_fatal_event;
Agrawal Ashish21ba2572016-09-03 16:40:10 +05303072 pParam->sta_roam_policy_params.dfs_mode =
3073 pMac->roam.configParam.sta_roam_policy.dfs_mode;
3074 pParam->sta_roam_policy_params.skip_unsafe_channels =
3075 pMac->roam.configParam.sta_roam_policy.skip_unsafe_channels;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +05303076 pParam->tx_aggregation_size =
3077 pMac->roam.configParam.tx_aggregation_size;
3078 pParam->rx_aggregation_size =
3079 pMac->roam.configParam.rx_aggregation_size;
Selvaraj, Sridhar4f684bb2017-01-19 15:59:23 +05303080 pParam->enable_bcast_probe_rsp =
3081 pMac->roam.configParam.enable_bcast_probe_rsp;
Selvaraj, Sridhara521aab2017-03-25 16:42:34 +05303082 pParam->qcn_ie_support =
3083 pMac->roam.configParam.qcn_ie_support;
Selvaraj, Sridhar97ce6582017-01-20 17:06:34 +05303084 pParam->fils_max_chan_guard_time =
3085 pMac->roam.configParam.fils_max_chan_guard_time;
Selvaraj, Sridhar57ce4df2017-05-29 18:30:49 +05303086 pParam->disallow_duration =
3087 pMac->roam.configParam.disallow_duration;
3088 pParam->rssi_channel_penalization =
3089 pMac->roam.configParam.rssi_channel_penalization;
3090 pParam->num_disallowed_aps =
3091 pMac->roam.configParam.num_disallowed_aps;
Sandeep Puligillae0875662016-02-12 16:09:21 -08003092
Krishna Kumaar Natarajan90bb6f12017-03-03 21:05:52 -08003093 csr_get_he_config_param(pParam, pMac);
3094
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303095 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003096}
3097
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303098QDF_STATUS csr_set_phy_mode(tHalHandle hHal, uint32_t phyMode, eCsrBand eBand,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 bool *pfRestartNeeded)
3100{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303101 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
3103 bool fRestartNeeded = false;
3104 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 if (eCSR_BAND_24 == eBand) {
3107 if (CSR_IS_RADIO_A_ONLY(pMac))
3108 goto end;
3109 if (eCSR_DOT11_MODE_11a & phyMode)
3110 goto end;
3111 }
3112 if (eCSR_BAND_5G == eBand) {
3113 if (CSR_IS_RADIO_BG_ONLY(pMac))
3114 goto end;
3115 if ((eCSR_DOT11_MODE_11b & phyMode)
3116 || (eCSR_DOT11_MODE_11b_ONLY & phyMode)
3117 || (eCSR_DOT11_MODE_11g & phyMode)
3118 || (eCSR_DOT11_MODE_11g_ONLY & phyMode))
3119 goto end;
3120 }
3121 if (eCSR_DOT11_MODE_AUTO & phyMode)
3122 newPhyMode = eCSR_DOT11_MODE_AUTO;
3123 else {
3124 /* Check for dual band and higher capability first */
3125 if (eCSR_DOT11_MODE_11n_ONLY & phyMode) {
3126 if (eCSR_DOT11_MODE_11n_ONLY != phyMode)
3127 goto end;
3128 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
3129 } else if (eCSR_DOT11_MODE_11g_ONLY & phyMode) {
3130 if (eCSR_DOT11_MODE_11g_ONLY != phyMode)
3131 goto end;
3132 if (eCSR_BAND_5G == eBand)
3133 goto end;
3134 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
3135 eBand = eCSR_BAND_24;
3136 } else if (eCSR_DOT11_MODE_11b_ONLY & phyMode) {
3137 if (eCSR_DOT11_MODE_11b_ONLY != phyMode)
3138 goto end;
3139 if (eCSR_BAND_5G == eBand)
3140 goto end;
3141 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
3142 eBand = eCSR_BAND_24;
3143 } else if (eCSR_DOT11_MODE_11n & phyMode) {
3144 newPhyMode = eCSR_DOT11_MODE_11n;
3145 } else if (eCSR_DOT11_MODE_abg & phyMode) {
3146 newPhyMode = eCSR_DOT11_MODE_abg;
3147 } else if (eCSR_DOT11_MODE_11a & phyMode) {
3148 if ((eCSR_DOT11_MODE_11g & phyMode)
3149 || (eCSR_DOT11_MODE_11b & phyMode)) {
3150 if (eCSR_BAND_ALL == eBand)
3151 newPhyMode = eCSR_DOT11_MODE_abg;
3152 else
3153 goto end;
3154 } else {
3155 newPhyMode = eCSR_DOT11_MODE_11a;
3156 eBand = eCSR_BAND_5G;
3157 }
3158 } else if (eCSR_DOT11_MODE_11g & phyMode) {
3159 newPhyMode = eCSR_DOT11_MODE_11g;
3160 eBand = eCSR_BAND_24;
3161 } else if (eCSR_DOT11_MODE_11b & phyMode) {
3162 newPhyMode = eCSR_DOT11_MODE_11b;
3163 eBand = eCSR_BAND_24;
3164 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003165 sme_err("can't recognize phymode 0x%08X", phyMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 newPhyMode = eCSR_DOT11_MODE_AUTO;
3167 }
3168 }
3169 /* Done validating */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303170 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003171 /* Now we need to check whether a restart is needed. */
3172 if (eBand != pMac->roam.configParam.eBand) {
3173 fRestartNeeded = true;
3174 goto end;
3175 }
3176 if (newPhyMode != pMac->roam.configParam.phyMode) {
3177 fRestartNeeded = true;
3178 goto end;
3179 }
3180end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303181 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003182 pMac->roam.configParam.eBand = eBand;
3183 pMac->roam.configParam.phyMode = newPhyMode;
3184 if (pfRestartNeeded)
3185 *pfRestartNeeded = fRestartNeeded;
3186 }
3187 return status;
3188}
3189
3190/**
3191 * csr_prune_ch_list() - prunes the channel list to keep only a type of channels
3192 * @ch_lst: existing channel list
3193 * @is_24_GHz: indicates if 2.5 GHz or 5 GHz channels are required
3194 *
3195 * Return: void
3196 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -07003197static void csr_prune_ch_list(tCsrChannel *ch_lst, bool is_24_GHz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198{
3199 uint8_t idx = 0, num_channels = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303200
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 for ( ; idx < ch_lst->numChannels; idx++) {
3202 if (is_24_GHz) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07003203 if (WLAN_REG_IS_24GHZ_CH(ch_lst->channelList[idx])) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204 ch_lst->channelList[num_channels] =
3205 ch_lst->channelList[idx];
3206 num_channels++;
3207 }
3208 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07003209 if (WLAN_REG_IS_5GHZ_CH(ch_lst->channelList[idx])) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210 ch_lst->channelList[num_channels] =
3211 ch_lst->channelList[idx];
3212 num_channels++;
3213 }
3214 }
3215 }
3216 /*
3217 * Cleanup the rest of channels. Note we only need to clean up the
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303218 * channels if we had to trim the list. Calling qdf_mem_set() with a 0
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219 * size is going to throw asserts on the debug builds so let's be a bit
3220 * smarter about that. Zero out the reset of the channels only if we
3221 * need to. The amount of memory to clear is the number of channesl that
3222 * we trimmed (ch_lst->numChannels - num_channels) times the size of a
3223 * channel in the structure.
3224 */
3225 if (ch_lst->numChannels > num_channels) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303226 qdf_mem_set(&ch_lst->channelList[num_channels],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 sizeof(ch_lst->channelList[0]) *
3228 (ch_lst->numChannels - num_channels), 0);
3229 }
3230 ch_lst->numChannels = num_channels;
3231}
3232
3233/**
3234 * csr_prune_channel_list_for_mode() - prunes the channel list
3235 * @mac_ctx: global mac context
3236 * @ch_lst: existing channel list
3237 *
3238 * Prunes the channel list according to band stored in mac_ctx
3239 *
3240 * Return: void
3241 */
3242void csr_prune_channel_list_for_mode(tpAniSirGlobal mac_ctx,
3243 tCsrChannel *ch_lst)
3244{
3245 /* for dual band NICs, don't need to trim the channel list.... */
3246 if (CSR_IS_OPEARTING_DUAL_BAND(mac_ctx))
3247 return;
3248 /*
3249 * 2.4 GHz band operation requires the channel list to be trimmed to
3250 * the 2.4 GHz channels only
3251 */
3252 if (CSR_IS_24_BAND_ONLY(mac_ctx))
3253 csr_prune_ch_list(ch_lst, true);
3254 else if (CSR_IS_5G_BAND_ONLY(mac_ctx))
3255 csr_prune_ch_list(ch_lst, false);
3256}
3257
3258#define INFRA_AP_DEFAULT_CHANNEL 6
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303259QDF_STATUS csr_is_valid_channel(tpAniSirGlobal pMac, uint8_t chnNum)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260{
3261 uint8_t index = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303262 QDF_STATUS status = QDF_STATUS_E_NOSUPPORT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263
3264 /* regulatory check */
3265 for (index = 0; index < pMac->scan.base_channels.numChannels;
3266 index++) {
3267 if (pMac->scan.base_channels.channelList[index] == chnNum) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303268 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269 break;
3270 }
3271 }
3272
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303273 if (status == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274 /* dfs nol */
3275 for (index = 0;
3276 index <
3277 pMac->sap.SapDfsInfo.numCurrentRegDomainDfsChannels;
3278 index++) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303279 tSapDfsNolInfo *dfsChan = &pMac->sap.SapDfsInfo.
3280 sapDfsChannelNolList[index];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281 if ((dfsChan->dfs_channel_number == chnNum)
3282 && (dfsChan->radar_status_flag ==
3283 eSAP_DFS_CHANNEL_UNAVAILABLE)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303284 QDF_TRACE(QDF_MODULE_ID_SME,
3285 QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003286 FL("channel %d is in dfs nol"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003287 chnNum);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303288 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 break;
3290 }
3291 }
3292 }
3293
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303294 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303295 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003296 FL("channel %d is not available"), chnNum);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297 }
3298
3299 return status;
3300}
3301
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303302QDF_STATUS csr_get_channel_and_power_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303304 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305 uint8_t num20MHzChannelsFound = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303306 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 uint8_t Index = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07003309 qdf_status = wlan_reg_get_channel_list_with_power(pMac->pdev,
3310 pMac->scan.defaultPowerTable,
3311 &num20MHzChannelsFound);
Amar Singhal7ccdc4f2015-10-30 15:10:05 -07003312
3313 if ((QDF_STATUS_SUCCESS != qdf_status) ||
3314 (num20MHzChannelsFound == 0)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003315 sme_err("failed to get channels");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303316 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303318 if (num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
3321 /* Move the channel list to the global data */
3322 /* structure -- this will be used as the scan list */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303323 for (Index = 0; Index < num20MHzChannelsFound; Index++)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 pMac->scan.base_channels.channelList[Index] =
Amar Singhala297bfa2015-10-15 15:07:29 -07003325 pMac->scan.defaultPowerTable[Index].chan_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326 pMac->scan.base_channels.numChannels =
3327 num20MHzChannelsFound;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003328 }
3329 return status;
3330}
3331
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303332QDF_STATUS csr_apply_channel_and_power_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303334 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003335
3336 csr_prune_channel_list_for_mode(pMac, &pMac->scan.base_channels);
3337 csr_save_channel_power_for_band(pMac, false);
3338 csr_save_channel_power_for_band(pMac, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 csr_apply_channel_power_info_to_fw(pMac,
3340 &pMac->scan.base_channels,
3341 pMac->scan.countryCodeCurrent);
3342
3343 csr_init_operating_classes((tHalHandle) pMac);
3344 return status;
3345}
3346
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303347static QDF_STATUS csr_init11d_info(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003348{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303349 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350 uint8_t index;
3351 uint32_t count = 0;
3352 tSirMacChanInfo *pChanInfo;
3353 tSirMacChanInfo *pChanInfoStart;
3354 bool applyConfig = true;
3355
3356 pMac->scan.currentCountryRSSI = -128;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303357 if (!ps11dinfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358 return status;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303359
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003360 if (ps11dinfo->Channels.numChannels
3361 && (WNI_CFG_VALID_CHANNEL_LIST_LEN >=
3362 ps11dinfo->Channels.numChannels)) {
3363 pMac->scan.base_channels.numChannels =
3364 ps11dinfo->Channels.numChannels;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303365 qdf_mem_copy(pMac->scan.base_channels.channelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366 ps11dinfo->Channels.channelList,
3367 ps11dinfo->Channels.numChannels);
3368 } else {
3369 /* No change */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303370 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 }
3372 /* legacy maintenance */
3373
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303374 qdf_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003375 WNI_CFG_COUNTRY_CODE_LEN);
3376
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303377 /* Tush: at csropen get this initialized with default,
3378 * during csr reset if this already set with some value
3379 * no need initilaize with default again
3380 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 if (0 == pMac->scan.countryCodeCurrent[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303382 qdf_mem_copy(pMac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003383 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
3384 }
3385 /* need to add the max power channel list */
3386 pChanInfo =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303387 qdf_mem_malloc(sizeof(tSirMacChanInfo) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003388 WNI_CFG_VALID_CHANNEL_LIST_LEN);
3389 if (pChanInfo != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003390 pChanInfoStart = pChanInfo;
3391 for (index = 0; index < ps11dinfo->Channels.numChannels;
3392 index++) {
3393 pChanInfo->firstChanNum =
3394 ps11dinfo->ChnPower[index].firstChannel;
3395 pChanInfo->numChannels =
3396 ps11dinfo->ChnPower[index].numChannels;
3397 pChanInfo->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303398 QDF_MIN(ps11dinfo->ChnPower[index].maxtxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 pMac->roam.configParam.nTxPowerCap);
3400 pChanInfo++;
3401 count++;
3402 }
3403 if (count) {
3404 csr_save_to_channel_power2_g_5_g(pMac,
3405 count *
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303406 sizeof(tSirMacChanInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 pChanInfoStart);
3408 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303409 qdf_mem_free(pChanInfoStart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303411 /* Only apply them to CFG when not in STOP state.
3412 * Otherwise they will be applied later
3413 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303414 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 for (index = 0; index < CSR_ROAM_SESSION_MAX; index++) {
3416 if ((CSR_IS_SESSION_VALID(pMac, index))
3417 && CSR_IS_ROAM_STOP(pMac, index)) {
3418 applyConfig = false;
3419 }
3420 }
3421
3422 if (true == applyConfig) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303423 /* Apply the base channel list, power info,
3424 * and set the Country code.
3425 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 csr_apply_channel_power_info_to_fw(pMac,
3427 &pMac->scan.
3428 base_channels,
3429 pMac->scan.
3430 countryCodeCurrent);
3431 }
3432 }
3433 return status;
3434}
3435
3436/* Initialize the Channel + Power List in the local cache and in the CFG */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303437QDF_STATUS csr_init_channel_power_list(tpAniSirGlobal pMac,
3438 tCsr11dinfo *ps11dinfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439{
3440 uint8_t index;
3441 uint32_t count = 0;
3442 tSirMacChanInfo *pChanInfo;
3443 tSirMacChanInfo *pChanInfoStart;
3444
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303445 if (!ps11dinfo || !pMac)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303446 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003447
3448 pChanInfo =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303449 qdf_mem_malloc(sizeof(tSirMacChanInfo) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450 WNI_CFG_VALID_CHANNEL_LIST_LEN);
3451 if (pChanInfo != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452 pChanInfoStart = pChanInfo;
3453
3454 for (index = 0; index < ps11dinfo->Channels.numChannels;
3455 index++) {
3456 pChanInfo->firstChanNum =
3457 ps11dinfo->ChnPower[index].firstChannel;
3458 pChanInfo->numChannels =
3459 ps11dinfo->ChnPower[index].numChannels;
3460 pChanInfo->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303461 QDF_MIN(ps11dinfo->ChnPower[index].maxtxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 pMac->roam.configParam.nTxPowerCap);
3463 pChanInfo++;
3464 count++;
3465 }
3466 if (count) {
3467 csr_save_to_channel_power2_g_5_g(pMac,
3468 count *
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303469 sizeof(tSirMacChanInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 pChanInfoStart);
3471 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303472 qdf_mem_free(pChanInfoStart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003473 }
3474
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303475 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476}
3477
Abhishek Singhd86d9832015-12-30 17:18:13 +05303478/**
3479 * csr_roam_remove_duplicate_cmd_from_list()- Remove duplicate roam cmd from
3480 * list
3481 *
3482 * @mac_ctx: pointer to global mac
3483 * @session_id: session id for the cmd
3484 * @list: pending list from which cmd needs to be removed
3485 * @command: cmd to be removed, can be NULL
3486 * @roam_reason: cmd with reason to be removed
3487 *
3488 * Remove duplicate command from the pending list.
3489 *
3490 * Return: void
3491 */
Krunal Soni72dba662017-02-15 20:13:17 -08003492static void csr_roam_remove_duplicate_pending_cmd_from_list(
3493 tpAniSirGlobal mac_ctx,
3494 uint32_t session_id,
Abhishek Singhd86d9832015-12-30 17:18:13 +05303495 tSmeCmd *command, eCsrRoamReason roam_reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496{
Abhishek Singhd86d9832015-12-30 17:18:13 +05303497 tListElem *entry, *next_entry;
3498 tSmeCmd *dup_cmd;
3499 tDblLinkList local_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003500
Abhishek Singhd86d9832015-12-30 17:18:13 +05303501 qdf_mem_zero(&local_list, sizeof(tDblLinkList));
3502 if (!QDF_IS_STATUS_SUCCESS(csr_ll_open(mac_ctx->hHdd, &local_list))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003503 sme_err("failed to open list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 return;
3505 }
Krunal Soni72dba662017-02-15 20:13:17 -08003506 csr_nonscan_pending_ll_lock(mac_ctx);
Krunal Sonia8270f52017-02-23 19:51:25 -08003507 entry = csr_nonscan_pending_ll_peek_head(mac_ctx, LL_ACCESS_NOLOCK);
Abhishek Singhd86d9832015-12-30 17:18:13 +05303508 while (entry) {
Krunal Soni72dba662017-02-15 20:13:17 -08003509 next_entry = csr_nonscan_pending_ll_next(mac_ctx, entry,
3510 LL_ACCESS_NOLOCK);
Abhishek Singhd86d9832015-12-30 17:18:13 +05303511 dup_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
3512 /*
3513 * Remove the previous command if..
3514 * - the new roam command is for the same RoamReason...
3515 * - the new roam command is a NewProfileList.
3516 * - the new roam command is a Forced Dissoc
3517 * - the new roam command is from an 802.11 OID
3518 * (OID_SSID or OID_BSSID).
3519 */
3520 if ((command && (command->sessionId == dup_cmd->sessionId) &&
3521 ((command->command == dup_cmd->command) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 /*
3523 * This peermac check is requried for Softap/GO
Abhishek Singhd86d9832015-12-30 17:18:13 +05303524 * scenarios. for STA scenario below OR check will
3525 * suffice as command will always be NULL for
3526 * STA scenarios
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003527 */
Abhishek Singhd86d9832015-12-30 17:18:13 +05303528 (!qdf_mem_cmp(dup_cmd->u.roamCmd.peerMac,
3529 command->u.roamCmd.peerMac,
3530 sizeof(QDF_MAC_ADDR_SIZE))) &&
3531 ((command->u.roamCmd.roamReason ==
3532 dup_cmd->u.roamCmd.roamReason) ||
3533 (eCsrForcedDisassoc ==
3534 command->u.roamCmd.roamReason) ||
3535 (eCsrHddIssued ==
3536 command->u.roamCmd.roamReason)))) ||
3537 /* OR if pCommand is NULL */
3538 ((session_id == dup_cmd->sessionId) &&
3539 (eSmeCommandRoam == dup_cmd->command) &&
3540 ((eCsrForcedDisassoc == roam_reason) ||
3541 (eCsrHddIssued == roam_reason)))) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303542 sme_debug("RoamReason: %d",
3543 dup_cmd->u.roamCmd.roamReason);
Abhishek Singhd86d9832015-12-30 17:18:13 +05303544 /* Remove the roam command from the pending list */
Krunal Soni72dba662017-02-15 20:13:17 -08003545 if (csr_nonscan_pending_ll_remove_entry(mac_ctx,
3546 entry, LL_ACCESS_NOLOCK))
Abhishek Singhd86d9832015-12-30 17:18:13 +05303547 csr_ll_insert_tail(&local_list, entry,
3548 LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549 }
Abhishek Singhd86d9832015-12-30 17:18:13 +05303550 entry = next_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551 }
Krunal Soni72dba662017-02-15 20:13:17 -08003552 csr_nonscan_pending_ll_unlock(mac_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553
Abhishek Singhd86d9832015-12-30 17:18:13 +05303554 while ((entry = csr_ll_remove_head(&local_list, LL_ACCESS_NOLOCK))) {
3555 dup_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556 /* Tell caller that the command is cancelled */
Abhishek Singhd86d9832015-12-30 17:18:13 +05303557 csr_roam_call_callback(mac_ctx, dup_cmd->sessionId, NULL,
3558 dup_cmd->u.roamCmd.roamId,
3559 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
Krunal Sonidea45952017-02-15 11:58:15 -08003560 csr_release_command(mac_ctx, dup_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003561 }
Abhishek Singhd86d9832015-12-30 17:18:13 +05303562 csr_ll_close(&local_list);
3563}
3564
3565/**
3566 * csr_roam_remove_duplicate_command()- Remove duplicate roam cmd
3567 * from pending lists.
3568 *
3569 * @mac_ctx: pointer to global mac
3570 * @session_id: session id for the cmd
3571 * @command: cmd to be removed, can be null
3572 * @roam_reason: cmd with reason to be removed
3573 *
3574 * Remove duplicate command from the sme and roam pending list.
3575 *
3576 * Return: void
3577 */
3578void csr_roam_remove_duplicate_command(tpAniSirGlobal mac_ctx,
3579 uint32_t session_id, tSmeCmd *command,
3580 eCsrRoamReason roam_reason)
3581{
3582 /* Always lock active list before locking pending lists */
Krunal Soni20126cb2017-02-15 16:26:57 -08003583 csr_nonscan_active_ll_lock(mac_ctx);
Krunal Soni72dba662017-02-15 20:13:17 -08003584 csr_roam_remove_duplicate_pending_cmd_from_list(mac_ctx,
3585 session_id, command, roam_reason);
Krunal Soni20126cb2017-02-15 16:26:57 -08003586 csr_nonscan_active_ll_unlock(mac_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003587}
3588
3589/**
3590 * csr_roam_populate_channels() - Helper function to populate channels
3591 * @beacon_ies: pointer to beacon ie
3592 * @roam_info: Roaming related information
3593 * @chan1: center freq 1
3594 * @chan2: center freq2
3595 *
3596 * This function will issue populate chan1 and chan2 based on beacon ie
3597 *
3598 * Return: none.
3599 */
3600static void csr_roam_populate_channels(tDot11fBeaconIEs *beacon_ies,
3601 tCsrRoamInfo *roam_info,
3602 uint8_t *chan1, uint8_t *chan2)
3603{
3604 ePhyChanBondState phy_state;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303605
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 if (beacon_ies->VHTOperation.present) {
3607 *chan1 = beacon_ies->VHTOperation.chanCenterFreqSeg1;
3608 *chan2 = beacon_ies->VHTOperation.chanCenterFreqSeg2;
3609 roam_info->chan_info.info = MODE_11AC_VHT80;
3610 } else if (beacon_ies->HTInfo.present) {
3611 if (beacon_ies->HTInfo.recommendedTxWidthSet ==
3612 eHT_CHANNEL_WIDTH_40MHZ) {
3613 phy_state = beacon_ies->HTInfo.secondaryChannelOffset;
3614 if (phy_state == PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
3615 *chan1 = beacon_ies->HTInfo.primaryChannel +
3616 CSR_CB_CENTER_CHANNEL_OFFSET;
3617 else if (phy_state == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
3618 *chan1 = beacon_ies->HTInfo.primaryChannel -
3619 CSR_CB_CENTER_CHANNEL_OFFSET;
3620 else
3621 *chan1 = beacon_ies->HTInfo.primaryChannel;
3622
3623 roam_info->chan_info.info = MODE_11NA_HT40;
3624 } else {
3625 *chan1 = beacon_ies->HTInfo.primaryChannel;
3626 roam_info->chan_info.info = MODE_11NA_HT20;
3627 }
3628 *chan2 = 0;
3629 } else {
3630 *chan1 = 0;
3631 *chan2 = 0;
3632 roam_info->chan_info.info = MODE_11A;
3633 }
3634}
3635
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303636QDF_STATUS csr_roam_call_callback(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003637 tCsrRoamInfo *pRoamInfo, uint32_t roamId,
3638 eRoamCmdStatus u1, eCsrRoamResult u2)
3639{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303640 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
3642 uint32_t rssi = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303643
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 WLAN_HOST_DIAG_EVENT_DEF(connectionStatus,
3645 host_event_wlan_status_payload_type);
3646#endif
3647 tCsrRoamSession *pSession;
3648 tDot11fBeaconIEs *beacon_ies = NULL;
3649 uint8_t chan1, chan2;
3650
3651 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003652 sme_err("Session ID: %d is not valid", sessionId);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303653 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303654 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 }
3656 pSession = CSR_GET_SESSION(pMac, sessionId);
3657
3658 if (false == pSession->sessionActive) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003659 sme_debug("Session is not Active");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303660 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 }
3662
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003663 sme_debug("Received RoamCmdStatus %d with Roam Result %d", u1, u2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003664
3665 if (eCSR_ROAM_ASSOCIATION_COMPLETION == u1 &&
3666 eCSR_ROAM_RESULT_ASSOCIATED == u2 && pRoamInfo) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003667 sme_info("Assoc complete result: %d status: %d reason: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668 u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303669 beacon_ies = qdf_mem_malloc(sizeof(tDot11fBeaconIEs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 if ((NULL != beacon_ies) && (NULL != pRoamInfo->pBssDesc)) {
3671 status = csr_parse_bss_description_ies(
3672 (tHalHandle) pMac, pRoamInfo->pBssDesc,
3673 beacon_ies);
3674 csr_roam_populate_channels(beacon_ies, pRoamInfo,
3675 &chan1, &chan2);
3676 if (0 != chan1)
3677 pRoamInfo->chan_info.band_center_freq1 =
3678 cds_chan_to_freq(chan1);
3679 else
3680 pRoamInfo->chan_info.band_center_freq1 = 0;
3681 if (0 != chan2)
3682 pRoamInfo->chan_info.band_center_freq2 =
3683 cds_chan_to_freq(chan2);
3684 else
3685 pRoamInfo->chan_info.band_center_freq2 = 0;
3686 } else {
3687 pRoamInfo->chan_info.band_center_freq1 = 0;
3688 pRoamInfo->chan_info.band_center_freq2 = 0;
3689 pRoamInfo->chan_info.info = 0;
3690 }
3691 pRoamInfo->chan_info.chan_id =
3692 pRoamInfo->u.pConnectedProfile->operationChannel;
3693 pRoamInfo->chan_info.mhz =
3694 cds_chan_to_freq(pRoamInfo->chan_info.chan_id);
3695 pRoamInfo->chan_info.reg_info_1 =
3696 (csr_get_cfg_max_tx_power(pMac,
3697 pRoamInfo->chan_info.chan_id) << 16);
3698 pRoamInfo->chan_info.reg_info_2 =
3699 (csr_get_cfg_max_tx_power(pMac,
3700 pRoamInfo->chan_info.chan_id) << 8);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303701 qdf_mem_free(beacon_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003702 } else if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED)
3703 && (pSession->bRefAssocStartCnt)) {
3704 /*
3705 * Decrement bRefAssocStartCnt for FT reassoc failure.
3706 * Reason: For FT reassoc failures, we first call
3707 * csr_roam_call_callback before notifying a failed roam
3708 * completion through csr_roam_complete. The latter in
3709 * turn calls csr_roam_process_results which tries to
3710 * once again call csr_roam_call_callback if bRefAssocStartCnt
3711 * is non-zero. Since this is redundant for FT reassoc
3712 * failure, decrement bRefAssocStartCnt.
3713 */
3714 pSession->bRefAssocStartCnt--;
3715 } else if (u1 == eCSR_ROAM_SET_CHANNEL_RSP && u2 ==
3716 eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS)
3717 pSession->connectedProfile.operationChannel =
3718 pRoamInfo->channelChangeRespEvent->newChannelNumber;
3719
3720 if (NULL != pSession->callback) {
3721 if (pRoamInfo) {
3722 pRoamInfo->sessionId = (uint8_t) sessionId;
3723 /*
3724 * the reasonCode will be passed to supplicant by
3725 * cfg80211_disconnected. Based on the document,
3726 * the reason code passed to supplicant needs to set
3727 * to 0 if unknow. eSIR_BEACON_MISSED reason code is not
3728 * recognizable so that we set to 0 instead.
3729 */
3730 pRoamInfo->reasonCode =
3731 (pRoamInfo->reasonCode == eSIR_BEACON_MISSED) ?
3732 0 : pRoamInfo->reasonCode;
3733 }
3734 status = pSession->callback(pSession->pContext, pRoamInfo,
3735 roamId, u1, u2);
3736 }
3737 /*
Abhishek Singh7a995582016-04-27 13:53:36 +05303738 * EVENT_WLAN_STATUS_V2: eCSR_ROAM_ASSOCIATION_COMPLETION,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739 * eCSR_ROAM_LOSTLINK,
3740 * eCSR_ROAM_DISASSOCIATED,
3741 */
3742#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303743 qdf_mem_set(&connectionStatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003744 sizeof(host_event_wlan_status_payload_type), 0);
3745
3746 if ((eCSR_ROAM_ASSOCIATION_COMPLETION == u1)
3747 && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo) {
3748 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
3749 connectionStatus.bssType =
3750 pRoamInfo->u.pConnectedProfile->BSSType;
3751
3752 if (NULL != pRoamInfo->pBssDesc) {
3753 connectionStatus.rssi =
3754 pRoamInfo->pBssDesc->rssi * (-1);
3755 connectionStatus.channel =
3756 pRoamInfo->pBssDesc->channelId;
3757 }
3758 if (cfg_set_int(pMac, WNI_CFG_CURRENT_RSSI,
3759 connectionStatus.rssi) == eSIR_FAILURE)
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003760 sme_err("Can't pass WNI_CFG_CURRENT_RSSI to cfg");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003761
3762 connectionStatus.qosCapability =
3763 pRoamInfo->u.pConnectedProfile->qosConnection;
3764 connectionStatus.authType =
3765 (uint8_t) diag_auth_type_from_csr_type(
3766 pRoamInfo->u.pConnectedProfile->AuthType);
3767 connectionStatus.encryptionType =
3768 (uint8_t) diag_enc_type_from_csr_type(
3769 pRoamInfo->u.pConnectedProfile->EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303770 qdf_mem_copy(connectionStatus.ssid,
Abhishek Singh7a995582016-04-27 13:53:36 +05303771 pRoamInfo->u.pConnectedProfile->SSID.ssId,
3772 pRoamInfo->u.pConnectedProfile->SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003773
3774 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303775 qdf_mem_copy(&pMac->sme.eventPayload, &connectionStatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003776 sizeof(host_event_wlan_status_payload_type));
3777 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05303778 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003779 }
3780 if ((eCSR_ROAM_MIC_ERROR_IND == u1)
3781 || (eCSR_ROAM_RESULT_MIC_FAILURE == u2)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303782 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783 sizeof(host_event_wlan_status_payload_type));
3784 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
3785 WNI_CFG_CURRENT_RSSI, &rssi)))
3786 connectionStatus.rssi = rssi;
3787
3788 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
3789 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
3790 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05303791 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792 }
3793 if (eCSR_ROAM_RESULT_FORCED == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303794 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795 sizeof(host_event_wlan_status_payload_type));
3796 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
3797 WNI_CFG_CURRENT_RSSI, &rssi)))
3798 connectionStatus.rssi = rssi;
3799
3800 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
3801 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
3802 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05303803 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003804 }
3805 if (eCSR_ROAM_RESULT_DISASSOC_IND == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303806 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807 sizeof(host_event_wlan_status_payload_type));
3808 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
3809 WNI_CFG_CURRENT_RSSI, &rssi)))
3810 connectionStatus.rssi = rssi;
3811
3812 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
3813 connectionStatus.reason = eCSR_REASON_DISASSOC;
3814 if (pRoamInfo)
3815 connectionStatus.reasonDisconnect =
3816 pRoamInfo->reasonCode;
3817
3818 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05303819 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820 }
3821 if (eCSR_ROAM_RESULT_DEAUTH_IND == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303822 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823 sizeof(host_event_wlan_status_payload_type));
3824 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
3825 WNI_CFG_CURRENT_RSSI, &rssi)))
3826 connectionStatus.rssi = rssi;
3827
3828 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
3829 connectionStatus.reason = eCSR_REASON_DEAUTH;
3830 if (pRoamInfo)
3831 connectionStatus.reasonDisconnect =
3832 pRoamInfo->reasonCode;
3833 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
Abhishek Singh7a995582016-04-27 13:53:36 +05303834 EVENT_WLAN_STATUS_V2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003835 }
3836#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
3837 return status;
3838}
3839
3840/* Returns whether handoff is currently in progress or not */
Jeff Johnson29e2ca12016-10-14 12:50:38 -07003841static
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003842bool csr_roam_is_handoff_in_progress(tpAniSirGlobal pMac, uint8_t sessionId)
3843{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003844 return csr_neighbor_roam_is_handoff_in_progress(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845}
3846
Jeff Johnson29e2ca12016-10-14 12:50:38 -07003847static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303848QDF_STATUS csr_roam_issue_disassociate(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003849 eCsrRoamSubState NewSubstate,
3850 bool fMICFailure)
3851{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303852 QDF_STATUS status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303853 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854 uint16_t reasonCode;
3855 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
3856
3857 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003858 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303859 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003860 }
3861
3862 if (fMICFailure) {
3863 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
3864 } else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF) {
3865 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
3866 } else if (eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT == NewSubstate) {
3867 reasonCode = eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
3868 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003869 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303870 "set to reason code eSIR_MAC_DISASSOC_LEAVING_BSS_REASON and set back NewSubstate");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003871 } else {
3872 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
3873 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003874 if ((csr_roam_is_handoff_in_progress(pMac, sessionId)) &&
3875 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)) {
3876 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
3877 &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303878 qdf_copy_macaddr(&bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003879 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.
3880 bssid);
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -08003881 } else if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303882 qdf_mem_copy(&bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303883 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884 }
3885
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003886 sme_debug("CSR Attempting to Disassociate Bssid=" MAC_ADDRESS_STR
3887 " subState: %s reason: %d", MAC_ADDR_ARRAY(bssId.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888 mac_trace_getcsr_roam_sub_state(NewSubstate), reasonCode);
3889
3890 csr_roam_substate_change(pMac, NewSubstate, sessionId);
3891
3892 status = csr_send_mb_disassoc_req_msg(pMac, sessionId, bssId.bytes,
3893 reasonCode);
3894
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303895 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896 csr_roam_link_down(pMac, sessionId);
3897#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05303898 /* no need to tell QoS that we are disassociating, it will be
3899 * taken care off in assoc req for HO
3900 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901 if (eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate) {
3902 /* notify QoS module that disassoc happening */
3903 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
3904 SME_QOS_CSR_DISCONNECT_REQ, NULL);
3905 }
3906#endif
3907 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003908 sme_warn("csr_send_mb_disassoc_req_msg failed status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003909 status);
3910 }
3911
3912 return status;
3913}
3914
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303915/**
3916 * csr_roam_issue_disassociate_sta_cmd() - disassociate a associated station
3917 * @sessionId: Session Id for Soft AP
3918 * @p_del_sta_params: Pointer to parameters of the station to disassoc
3919 *
3920 * CSR function that HDD calls to delete a associated station
3921 *
3922 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS_* on error
3923 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303924QDF_STATUS csr_roam_issue_disassociate_sta_cmd(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925 uint32_t sessionId,
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303926 struct tagCsrDelStaParams
3927 *p_del_sta_params)
3928
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303930 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003931 tSmeCmd *pCommand;
3932
3933 do {
3934 pCommand = csr_get_command_buffer(pMac);
3935 if (!pCommand) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003936 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303937 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003938 break;
3939 }
3940 pCommand->command = eSmeCommandRoam;
3941 pCommand->sessionId = (uint8_t) sessionId;
3942 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
Deepthi Gowrib3bfefd2016-09-13 15:14:34 +05303943 qdf_mem_copy(pCommand->u.roamCmd.peerMac,
3944 p_del_sta_params->peerMacAddr.bytes,
3945 sizeof(pCommand->u.roamCmd.peerMac));
3946 pCommand->u.roamCmd.reason =
3947 (tSirMacReasonCodes)p_del_sta_params->reason_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003948 status = csr_queue_sme_command(pMac, pCommand, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303949 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003950 sme_err("fail to send message status: %d", status);
Krunal Sonidea45952017-02-15 11:58:15 -08003951 csr_release_command(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003952 }
3953 } while (0);
3954
3955 return status;
3956}
3957
3958/**
3959 * csr_roam_issue_deauthSta() - delete a associated station
3960 * @sessionId: Session Id for Soft AP
3961 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3962 *
3963 * CSR function that HDD calls to delete a associated station
3964 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303965 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003966 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303967QDF_STATUS csr_roam_issue_deauth_sta_cmd(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968 uint32_t sessionId,
3969 struct tagCsrDelStaParams *pDelStaParams)
3970{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303971 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003972 tSmeCmd *pCommand;
3973
3974 do {
3975 pCommand = csr_get_command_buffer(pMac);
3976 if (!pCommand) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003977 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303978 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979 break;
3980 }
3981 pCommand->command = eSmeCommandRoam;
3982 pCommand->sessionId = (uint8_t) sessionId;
3983 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303984 qdf_mem_copy(pCommand->u.roamCmd.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 pDelStaParams->peerMacAddr.bytes,
3986 sizeof(tSirMacAddr));
3987 pCommand->u.roamCmd.reason =
3988 (tSirMacReasonCodes)pDelStaParams->reason_code;
3989 status = csr_queue_sme_command(pMac, pCommand, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303990 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07003991 sme_err("fail to send message status: %d", status);
Krunal Sonidea45952017-02-15 11:58:15 -08003992 csr_release_command(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993 }
3994 } while (0);
3995
3996 return status;
3997}
3998
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303999static QDF_STATUS
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07004000csr_send_mb_tkip_counter_measures_req_msg(tpAniSirGlobal pMac,
4001 uint32_t sessionId, bool bEnable,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304002 struct qdf_mac_addr *bssId)
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07004003{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304004 QDF_STATUS status = QDF_STATUS_SUCCESS;
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07004005 tSirSmeTkipCntrMeasReq *pMsg;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304006
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07004007 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304008 pMsg = qdf_mem_malloc(sizeof(tSirSmeTkipCntrMeasReq));
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07004009 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304010 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07004011 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304012 status = QDF_STATUS_SUCCESS;
4013 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07004014 break;
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07004015 pMsg->messageType = eWNI_SME_TKIP_CNTR_MEAS_REQ;
4016 pMsg->length = sizeof(tSirSmeTkipCntrMeasReq);
4017 pMsg->sessionId = sessionId;
4018 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05304019 qdf_copy_macaddr(&pMsg->bssId, bssId);
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07004020 pMsg->bEnable = bEnable;
Rajeev Kumard138ac52017-01-30 18:38:37 -08004021 status = umac_send_mb_message_to_mac(pMsg);
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07004022 } while (0);
4023 return status;
4024}
4025
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304026QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027csr_roam_issue_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t sessionId,
4028 bool bEnable)
4029{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304030 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Anurag Chouhan6d760662016-02-20 16:05:43 +05304031 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304033
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304035 sme_err("csr_roam_issue_tkip_counter_measures:CSR Session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004036 return status;
4037 }
4038 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304039 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304040 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004041 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304042 sme_err("csr_roam_issue_tkip_counter_measures:Connected BSS Description in CSR Session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004043 return status;
4044 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304045 sme_debug("CSR issuing tkip counter measures for Bssid:" MAC_ADDRESS_STR" Enable: %d",
4046 MAC_ADDR_ARRAY(bssId.bytes), bEnable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047 status =
4048 csr_send_mb_tkip_counter_measures_req_msg(pMac, sessionId,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07004049 bEnable, &bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050 return status;
4051}
4052
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304053QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004054csr_roam_get_associated_stas(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304055 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056 void *pfnSapEventCallback, uint8_t *pAssocStasBuf)
4057{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304058 QDF_STATUS status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05304059 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004060 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304061
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004062 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304063 sme_err("csr_roam_get_associated_stas:CSR Session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064 return status;
4065 }
4066 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304067 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304068 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004069 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304070 sme_err("csr_roam_get_associated_stas:Connected BSS Description in CSR Session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 return status;
4072 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304073 sme_debug("CSR getting associated stations for Bssid: " MAC_ADDRESS_STR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004074 MAC_ADDR_ARRAY(bssId.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075 status =
4076 csr_send_mb_get_associated_stas_req_msg(pMac, sessionId, modId,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08004077 bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004078 pUsrContext,
4079 pfnSapEventCallback,
4080 pAssocStasBuf);
4081 return status;
4082}
4083
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304084QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085csr_roam_get_wps_session_overlap(tpAniSirGlobal pMac, uint32_t sessionId,
4086 void *pUsrContext, void *pfnSapEventCallback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304087 struct qdf_mac_addr pRemoveMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004088{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304089 QDF_STATUS status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05304090 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
4092
4093 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304094 sme_err("csr_roam_get_wps_session_overlap:CSR Session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004095 return status;
4096 }
4097 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304098 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304099 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304101 sme_err("csr_roam_get_wps_session_overlap:Connected BSS Description in CSR Session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004102 return status;
4103 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304104 sme_debug("CSR getting WPS Session Overlap for Bssid: " MAC_ADDRESS_STR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004105 MAC_ADDR_ARRAY(bssId.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08004107 status = csr_send_mb_get_wpspbc_sessions(pMac, sessionId, bssId,
4108 pUsrContext, pfnSapEventCallback, pRemoveMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109
4110 return status;
4111}
4112
Jeff Johnson29e2ca12016-10-14 12:50:38 -07004113static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304114QDF_STATUS csr_roam_issue_deauth(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004115 eCsrRoamSubState NewSubstate)
4116{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304117 QDF_STATUS status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05304118 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004119 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
4120
4121 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004122 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304123 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004124 }
4125
4126 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304127 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304128 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004130 sme_debug("CSR Attempting to Deauth Bssid= " MAC_ADDRESS_STR,
4131 MAC_ADDR_ARRAY(bssId.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004132 csr_roam_substate_change(pMac, NewSubstate, sessionId);
4133
4134 status =
4135 csr_send_mb_deauth_req_msg(pMac, sessionId, bssId.bytes,
4136 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304137 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138 csr_roam_link_down(pMac, sessionId);
4139 else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004140 sme_err("csr_send_mb_deauth_req_msg failed with status %d Session ID: %d"
4141 MAC_ADDRESS_STR, status, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142 MAC_ADDR_ARRAY(bssId.bytes));
4143 }
4144
4145 return status;
4146}
4147
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304148QDF_STATUS csr_roam_save_connected_bss_desc(tpAniSirGlobal pMac,
4149 uint32_t sessionId,
4150 tSirBssDescription *pBssDesc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004151{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304152 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
4154 uint32_t size;
4155
4156 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004157 sme_err(" session %d not found ", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304158 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004159 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304160 /* If no BSS description was found in this connection
4161 * (happens with start IBSS), then nix the BSS description
4162 * that we keep around for the connected BSS) and get out.
4163 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164 if (NULL == pBssDesc) {
4165 csr_free_connect_bss_desc(pMac, sessionId);
4166 } else {
4167 size = pBssDesc->length + sizeof(pBssDesc->length);
4168 if (NULL != pSession->pConnectBssDesc) {
4169 if (((pSession->pConnectBssDesc->length) +
4170 sizeof(pSession->pConnectBssDesc->length)) <
4171 size) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304172 /* not enough room for the new BSS,
4173 * pMac->roam.pConnectBssDesc is freed inside
4174 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004175 csr_free_connect_bss_desc(pMac, sessionId);
4176 }
4177 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304178 if (NULL == pSession->pConnectBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304179 pSession->pConnectBssDesc = qdf_mem_malloc(size);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304180
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181 if (NULL == pSession->pConnectBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304182 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 else
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304184 qdf_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185 }
4186 return status;
4187}
4188
Jeff Johnson29e2ca12016-10-14 12:50:38 -07004189static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304190QDF_STATUS csr_roam_prepare_bss_config(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191 tCsrRoamProfile *pProfile,
4192 tSirBssDescription *pBssDesc,
4193 tBssConfigParam *pBssConfig,
4194 tDot11fBeaconIEs *pIes)
4195{
4196 eCsrCfgDot11Mode cfgDot11Mode;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304197
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304198 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004199 if (pIes == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304200 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304202 qdf_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203 sizeof(tSirMacCapabilityInfo));
4204 /* get qos */
4205 pBssConfig->qosType = csr_get_qo_s_from_bss_desc(pMac, pBssDesc, pIes);
4206 /* get SSID */
4207 if (pIes->SSID.present) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304208 qdf_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209 pIes->SSID.num_ssid);
4210 pBssConfig->SSID.length = pIes->SSID.num_ssid;
4211 } else
4212 pBssConfig->SSID.length = 0;
4213 if (csr_is_nullssid(pBssConfig->SSID.ssId, pBssConfig->SSID.length)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004214 sme_warn("BSS desc SSID is a wild card");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215 /* Return failed if profile doesn't have an SSID either. */
4216 if (pProfile->SSIDs.numOfSSIDs == 0) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004217 sme_warn("BSS desc and profile doesn't have SSID");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304218 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004219 }
4220 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07004221 if (WLAN_REG_IS_5GHZ_CH(pBssDesc->channelId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222 pBssConfig->eBand = eCSR_BAND_5G;
4223 else
4224 pBssConfig->eBand = eCSR_BAND_24;
4225 /* phymode */
4226 if (csr_is_phy_mode_match(pMac, pProfile->phyMode, pBssDesc,
4227 pProfile, &cfgDot11Mode, pIes)) {
4228 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
4229 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004230 sme_warn("Can not find match phy mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231 /* force it */
4232 if (eCSR_BAND_24 == pBssConfig->eBand)
4233 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
4234 else
4235 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
4236 }
Padma, Santhosh Kumar19f57652017-05-26 18:03:45 +05304237
4238 sme_debug("phyMode=%d, uCfgDot11Mode=%d",
4239 pProfile->phyMode, pBssConfig->uCfgDot11Mode);
4240
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241 /* Qos */
4242 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
4243 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos)) {
4244 /*
4245 * Joining BSS is not 11n capable and WMM is disabled on client.
4246 * Disable QoS and WMM
4247 */
4248 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
4249 }
4250
4251 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N)
4252 || (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC))
4253 && ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP)
4254 || (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF)
4255 || (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF))) {
4256 /* Joining BSS is 11n capable and WMM is disabled on AP. */
4257 /* Assume all HT AP's are QOS AP's and enable WMM */
4258 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
4259 }
4260 /* auth type */
4261 switch (pProfile->negotiatedAuthType) {
4262 default:
4263 case eCSR_AUTH_TYPE_WPA:
4264 case eCSR_AUTH_TYPE_WPA_PSK:
4265 case eCSR_AUTH_TYPE_WPA_NONE:
4266 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4267 pBssConfig->authType = eSIR_OPEN_SYSTEM;
4268 break;
4269 case eCSR_AUTH_TYPE_SHARED_KEY:
4270 pBssConfig->authType = eSIR_SHARED_KEY;
4271 break;
4272 case eCSR_AUTH_TYPE_AUTOSWITCH:
4273 pBssConfig->authType = eSIR_AUTO_SWITCH;
4274 break;
4275 }
4276 /* short slot time */
4277 if (eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode)
4278 pBssConfig->uShortSlotTime =
4279 pMac->roam.configParam.shortSlotTime;
4280 else
4281 pBssConfig->uShortSlotTime = 0;
4282
4283 if (pBssConfig->BssCap.ibss)
4284 /* We don't support 11h on IBSS */
4285 pBssConfig->f11hSupport = false;
4286 else
4287 pBssConfig->f11hSupport =
4288 pMac->roam.configParam.Is11hSupportEnabled;
4289 /* power constraint */
4290 pBssConfig->uPowerLimit =
4291 csr_get11h_power_constraint(pMac, &pIes->PowerConstraints);
4292 /* heartbeat */
4293 if (CSR_IS_11A_BSS(pBssDesc))
4294 pBssConfig->uHeartBeatThresh =
4295 pMac->roam.configParam.HeartbeatThresh50;
4296 else
4297 pBssConfig->uHeartBeatThresh =
4298 pMac->roam.configParam.HeartbeatThresh24;
4299
4300 /*
4301 * Join timeout: if we find a BeaconInterval in the BssDescription,
4302 * then set the Join Timeout to be 10 x the BeaconInterval.
4303 */
4304 if (pBssDesc->beaconInterval)
4305 /* Make sure it is bigger than the minimal */
4306 pBssConfig->uJoinTimeOut =
Anurag Chouhan6d760662016-02-20 16:05:43 +05304307 QDF_MAX(10 * pBssDesc->beaconInterval,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308 CSR_JOIN_FAILURE_TIMEOUT_MIN);
4309 else
4310 pBssConfig->uJoinTimeOut =
4311 CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
4312 /* validate CB */
Krishna Kumaar Natarajanf86c6ed2017-03-27 11:36:29 -07004313 if ((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
4314 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N_ONLY) ||
4315 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC) ||
4316 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC_ONLY) ||
4317 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AX) ||
4318 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AX_ONLY))
Kiran Kumar Lokere35fb5242017-03-10 20:16:44 -08004319 pBssConfig->cbMode = csr_get_cb_mode_from_ies(pMac,
4320 pBssDesc->channelId, pIes);
4321 else
4322 pBssConfig->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304324 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004325}
4326
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07004327QDF_STATUS csr_roam_prepare_bss_config_from_profile(tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304328 tCsrRoamProfile *pProfile,
4329 tBssConfigParam *pBssConfig,
4330 tSirBssDescription *pBssDesc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004331{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304332 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333 uint8_t operationChannel = 0;
4334 uint8_t qAPisEnabled = false;
4335 /* SSID */
4336 pBssConfig->SSID.length = 0;
4337 if (pProfile->SSIDs.numOfSSIDs) {
4338 /* only use the first one */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304339 qdf_mem_copy(&pBssConfig->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004340 &pProfile->SSIDs.SSIDList[0].SSID,
4341 sizeof(tSirMacSSid));
4342 } else {
4343 /* SSID must present */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304344 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004345 }
4346 /* Settomg up the capabilities */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304347 if (csr_is_bss_type_ibss(pProfile->BSSType))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004348 pBssConfig->BssCap.ibss = 1;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304349 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004350 pBssConfig->BssCap.ess = 1;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304351
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004352 if (eCSR_ENCRYPT_TYPE_NONE !=
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304353 pProfile->EncryptionType.encryptionType[0])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004354 pBssConfig->BssCap.privacy = 1;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304355
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004356 pBssConfig->eBand = pMac->roam.configParam.eBand;
4357 /* phymode */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304358 if (pProfile->ChannelInfo.ChannelList)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359 operationChannel = pProfile->ChannelInfo.ChannelList[0];
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304360 pBssConfig->uCfgDot11Mode = csr_roam_get_phy_mode_band_for_bss(pMac,
4361 pProfile, operationChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004362 &pBssConfig->eBand);
4363 /* QOS */
4364 /* Is this correct to always set to this // *** */
4365 if (pBssConfig->BssCap.ess == 1) {
4366 /*For Softap case enable WMM */
4367 if (CSR_IS_INFRA_AP(pProfile)
4368 && (eCsrRoamWmmNoQos !=
4369 pMac->roam.configParam.WMMSupportMode)) {
4370 qAPisEnabled = true;
4371 } else
4372 if (csr_roam_get_qos_info_from_bss(pMac, pBssDesc) ==
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304373 QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374 qAPisEnabled = true;
4375 } else {
4376 qAPisEnabled = false;
4377 }
4378 } else {
4379 qAPisEnabled = true;
4380 }
4381 if ((eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode &&
4382 qAPisEnabled) ||
4383 ((eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode &&
4384 qAPisEnabled))) {
4385 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
4386 } else {
4387 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
4388 }
4389
4390 /* auth type */
4391 /* Take the preferred Auth type. */
4392 switch (pProfile->AuthType.authType[0]) {
4393 default:
4394 case eCSR_AUTH_TYPE_WPA:
4395 case eCSR_AUTH_TYPE_WPA_PSK:
4396 case eCSR_AUTH_TYPE_WPA_NONE:
4397 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4398 pBssConfig->authType = eSIR_OPEN_SYSTEM;
4399 break;
4400 case eCSR_AUTH_TYPE_SHARED_KEY:
4401 pBssConfig->authType = eSIR_SHARED_KEY;
4402 break;
4403 case eCSR_AUTH_TYPE_AUTOSWITCH:
4404 pBssConfig->authType = eSIR_AUTO_SWITCH;
4405 break;
4406 }
4407 /* short slot time */
4408 if (WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode) {
4409 pBssConfig->uShortSlotTime =
4410 pMac->roam.configParam.shortSlotTime;
4411 } else {
4412 pBssConfig->uShortSlotTime = 0;
4413 }
4414 /* power constraint. We don't support 11h on IBSS */
4415 pBssConfig->f11hSupport = false;
4416 pBssConfig->uPowerLimit = 0;
4417 /* heartbeat */
4418 if (eCSR_BAND_5G == pBssConfig->eBand) {
4419 pBssConfig->uHeartBeatThresh =
4420 pMac->roam.configParam.HeartbeatThresh50;
4421 } else {
4422 pBssConfig->uHeartBeatThresh =
4423 pMac->roam.configParam.HeartbeatThresh24;
4424 }
4425 /* Join timeout */
4426 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
4427
4428 return status;
4429}
4430
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304431static QDF_STATUS csr_roam_get_qos_info_from_bss(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004432 tSirBssDescription *pBssDesc)
4433{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304434 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435 tDot11fBeaconIEs *pIes = NULL;
4436
4437 do {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304438 if (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004439 csr_get_parsed_bss_description_ies(
4440 pMac, pBssDesc, &pIes))) {
4441 /* err msg */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304442 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004443 "csr_roam_get_qos_info_from_bss() failed");
4444 break;
4445 }
4446 /* check if the AP is QAP & it supports APSD */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304447 if (CSR_IS_QOS_BSS(pIes))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304448 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449 } while (0);
4450
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304451 if (NULL != pIes)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304452 qdf_mem_free(pIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453
4454 return status;
4455}
4456
4457void csr_set_cfg_privacy(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
4458 bool fPrivacy)
4459{
4460 /*
4461 * the only difference between this function and
4462 * the csr_set_cfg_privacyFromProfile() is the setting of the privacy
4463 * CFG based on the advertised privacy setting from the AP for WPA
4464 * associations. See note below in this function...
4465 */
4466 uint32_t PrivacyEnabled = 0, RsnEnabled = 0, WepDefaultKeyId = 0;
4467 uint32_t WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
4468 uint32_t Key0Length = 0, Key1Length = 0, Key2Length = 0, Key3Length = 0;
4469
4470 /* Reserve for the biggest key */
4471 uint8_t Key0[WNI_CFG_WEP_DEFAULT_KEY_1_LEN];
4472 uint8_t Key1[WNI_CFG_WEP_DEFAULT_KEY_2_LEN];
4473 uint8_t Key2[WNI_CFG_WEP_DEFAULT_KEY_3_LEN];
4474 uint8_t Key3[WNI_CFG_WEP_DEFAULT_KEY_4_LEN];
4475
4476 switch (pProfile->negotiatedUCEncryptionType) {
4477 case eCSR_ENCRYPT_TYPE_NONE:
4478 /* for NO encryption, turn off Privacy and Rsn. */
4479 PrivacyEnabled = 0;
4480 RsnEnabled = 0;
4481 /* clear out the WEP keys that may be hanging around. */
4482 Key0Length = 0;
4483 Key1Length = 0;
4484 Key2Length = 0;
4485 Key3Length = 0;
4486 break;
4487
4488 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4489 case eCSR_ENCRYPT_TYPE_WEP40:
4490
4491 /* Privacy is ON. NO RSN for Wep40 static key. */
4492 PrivacyEnabled = 1;
4493 RsnEnabled = 0;
4494 /* Set the Wep default key ID. */
4495 WepDefaultKeyId = pProfile->Keys.defaultIndex;
4496 /* Wep key size if 5 bytes (40 bits). */
4497 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
4498 /*
4499 * set encryption keys in the CFG database or
4500 * clear those that are not present in this profile.
4501 */
4502 if (pProfile->Keys.KeyLength[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304503 qdf_mem_copy(Key0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 pProfile->Keys.KeyMaterial[0],
4505 WNI_CFG_WEP_KEY_LENGTH_5);
4506 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
4507 } else {
4508 Key0Length = 0;
4509 }
4510
4511 if (pProfile->Keys.KeyLength[1]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304512 qdf_mem_copy(Key1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513 pProfile->Keys.KeyMaterial[1],
4514 WNI_CFG_WEP_KEY_LENGTH_5);
4515 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
4516 } else {
4517 Key1Length = 0;
4518 }
4519
4520 if (pProfile->Keys.KeyLength[2]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304521 qdf_mem_copy(Key2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 pProfile->Keys.KeyMaterial[2],
4523 WNI_CFG_WEP_KEY_LENGTH_5);
4524 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
4525 } else {
4526 Key2Length = 0;
4527 }
4528
4529 if (pProfile->Keys.KeyLength[3]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304530 qdf_mem_copy(Key3,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004531 pProfile->Keys.KeyMaterial[3],
4532 WNI_CFG_WEP_KEY_LENGTH_5);
4533 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
4534 } else {
4535 Key3Length = 0;
4536 }
4537 break;
4538
4539 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4540 case eCSR_ENCRYPT_TYPE_WEP104:
4541
4542 /* Privacy is ON. NO RSN for Wep40 static key. */
4543 PrivacyEnabled = 1;
4544 RsnEnabled = 0;
4545 /* Set the Wep default key ID. */
4546 WepDefaultKeyId = pProfile->Keys.defaultIndex;
4547 /* Wep key size if 13 bytes (104 bits). */
4548 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
4549 /*
4550 * set encryption keys in the CFG database or clear
4551 * those that are not present in this profile.
4552 */
4553 if (pProfile->Keys.KeyLength[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304554 qdf_mem_copy(Key0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555 pProfile->Keys.KeyMaterial[0],
4556 WNI_CFG_WEP_KEY_LENGTH_13);
4557 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
4558 } else {
4559 Key0Length = 0;
4560 }
4561
4562 if (pProfile->Keys.KeyLength[1]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304563 qdf_mem_copy(Key1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004564 pProfile->Keys.KeyMaterial[1],
4565 WNI_CFG_WEP_KEY_LENGTH_13);
4566 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
4567 } else {
4568 Key1Length = 0;
4569 }
4570
4571 if (pProfile->Keys.KeyLength[2]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304572 qdf_mem_copy(Key2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573 pProfile->Keys.KeyMaterial[2],
4574 WNI_CFG_WEP_KEY_LENGTH_13);
4575 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
4576 } else {
4577 Key2Length = 0;
4578 }
4579
4580 if (pProfile->Keys.KeyLength[3]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304581 qdf_mem_copy(Key3,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004582 pProfile->Keys.KeyMaterial[3],
4583 WNI_CFG_WEP_KEY_LENGTH_13);
4584 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
4585 } else {
4586 Key3Length = 0;
4587 }
4588 break;
4589
4590 case eCSR_ENCRYPT_TYPE_TKIP:
4591 case eCSR_ENCRYPT_TYPE_AES:
4592#ifdef FEATURE_WLAN_WAPI
4593 case eCSR_ENCRYPT_TYPE_WPI:
4594#endif /* FEATURE_WLAN_WAPI */
4595 /*
4596 * this is the only difference between this function and
4597 * the csr_set_cfg_privacyFromProfile().
4598 * (setting of the privacy CFG based on the advertised
4599 * privacy setting from AP for WPA/WAPI associations).
4600 */
4601 PrivacyEnabled = (0 != fPrivacy);
4602 /* turn on RSN enabled for WPA associations */
4603 RsnEnabled = 1;
4604 /* clear static WEP keys that may be hanging around. */
4605 Key0Length = 0;
4606 Key1Length = 0;
4607 Key2Length = 0;
4608 Key3Length = 0;
4609 break;
4610 default:
4611 PrivacyEnabled = 0;
4612 RsnEnabled = 0;
4613 break;
4614 }
4615
4616 cfg_set_int(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled);
4617 cfg_set_int(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled);
4618 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length);
4619 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length);
4620 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length);
4621 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length);
4622 cfg_set_int(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength);
4623 cfg_set_int(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId);
4624}
4625
4626static void csr_set_cfg_ssid(tpAniSirGlobal pMac, tSirMacSSid *pSSID)
4627{
4628 uint32_t len = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304629
4630 if (pSSID->length <= WNI_CFG_SSID_LEN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631 len = pSSID->length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632 cfg_set_str(pMac, WNI_CFG_SSID, (uint8_t *) pSSID->ssId, len);
4633}
4634
Jeff Johnson29e2ca12016-10-14 12:50:38 -07004635static QDF_STATUS csr_set_qos_to_cfg(tpAniSirGlobal pMac, uint32_t sessionId,
4636 eCsrMediaAccessType qosType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004637{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304638 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004639 uint32_t QoSEnabled;
4640 uint32_t WmeEnabled;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304641 /* set the CFG enable/disable variables based on the
4642 * qosType being configured.
4643 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 switch (qosType) {
4645 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
4646 QoSEnabled = false;
4647 WmeEnabled = true;
4648 break;
4649 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
4650 QoSEnabled = false;
4651 WmeEnabled = true;
4652 break;
4653 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
4654 QoSEnabled = false;
4655 WmeEnabled = true;
4656 break;
4657 case eCSR_MEDIUM_ACCESS_11e_eDCF:
4658 QoSEnabled = true;
4659 WmeEnabled = false;
4660 break;
4661 case eCSR_MEDIUM_ACCESS_11e_HCF:
4662 QoSEnabled = true;
4663 WmeEnabled = false;
4664 break;
4665 default:
4666 case eCSR_MEDIUM_ACCESS_DCF:
4667 QoSEnabled = false;
4668 WmeEnabled = false;
4669 break;
4670 }
4671 /* save the WMM setting for later use */
4672 pMac->roam.roamSession[sessionId].fWMMConnection = (bool) WmeEnabled;
4673 pMac->roam.roamSession[sessionId].fQOSConnection = (bool) QoSEnabled;
4674 return status;
4675}
4676
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304677static QDF_STATUS csr_get_rate_set(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678 tCsrRoamProfile *pProfile, eCsrPhyMode phyMode,
4679 tSirBssDescription *pBssDesc,
4680 tDot11fBeaconIEs *pIes,
4681 tSirMacRateSet *pOpRateSet,
4682 tSirMacRateSet *pExRateSet)
4683{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304684 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004685 int i;
4686 eCsrCfgDot11Mode cfgDot11Mode;
4687 uint8_t *pDstRate;
4688 uint16_t rateBitmap = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304689
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304690 qdf_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
4691 qdf_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304692 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004693
4694 if (NULL == pIes) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004695 sme_err("failed to parse BssDesc");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004696 return status;
4697 }
4698
4699 csr_is_phy_mode_match(pMac, phyMode, pBssDesc, pProfile,
4700 &cfgDot11Mode, pIes);
4701 /*
4702 * Originally, we thought that for 11a networks, the 11a rates
4703 * are always in the Operational Rate set & for 11b and 11g
4704 * networks, the 11b rates appear in the Operational Rate set.
4705 * Consequently, in either case, we would blindly put the rates
4706 * we support into our Operational Rate set.
4707 * (including the basic rates, which we've already verified are
4708 * supported earlier in the roaming decision).
4709 * However, it turns out that this is not always the case.
4710 * Some AP's (e.g. D-Link DI-784) ram 11g rates into the
4711 * Operational Rate set too. Now, we're a little more careful.
4712 */
4713 pDstRate = pOpRateSet->rate;
4714 if (pIes->SuppRates.present) {
4715 for (i = 0; i < pIes->SuppRates.num_rates; i++) {
4716 if (csr_rates_is_dot11_rate_supported(pMac,
4717 pIes->SuppRates.rates[i]) &&
4718 !csr_check_rate_bitmap(
4719 pIes->SuppRates.rates[i],
4720 rateBitmap)) {
4721 csr_add_rate_bitmap(pIes->SuppRates.
4722 rates[i], &rateBitmap);
4723 *pDstRate++ = pIes->SuppRates.rates[i];
4724 pOpRateSet->numRates++;
4725 }
4726 }
4727 }
Abhishek Singh10112382015-12-03 16:06:59 +05304728 /*
4729 * If there are Extended Rates in the beacon, we will reflect the
4730 * extended rates that we support in our Extended Operational Rate
4731 * set.
4732 */
4733 if (pIes->ExtSuppRates.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004734 pDstRate = pExRateSet->rate;
4735 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++) {
4736 if (csr_rates_is_dot11_rate_supported(pMac,
4737 pIes->ExtSuppRates.rates[i]) &&
4738 !csr_check_rate_bitmap(
4739 pIes->ExtSuppRates.rates[i],
4740 rateBitmap)) {
4741 *pDstRate++ = pIes->ExtSuppRates.rates[i];
4742 pExRateSet->numRates++;
4743 }
4744 }
4745 }
4746 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304747 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748 return status;
4749}
4750
4751static void csr_set_cfg_rate_set(tpAniSirGlobal pMac, eCsrPhyMode phyMode,
4752 tCsrRoamProfile *pProfile,
4753 tSirBssDescription *pBssDesc,
4754 tDot11fBeaconIEs *pIes)
4755{
4756 int i;
4757 uint8_t *pDstRate;
4758 eCsrCfgDot11Mode cfgDot11Mode;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304759 /* leave enough room for the max number of rates */
4760 uint8_t OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004761 uint32_t OperationalRatesLength = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304762 /* leave enough room for the max number of rates */
4763 uint8_t ExtendedOperationalRates
4764 [CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004765 uint32_t ExtendedOperationalRatesLength = 0;
4766 uint8_t MCSRateIdxSet[SIZE_OF_SUPPORTED_MCS_SET];
4767 uint32_t MCSRateLength = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304768
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304769 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770 if (NULL != pIes) {
4771 csr_is_phy_mode_match(pMac, phyMode, pBssDesc, pProfile,
4772 &cfgDot11Mode, pIes);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304773 /* Originally, we thought that for 11a networks, the 11a rates
4774 * are always in the Operational Rate set & for 11b and 11g
4775 * networks, the 11b rates appear in the Operational Rate set.
4776 * Consequently, in either case, we would blindly put the rates
4777 * we support into our Operational Rate set (including the basic
4778 * rates, which we have already verified are supported earlier
4779 * in the roaming decision). However, it turns out that this is
4780 * not always the case. Some AP's (e.g. D-Link DI-784) ram 11g
4781 * rates into the Operational Rate set, too. Now, we're a
4782 * little more careful:
4783 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004784 pDstRate = OperationalRates;
4785 if (pIes->SuppRates.present) {
4786 for (i = 0; i < pIes->SuppRates.num_rates; i++) {
4787 if (csr_rates_is_dot11_rate_supported
4788 (pMac, pIes->SuppRates.rates[i])
4789 && (OperationalRatesLength <
4790 CSR_DOT11_SUPPORTED_RATES_MAX)) {
4791 *pDstRate++ = pIes->SuppRates.rates[i];
4792 OperationalRatesLength++;
4793 }
4794 }
4795 }
4796 if (eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
4797 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
4798 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304799 /* If there are Extended Rates in the beacon, we will
4800 * reflect those extended rates that we support in out
4801 * Extended Operational Rate set:
4802 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004803 pDstRate = ExtendedOperationalRates;
4804 if (pIes->ExtSuppRates.present) {
4805 for (i = 0; i < pIes->ExtSuppRates.num_rates;
4806 i++) {
4807 if (csr_rates_is_dot11_rate_supported
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304808 (pMac, pIes->ExtSuppRates.
4809 rates[i])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004810 && (ExtendedOperationalRatesLength <
4811 CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX)) {
4812 *pDstRate++ =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304813 pIes->ExtSuppRates.
4814 rates[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004815 ExtendedOperationalRatesLength++;
4816 }
4817 }
4818 }
4819 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304820 /* Enable proprietary MAC features if peer node is Airgo node
4821 * and STA user wants to use them For ANI network companions,
4822 * we need to populate the proprietary rate set with any
4823 * proprietary rates we found in the beacon, only if user allows
4824 * them.
4825 */
4826 /* No proprietary modes... */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004827 /* Get MCS Rate */
4828 pDstRate = MCSRateIdxSet;
4829 if (pIes->HTCaps.present) {
4830 for (i = 0; i < VALID_MAX_MCS_INDEX; i++) {
4831 if ((unsigned int)pIes->HTCaps.
4832 supportedMCSSet[0] & (1 << i)) {
4833 MCSRateLength++;
4834 *pDstRate++ = i;
4835 }
4836 }
4837 }
4838 /* Set the operational rate set CFG variables... */
4839 cfg_set_str(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
4840 OperationalRates, OperationalRatesLength);
4841 cfg_set_str(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
4842 ExtendedOperationalRates,
4843 ExtendedOperationalRatesLength);
4844 cfg_set_str(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
4845 MCSRateLength);
4846 } /* Parsing BSSDesc */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304847 else
Srinivas Girigowda81aef902017-03-17 09:34:19 -07004848 sme_err("failed to parse BssDesc");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004849}
4850
4851static void csr_set_cfg_rate_set_from_profile(tpAniSirGlobal pMac,
4852 tCsrRoamProfile *pProfile)
4853{
4854 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
4855 {8,
4856 {SIR_MAC_RATE_6,
4857 SIR_MAC_RATE_9,
4858 SIR_MAC_RATE_12,
4859 SIR_MAC_RATE_18,
4860 SIR_MAC_RATE_24,
4861 SIR_MAC_RATE_36,
4862 SIR_MAC_RATE_48,
4863 SIR_MAC_RATE_54} } };
4864 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
4865 {4,
4866 {SIR_MAC_RATE_1,
4867 SIR_MAC_RATE_2,
4868 SIR_MAC_RATE_5_5,
4869 SIR_MAC_RATE_11} } };
4870
4871 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
4872 {SIR_MAC_RATE_72,
4873 SIR_MAC_RATE_96,
4874 SIR_MAC_RATE_108} };
4875 eCsrCfgDot11Mode cfgDot11Mode;
4876 eCsrBand eBand;
4877 /* leave enough room for the max number of rates */
4878 uint8_t OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
4879 uint32_t OperationalRatesLength = 0;
4880 /* leave enough room for the max number of rates */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304881 uint8_t ExtendedOperationalRates
4882 [CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004883 uint32_t ExtendedOperationalRatesLength = 0;
4884 /* leave enough room for the max number of proprietary rates */
4885 uint8_t ProprietaryOperationalRates[4];
4886 uint32_t ProprietaryOperationalRatesLength = 0;
4887 uint32_t PropRatesEnable = 0;
4888 uint8_t operationChannel = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304889
4890 if (pProfile->ChannelInfo.ChannelList)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004891 operationChannel = pProfile->ChannelInfo.ChannelList[0];
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304892 cfgDot11Mode = csr_roam_get_phy_mode_band_for_bss(pMac, pProfile,
4893 operationChannel,
4894 &eBand);
4895 /* For 11a networks, the 11a rates go into the Operational Rate set.
4896 * For 11b and 11g networks, the 11b rates appear in the Operational
4897 * Rate set. In either case, we can blindly put the rates we support
4898 * into our Operational Rate set (including the basic rates, which we
4899 * have already verified are supported earlier in the roaming decision).
4900 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004901 if (eCSR_BAND_5G == eBand) {
4902 /* 11a rates into the Operational Rate Set. */
4903 OperationalRatesLength =
4904 DefaultSupportedRates11a.supportedRateSet.numRates *
4905 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304906 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907 DefaultSupportedRates11a.supportedRateSet.rate,
4908 OperationalRatesLength);
4909
4910 /* Nothing in the Extended rate set. */
4911 ExtendedOperationalRatesLength = 0;
4912 /* populate proprietary rates if user allows them */
4913 if (pMac->roam.configParam.ProprietaryRatesEnabled) {
4914 ProprietaryOperationalRatesLength =
4915 DefaultSupportedPropRates.numPropRates *
4916 sizeof(*DefaultSupportedPropRates.propRate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304917 qdf_mem_copy(ProprietaryOperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004918 DefaultSupportedPropRates.propRate,
4919 ProprietaryOperationalRatesLength);
4920 } else {
4921 /* No proprietary modes */
4922 ProprietaryOperationalRatesLength = 0;
4923 }
4924 } else if (eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode) {
4925 /* 11b rates into the Operational Rate Set. */
4926 OperationalRatesLength =
4927 DefaultSupportedRates11b.supportedRateSet.numRates *
4928 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304929 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004930 DefaultSupportedRates11b.supportedRateSet.rate,
4931 OperationalRatesLength);
4932 /* Nothing in the Extended rate set. */
4933 ExtendedOperationalRatesLength = 0;
4934 /* No proprietary modes */
4935 ProprietaryOperationalRatesLength = 0;
4936 } else {
4937 /* 11G */
4938
4939 /* 11b rates into the Operational Rate Set. */
4940 OperationalRatesLength =
4941 DefaultSupportedRates11b.supportedRateSet.numRates *
4942 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304943 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 DefaultSupportedRates11b.supportedRateSet.rate,
4945 OperationalRatesLength);
4946
4947 /* 11a rates go in the Extended rate set. */
4948 ExtendedOperationalRatesLength =
4949 DefaultSupportedRates11a.supportedRateSet.numRates *
4950 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304951 qdf_mem_copy(ExtendedOperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004952 DefaultSupportedRates11a.supportedRateSet.rate,
4953 ExtendedOperationalRatesLength);
4954
4955 /* populate proprietary rates if user allows them */
4956 if (pMac->roam.configParam.ProprietaryRatesEnabled) {
4957 ProprietaryOperationalRatesLength =
4958 DefaultSupportedPropRates.numPropRates *
4959 sizeof(*DefaultSupportedPropRates.propRate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304960 qdf_mem_copy(ProprietaryOperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961 DefaultSupportedPropRates.propRate,
4962 ProprietaryOperationalRatesLength);
4963 } else {
4964 /* No proprietary modes */
4965 ProprietaryOperationalRatesLength = 0;
4966 }
4967 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304968 /* set this to 1 if prop. rates need to be advertised in to the
4969 * IBSS beacon and user wants to use them
4970 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004971 if (ProprietaryOperationalRatesLength
4972 && pMac->roam.configParam.ProprietaryRatesEnabled) {
4973 PropRatesEnable = 1;
4974 } else {
4975 PropRatesEnable = 0;
4976 }
4977
4978 /* Set the operational rate set CFG variables... */
4979 cfg_set_str(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
4980 OperationalRatesLength);
4981 cfg_set_str(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05304982 ExtendedOperationalRates,
4983 ExtendedOperationalRatesLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004984 cfg_set_str(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
4985 ProprietaryOperationalRates,
4986 ProprietaryOperationalRatesLength);
4987}
4988
Krunal Sonif3583022017-02-10 17:18:10 -08004989void csr_roam_ccm_cfg_set_callback(tpAniSirGlobal pMac, int32_t result,
4990 uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004991{
4992 tListElem *pEntry =
Krunal Sonia8270f52017-02-23 19:51:25 -08004993 csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004994 uint32_t sessionId;
4995 tSmeCmd *pCommand = NULL;
4996#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4997 tCsrRoamSession *pSession = NULL;
4998#endif
4999 if (NULL == pEntry) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005000 sme_err("CFG_CNF with active list empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005001 return;
5002 }
5003 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
5004 sessionId = pCommand->sessionId;
5005#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5006 pSession = &pMac->roam.roamSession[sessionId];
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08005007 if (pSession->roam_synch_in_progress) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305008 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005009 "LFR3:csr_roam_cfg_set_callback");
5010 }
5011#endif
5012
5013 if (CSR_IS_ROAM_JOINING(pMac, sessionId)
5014 && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId)) {
Krunal Sonia8270f52017-02-23 19:51:25 -08005015 csr_roaming_state_config_cnf_processor(pMac, pCommand,
5016 (uint32_t) result, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005017 }
5018}
5019
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005020/* pIes may be NULL */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305021QDF_STATUS csr_roam_set_bss_config_cfg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005022 tCsrRoamProfile *pProfile,
5023 tSirBssDescription *pBssDesc,
5024 tBssConfigParam *pBssConfig,
5025 tDot11fBeaconIEs *pIes, bool resetCountry)
5026{
5027 tSirRetStatus status;
5028 uint32_t cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
5029 uint8_t channel = 0;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08005030 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
5031
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305032 /* Make sure we have the domain info for the BSS we try to connect to.
5033 * Do we need to worry about sequence for OSs that are not Windows??
5034 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005035 if (pBssDesc) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05305036 if ((QDF_SAP_MODE !=
Peng Xuf5d60c82015-10-02 17:17:03 -07005037 csr_get_session_persona(pMac, sessionId)) &&
5038 csr_learn_11dcountry_information(
5039 pMac, pBssDesc, pIes, true)) {
5040 csr_apply_country_information(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005041 }
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -07005042 if ((wlan_reg_11d_enabled_on_host(pMac->psoc)) && pIes) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305043 if (!pIes->Country.present)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005044 csr_apply_channel_power_info_wrapper(pMac);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305045 else
5046 /* Let's also update the below to make sure
5047 * we don't update CC while connected to an
5048 * AP which is advertising some CC
5049 */
5050 qdf_mem_copy(pMac->scan.currentCountryBssid.
5051 bytes, pBssDesc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005052 sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005053 }
5054 }
5055 /* Qos */
5056 csr_set_qos_to_cfg(pMac, sessionId, pBssConfig->qosType);
5057 /* SSID */
5058 csr_set_cfg_ssid(pMac, &pBssConfig->SSID);
5059
5060 /* Auth type */
5061 cfg_set_int(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType);
5062 /* encryption type */
5063 csr_set_cfg_privacy(pMac, pProfile, (bool) pBssConfig->BssCap.privacy);
5064 /* short slot time */
5065 cfg_set_int(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED,
5066 pBssConfig->uShortSlotTime);
5067 /* 11d */
5068 cfg_set_int(pMac, WNI_CFG_11D_ENABLED,
5069 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport :
5070 pProfile->ieee80211d));
5071 cfg_set_int(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT,
5072 pBssConfig->uPowerLimit);
5073 /* CB */
5074
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305075 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_IBSS(pProfile))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005076 channel = pProfile->operationChannel;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305077 else if (pBssDesc)
5078 channel = pBssDesc->channelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005079 if (0 != channel) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005080 /* for now if we are on 2.4 Ghz, CB will be always disabled */
5081 if (WLAN_REG_IS_24GHZ_CH(channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005082 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005083 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005084 cfgCb = pBssConfig->cbMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005085 }
5086 /* Rate */
5087 /* Fixed Rate */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305088 if (pBssDesc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005089 csr_set_cfg_rate_set(pMac, (eCsrPhyMode) pProfile->phyMode,
5090 pProfile, pBssDesc, pIes);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305091 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005092 csr_set_cfg_rate_set_from_profile(pMac, pProfile);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08005093 status = cfg_set_int(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT,
5094 pBssConfig->uJoinTimeOut);
5095 /* Any roaming related changes should be above this line */
Arif Hussain557920f2016-09-07 16:03:46 -07005096 if (pSession && pSession->roam_synch_in_progress) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005097 sme_debug("Roam synch is in progress Session_id: %d",
5098 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305099 return QDF_STATUS_SUCCESS;
Arif Hussain557920f2016-09-07 16:03:46 -07005100 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305101 /* Make this the last CFG to set. The callback will trigger a
5102 * join_req Join time out
5103 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005104 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId);
5105
Krunal Sonif3583022017-02-10 17:18:10 -08005106 csr_roam_ccm_cfg_set_callback(pMac, status, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305107 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005108}
5109
Jeff Johnson29e2ca12016-10-14 12:50:38 -07005110static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305111QDF_STATUS csr_roam_stop_network(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005112 tCsrRoamProfile *pProfile,
5113 tSirBssDescription *pBssDesc,
5114 tDot11fBeaconIEs *pIes)
5115{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305116 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117 tBssConfigParam *pBssConfig;
5118 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
5119
5120 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005121 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305122 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005123 }
5124
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305125 pBssConfig = qdf_mem_malloc(sizeof(tBssConfigParam));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005126 if (NULL == pBssConfig)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305127 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005128
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005129 sme_debug("session id: %d", sessionId);
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +05305130
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005131 status = csr_roam_prepare_bss_config(pMac, pProfile, pBssDesc,
5132 pBssConfig, pIes);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305133 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005134 eCsrRoamSubState substate;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305135
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005136 substate = eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING;
5137 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
5138 /* This will allow to pass cbMode during join req */
5139 pSession->bssParams.cbMode = pBssConfig->cbMode;
5140 /* For IBSS, we need to prepare some more information */
5141 if (csr_is_bss_type_ibss(pProfile->BSSType) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005142 CSR_IS_INFRA_AP(pProfile))
5143 csr_roam_prepare_bss_params(pMac, sessionId, pProfile,
5144 pBssDesc, pBssConfig, pIes);
5145
5146 /*
5147 * If we are in an IBSS, then stop the IBSS...
5148 * Not worry about WDS connection for now
5149 */
5150 if (csr_is_conn_state_ibss(pMac, sessionId)) {
5151 status = csr_roam_issue_stop_bss(pMac, sessionId,
5152 substate);
5153 } else if (csr_is_conn_state_infra(pMac, sessionId)) {
5154 /*
5155 * the new Bss is an Ibss OR we are roaming from
5156 * Infra to Infra across SSIDs
5157 * (roaming to a new SSID)...
5158 * Not worry about WDS connection for now
5159 */
5160 if (pBssDesc && (csr_is_ibss_bss_desc(pBssDesc) ||
5161 !csr_is_ssid_equal(pMac,
5162 pSession->pConnectBssDesc,
5163 pBssDesc, pIes)))
5164 status = csr_roam_issue_disassociate(pMac,
5165 sessionId, substate, false);
5166 else if (pBssDesc)
5167 /*
5168 * In an infra & going to an infra network with
5169 * the same SSID. This calls for a reassoc seq.
5170 * So issue the CFG sets for this new AP. Set
5171 * parameters for this Bss.
5172 */
5173 status = csr_roam_set_bss_config_cfg(pMac,
5174 sessionId, pProfile, pBssDesc,
5175 pBssConfig, pIes, false);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07005176 } else if (pBssDesc ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005177 CSR_IS_INFRA_AP(pProfile)) {
5178 /*
5179 * Neither in IBSS nor in Infra. We can go ahead and set
5180 * the cfg for tne new network... nothing to stop.
5181 */
5182 bool is11rRoamingFlag = false;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305183
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005184 is11rRoamingFlag = csr_roam_is11r_assoc(pMac,
5185 sessionId);
5186 /* Set parameters for this Bss. */
5187 status = csr_roam_set_bss_config_cfg(pMac, sessionId,
5188 pProfile, pBssDesc, pBssConfig, pIes,
5189 is11rRoamingFlag);
5190 }
5191 } /* Success getting BSS config info */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305192 qdf_mem_free(pBssConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005193 return status;
5194}
5195
5196/**
5197 * csr_roam_state_for_same_profile() - Determine roam state for same profile
5198 * @mac_ctx: pointer to mac context
5199 * @profile: Roam profile
5200 * @session: Roam session
5201 * @session_id: session id
5202 * @ies_local: local ies
5203 * @bss_descr: bss description
5204 *
5205 * This function will determine the roam state for same profile
5206 *
5207 * Return: Roaming state.
5208 */
5209static eCsrJoinState csr_roam_state_for_same_profile(tpAniSirGlobal mac_ctx,
5210 tCsrRoamProfile *profile, tCsrRoamSession *session,
5211 uint32_t session_id, tDot11fBeaconIEs *ies_local,
5212 tSirBssDescription *bss_descr)
5213{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305214 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005215 tBssConfigParam bssConfig;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305216
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005217 if (csr_roam_is_same_profile_keys(mac_ctx, &session->connectedProfile,
5218 profile))
5219 return eCsrReassocToSelfNoCapChange;
5220 /* The key changes */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305221 qdf_mem_set(&bssConfig, sizeof(bssConfig), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005222 status = csr_roam_prepare_bss_config(mac_ctx, profile, bss_descr,
5223 &bssConfig, ies_local);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305224 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005225 session->bssParams.uCfgDot11Mode =
5226 bssConfig.uCfgDot11Mode;
5227 session->bssParams.cbMode =
5228 bssConfig.cbMode;
5229 /* reapply the cfg including keys so reassoc happens. */
5230 status = csr_roam_set_bss_config_cfg(mac_ctx, session_id,
5231 profile, bss_descr, &bssConfig,
5232 ies_local, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305233 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005234 return eCsrContinueRoaming;
5235 }
5236
5237 return eCsrStopRoaming;
5238
5239}
5240
Jeff Johnson29e2ca12016-10-14 12:50:38 -07005241static eCsrJoinState csr_roam_join(tpAniSirGlobal pMac, uint32_t sessionId,
5242 tCsrScanResultInfo *pScanResult,
5243 tCsrRoamProfile *pProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005244{
5245 eCsrJoinState eRoamState = eCsrContinueRoaming;
5246 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
5247 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *) (pScanResult->pvIes);
5248 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
5249
5250 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005251 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005252 return eCsrStopRoaming;
5253 }
5254
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255 if (!pIesLocal &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305256 !QDF_IS_STATUS_SUCCESS(csr_get_parsed_bss_description_ies(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005257 pBssDesc, &pIesLocal))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005258 sme_err("fail to parse IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005259 return eCsrStopRoaming;
5260 }
5261 if (csr_is_infra_bss_desc(pBssDesc)) {
5262 /*
5263 * If we are connected in infra mode and the join bss descr is
5264 * for the same BssID, then we are attempting to join the AP we
5265 * are already connected with. In that case, see if the Bss or
5266 * sta capabilities have changed and handle the changes
5267 * without disturbing the current association
5268 */
5269
5270 if (csr_is_conn_state_connected_infra(pMac, sessionId) &&
5271 csr_is_bss_id_equal(pMac,
5272 pBssDesc, pSession->pConnectBssDesc) &&
5273 csr_is_ssid_equal(pMac, pSession->pConnectBssDesc,
5274 pBssDesc, pIesLocal)) {
5275 /*
5276 * Check to see if the Auth type has changed in the
5277 * profile. If so, we don't want to reassociate with
5278 * authenticating first. To force this, stop the
5279 * current association (Disassociate) and then re 'Join'
5280 * the AP, wihch will force an Authentication (with the
5281 * new Auth type) followed by a new Association.
5282 */
5283 if (csr_is_same_profile(pMac,
5284 &pSession->connectedProfile, pProfile)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005285 sme_warn("detect same profile");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286 eRoamState =
5287 csr_roam_state_for_same_profile(pMac,
5288 pProfile, pSession, sessionId,
5289 pIesLocal, pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305290 } else if (!QDF_IS_STATUS_SUCCESS(
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305291 csr_roam_issue_disassociate(
5292 pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005293 sessionId,
5294 eCSR_ROAM_SUBSTATE_DISASSOC_REQ,
5295 false))) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305296 sme_err("fail disassoc session %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005297 sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305298 eRoamState = eCsrStopRoaming;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305300 } else if (!QDF_IS_STATUS_SUCCESS(csr_roam_stop_network(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305301 sessionId, pProfile, pBssDesc, pIesLocal)))
5302 /* we used to pre-auth here with open auth
5303 * networks but that wasn't working so well.
5304 * stop the existing network before attempting
5305 * to join the new network.
5306 */
5307 eRoamState = eCsrStopRoaming;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305308 } else if (!QDF_IS_STATUS_SUCCESS(csr_roam_stop_network(pMac, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309 pProfile, pBssDesc,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305310 pIesLocal)))
5311 eRoamState = eCsrStopRoaming;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312
5313 if (pIesLocal && !pScanResult->pvIes)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305314 qdf_mem_free(pIesLocal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005315 return eRoamState;
5316}
5317
Jeff Johnson29e2ca12016-10-14 12:50:38 -07005318static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305319QDF_STATUS csr_roam_should_roam(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005320 tSirBssDescription *pBssDesc, uint32_t roamId)
5321{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305322 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005323 tCsrRoamInfo roamInfo;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305324
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305325 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326 roamInfo.pBssDesc = pBssDesc;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305327 status = csr_roam_call_callback(pMac, sessionId, &roamInfo, roamId,
5328 eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005329 return status;
5330}
5331
5332/* In case no matching BSS is found, use whatever default we can find */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305333static void csr_roam_assign_default_param(tpAniSirGlobal pMac,
5334 tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005335{
5336 /* Need to get all negotiated types in place first */
5337 /* auth type */
5338 /* Take the preferred Auth type. */
5339 switch (pCommand->u.roamCmd.roamProfile.AuthType.authType[0]) {
5340 default:
5341 case eCSR_AUTH_TYPE_WPA:
5342 case eCSR_AUTH_TYPE_WPA_PSK:
5343 case eCSR_AUTH_TYPE_WPA_NONE:
5344 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5345 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
5346 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5347 break;
5348
5349 case eCSR_AUTH_TYPE_SHARED_KEY:
5350 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
5351 eCSR_AUTH_TYPE_SHARED_KEY;
5352 break;
5353
5354 case eCSR_AUTH_TYPE_AUTOSWITCH:
5355 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
5356 eCSR_AUTH_TYPE_AUTOSWITCH;
5357 break;
5358 }
5359 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305360 pCommand->u.roamCmd.roamProfile.EncryptionType.
5361 encryptionType[0];
5362 /* In this case, the multicast encryption needs to follow the
5363 * uncast ones.
5364 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005365 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305366 pCommand->u.roamCmd.roamProfile.EncryptionType.
5367 encryptionType[0];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005368}
5369
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305370static void csr_set_abort_roaming_command(tpAniSirGlobal pMac,
5371 tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005372{
5373 switch (pCommand->u.roamCmd.roamReason) {
5374 case eCsrLostLink1:
Krunal Sonid8e8e3d2017-02-23 19:52:28 -08005375 pCommand->u.roamCmd.roamReason = eCsrLostLink1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005376 break;
5377 case eCsrLostLink2:
Krunal Sonid8e8e3d2017-02-23 19:52:28 -08005378 pCommand->u.roamCmd.roamReason = eCsrLostLink2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005379 break;
5380 case eCsrLostLink3:
Krunal Sonid8e8e3d2017-02-23 19:52:28 -08005381 pCommand->u.roamCmd.roamReason = eCsrLostLink3;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005382 break;
5383 default:
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005384 sme_err("aborting roaming reason %d not recognized",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005385 pCommand->u.roamCmd.roamReason);
5386 break;
5387 }
5388}
5389
5390/**
5391 * csr_roam_select_bss() - Handle join scenario based on profile
5392 * @mac_ctx: Global MAC Context
5393 * @roam_bss_entry: The next BSS to join
5394 * @csr_result_info: Result of join
5395 * @csr_scan_result: Global scan result
5396 * @session_id: SME Session ID
5397 * @roam_id: Roaming ID
5398 * @roam_state: Current roaming state
5399 * @bss_list: BSS List
5400 *
5401 * Return: true if the entire BSS list is done, false otherwise.
5402 */
5403static bool csr_roam_select_bss(tpAniSirGlobal mac_ctx,
5404 tListElem *roam_bss_entry, tCsrScanResultInfo **csr_result_info,
5405 tCsrScanResult **csr_scan_result, uint32_t session_id,
5406 uint32_t roam_id, eCsrJoinState *roam_state,
5407 tScanResultList *bss_list)
5408{
5409 uint8_t conc_channel = 0;
5410 bool status = false;
5411 tCsrScanResult *scan_result = NULL;
5412 tCsrScanResultInfo *result = NULL;
5413
5414 while (roam_bss_entry) {
5415 scan_result = GET_BASE_ADDR(roam_bss_entry, tCsrScanResult,
5416 Link);
5417 /*
5418 * If concurrency enabled take the
5419 * concurrent connected channel first.
5420 * Valid multichannel concurrent
5421 * sessions exempted
5422 */
5423 result = &scan_result->Result;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08005424 if (policy_mgr_concurrent_open_sessions_running(mac_ctx->psoc)
5425 && !csr_is_valid_mc_concurrent_session(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005426 session_id, &result->BssDescriptor)) {
5427 conc_channel = csr_get_concurrent_operation_channel(
5428 mac_ctx);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005429 sme_debug("csr Conc Channel: %d", conc_channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430 if ((conc_channel) && (conc_channel ==
5431 result->BssDescriptor.channelId)) {
5432 /*
5433 * make this 0 because we do not want the below
5434 * check to pass as we don't want to connect on
5435 * other channel
5436 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005437 sme_debug("Conc chnl match: %d", conc_channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438 conc_channel = 0;
5439 }
5440 }
5441
5442 /* Ok to roam this */
5443 if (!conc_channel &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305444 QDF_IS_STATUS_SUCCESS(csr_roam_should_roam(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 session_id, &result->BssDescriptor, roam_id))) {
5446 status = false;
5447 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005448 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305449 *roam_state = eCsrStopRoamingDueToConcurrency;
5450 status = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 roam_bss_entry = csr_ll_next(&bss_list->List, roam_bss_entry,
5452 LL_ACCESS_LOCK);
5453 }
5454 *csr_result_info = result;
5455 *csr_scan_result = scan_result;
5456 return status;
5457}
5458
5459/**
5460 * csr_roam_join_handle_profile() - Handle join scenario based on profile
5461 * @mac_ctx: Global MAC Context
5462 * @session_id: SME Session ID
5463 * @cmd: Command
5464 * @roam_info_ptr: Pointed to the roaming info for join
5465 * @roam_state: Current roaming state
5466 * @result: Result of join
5467 * @scan_result: Global scan result
5468 *
5469 * Return: None
5470 */
5471static void csr_roam_join_handle_profile(tpAniSirGlobal mac_ctx,
5472 uint32_t session_id, tSmeCmd *cmd, tCsrRoamInfo *roam_info_ptr,
5473 eCsrJoinState *roam_state, tCsrScanResultInfo *result,
5474 tCsrScanResult *scan_result)
5475{
5476#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5477 uint8_t acm_mask = 0;
5478#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305479 QDF_STATUS status;
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07005480 tCsrRoamSession *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005481 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
5482 tDot11fBeaconIEs *ies_local = NULL;
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07005483
5484 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005485 sme_err("Invalid session id %d", session_id);
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07005486 return;
5487 }
5488 session = CSR_GET_SESSION(mac_ctx, session_id);
5489
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005490 /*
5491 * We have something to roam, tell HDD when it is infra.
5492 * For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005493 */
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07005494 if (CSR_IS_INFRASTRUCTURE(profile) && roam_info_ptr) {
5495 if (session->bRefAssocStartCnt) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005496 session->bRefAssocStartCnt--;
5497 roam_info_ptr->pProfile = profile;
5498 /*
5499 * Complete the last assoc attempt as a
5500 * new one is about to be tried
5501 */
5502 csr_roam_call_callback(mac_ctx, session_id,
5503 roam_info_ptr, cmd->u.roamCmd.roamId,
5504 eCSR_ROAM_ASSOCIATION_COMPLETION,
5505 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
5506 }
5507 /* If roaming has stopped, don't continue the roaming command */
5508 if (!CSR_IS_ROAMING(session) && CSR_IS_ROAMING_COMMAND(cmd)) {
5509 /* No need to complete roaming as it already complete */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005510 sme_debug("Roam cmd(reason %d)aborted as roam complete",
5511 cmd->u.roamCmd.roamReason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005512 *roam_state = eCsrStopRoaming;
5513 csr_set_abort_roaming_command(mac_ctx, cmd);
5514 return;
5515 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305516 qdf_mem_set(roam_info_ptr, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517 if (!scan_result)
5518 cmd->u.roamCmd.roamProfile.uapsd_mask = 0;
5519 else
5520 ies_local = scan_result->Result.pvIes;
5521
Naveen Rawat48f51d02016-07-22 10:15:08 -07005522 if (!result) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005523 sme_err(" cannot parse IEs");
Naveen Rawat48f51d02016-07-22 10:15:08 -07005524 *roam_state = eCsrStopRoaming;
5525 return;
5526 } else if (scan_result && !ies_local &&
5527 (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005528 csr_get_parsed_bss_description_ies(
Naveen Rawat48f51d02016-07-22 10:15:08 -07005529 mac_ctx, &result->BssDescriptor,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005530 &ies_local)))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005531 sme_err(" cannot parse IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005532 *roam_state = eCsrStopRoaming;
5533 return;
5534 }
Naveen Rawat48f51d02016-07-22 10:15:08 -07005535 roam_info_ptr->pBssDesc = &result->BssDescriptor;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005536 cmd->u.roamCmd.pLastRoamBss = roam_info_ptr->pBssDesc;
5537 /* dont put uapsd_mask if BSS doesn't support uAPSD */
5538 if (scan_result && cmd->u.roamCmd.roamProfile.uapsd_mask
5539 && CSR_IS_QOS_BSS(ies_local)
5540 && CSR_IS_UAPSD_BSS(ies_local)) {
5541#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Naveen Rawat48f51d02016-07-22 10:15:08 -07005542 acm_mask = sme_qos_get_acm_mask(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005543 &result->BssDescriptor, ies_local);
5544#endif /* WLAN_MDM_CODE_REDUCTION_OPT */
5545 } else {
5546 cmd->u.roamCmd.roamProfile.uapsd_mask = 0;
5547 }
Naveen Rawat48f51d02016-07-22 10:15:08 -07005548 if (ies_local && !result->pvIes)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305549 qdf_mem_free(ies_local);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005550 roam_info_ptr->pProfile = profile;
5551 session->bRefAssocStartCnt++;
5552 csr_roam_call_callback(mac_ctx, session_id, roam_info_ptr,
5553 cmd->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_START,
5554 eCSR_ROAM_RESULT_NONE);
5555 }
5556 if (NULL != cmd->u.roamCmd.pRoamBssEntry) {
5557 /*
5558 * We have BSS
5559 * Need to assign these value because
5560 * they are used in csr_is_same_profile
5561 */
5562 scan_result = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
5563 tCsrScanResult, Link);
5564 /*
5565 * The OSEN IE doesn't provide the cipher suite.Therefore set
5566 * to constant value of AES
5567 */
5568 if (cmd->u.roamCmd.roamProfile.bOSENAssociation) {
5569 cmd->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
5570 eCSR_ENCRYPT_TYPE_AES;
5571 cmd->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
5572 eCSR_ENCRYPT_TYPE_AES;
5573 } else {
5574 /* Negotiated while building scan result. */
5575 cmd->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
5576 scan_result->ucEncryptionType;
5577 cmd->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
5578 scan_result->mcEncryptionType;
5579 }
5580 cmd->u.roamCmd.roamProfile.negotiatedAuthType =
5581 scan_result->authType;
5582 if (CSR_IS_START_IBSS(&cmd->u.roamCmd.roamProfile)) {
5583 if (csr_is_same_profile(mac_ctx,
5584 &session->connectedProfile, profile)) {
5585 *roam_state = eCsrStartIbssSameIbss;
5586 return;
5587 }
5588 }
5589 if (cmd->u.roamCmd.fReassocToSelfNoCapChange) {
5590 /* trying to connect to the one already connected */
5591 cmd->u.roamCmd.fReassocToSelfNoCapChange = false;
5592 *roam_state = eCsrReassocToSelfNoCapChange;
5593 return;
5594 }
5595 /* Attempt to Join this Bss... */
5596 *roam_state = csr_roam_join(mac_ctx, session_id,
5597 &scan_result->Result, profile);
5598 return;
5599 }
5600
5601 /* For an IBSS profile, then we need to start the IBSS. */
5602 if (CSR_IS_START_IBSS(profile)) {
5603 bool same_ibss = false;
5604 /* Attempt to start this IBSS... */
5605 csr_roam_assign_default_param(mac_ctx, cmd);
5606 status = csr_roam_start_ibss(mac_ctx, session_id,
5607 profile, &same_ibss);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305608 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005609 if (same_ibss)
5610 *roam_state = eCsrStartIbssSameIbss;
5611 else
5612 *roam_state = eCsrContinueRoaming;
5613 } else {
5614 /* it somehow fail need to stop */
5615 *roam_state = eCsrStopRoaming;
5616 }
5617 return;
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07005618 } else if (CSR_IS_INFRA_AP(profile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619 /* Attempt to start this WDS... */
5620 csr_roam_assign_default_param(mac_ctx, cmd);
5621 /* For AP WDS, we dont have any BSSDescription */
5622 status = csr_roam_start_wds(mac_ctx, session_id, profile, NULL);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305623 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005624 *roam_state = eCsrContinueRoaming;
5625 else
5626 *roam_state = eCsrStopRoaming;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07005627 } else if (CSR_IS_NDI(profile)) {
5628 csr_roam_assign_default_param(mac_ctx, cmd);
5629 status = csr_roam_start_ndi(mac_ctx, session_id, profile);
5630 if (QDF_IS_STATUS_SUCCESS(status))
5631 *roam_state = eCsrContinueRoaming;
5632 else
5633 *roam_state = eCsrStopRoaming;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005634 } else {
5635 /* Nothing we can do */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005636 sme_warn("cannot continue without BSS list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005637 *roam_state = eCsrStopRoaming;
5638 return;
5639 }
5640
5641}
5642/**
5643 * csr_roam_join_next_bss() - Pick the next BSS for join
5644 * @mac_ctx: Global MAC Context
5645 * @cmd: Command
5646 * @use_same_bss: Use Same BSS to Join
5647 *
5648 * Return: The Join State
5649 */
5650static eCsrJoinState csr_roam_join_next_bss(tpAniSirGlobal mac_ctx,
5651 tSmeCmd *cmd, bool use_same_bss)
5652{
5653 tCsrScanResult *scan_result = NULL;
5654 eCsrJoinState roam_state = eCsrStopRoaming;
5655 tScanResultList *bss_list =
5656 (tScanResultList *) cmd->u.roamCmd.hBSSList;
5657 bool done = false;
Kapil Guptaffa26022017-08-16 12:20:09 +05305658 tCsrRoamInfo *roam_info = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005659 uint32_t session_id = cmd->sessionId;
5660 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
5661 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
5662 tCsrRoamJoinStatus *join_status;
5663 tCsrScanResultInfo *result = NULL;
5664
5665 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005666 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667 return eCsrStopRoaming;
5668 }
5669
Kapil Guptaffa26022017-08-16 12:20:09 +05305670 roam_info = qdf_mem_malloc(sizeof (*roam_info));
5671 if (!roam_info) {
5672 sme_err("failed to allocate memory");
5673 return eCsrStopRoaming;
5674 }
5675 qdf_mem_copy(&roam_info->bssid, &session->joinFailStatusCode.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005676 sizeof(tSirMacAddr));
5677 /*
5678 * When handling AP's capability change, continue to associate
5679 * to same BSS and make sure pRoamBssEntry is not Null.
5680 */
5681 if ((NULL != bss_list) &&
5682 ((false == use_same_bss) ||
5683 (cmd->u.roamCmd.pRoamBssEntry == NULL))) {
5684 if (cmd->u.roamCmd.pRoamBssEntry == NULL) {
5685 /* Try the first BSS */
5686 cmd->u.roamCmd.pLastRoamBss = NULL;
5687 cmd->u.roamCmd.pRoamBssEntry =
5688 csr_ll_peek_head(&bss_list->List,
5689 LL_ACCESS_LOCK);
5690 } else {
5691 cmd->u.roamCmd.pRoamBssEntry =
5692 csr_ll_next(&bss_list->List,
5693 cmd->u.roamCmd.pRoamBssEntry,
5694 LL_ACCESS_LOCK);
5695 /*
5696 * Done with all the BSSs.
5697 * In this case, will tell HDD the
5698 * completion
5699 */
5700 if (NULL == cmd->u.roamCmd.pRoamBssEntry)
5701 goto end;
5702 /*
5703 * We need to indicate to HDD that we
5704 * are done with this one.
5705 */
Kapil Guptaffa26022017-08-16 12:20:09 +05305706 roam_info->pBssDesc = cmd->u.roamCmd.pLastRoamBss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005707 join_status = &session->joinFailStatusCode;
Kapil Guptaffa26022017-08-16 12:20:09 +05305708 roam_info->statusCode = join_status->statusCode;
5709 roam_info->reasonCode = join_status->reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005710 }
5711 done = csr_roam_select_bss(mac_ctx,
5712 cmd->u.roamCmd.pRoamBssEntry, &result,
5713 &scan_result, session_id, cmd->u.roamCmd.roamId,
5714 &roam_state, bss_list);
5715 if (done)
5716 goto end;
5717 }
Kapil Guptaffa26022017-08-16 12:20:09 +05305718 roam_info->u.pConnectedProfile = &session->connectedProfile;
Naveen Rawata395d252016-06-15 11:07:24 -07005719
Kapil Guptaffa26022017-08-16 12:20:09 +05305720 csr_roam_join_handle_profile(mac_ctx, session_id, cmd, roam_info,
Naveen Rawat696a9302016-06-15 11:07:24 -07005721 &roam_state, result, scan_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005722end:
5723 if ((eCsrStopRoaming == roam_state) && CSR_IS_INFRASTRUCTURE(profile) &&
5724 (session->bRefAssocStartCnt > 0)) {
5725 /*
5726 * Need to indicate association_completion if association_start
5727 * has been done
5728 */
5729 session->bRefAssocStartCnt--;
5730 /*
5731 * Complete the last assoc attempte as a
5732 * new one is about to be tried
5733 */
Kapil Guptaffa26022017-08-16 12:20:09 +05305734 roam_info->pProfile = profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005735 csr_roam_call_callback(mac_ctx, session_id,
Kapil Guptaffa26022017-08-16 12:20:09 +05305736 roam_info, cmd->u.roamCmd.roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005737 eCSR_ROAM_ASSOCIATION_COMPLETION,
5738 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
5739 }
Kapil Guptaffa26022017-08-16 12:20:09 +05305740 qdf_mem_free(roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005741
5742 return roam_state;
5743}
5744
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305745static QDF_STATUS csr_roam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005746{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305747 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748 eCsrJoinState RoamState;
5749 eCsrRoamSubState substate;
5750 uint32_t sessionId = pCommand->sessionId;
5751
5752 /* Attept to join a Bss... */
5753 RoamState = csr_roam_join_next_bss(pMac, pCommand, false);
5754
5755 /* if nothing to join.. */
5756 if ((eCsrStopRoaming == RoamState) ||
5757 (eCsrStopRoamingDueToConcurrency == RoamState)) {
5758 bool fComplete = false;
5759 /* and if connected in Infrastructure mode... */
5760 if (csr_is_conn_state_infra(pMac, sessionId)) {
5761 /* ... then we need to issue a disassociation */
5762 substate = eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN;
5763 status = csr_roam_issue_disassociate(pMac, sessionId,
5764 substate, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305765 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005766 sme_warn("fail issuing disassoc status = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005767 status);
5768 /*
5769 * roam command is completed by caller in the
5770 * failed case
5771 */
5772 fComplete = true;
5773 }
5774 } else if (csr_is_conn_state_ibss(pMac, sessionId)) {
5775 status = csr_roam_issue_stop_bss(pMac, sessionId,
5776 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305777 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005778 sme_warn("fail issuing stop bss status = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005779 status);
5780 /*
5781 * roam command is completed by caller in the
5782 * failed case
5783 */
5784 fComplete = true;
5785 }
5786 } else if (csr_is_conn_state_connected_infra_ap(pMac,
5787 sessionId)) {
5788 substate = eCSR_ROAM_SUBSTATE_STOP_BSS_REQ;
5789 status = csr_roam_issue_stop_bss(pMac, sessionId,
5790 substate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305791 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005792 sme_warn("fail issuing stop bss status = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005793 status);
5794 /*
5795 * roam command is completed by caller in the
5796 * failed case
5797 */
5798 fComplete = true;
5799 }
5800 } else {
5801 fComplete = true;
5802 }
5803
5804 if (fComplete) {
5805 /* otherwise, we can complete the Roam command here. */
5806 if (eCsrStopRoamingDueToConcurrency == RoamState)
5807 csr_roam_complete(pMac,
Krunal Sonif3583022017-02-10 17:18:10 -08005808 eCsrJoinFailureDueToConcurrency, NULL,
5809 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005810 else
5811 csr_roam_complete(pMac,
Krunal Sonif3583022017-02-10 17:18:10 -08005812 eCsrNothingToJoin, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005813 }
5814 } else if (eCsrReassocToSelfNoCapChange == RoamState) {
5815 csr_roam_complete(pMac, eCsrSilentlyStopRoamingSaveState,
Krunal Sonif3583022017-02-10 17:18:10 -08005816 NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005817 } else if (eCsrStartIbssSameIbss == RoamState) {
Krunal Sonif3583022017-02-10 17:18:10 -08005818 csr_roam_complete(pMac, eCsrSilentlyStopRoaming, NULL,
5819 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005820 }
5821
5822 return status;
5823}
5824
Jeff Johnson29e2ca12016-10-14 12:50:38 -07005825static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305826QDF_STATUS csr_process_ft_reassoc_roam_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005827 tSmeCmd *pCommand)
5828{
5829 uint32_t sessionId;
5830 tCsrRoamSession *pSession;
5831 tCsrScanResult *pScanResult = NULL;
5832 tSirBssDescription *pBssDesc = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305833 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305834
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005835 sessionId = pCommand->sessionId;
5836 pSession = CSR_GET_SESSION(pMac, sessionId);
5837
5838 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005839 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305840 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841 }
5842
5843 if (CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming) {
5844 /* the roaming is cancelled. Simply complete the command */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005845 sme_debug("Roam command canceled");
Krunal Sonif3583022017-02-10 17:18:10 -08005846 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305847 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005848 }
5849 if (pCommand->u.roamCmd.pRoamBssEntry) {
5850 pScanResult =
5851 GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry,
5852 tCsrScanResult, Link);
5853 pBssDesc = &pScanResult->Result.BssDescriptor;
5854 } else {
5855 /* the roaming is cancelled. Simply complete the command */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005856 sme_debug("Roam command canceled");
Krunal Sonif3583022017-02-10 17:18:10 -08005857 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305858 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005859 }
5860 status = csr_roam_issue_reassociate(pMac, sessionId, pBssDesc,
5861 (tDot11fBeaconIEs *) (pScanResult->
5862 Result.pvIes),
5863 &pCommand->u.roamCmd.roamProfile);
5864 return status;
5865}
5866
5867/**
5868 * csr_roam_trigger_reassociate() - Helper function to trigger reassociate
5869 * @mac_ctx: pointer to mac context
5870 * @cmd: sme command
5871 * @roam_info: Roaming infor structure
5872 * @session_ptr: session pointer
5873 * @session_id: session id
5874 *
5875 * This function will trigger reassociate.
5876 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305877 * Return: QDF_STATUS for success or failure.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005878 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305879static QDF_STATUS csr_roam_trigger_reassociate(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005880 tSmeCmd *cmd, tCsrRoamInfo *roam_info,
5881 tCsrRoamSession *session_ptr, uint32_t session_id)
5882{
5883 tDot11fBeaconIEs *pIes = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305884 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005885
5886 if (session_ptr->pConnectBssDesc) {
5887 status = csr_get_parsed_bss_description_ies(mac_ctx,
5888 session_ptr->pConnectBssDesc, &pIes);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305889 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005890 sme_err("fail to parse IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005891 } else {
5892 roam_info->reasonCode =
5893 eCsrRoamReasonStaCapabilityChanged;
5894 csr_roam_call_callback(mac_ctx, session_ptr->sessionId,
5895 roam_info, 0, eCSR_ROAM_ROAMING_START,
5896 eCSR_ROAM_RESULT_NONE);
5897 session_ptr->roamingReason = eCsrReassocRoaming;
5898 roam_info->pBssDesc = session_ptr->pConnectBssDesc;
5899 roam_info->pProfile = &cmd->u.roamCmd.roamProfile;
5900 session_ptr->bRefAssocStartCnt++;
5901 csr_roam_call_callback(mac_ctx, session_id, roam_info,
5902 cmd->u.roamCmd.roamId,
5903 eCSR_ROAM_ASSOCIATION_START,
5904 eCSR_ROAM_RESULT_NONE);
5905
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005906 sme_debug("calling csr_roam_issue_reassociate");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005907 status = csr_roam_issue_reassociate(mac_ctx, session_id,
5908 session_ptr->pConnectBssDesc, pIes,
5909 &cmd->u.roamCmd.roamProfile);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305910 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005911 sme_err("failed status %d", status);
Krunal Sonidea45952017-02-15 11:58:15 -08005912 csr_release_command(mac_ctx, cmd);
Zhu Jianmine5594d12017-07-11 12:22:46 +08005913 } else {
5914 csr_neighbor_roam_state_transition(mac_ctx,
5915 eCSR_NEIGHBOR_ROAM_STATE_REASSOCIATING,
5916 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005917 }
5918
Zhu Jianmine5594d12017-07-11 12:22:46 +08005919
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305920 qdf_mem_free(pIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005921 pIes = NULL;
5922 }
5923 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005924 sme_err("reassoc to same AP failed as connected BSS is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305925 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005926 }
5927 return status;
5928}
5929
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305930QDF_STATUS csr_roam_process_command(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005931{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305932 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005933 tCsrRoamInfo roamInfo;
5934 uint32_t sessionId = pCommand->sessionId;
5935 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
5936
5937 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005938 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305939 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005940 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005941 sme_debug("Roam Reason: %d sessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005942 pCommand->u.roamCmd.roamReason, sessionId);
5943
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07005944 pSession->disconnect_reason = pCommand->u.roamCmd.disconnect_reason;
5945
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005946 switch (pCommand->u.roamCmd.roamReason) {
5947 case eCsrForcedDisassoc:
5948 if (eCSR_ROAMING_STATE_IDLE == pMac->roam.curState[sessionId]) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005949 sme_err("Ignore eCsrForcedDisassoc cmd on roam state %d",
5950 eCSR_ROAMING_STATE_IDLE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305951 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005952 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005953 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
5954 true, false);
5955 csr_free_roam_profile(pMac, sessionId);
5956 break;
5957 case eCsrSmeIssuedDisassocForHandoff:
5958 /* Not to free pMac->roam.pCurRoamProfile (via
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05305959 * csr_free_roam_profile) because its needed after disconnect
5960 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005961 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
5962 true, false);
5963
5964 break;
5965 case eCsrForcedDisassocMICFailure:
5966 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
5967 true, true);
5968 csr_free_roam_profile(pMac, sessionId);
5969 break;
5970 case eCsrForcedDeauth:
5971 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
5972 false, false);
5973 csr_free_roam_profile(pMac, sessionId);
5974 break;
5975 case eCsrHddIssuedReassocToSameAP:
5976 case eCsrSmeIssuedReassocToSameAP:
5977 status = csr_roam_trigger_reassociate(pMac, pCommand, &roamInfo,
5978 pSession, sessionId);
5979 break;
5980 case eCsrCapsChange:
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005981 sme_err("received eCsrCapsChange ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
5983 sessionId);
5984 status = csr_roam_issue_disassociate(pMac, sessionId,
5985 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
5986 false);
5987 break;
5988 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda81aef902017-03-17 09:34:19 -07005989 sme_debug("received FT Reassoc Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005990 status = csr_process_ft_reassoc_roam_command(pMac, pCommand);
5991 break;
5992
5993 case eCsrStopBss:
5994 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
5995 sessionId);
5996 status = csr_roam_issue_stop_bss(pMac, sessionId,
5997 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
5998 break;
5999
6000 case eCsrForcedDisassocSta:
6001 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
6002 sessionId);
6003 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ,
6004 sessionId);
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006005 sme_debug("Disassociate issued with reason: %d",
yeshwanth sriram guntuka46f004f2017-02-07 12:22:31 +05306006 pCommand->u.roamCmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007 status = csr_send_mb_disassoc_req_msg(pMac, sessionId,
6008 pCommand->u.roamCmd.peerMac,
6009 pCommand->u.roamCmd.reason);
6010 break;
6011
6012 case eCsrForcedDeauthSta:
6013 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
6014 sessionId);
6015 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ,
6016 sessionId);
6017 status = csr_send_mb_deauth_req_msg(pMac, sessionId,
6018 pCommand->u.roamCmd.peerMac,
6019 pCommand->u.roamCmd.reason);
6020 break;
6021
6022 case eCsrPerformPreauth:
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006023 sme_debug("Attempting FT PreAuth Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006024 status = csr_roam_issue_ft_preauth_req(pMac, sessionId,
6025 pCommand->u.roamCmd.pLastRoamBss);
6026 break;
6027 default:
6028 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
6029 sessionId);
6030
6031 if (pCommand->u.roamCmd.fUpdateCurRoamProfile) {
6032 /* Remember the roaming profile */
6033 csr_free_roam_profile(pMac, sessionId);
6034 pSession->pCurRoamProfile =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306035 qdf_mem_malloc(sizeof(tCsrRoamProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006036 if (NULL != pSession->pCurRoamProfile) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006037 csr_roam_copy_profile(pMac,
6038 pSession->pCurRoamProfile,
6039 &pCommand->u.roamCmd.roamProfile);
6040 }
6041 }
6042 /*
6043 * At this point original uapsd_mask is saved in
6044 * pCurRoamProfile. uapsd_mask in the pCommand may change from
6045 * this point on. Attempt to roam with the new scan results
6046 * (if we need to..)
6047 */
6048 status = csr_roam(pMac, pCommand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306049 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006050 sme_warn("csr_roam() failed with status = 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006051 status);
6052 break;
6053 }
6054 return status;
6055}
6056
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006057void csr_reinit_roam_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
6058{
6059 if (pCommand->u.roamCmd.fReleaseBssList) {
6060 csr_scan_result_purge(pMac, pCommand->u.roamCmd.hBSSList);
6061 pCommand->u.roamCmd.fReleaseBssList = false;
6062 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6063 }
6064 if (pCommand->u.roamCmd.fReleaseProfile) {
6065 csr_release_profile(pMac, &pCommand->u.roamCmd.roamProfile);
6066 pCommand->u.roamCmd.fReleaseProfile = false;
6067 }
6068 pCommand->u.roamCmd.pRoamBssEntry = NULL;
6069 /* Because u.roamCmd is union and share with scanCmd and StatusChange */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306070 qdf_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006071}
6072
6073void csr_reinit_wm_status_change_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
6074{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306075 qdf_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006076 0);
6077}
6078
Krunal Sonia8270f52017-02-23 19:51:25 -08006079void csr_roam_complete(tpAniSirGlobal mac_ctx, eCsrRoamCompleteResult Result,
6080 void *Context, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006081{
Krunal Sonia8270f52017-02-23 19:51:25 -08006082 tSmeCmd *sme_cmd;
6083 struct wlan_serialization_command *cmd;
6084
6085 cmd = wlan_serialization_peek_head_active_cmd_using_psoc(
6086 mac_ctx->psoc, false);
6087 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006088 sme_err("Roam completion called but cmd is not active");
Krunal Sonia8270f52017-02-23 19:51:25 -08006089 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006090 }
Krunal Sonia8270f52017-02-23 19:51:25 -08006091 sme_cmd = cmd->umac_cmd;
6092 if (!sme_cmd) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -07006093 sme_err("sme_cmd is NULL");
Krunal Sonia8270f52017-02-23 19:51:25 -08006094 return;
6095 }
6096 if (eSmeCommandRoam == sme_cmd->command) {
6097 csr_roam_process_results(mac_ctx, sme_cmd, Result, Context);
6098 csr_release_command(mac_ctx, sme_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006099 }
6100}
6101
Krunal Sonia8270f52017-02-23 19:51:25 -08006102
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006103void csr_reset_pmkid_candidate_list(tpAniSirGlobal pMac, uint32_t sessionId)
6104{
6105 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306106
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006107 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306108 sme_err("session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006109 return;
6110 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306111 qdf_mem_set(&(pSession->PmkidCandidateInfo[0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006112 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
6113 pSession->NumPmkidCandidate = 0;
6114}
6115
6116#ifdef FEATURE_WLAN_WAPI
6117void csr_reset_bkid_candidate_list(tpAniSirGlobal pMac, uint32_t sessionId)
6118{
6119 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306120
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006121 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306122 sme_err("session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006123 return;
6124 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306125 qdf_mem_set(&(pSession->BkidCandidateInfo[0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006126 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
6127 pSession->NumBkidCandidate = 0;
6128}
6129#endif /* FEATURE_WLAN_WAPI */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006130
6131/**
6132 * csr_roam_save_params() - Helper function to save params
6133 * @mac_ctx: pointer to mac context
6134 * @session_ptr: Session pointer
6135 * @auth_type: auth type
6136 * @ie_ptr: pointer to ie
6137 * @ie_local: pointr to local ie
6138 *
6139 * This function will save params to session
6140 *
6141 * Return: none.
6142 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306143static QDF_STATUS csr_roam_save_params(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006144 tCsrRoamSession *session_ptr,
6145 eCsrAuthType auth_type,
6146 tDot11fBeaconIEs *ie_ptr,
6147 tDot11fBeaconIEs *ie_local)
6148{
6149 uint32_t nIeLen;
6150 uint8_t *pIeBuf;
6151
6152 if ((eCSR_AUTH_TYPE_RSN == auth_type) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006153 (eCSR_AUTH_TYPE_FT_RSN == auth_type) ||
6154 (eCSR_AUTH_TYPE_FT_RSN_PSK == auth_type) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006155#if defined WLAN_FEATURE_11W
6156 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == auth_type) ||
6157 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == auth_type) ||
6158#endif
6159 (eCSR_AUTH_TYPE_RSN_PSK == auth_type)) {
6160 if (ie_local->RSN.present) {
6161 tDot11fIERSN *rsnie = &ie_local->RSN;
6162 /*
6163 * Calculate the actual length
6164 * version + gp_cipher_suite + pwise_cipher_suite_count
6165 * + akm_suite_count + reserved + pwise_cipher_suites
6166 */
6167 nIeLen = 8 + 2 + 2
6168 + (rsnie->pwise_cipher_suite_count * 4)
6169 + (rsnie->akm_suite_count * 4);
6170 if (rsnie->pmkid_count)
6171 /* pmkid */
6172 nIeLen += 2 + rsnie->pmkid_count * 4;
6173
6174 /* nIeLen doesn't count EID and length fields */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306175 session_ptr->pWpaRsnRspIE = qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006176 if (NULL == session_ptr->pWpaRsnRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306177 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006178
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006179 session_ptr->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
6180 session_ptr->pWpaRsnRspIE[1] = (uint8_t) nIeLen;
6181 /* copy upto akm_suites */
6182 pIeBuf = session_ptr->pWpaRsnRspIE + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306183 qdf_mem_copy(pIeBuf, &rsnie->version,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006184 sizeof(rsnie->version));
6185 pIeBuf += sizeof(rsnie->version);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306186 qdf_mem_copy(pIeBuf, &rsnie->gp_cipher_suite,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006187 sizeof(rsnie->gp_cipher_suite));
6188 pIeBuf += sizeof(rsnie->gp_cipher_suite);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306189 qdf_mem_copy(pIeBuf, &rsnie->pwise_cipher_suite_count,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006190 sizeof(rsnie->pwise_cipher_suite_count));
6191 pIeBuf += sizeof(rsnie->pwise_cipher_suite_count);
6192 if (rsnie->pwise_cipher_suite_count) {
6193 /* copy pwise_cipher_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306194 qdf_mem_copy(pIeBuf, rsnie->pwise_cipher_suites,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006195 rsnie->pwise_cipher_suite_count * 4);
6196 pIeBuf += rsnie->pwise_cipher_suite_count * 4;
6197 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306198 qdf_mem_copy(pIeBuf, &rsnie->akm_suite_count, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006199 pIeBuf += 2;
6200 if (rsnie->akm_suite_count) {
6201 /* copy akm_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306202 qdf_mem_copy(pIeBuf, rsnie->akm_suites,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006203 rsnie->akm_suite_count * 4);
6204 pIeBuf += rsnie->akm_suite_count * 4;
6205 }
6206 /* copy the rest */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306207 qdf_mem_copy(pIeBuf, rsnie->akm_suites +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006208 rsnie->akm_suite_count * 4,
6209 2 + rsnie->pmkid_count * 4);
6210 session_ptr->nWpaRsnRspIeLength = nIeLen + 2;
6211 }
6212 } else if ((eCSR_AUTH_TYPE_WPA == auth_type) ||
6213 (eCSR_AUTH_TYPE_WPA_PSK == auth_type)) {
6214 if (ie_local->WPA.present) {
6215 tDot11fIEWPA *wpaie = &ie_local->WPA;
6216 /* Calculate the actual length wpaie */
6217 nIeLen = 12 + 2 /* auth_suite_count */
6218 + wpaie->unicast_cipher_count * 4
6219 + wpaie->auth_suite_count * 4;
6220
6221 /* The WPA capabilities follows the Auth Suite
6222 * (two octects)-- this field is optional, and
6223 * we always "send" zero, so just remove it. This is
6224 * consistent with our assumptions in the frames
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306225 * compiler; nIeLen doesn't count EID & length fields
6226 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306227 session_ptr->pWpaRsnRspIE = qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006228 if (NULL == session_ptr->pWpaRsnRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306229 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006230 session_ptr->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
6231 session_ptr->pWpaRsnRspIE[1] = (uint8_t) nIeLen;
6232 pIeBuf = session_ptr->pWpaRsnRspIE + 2;
6233 /* Copy WPA OUI */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306234 qdf_mem_copy(pIeBuf, &csr_wpa_oui[1], 4);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006235 pIeBuf += 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306236 qdf_mem_copy(pIeBuf, &wpaie->version,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006237 8 + wpaie->unicast_cipher_count * 4);
6238 pIeBuf += 8 + wpaie->unicast_cipher_count * 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306239 qdf_mem_copy(pIeBuf, &wpaie->auth_suite_count,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006240 2 + wpaie->auth_suite_count * 4);
6241 pIeBuf += wpaie->auth_suite_count * 4;
6242 session_ptr->nWpaRsnRspIeLength = nIeLen + 2;
6243 }
6244 }
6245#ifdef FEATURE_WLAN_WAPI
6246 else if ((eCSR_AUTH_TYPE_WAPI_WAI_PSK == auth_type) ||
6247 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ==
6248 auth_type)) {
6249 if (ie_local->WAPI.present) {
6250 tDot11fIEWAPI *wapi_ie = &ie_local->WAPI;
6251 /* Calculate the actual length of wapi ie*/
6252 nIeLen = 4 + 2 /* pwise_cipher_suite_count */
6253 + wapi_ie->akm_suite_count * 4
6254 + wapi_ie->unicast_cipher_suite_count * 4
6255 + 6; /* gp_cipher_suite + preauth + reserved */
6256
6257 if (wapi_ie->bkid_count)
6258 nIeLen += 2 + wapi_ie->bkid_count * 4;
6259
6260 /* nIeLen doesn't count EID and length fields */
6261 session_ptr->pWapiRspIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306262 qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006263 if (NULL == session_ptr->pWapiRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306264 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006265 session_ptr->pWapiRspIE[0] = DOT11F_EID_WAPI;
6266 session_ptr->pWapiRspIE[1] = (uint8_t) nIeLen;
6267 pIeBuf = session_ptr->pWapiRspIE + 2;
6268 /* copy upto akm_suite_count */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306269 qdf_mem_copy(pIeBuf, &wapi_ie->version, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006270 pIeBuf += 4;
6271 if (wapi_ie->akm_suite_count) {
6272 /* copy akm_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306273 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006274 wapi_ie->akm_suites,
6275 wapi_ie->akm_suite_count * 4);
6276 pIeBuf += wapi_ie->akm_suite_count * 4;
6277 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306278 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006279 &wapi_ie->unicast_cipher_suite_count, 2);
6280 pIeBuf += 2;
6281 if (wapi_ie->unicast_cipher_suite_count) {
6282 uint16_t suite_size =
6283 wapi_ie->unicast_cipher_suite_count * 4;
6284 /* copy pwise_cipher_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306285 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006286 wapi_ie->unicast_cipher_suites,
6287 suite_size);
6288 pIeBuf += suite_size;
6289 }
6290 /* gp_cipher_suite */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306291 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006292 wapi_ie->multicast_cipher_suite, 4);
6293 pIeBuf += 4;
6294 /* preauth + reserved */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306295 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006296 wapi_ie->multicast_cipher_suite + 4, 2);
6297 pIeBuf += 2;
6298 if (wapi_ie->bkid_count) {
6299 /* bkid_count */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306300 qdf_mem_copy(pIeBuf, &wapi_ie->bkid_count, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006301 pIeBuf += 2;
6302 /* copy akm_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306303 qdf_mem_copy(pIeBuf, wapi_ie->bkid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006304 wapi_ie->bkid_count * 4);
6305 pIeBuf += wapi_ie->bkid_count * 4;
6306 }
6307 session_ptr->nWapiRspIeLength = nIeLen + 2;
6308 }
6309 }
6310#endif /* FEATURE_WLAN_WAPI */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306311 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006312}
6313
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306314static QDF_STATUS csr_roam_save_security_rsp_ie(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006315 uint32_t sessionId,
6316 eCsrAuthType authType,
6317 tSirBssDescription *pSirBssDesc,
6318 tDot11fBeaconIEs *pIes)
6319{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306320 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006321 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
6322 tDot11fBeaconIEs *pIesLocal = pIes;
6323
6324 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006325 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306326 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006327 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006328
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006329 sme_debug("authType %d session %d", authType, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006330 if ((eCSR_AUTH_TYPE_WPA == authType) ||
6331 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
6332 (eCSR_AUTH_TYPE_RSN == authType) ||
6333 (eCSR_AUTH_TYPE_RSN_PSK == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006334 || (eCSR_AUTH_TYPE_FT_RSN == authType) ||
6335 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006336#ifdef FEATURE_WLAN_WAPI
6337 || (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
6338 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
6339#endif /* FEATURE_WLAN_WAPI */
6340#ifdef WLAN_FEATURE_11W
6341 || (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
6342 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
6343#endif /* FEATURE_WLAN_WAPI */
6344 ) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306345 if (!pIesLocal && !QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006346 (csr_get_parsed_bss_description_ies(pMac,
6347 pSirBssDesc, &pIesLocal)))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006348 sme_err(" cannot parse IEs");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006349 if (pIesLocal) {
6350 status = csr_roam_save_params(pMac, pSession, authType,
6351 pIes, pIesLocal);
6352 if (!pIes)
6353 /* locally allocated */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306354 qdf_mem_free(pIesLocal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006355 }
6356 }
6357 return status;
6358}
6359
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006360/* Returns whether the current association is a 11r assoc or not */
6361bool csr_roam_is11r_assoc(tpAniSirGlobal pMac, uint8_t sessionId)
6362{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006363 return csr_neighbor_roam_is11r_assoc(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006364}
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -08006365
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006366/* Returns whether "Legacy Fast Roaming" is currently enabled...or not */
6367bool csr_roam_is_fast_roam_enabled(tpAniSirGlobal pMac, uint32_t sessionId)
6368{
6369 tCsrRoamSession *pSession = NULL;
6370
6371 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
6372 pSession = CSR_GET_SESSION(pMac, sessionId);
6373 if (NULL != pSession->pCurRoamProfile) {
6374 if (pSession->pCurRoamProfile->csrPersona !=
Anurag Chouhan6d760662016-02-20 16:05:43 +05306375 QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006376 return false;
6377 }
6378 }
6379 }
6380 if (true == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac)) {
6381 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
6382 } else {
6383 return pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
6384 (!csr_is_concurrent_session_running(pMac));
6385 }
6386}
6387
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006388#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
Jeff Johnson29e2ca12016-10-14 12:50:38 -07006389static eCsrPhyMode csr_roamdot11mode_to_phymode(uint8_t dot11mode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006390{
6391 eCsrPhyMode phymode = eCSR_DOT11_MODE_abg;
6392
6393 switch (dot11mode) {
6394 case WNI_CFG_DOT11_MODE_ALL:
6395 phymode = eCSR_DOT11_MODE_abg;
6396 break;
6397 case WNI_CFG_DOT11_MODE_11A:
6398 phymode = eCSR_DOT11_MODE_11a;
6399 break;
6400 case WNI_CFG_DOT11_MODE_11B:
6401 phymode = eCSR_DOT11_MODE_11b;
6402 break;
6403 case WNI_CFG_DOT11_MODE_11G:
6404 phymode = eCSR_DOT11_MODE_11g;
6405 break;
6406 case WNI_CFG_DOT11_MODE_11N:
6407 phymode = eCSR_DOT11_MODE_11n;
6408 break;
6409 case WNI_CFG_DOT11_MODE_11G_ONLY:
6410 phymode = eCSR_DOT11_MODE_11g_ONLY;
6411 break;
6412 case WNI_CFG_DOT11_MODE_11N_ONLY:
6413 phymode = eCSR_DOT11_MODE_11n_ONLY;
6414 break;
6415 case WNI_CFG_DOT11_MODE_11AC:
6416 phymode = eCSR_DOT11_MODE_11ac;
6417 break;
6418 case WNI_CFG_DOT11_MODE_11AC_ONLY:
6419 phymode = eCSR_DOT11_MODE_11ac_ONLY;
6420 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08006421 case WNI_CFG_DOT11_MODE_11AX:
6422 phymode = eCSR_DOT11_MODE_11ax;
6423 break;
6424 case WNI_CFG_DOT11_MODE_11AX_ONLY:
6425 phymode = eCSR_DOT11_MODE_11ax_ONLY;
6426 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006427 default:
6428 break;
6429 }
6430
6431 return phymode;
6432}
6433#endif
6434
6435#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306436static void csr_roam_synch_clean_up(tpAniSirGlobal mac, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006437{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07006438 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006439 struct roam_offload_synch_fail *roam_offload_failed = NULL;
6440 tCsrRoamSession *session = &mac->roam.roamSession[session_id];
6441
6442 /* Clean up the roam synch in progress for LFR3 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306443 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006444 "%s: Roam Synch Failed, Clean Up", __func__);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08006445 session->roam_synch_in_progress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006446
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306447 roam_offload_failed = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006448 sizeof(struct roam_offload_synch_fail));
6449 if (NULL == roam_offload_failed) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306450 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306451 "%s: unable to allocate memory for roam synch fail",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006452 __func__);
6453 return;
6454 }
6455
6456 roam_offload_failed->session_id = session_id;
6457 msg.type = WMA_ROAM_OFFLOAD_SYNCH_FAIL;
6458 msg.reserved = 0;
6459 msg.bodyptr = roam_offload_failed;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -08006460 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006461 &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306462 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006463 "%s: Unable to post WMA_ROAM_OFFLOAD_SYNCH_FAIL to WMA",
6464 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306465 qdf_mem_free(roam_offload_failed);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006466 }
6467}
6468#endif
6469
6470#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6471/**
6472 * csr_roam_copy_ht_profile() - Copy from src to dst
6473 * @dst_profile: Destination HT profile
6474 * @src_profile: Source HT profile
6475 *
6476 * Copy the HT profile from the given source to destination
6477 *
6478 * Return: None
6479 */
6480static void csr_roam_copy_ht_profile(tCsrRoamHTProfile *dst_profile,
6481 tSirSmeHTProfile *src_profile)
6482{
6483 dst_profile->phymode =
6484 csr_roamdot11mode_to_phymode(src_profile->dot11mode);
6485 dst_profile->htCapability = src_profile->htCapability;
6486 dst_profile->htSupportedChannelWidthSet =
6487 src_profile->htSupportedChannelWidthSet;
6488 dst_profile->htRecommendedTxWidthSet =
6489 src_profile->htRecommendedTxWidthSet;
6490 dst_profile->htSecondaryChannelOffset =
6491 src_profile->htSecondaryChannelOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006492 dst_profile->vhtCapability = src_profile->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006493 dst_profile->apCenterChan = src_profile->apCenterChan;
6494 dst_profile->apChanWidth = src_profile->apChanWidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006495}
6496#endif
6497
6498/**
6499 * csr_roam_process_results_default() - Process the result for start bss
6500 * @mac_ctx: Global MAC Context
6501 * @cmd: Command to be processed
6502 * @context: Additional data in context of the cmd
6503 *
6504 * Return: None
6505 */
6506static void csr_roam_process_results_default(tpAniSirGlobal mac_ctx,
6507 tSmeCmd *cmd, void *context, eCsrRoamCompleteResult res)
6508{
6509 uint32_t session_id = cmd->sessionId;
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07006510 tCsrRoamSession *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006511 tCsrRoamInfo roam_info;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306512 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006513
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07006514 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006515 sme_err("Invalid session id %d", session_id);
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07006516 return;
6517 }
6518 session = CSR_GET_SESSION(mac_ctx, session_id);
6519
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006520 sme_debug("receives no association indication");
6521 sme_debug("Assoc ref count: %d", session->bRefAssocStartCnt);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006522 if (CSR_IS_INFRASTRUCTURE(&session->connectedProfile)
6523 || CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ(mac_ctx, session_id)) {
6524 /*
6525 * do not free for the other profiles as we need
6526 * to send down stop BSS later
6527 */
6528 csr_free_connect_bss_desc(mac_ctx, session_id);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08006529 csr_roam_free_connect_profile(&session->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006530 csr_roam_free_connected_info(mac_ctx, &session->connectedInfo);
6531 csr_set_default_dot11_mode(mac_ctx);
6532 }
6533
6534 switch (cmd->u.roamCmd.roamReason) {
6535 /*
6536 * If this transition is because of an 802.11 OID, then we
6537 * transition back to INIT state so we sit waiting for more
6538 * OIDs to be issued and we don't start the IDLE timer.
6539 */
6540 case eCsrSmeIssuedFTReassoc:
6541 case eCsrSmeIssuedAssocToSimilarAP:
6542 case eCsrHddIssued:
6543 case eCsrSmeIssuedDisassocForHandoff:
6544 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
6545 session_id);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306546 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006547 roam_info.pBssDesc = cmd->u.roamCmd.pLastRoamBss;
6548 roam_info.pProfile = &cmd->u.roamCmd.roamProfile;
6549 roam_info.statusCode = session->joinFailStatusCode.statusCode;
6550 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306551 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006552 &session->joinFailStatusCode.bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306553 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006554
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006555 /*
6556 * If Join fails while Handoff is in progress, indicate
6557 * disassociated event to supplicant to reconnect
6558 */
6559 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)) {
6560 csr_neighbor_roam_indicate_connect(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306561 (uint8_t)session_id, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006562 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006563 if (session->bRefAssocStartCnt > 0) {
6564 session->bRefAssocStartCnt--;
6565 if (eCsrJoinFailureDueToConcurrency == res)
6566 csr_roam_call_callback(mac_ctx, session_id,
6567 &roam_info, cmd->u.roamCmd.roamId,
6568 eCSR_ROAM_ASSOCIATION_COMPLETION,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05306569 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006570 else
6571 csr_roam_call_callback(mac_ctx, session_id,
6572 &roam_info, cmd->u.roamCmd.roamId,
6573 eCSR_ROAM_ASSOCIATION_COMPLETION,
6574 eCSR_ROAM_RESULT_FAILURE);
6575 } else {
6576 /*
6577 * bRefAssocStartCnt is not incremented when
6578 * eRoamState == eCsrStopRoamingDueToConcurrency
6579 * in csr_roam_join_next_bss API. so handle this in
6580 * else case by sending assoc failure
6581 */
6582 csr_roam_call_callback(mac_ctx, session_id,
6583 &roam_info, cmd->u.scanCmd.roamId,
6584 eCSR_ROAM_ASSOCIATION_FAILURE,
6585 eCSR_ROAM_RESULT_FAILURE);
6586 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006587 sme_debug("roam(reason %d) failed", cmd->u.roamCmd.roamReason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006588#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6589 sme_qos_update_hand_off((uint8_t) session_id, false);
6590 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
6591 SME_QOS_CSR_DISCONNECT_IND, NULL);
6592#endif
6593 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
6594 eCSR_ROAM_RESULT_FAILURE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006595 break;
6596 case eCsrHddIssuedReassocToSameAP:
6597 case eCsrSmeIssuedReassocToSameAP:
6598 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
6599 session_id);
6600
6601 csr_roam_call_callback(mac_ctx, session_id, NULL,
6602 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
6603 eCSR_ROAM_RESULT_FORCED);
6604#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6605 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
6606 SME_QOS_CSR_DISCONNECT_IND, NULL);
6607#endif
6608 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
6609 eCSR_ROAM_RESULT_FAILURE, false);
6610 break;
6611 case eCsrForcedDisassoc:
6612 case eCsrForcedDeauth:
6613 case eCsrSmeIssuedIbssJoinFailure:
6614 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
6615 session_id);
6616
6617 if (eCsrSmeIssuedIbssJoinFailure == cmd->u.roamCmd.roamReason)
6618 /* notify HDD that IBSS join failed */
6619 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
6620 eCSR_ROAM_IBSS_IND,
6621 eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6622 else
6623 csr_roam_call_callback(mac_ctx, session_id, NULL,
6624 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
6625 eCSR_ROAM_RESULT_FORCED);
6626#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6627 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
6628 SME_QOS_CSR_DISCONNECT_IND,
6629 NULL);
6630#endif
6631 csr_roam_link_down(mac_ctx, session_id);
6632
6633 if (mac_ctx->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006634 sme_warn("FW still in connected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006635 break;
6636 }
6637 break;
6638 case eCsrForcedIbssLeave:
6639 csr_roam_call_callback(mac_ctx, session_id, NULL,
6640 cmd->u.roamCmd.roamId, eCSR_ROAM_IBSS_LEAVE,
6641 eCSR_ROAM_RESULT_IBSS_STOP);
Krunal Soni2c68f232015-10-26 20:52:51 -07006642 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006643 break;
6644 case eCsrForcedDisassocMICFailure:
6645 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
6646 session_id);
6647
6648 csr_roam_call_callback(mac_ctx, session_id, NULL,
6649 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
6650 eCSR_ROAM_RESULT_MIC_FAILURE);
6651#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6652 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
6653 SME_QOS_CSR_DISCONNECT_REQ, NULL);
6654#endif
6655 break;
6656 case eCsrStopBss:
6657 csr_roam_call_callback(mac_ctx, session_id, NULL,
6658 cmd->u.roamCmd.roamId, eCSR_ROAM_INFRA_IND,
6659 eCSR_ROAM_RESULT_INFRA_STOPPED);
6660 break;
6661 case eCsrForcedDisassocSta:
6662 case eCsrForcedDeauthSta:
6663 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
6664 session_id);
6665 session = CSR_GET_SESSION(mac_ctx, session_id);
6666 if (CSR_IS_SESSION_VALID(mac_ctx, session_id) &&
6667 CSR_IS_INFRA_AP(&session->connectedProfile)) {
6668 roam_info.u.pConnectedProfile =
6669 &session->connectedProfile;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306670 qdf_mem_copy(roam_info.peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006671 cmd->u.roamCmd.peerMac,
6672 sizeof(tSirMacAddr));
6673 roam_info.reasonCode = eCSR_ROAM_RESULT_FORCED;
6674 roam_info.statusCode = eSIR_SME_SUCCESS;
6675 status = csr_roam_call_callback(mac_ctx, session_id,
6676 &roam_info, cmd->u.roamCmd.roamId,
6677 eCSR_ROAM_LOSTLINK,
6678 eCSR_ROAM_RESULT_FORCED);
6679 }
6680 break;
6681 case eCsrLostLink1:
6682 /* if lost link roam1 failed, then issue lost link Scan2 ... */
6683 csr_scan_request_lost_link2(mac_ctx, session_id);
6684 break;
6685 case eCsrLostLink2:
6686 /* if lost link roam2 failed, then issue lost link scan3 ... */
6687 csr_scan_request_lost_link3(mac_ctx, session_id);
6688 break;
6689 case eCsrLostLink3:
6690 default:
6691 csr_roam_state_change(mac_ctx,
6692 eCSR_ROAMING_STATE_IDLE, session_id);
6693
6694 /* We are done with one round of lostlink roaming here */
6695 csr_scan_handle_failed_lostlink3(mac_ctx, session_id);
6696 break;
6697 }
6698}
6699
6700/**
6701 * csr_roam_process_start_bss_success() - Process the result for start bss
6702 * @mac_ctx: Global MAC Context
6703 * @cmd: Command to be processed
6704 * @context: Additional data in context of the cmd
6705 *
6706 * Return: None
6707 */
6708static void csr_roam_process_start_bss_success(tpAniSirGlobal mac_ctx,
6709 tSmeCmd *cmd, void *context)
6710{
6711 uint32_t session_id = cmd->sessionId;
6712 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07006713 tCsrRoamSession *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006714 tSirBssDescription *bss_desc = NULL;
6715 tCsrRoamInfo roam_info;
6716 tSirSmeStartBssRsp *start_bss_rsp = NULL;
6717 tCsrScanResult *scan_res = NULL;
6718 eRoamCmdStatus roam_status;
6719 eCsrRoamResult roam_result;
6720 tDot11fBeaconIEs *ies_ptr = NULL;
6721 tSirMacAddr bcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306722 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006723 host_log_ibss_pkt_type *ibss_log;
6724 uint32_t bi;
6725#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6726 tSirSmeHTProfile *src_profile = NULL;
6727 tCsrRoamHTProfile *dst_profile = NULL;
6728#endif
6729
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07006730 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006731 sme_err("Invalid session id %d", session_id);
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07006732 return;
6733 }
6734 session = CSR_GET_SESSION(mac_ctx, session_id);
6735
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006736 /*
6737 * on the StartBss Response, LIM is returning the Bss Description that
6738 * we are beaconing. Add this Bss Description to our scan results and
6739 * chain the Profile to this Bss Description. On a Start BSS, there was
6740 * no detected Bss description (no partner) so we issued the Start Bss
6741 * to start the Ibss without any Bss description. Lim was kind enough
6742 * to return the Bss Description that we start beaconing for the newly
6743 * started Ibss.
6744 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006745 sme_debug("receives start BSS ok indication");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306746 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006747 start_bss_rsp = (tSirSmeStartBssRsp *) context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306748 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006749 if (CSR_IS_IBSS(profile))
6750 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
6751 else if (CSR_IS_INFRA_AP(profile))
6752 session->connectState =
6753 eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07006754 else if (CSR_IS_NDI(profile))
6755 session->connectState = eCSR_CONNECT_STATE_TYPE_NDI_STARTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006756 else
6757 session->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07006758
6759 bss_desc = &start_bss_rsp->bssDescription;
6760 if (CSR_IS_NDI(profile)) {
6761 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
6762 session_id);
6763 csr_roam_save_ndi_connected_info(mac_ctx, session_id, profile,
6764 bss_desc);
6765 roam_info.u.pConnectedProfile = &session->connectedProfile;
6766 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
6767 sizeof(struct qdf_mac_addr));
Naveen Rawatcb186cf2016-07-11 13:47:19 -07006768 } else {
6769 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
6770 session_id);
6771 if (!QDF_IS_STATUS_SUCCESS
6772 (csr_get_parsed_bss_description_ies(mac_ctx, bss_desc,
6773 &ies_ptr))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006774 sme_warn("cannot parse IBSS IEs");
Naveen Rawatcb186cf2016-07-11 13:47:19 -07006775 roam_info.pBssDesc = bss_desc;
6776 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
6777 cmd->u.roamCmd.roamId, eCSR_ROAM_IBSS_IND,
6778 eCSR_ROAM_RESULT_IBSS_START_FAILED);
6779 return;
6780 }
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006781 }
Naveen Rawat334c51b2017-05-05 17:33:32 -07006782 if (!CSR_IS_INFRA_AP(profile) && !CSR_IS_NDI(profile)) {
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006783 scan_res =
6784 csr_scan_append_bss_description(mac_ctx,
6785 bss_desc, ies_ptr, false,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006786 session_id);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006787 }
6788 csr_roam_save_connected_bss_desc(mac_ctx, session_id, bss_desc);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08006789 csr_roam_free_connect_profile(&session->connectedProfile);
6790 csr_roam_free_connected_info(mac_ctx, &session->connectedInfo);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07006791 csr_roam_save_connected_infomation(mac_ctx, session_id,
6792 profile, bss_desc, ies_ptr);
6793 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306794 sizeof(struct qdf_mac_addr));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006795 /* We are done with the IEs so free it */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306796 qdf_mem_free(ies_ptr);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006797#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6798 WLAN_HOST_DIAG_LOG_ALLOC(ibss_log,
6799 host_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6800 if (ibss_log) {
6801 if (CSR_INVALID_SCANRESULT_HANDLE ==
6802 cmd->u.roamCmd.hBSSList) {
6803 /*
6804 * We start the IBSS (didn't find any
6805 * matched IBSS out there)
6806 */
6807 ibss_log->eventId =
6808 WLAN_IBSS_EVENT_START_IBSS_RSP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006809 } else {
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006810 ibss_log->eventId =
6811 WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
6812 }
6813 if (bss_desc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306814 qdf_mem_copy(ibss_log->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306815 bss_desc->bssId, QDF_MAC_ADDR_SIZE);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006816 ibss_log->operatingChannel =
6817 bss_desc->channelId;
6818 }
6819 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(
6820 mac_ctx,
6821 WNI_CFG_BEACON_INTERVAL,
6822 &bi)))
6823 /* U8 is not enough for BI */
6824 ibss_log->beaconInterval = (uint8_t) bi;
6825 WLAN_HOST_DIAG_LOG_REPORT(ibss_log);
6826 }
6827#endif
6828 /*
6829 * Only set context for non-WDS_STA. We don't even need it for
6830 * WDS_AP. But since the encryption.
6831 * is WPA2-PSK so it won't matter.
6832 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08006833 if (session->pCurRoamProfile &&
6834 !CSR_IS_INFRA_AP(session->pCurRoamProfile)) {
6835 if (CSR_IS_ENC_TYPE_STATIC(
6836 profile->negotiatedUCEncryptionType)) {
6837 /*
6838 * Issue the set Context request to LIM to establish
6839 * the Broadcast STA context for the Ibss. In Rome IBSS
6840 * case, dummy key installation will break proper BSS
6841 * key installation, so skip it.
6842 */
6843 if (!CSR_IS_IBSS(session->pCurRoamProfile)) {
6844 /* NO keys. these key parameters don't matter */
6845 csr_roam_issue_set_context_req(mac_ctx,
6846 session_id,
6847 profile->negotiatedMCEncryptionType,
6848 bss_desc, &bcast_mac, false,
6849 false, eSIR_TX_RX, 0, 0, NULL, 0);
6850 }
6851 }
6852 if (CSR_IS_IBSS(session->pCurRoamProfile) &&
6853 (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
6854 profile->negotiatedUCEncryptionType ||
6855 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
6856 profile->negotiatedUCEncryptionType ||
6857 eCSR_ENCRYPT_TYPE_TKIP ==
6858 profile->negotiatedUCEncryptionType ||
6859 eCSR_ENCRYPT_TYPE_AES ==
6860 profile->negotiatedUCEncryptionType)) {
6861 roam_info.fAuthRequired = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006862 }
6863 }
6864 /*
6865 * Only tell upper layer is we start the BSS because Vista doesn't like
6866 * multiple connection indications. If we don't start the BSS ourself,
6867 * handler of eSIR_SME_JOINED_NEW_BSS will trigger the connection start
6868 * indication in Vista
6869 */
6870 if (!CSR_IS_JOIN_TO_IBSS(profile)) {
6871 roam_status = eCSR_ROAM_IBSS_IND;
6872 roam_result = eCSR_ROAM_RESULT_IBSS_STARTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006873 if (CSR_IS_INFRA_AP(profile)) {
6874 roam_status = eCSR_ROAM_INFRA_IND;
6875 roam_result = eCSR_ROAM_RESULT_INFRA_STARTED;
6876 }
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07006877 roam_info.staId = (uint8_t) start_bss_rsp->staId;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07006878 if (CSR_IS_NDI(profile)) {
6879 csr_roam_update_ndp_return_params(mac_ctx,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07006880 eCsrStartBssSuccess,
6881 &roam_status,
6882 &roam_result,
6883 &roam_info);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07006884 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006885 /*
6886 * Only tell upper layer is we start the BSS because Vista
6887 * doesn't like multiple connection indications. If we don't
6888 * start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS
6889 * will trigger the connection start indication in Vista
6890 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006891 roam_info.statusCode = session->joinFailStatusCode.statusCode;
6892 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
6893 /* We start the IBSS (didn't find any matched IBSS out there) */
6894 roam_info.pBssDesc = bss_desc;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07006895 if (bss_desc)
6896 qdf_mem_copy(roam_info.bssid.bytes, bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306897 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006898 if (!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
6899 (csr_is_concurrent_session_running(mac_ctx))) {
6900 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
6901 }
6902#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6903 dst_profile = &session->connectedProfile.HTProfile;
6904 src_profile = &start_bss_rsp->HTProfile;
6905 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306906 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006907 csr_roam_copy_ht_profile(dst_profile, src_profile);
6908#endif
6909 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
6910 cmd->u.roamCmd.roamId,
6911 roam_status, roam_result);
6912 }
6913
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006914}
6915
6916/**
6917 * csr_roam_process_join_res() - Process the Join results
6918 * @mac_ctx: Global MAC Context
6919 * @result: Result after the command was processed
6920 * @cmd: Command to be processed
6921 * @context: Additional data in context of the cmd
6922 *
6923 * Process the join results which are obtained in a succesful join
6924 *
6925 * Return: None
6926 */
6927static void csr_roam_process_join_res(tpAniSirGlobal mac_ctx,
6928 eCsrRoamCompleteResult res, tSmeCmd *cmd, void *context)
6929{
6930 tSirMacAddr bcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
6931 sme_QosAssocInfo assoc_info;
6932 uint32_t key_timeout_interval = 0;
6933 uint8_t acm_mask = 0; /* HDD needs ACM mask in assoc rsp callback */
6934 uint32_t session_id = cmd->sessionId;
6935 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07006936 tCsrRoamSession *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006937 tSirBssDescription *bss_desc = NULL;
6938 tCsrScanResult *scan_res = NULL;
6939 sme_qos_csr_event_indType ind_qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006940#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6941 tSirSmeHTProfile *src_profile = NULL;
6942 tCsrRoamHTProfile *dst_profile = NULL;
6943#endif
6944 tCsrRoamConnectedProfile *conn_profile = NULL;
6945 tDot11fBeaconIEs *ies_ptr = NULL;
6946 tCsrRoamInfo roam_info;
6947 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
6948 tSirSmeJoinRsp *join_rsp = (tSirSmeJoinRsp *) context;
6949 uint32_t len;
6950
Nishank Aggarwal68d39272017-05-15 17:05:14 +05306951 if (!join_rsp) {
6952 sme_err("join_rsp is NULL");
6953 return;
6954 }
6955
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07006956 if (!CSR_IS_SESSION_VALID(mac_ctx, session_id)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006957 sme_err("Invalid session id %d", session_id);
Naveen Rawat7ecf53d2016-06-27 15:31:48 -07006958 return;
6959 }
6960 session = CSR_GET_SESSION(mac_ctx, session_id);
6961
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006962 conn_profile = &session->connectedProfile;
Anurag Chouhan5de8d172016-07-13 14:44:28 +05306963 if (eCsrReassocSuccess == res) {
6964 roam_info.reassoc = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006965 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
Anurag Chouhan5de8d172016-07-13 14:44:28 +05306966 } else {
6967 roam_info.reassoc = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006968 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
Anurag Chouhan5de8d172016-07-13 14:44:28 +05306969 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07006970 sme_debug("receives association indication");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306971 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006972 /* always free the memory here */
6973 if (session->pWpaRsnRspIE) {
6974 session->nWpaRsnRspIeLength = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306975 qdf_mem_free(session->pWpaRsnRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006976 session->pWpaRsnRspIE = NULL;
6977 }
6978#ifdef FEATURE_WLAN_WAPI
6979 if (session->pWapiRspIE) {
6980 session->nWapiRspIeLength = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306981 qdf_mem_free(session->pWapiRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006982 session->pWapiRspIE = NULL;
6983 }
6984#endif /* FEATURE_WLAN_WAPI */
6985#ifdef FEATURE_WLAN_BTAMP_UT_RF
6986 session->maxRetryCount = 0;
6987 csr_roam_stop_join_retry_timer(mac_ctx, session_id);
6988#endif
6989 /*
6990 * Reset remain_in_power_active_till_dhcp as
6991 * it might have been set by last failed secured connection.
6992 * It should be set only for secured connection.
6993 */
6994 ps_global_info->remain_in_power_active_till_dhcp = false;
6995 if (CSR_IS_INFRASTRUCTURE(profile))
6996 session->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
6997 else
6998 session->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
6999 /*
7000 * Use the last connected bssdesc for reassoc-ing to the same AP.
7001 * NOTE: What to do when reassoc to a different AP???
7002 */
7003 if ((eCsrHddIssuedReassocToSameAP == cmd->u.roamCmd.roamReason)
7004 || (eCsrSmeIssuedReassocToSameAP ==
7005 cmd->u.roamCmd.roamReason)) {
7006 bss_desc = session->pConnectBssDesc;
7007 if (bss_desc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307008 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307009 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007010 } else {
7011 if (cmd->u.roamCmd.pRoamBssEntry) {
7012 scan_res = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
7013 tCsrScanResult, Link);
7014 if (scan_res != NULL) {
7015 bss_desc = &scan_res->Result.BssDescriptor;
7016 ies_ptr = (tDot11fBeaconIEs *)
7017 (scan_res->Result.pvIes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307018 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307019 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007020 }
7021 }
7022 }
7023 if (bss_desc) {
7024 roam_info.staId = STA_INVALID_IDX;
7025 csr_roam_save_connected_infomation(mac_ctx, session_id,
7026 profile, bss_desc, ies_ptr);
7027 /* Save WPA/RSN IE */
7028 csr_roam_save_security_rsp_ie(mac_ctx, session_id,
7029 profile->negotiatedAuthType, bss_desc, ies_ptr);
7030#ifdef FEATURE_WLAN_ESE
7031 roam_info.isESEAssoc = conn_profile->isESEAssoc;
7032#endif
7033
7034 /*
7035 * csr_roam_state_change also affects sub-state.
7036 * Hence, csr_roam_state_change happens first and then
7037 * substate change.
7038 * Moving even save profile above so that below
7039 * mentioned conditon is also met.
7040 * JEZ100225: Moved to after saving the profile.
7041 * Fix needed in main/latest
7042 */
7043 csr_roam_state_change(mac_ctx,
7044 eCSR_ROAMING_STATE_JOINED, session_id);
7045
7046 /*
7047 * Make sure the Set Context is issued before link
7048 * indication to NDIS. After link indication is
7049 * made to NDIS, frames could start flowing.
7050 * If we have not set context with LIM, the frames
7051 * will be dropped for the security context may not
7052 * be set properly.
7053 *
7054 * this was causing issues in the 2c_wlan_wep WHQL test
7055 * when the SetContext was issued after the link
7056 * indication. (Link Indication happens in the
7057 * profFSMSetConnectedInfra call).
7058 *
7059 * this reordering was done on titan_prod_usb branch
7060 * and is being replicated here.
7061 */
7062
7063 if (CSR_IS_ENC_TYPE_STATIC
7064 (profile->negotiatedUCEncryptionType) &&
7065 !profile->bWPSAssociation) {
7066 /*
7067 * Issue the set Context request to LIM to establish
7068 * the Unicast STA context
7069 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307070 if (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007071 csr_roam_issue_set_context_req(mac_ctx,
7072 session_id,
7073 profile->negotiatedUCEncryptionType,
7074 bss_desc, &(bss_desc->bssId),
7075 false, true,
7076 eSIR_TX_RX, 0, 0, NULL, 0))) {
7077 /* NO keys. these key parameters don't matter */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007078 sme_err("Set context for unicast fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007079 csr_roam_substate_change(mac_ctx,
7080 eCSR_ROAM_SUBSTATE_NONE, session_id);
7081 }
7082 /*
7083 * Issue the set Context request to LIM
7084 * to establish the Broadcast STA context
7085 * NO keys. these key parameters don't matter
7086 */
7087 csr_roam_issue_set_context_req(mac_ctx, session_id,
7088 profile->negotiatedMCEncryptionType,
7089 bss_desc, &bcast_mac, false, false,
7090 eSIR_TX_RX, 0, 0, NULL, 0);
7091 } else {
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007092 /* Need to wait for supplicant authtication */
7093 roam_info.fAuthRequired = true;
7094 /*
7095 * Set the substate to WaitForKey in case
7096 * authentiation is needed
7097 */
7098 csr_roam_substate_change(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007099 eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY,
7100 session_id);
7101
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007102 /*
7103 * Set remain_in_power_active_till_dhcp to make
7104 * sure we wait for until keys are set before
7105 * going into BMPS.
7106 */
7107 ps_global_info->remain_in_power_active_till_dhcp
7108 = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007109
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007110 if (profile->bWPSAssociation)
7111 key_timeout_interval =
7112 CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
7113 else
7114 key_timeout_interval =
7115 CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007116
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007117 /* Save session_id in case of timeout */
7118 mac_ctx->roam.WaitForKeyTimerInfo.sessionId =
7119 (uint8_t) session_id;
7120 /*
7121 * This time should be long enough for the rest
7122 * of the process plus setting key
7123 */
7124 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007125 (csr_roam_start_wait_for_key_timer(
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007126 mac_ctx, key_timeout_interval))
7127 ) {
7128 /* Reset state so nothing is blocked. */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007129 sme_err("Failed preauth timer start");
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -08007130 csr_roam_substate_change(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007131 eCSR_ROAM_SUBSTATE_NONE,
7132 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007133 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007134 }
7135
7136 assoc_info.pBssDesc = bss_desc; /* could be NULL */
7137 assoc_info.pProfile = profile;
7138 if (context) {
7139#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007140 if (session->roam_synch_in_progress)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307141 QDF_TRACE(QDF_MODULE_ID_SME,
7142 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007143 FL("LFR3:Clear Connected info"));
7144#endif
7145 csr_roam_free_connected_info(mac_ctx,
7146 &session->connectedInfo);
7147 len = join_rsp->assocReqLength +
7148 join_rsp->assocRspLength +
7149 join_rsp->beaconLength;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007150 len += join_rsp->parsedRicRspLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007151#ifdef FEATURE_WLAN_ESE
7152 len += join_rsp->tspecIeLen;
7153#endif
7154 if (len) {
7155 session->connectedInfo.pbFrames =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307156 qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007157 if (session->connectedInfo.pbFrames !=
7158 NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307159 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007160 session->connectedInfo.pbFrames,
7161 join_rsp->frames, len);
7162 session->connectedInfo.nAssocReqLength =
7163 join_rsp->assocReqLength;
7164 session->connectedInfo.nAssocRspLength =
7165 join_rsp->assocRspLength;
7166 session->connectedInfo.nBeaconLength =
7167 join_rsp->beaconLength;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007168 session->connectedInfo.nRICRspLength =
7169 join_rsp->parsedRicRspLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007170#ifdef FEATURE_WLAN_ESE
7171 session->connectedInfo.nTspecIeLength =
7172 join_rsp->tspecIeLen;
7173#endif
7174 roam_info.nAssocReqLength =
7175 join_rsp->assocReqLength;
7176 roam_info.nAssocRspLength =
7177 join_rsp->assocRspLength;
7178 roam_info.nBeaconLength =
7179 join_rsp->beaconLength;
7180 roam_info.pbFrames =
7181 session->connectedInfo.pbFrames;
7182 }
7183 }
7184 if (cmd->u.roamCmd.fReassoc)
7185 roam_info.fReassocReq =
7186 roam_info.fReassocRsp = true;
7187 conn_profile->vht_channel_width =
7188 join_rsp->vht_channel_width;
7189 session->connectedInfo.staId =
7190 (uint8_t) join_rsp->staId;
7191 roam_info.staId = (uint8_t) join_rsp->staId;
7192 roam_info.ucastSig = (uint8_t) join_rsp->ucastSig;
7193 roam_info.bcastSig = (uint8_t) join_rsp->bcastSig;
7194 roam_info.timingMeasCap = join_rsp->timingMeasCap;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05307195 roam_info.chan_info.nss = join_rsp->nss;
7196 roam_info.chan_info.rate_flags =
7197 join_rsp->max_rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007198#ifdef FEATURE_WLAN_TDLS
7199 roam_info.tdls_prohibited = join_rsp->tdls_prohibited;
7200 roam_info.tdls_chan_swit_prohibited =
7201 join_rsp->tdls_chan_swit_prohibited;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007202 sme_debug("tdls:prohibit: %d chan_swit_prohibit: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007203 roam_info.tdls_prohibited,
7204 roam_info.tdls_chan_swit_prohibited);
7205#endif
7206#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
7207 src_profile = &join_rsp->HTProfile;
7208 dst_profile = &conn_profile->HTProfile;
7209 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05307210 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007211 csr_roam_copy_ht_profile(dst_profile,
7212 src_profile);
7213#endif
Anurag Chouhan5de8d172016-07-13 14:44:28 +05307214 roam_info.vht_caps = join_rsp->vht_caps;
7215 roam_info.ht_caps = join_rsp->ht_caps;
7216 roam_info.hs20vendor_ie = join_rsp->hs20vendor_ie;
7217 roam_info.ht_operation = join_rsp->ht_operation;
7218 roam_info.vht_operation = join_rsp->vht_operation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007219 } else {
7220 if (cmd->u.roamCmd.fReassoc) {
7221 roam_info.fReassocReq =
7222 roam_info.fReassocRsp = true;
7223 roam_info.nAssocReqLength =
7224 session->connectedInfo.nAssocReqLength;
7225 roam_info.nAssocRspLength =
7226 session->connectedInfo.nAssocRspLength;
7227 roam_info.nBeaconLength =
7228 session->connectedInfo.nBeaconLength;
7229 roam_info.pbFrames =
7230 session->connectedInfo.pbFrames;
7231 }
7232 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007233 /*
7234 * Update the staId from the previous connected profile info
7235 * as the reassociation is triggred at SME/HDD
7236 */
7237
7238 if ((eCsrHddIssuedReassocToSameAP ==
7239 cmd->u.roamCmd.roamReason) ||
7240 (eCsrSmeIssuedReassocToSameAP ==
7241 cmd->u.roamCmd.roamReason))
7242 roam_info.staId = session->connectedInfo.staId;
7243
7244#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7245 /*
7246 * Indicate SME-QOS with reassoc success event,
7247 * only after copying the frames
7248 */
7249 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id, ind_qos,
7250 &assoc_info);
7251#endif
7252 roam_info.pBssDesc = bss_desc;
7253 roam_info.statusCode =
7254 session->joinFailStatusCode.statusCode;
7255 roam_info.reasonCode =
7256 session->joinFailStatusCode.reasonCode;
7257#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7258 acm_mask = sme_qos_get_acm_mask(mac_ctx, bss_desc, NULL);
7259#endif
7260 conn_profile->acm_mask = acm_mask;
7261 /*
7262 * start UAPSD if uapsd_mask is not 0 because HDD will
7263 * configure for trigger frame It may be better to let QoS do
7264 * this????
7265 */
7266 if (conn_profile->modifyProfileFields.uapsd_mask) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007267 sme_err(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007268 " uapsd_mask (0x%X) set, request UAPSD now",
7269 conn_profile->modifyProfileFields.uapsd_mask);
7270 sme_ps_start_uapsd(mac_ctx, session_id,
7271 NULL, NULL);
7272 }
7273 conn_profile->dot11Mode = session->bssParams.uCfgDot11Mode;
7274 roam_info.u.pConnectedProfile = conn_profile;
7275
7276 if (session->bRefAssocStartCnt > 0) {
7277 session->bRefAssocStartCnt--;
7278 if (!IS_FEATURE_SUPPORTED_BY_FW
7279 (SLM_SESSIONIZATION) &&
7280 (csr_is_concurrent_session_running(mac_ctx))) {
7281 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
7282 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007283 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
7284 cmd->u.roamCmd.roamId,
7285 eCSR_ROAM_ASSOCIATION_COMPLETION,
7286 eCSR_ROAM_RESULT_ASSOCIATED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007287 }
7288
7289 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
7290 eCSR_ROAM_RESULT_NONE, true);
7291 csr_reset_pmkid_candidate_list(mac_ctx, session_id);
7292#ifdef FEATURE_WLAN_WAPI
7293 csr_reset_bkid_candidate_list(mac_ctx, session_id);
7294#endif
7295 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007296 sme_warn("Roam command doesn't have a BSS desc");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007297 }
7298 /* Not to signal link up because keys are yet to be set.
7299 * The linkup function will overwrite the sub-state that
7300 * we need to keep at this point.
7301 */
7302 if (!CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id)) {
7303#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007304 if (session->roam_synch_in_progress) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307305 QDF_TRACE(QDF_MODULE_ID_SME,
7306 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007307 FL
7308 ("NO CSR_IS_WAIT_FOR_KEY -> csr_roam_link_up"));
7309 }
7310#endif
7311 csr_roam_link_up(mac_ctx, conn_profile->bssid);
7312 }
7313}
7314
7315/**
7316 * csr_roam_process_results() - Process the Roam Results
7317 * @mac_ctx: Global MAC Context
7318 * @cmd: Command that has been processed
7319 * @res: Results available after processing the command
7320 * @context: Context
7321 *
7322 * Process the available results and make an appropriate decision
7323 *
7324 * Return: true if the command can be released, else not.
7325 */
7326static bool csr_roam_process_results(tpAniSirGlobal mac_ctx, tSmeCmd *cmd,
7327 eCsrRoamCompleteResult res, void *context)
7328{
7329 bool release_cmd = true;
7330 tSirBssDescription *bss_desc = NULL;
7331 tCsrRoamInfo roam_info;
7332 uint32_t session_id = cmd->sessionId;
7333 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
7334 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
7335 eRoamCmdStatus roam_status;
7336 eCsrRoamResult roam_result;
7337 host_log_ibss_pkt_type *ibss_log;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007338 tSirSmeStartBssRsp *start_bss_rsp = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007339
7340 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007341 sme_err("session %d not found ", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007342 return false;
7343 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007344
7345 sme_debug("Processing ROAM results...");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007346 switch (res) {
7347 case eCsrJoinSuccess:
7348 case eCsrReassocSuccess:
7349 csr_roam_process_join_res(mac_ctx, res, cmd, context);
7350 break;
7351 case eCsrStartBssSuccess:
7352 csr_roam_process_start_bss_success(mac_ctx, cmd, context);
7353 break;
7354 case eCsrStartBssFailure:
7355#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7356 WLAN_HOST_DIAG_LOG_ALLOC(ibss_log,
7357 host_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7358 if (ibss_log) {
7359 ibss_log->status = WLAN_IBSS_STATUS_FAILURE;
7360 WLAN_HOST_DIAG_LOG_REPORT(ibss_log);
7361 }
7362#endif
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007363 start_bss_rsp = (tSirSmeStartBssRsp *)context;
7364 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007365 roam_status = eCSR_ROAM_IBSS_IND;
7366 roam_result = eCSR_ROAM_RESULT_IBSS_STARTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007367 if (CSR_IS_INFRA_AP(profile)) {
7368 roam_status = eCSR_ROAM_INFRA_IND;
7369 roam_result = eCSR_ROAM_RESULT_INFRA_START_FAILED;
7370 }
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007371 if (CSR_IS_NDI(profile)) {
7372 csr_roam_update_ndp_return_params(mac_ctx,
7373 eCsrStartBssFailure,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07007374 &roam_status, &roam_result, &roam_info);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07007375 }
7376
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307377 if (context)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007378 bss_desc = (tSirBssDescription *) context;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307379 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007380 bss_desc = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007381 roam_info.pBssDesc = bss_desc;
7382 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
7383 cmd->u.roamCmd.roamId, roam_status,
7384 roam_result);
7385 csr_set_default_dot11_mode(mac_ctx);
7386 break;
7387 case eCsrSilentlyStopRoaming:
7388 /*
7389 * We are here because we try to start the same IBSS.
7390 * No message to PE. return the roaming state to Joined.
7391 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007392 sme_debug("receives silently stop roam ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007393 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
7394 session_id);
7395 csr_roam_substate_change(mac_ctx, eCSR_ROAM_SUBSTATE_NONE,
7396 session_id);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307397 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007398 roam_info.pBssDesc = session->pConnectBssDesc;
7399 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307400 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007401 &roam_info.pBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307402 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007403 /*
7404 * Since there is no change in the current state, simply pass
7405 * back no result otherwise HDD may be mistakenly mark to
7406 * disconnected state.
7407 */
7408 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
7409 cmd->u.roamCmd.roamId,
7410 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE);
7411 break;
7412 case eCsrSilentlyStopRoamingSaveState:
7413 /* We are here because we try to connect to the same AP */
7414 /* No message to PE */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007415 sme_debug("receives silently stop roaming indication");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307416 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007417
7418 /* to aviod resetting the substate to NONE */
7419 mac_ctx->roam.curState[session_id] = eCSR_ROAMING_STATE_JOINED;
7420 /*
7421 * No need to change substate to wai_for_key because there
7422 * is no state change
7423 */
7424 roam_info.pBssDesc = session->pConnectBssDesc;
7425 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307426 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007427 &roam_info.pBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05307428 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007429 roam_info.statusCode = session->joinFailStatusCode.statusCode;
7430 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
7431 roam_info.nBeaconLength = session->connectedInfo.nBeaconLength;
7432 roam_info.nAssocReqLength =
7433 session->connectedInfo.nAssocReqLength;
7434 roam_info.nAssocRspLength =
7435 session->connectedInfo.nAssocRspLength;
7436 roam_info.pbFrames = session->connectedInfo.pbFrames;
7437 roam_info.staId = session->connectedInfo.staId;
7438 roam_info.u.pConnectedProfile = &session->connectedProfile;
Abhishek Singhacfdc922015-12-30 17:31:21 +05307439 if (0 == roam_info.staId)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307440 QDF_ASSERT(0);
Abhishek Singhacfdc922015-12-30 17:31:21 +05307441
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007442 session->bRefAssocStartCnt--;
7443 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
7444 cmd->u.roamCmd.roamId,
7445 eCSR_ROAM_ASSOCIATION_COMPLETION,
7446 eCSR_ROAM_RESULT_ASSOCIATED);
7447 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
7448 eCSR_ROAM_RESULT_ASSOCIATED, true);
7449 break;
7450 case eCsrReassocFailure:
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007451 /*
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307452 * Currently Reassoc failure is handled through eCsrJoinFailure
7453 * Need to revisit for eCsrReassocFailure handling
7454 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007455#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7456 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
7457 SME_QOS_CSR_REASSOC_FAILURE, NULL);
7458#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007459 break;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07007460 case eCsrStopBssSuccess:
7461 if (CSR_IS_NDI(profile)) {
7462 csr_roam_update_ndp_return_params(mac_ctx, res,
7463 &roam_status, &roam_result, &roam_info);
7464 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
7465 cmd->u.roamCmd.roamId,
7466 roam_status, roam_result);
7467 }
7468 break;
7469 case eCsrStopBssFailure:
7470 if (CSR_IS_NDI(profile)) {
7471 csr_roam_update_ndp_return_params(mac_ctx, res,
7472 &roam_status, &roam_result, &roam_info);
7473 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
7474 cmd->u.roamCmd.roamId,
7475 roam_status, roam_result);
7476 }
7477 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007478 case eCsrJoinFailure:
7479 case eCsrNothingToJoin:
7480 case eCsrJoinFailureDueToConcurrency:
7481 default:
7482 csr_roam_process_results_default(mac_ctx, cmd, context, res);
7483 break;
7484 }
7485 return release_cmd;
7486}
7487
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307488QDF_STATUS csr_roam_copy_profile(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007489 tCsrRoamProfile *pDstProfile,
7490 tCsrRoamProfile *pSrcProfile)
7491{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307492 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007493 uint32_t size = 0;
7494
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307495 qdf_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007496 if (pSrcProfile->BSSIDs.numOfBSSIDs) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307497 size = sizeof(struct qdf_mac_addr) * pSrcProfile->BSSIDs.
7498 numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307499 pDstProfile->BSSIDs.bssid = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007500 if (NULL == pDstProfile->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307501 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007502 goto end;
7503 }
7504 pDstProfile->BSSIDs.numOfBSSIDs =
7505 pSrcProfile->BSSIDs.numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307506 qdf_mem_copy(pDstProfile->BSSIDs.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007507 pSrcProfile->BSSIDs.bssid, size);
7508 }
7509 if (pSrcProfile->SSIDs.numOfSSIDs) {
7510 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307511 pDstProfile->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007512 if (NULL == pDstProfile->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307513 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007514 goto end;
7515 }
7516 pDstProfile->SSIDs.numOfSSIDs =
7517 pSrcProfile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307518 qdf_mem_copy(pDstProfile->SSIDs.SSIDList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007519 pSrcProfile->SSIDs.SSIDList, size);
7520 }
7521 if (pSrcProfile->nWPAReqIELength) {
7522 pDstProfile->pWPAReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307523 qdf_mem_malloc(pSrcProfile->nWPAReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007524 if (NULL == pDstProfile->pWPAReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307525 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007526 goto end;
7527 }
7528 pDstProfile->nWPAReqIELength =
7529 pSrcProfile->nWPAReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307530 qdf_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007531 pSrcProfile->nWPAReqIELength);
7532 }
7533 if (pSrcProfile->nRSNReqIELength) {
7534 pDstProfile->pRSNReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307535 qdf_mem_malloc(pSrcProfile->nRSNReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007536 if (NULL == pDstProfile->pRSNReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307537 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007538 goto end;
7539 }
7540 pDstProfile->nRSNReqIELength =
7541 pSrcProfile->nRSNReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307542 qdf_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007543 pSrcProfile->nRSNReqIELength);
7544 }
7545#ifdef FEATURE_WLAN_WAPI
7546 if (pSrcProfile->nWAPIReqIELength) {
7547 pDstProfile->pWAPIReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307548 qdf_mem_malloc(pSrcProfile->nWAPIReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007549 if (NULL == pDstProfile->pWAPIReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307550 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007551 goto end;
7552 }
7553 pDstProfile->nWAPIReqIELength =
7554 pSrcProfile->nWAPIReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307555 qdf_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007556 pSrcProfile->nWAPIReqIELength);
7557 }
7558#endif /* FEATURE_WLAN_WAPI */
7559 if (pSrcProfile->nAddIEScanLength) {
7560 pDstProfile->pAddIEScan =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307561 qdf_mem_malloc(pSrcProfile->nAddIEScanLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007562 if (NULL == pDstProfile->pAddIEScan) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307563 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007564 goto end;
7565 }
7566 pDstProfile->nAddIEScanLength =
7567 pSrcProfile->nAddIEScanLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307568 qdf_mem_copy(pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007569 pSrcProfile->nAddIEScanLength);
7570 }
7571 if (pSrcProfile->nAddIEAssocLength) {
7572 pDstProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307573 qdf_mem_malloc(pSrcProfile->nAddIEAssocLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007574 if (NULL == pDstProfile->pAddIEAssoc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307575 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007576 goto end;
7577 }
7578 pDstProfile->nAddIEAssocLength =
7579 pSrcProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307580 qdf_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007581 pSrcProfile->nAddIEAssocLength);
7582 }
7583 if (pSrcProfile->ChannelInfo.ChannelList) {
7584 pDstProfile->ChannelInfo.ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307585 qdf_mem_malloc(pSrcProfile->ChannelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007586 numOfChannels);
7587 if (NULL == pDstProfile->ChannelInfo.ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307588 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007589 goto end;
7590 }
7591 pDstProfile->ChannelInfo.numOfChannels =
7592 pSrcProfile->ChannelInfo.numOfChannels;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307593 qdf_mem_copy(pDstProfile->ChannelInfo.ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007594 pSrcProfile->ChannelInfo.ChannelList,
7595 pSrcProfile->ChannelInfo.numOfChannels);
7596 }
7597 pDstProfile->AuthType = pSrcProfile->AuthType;
7598 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
7599 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
7600 pDstProfile->negotiatedUCEncryptionType =
7601 pSrcProfile->negotiatedUCEncryptionType;
7602 pDstProfile->negotiatedMCEncryptionType =
7603 pSrcProfile->negotiatedMCEncryptionType;
7604 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
7605#ifdef WLAN_FEATURE_11W
7606 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
7607 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
7608 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
7609#endif
7610 pDstProfile->BSSType = pSrcProfile->BSSType;
7611 pDstProfile->phyMode = pSrcProfile->phyMode;
7612 pDstProfile->csrPersona = pSrcProfile->csrPersona;
7613
7614#ifdef FEATURE_WLAN_WAPI
7615 if (csr_is_profile_wapi(pSrcProfile))
7616 if (pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
7617 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
7618#endif /* FEATURE_WLAN_WAPI */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007619 pDstProfile->ch_params.ch_width = pSrcProfile->ch_params.ch_width;
7620 pDstProfile->ch_params.center_freq_seg0 =
7621 pSrcProfile->ch_params.center_freq_seg0;
7622 pDstProfile->ch_params.center_freq_seg1 =
7623 pSrcProfile->ch_params.center_freq_seg1;
7624 pDstProfile->ch_params.sec_ch_offset =
7625 pSrcProfile->ch_params.sec_ch_offset;
7626 /*Save the WPS info */
7627 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
7628 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
7629 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
7630 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
7631 pDstProfile->privacy = pSrcProfile->privacy;
7632 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
7633 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
7634 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
7635 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
7636 pDstProfile->SSIDs.SSIDList[0].ssidHidden =
7637 pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
7638 pDstProfile->protEnabled = pSrcProfile->protEnabled;
7639 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
7640 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
7641 pDstProfile->wps_state = pSrcProfile->wps_state;
7642 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
7643 pDstProfile->sap_dot11mc = pSrcProfile->sap_dot11mc;
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +05307644 pDstProfile->do_not_roam = pSrcProfile->do_not_roam;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307645 qdf_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007646 sizeof(pDstProfile->Keys));
7647#ifdef WLAN_FEATURE_11W
7648 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
7649 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
7650 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
7651#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007652 if (pSrcProfile->MDID.mdiePresent) {
7653 pDstProfile->MDID.mdiePresent = 1;
7654 pDstProfile->MDID.mobilityDomain =
7655 pSrcProfile->MDID.mobilityDomain;
7656 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307657 qdf_mem_copy(&pDstProfile->addIeParams, &pSrcProfile->addIeParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007658 sizeof(tSirAddIeParams));
Agrawal Ashish06e76d22016-08-18 16:44:48 +05307659 if (pSrcProfile->supported_rates.numRates) {
7660 qdf_mem_copy(pDstProfile->supported_rates.rate,
7661 pSrcProfile->supported_rates.rate,
7662 pSrcProfile->supported_rates.numRates);
7663 pDstProfile->supported_rates.numRates =
7664 pSrcProfile->supported_rates.numRates;
7665 }
7666 if (pSrcProfile->extended_rates.numRates) {
7667 qdf_mem_copy(pDstProfile->extended_rates.rate,
7668 pSrcProfile->extended_rates.rate,
7669 pSrcProfile->extended_rates.numRates);
7670 pDstProfile->extended_rates.numRates =
7671 pSrcProfile->extended_rates.numRates;
7672 }
Arif Hussain671a1902017-03-17 09:08:32 -07007673 pDstProfile->cac_duration_ms = pSrcProfile->cac_duration_ms;
7674 pDstProfile->dfs_regdomain = pSrcProfile->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007675end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307676 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007677 csr_release_profile(pMac, pDstProfile);
7678 pDstProfile = NULL;
7679 }
7680
7681 return status;
7682}
7683
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307684QDF_STATUS csr_roam_copy_connected_profile(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007685 uint32_t sessionId, tCsrRoamProfile *pDstProfile)
7686{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307687 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007688 tCsrRoamConnectedProfile *pSrcProfile =
7689 &pMac->roam.roamSession[sessionId].connectedProfile;
7690
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307691 qdf_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007692
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307693 pDstProfile->BSSIDs.bssid = qdf_mem_malloc(sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007694 if (NULL == pDstProfile->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307695 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007696 sme_err("failed to allocate memory for BSSID "
7697 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007698 MAC_ADDR_ARRAY(pSrcProfile->bssid.bytes));
7699 goto end;
7700 }
7701 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Anurag Chouhanc5548422016-02-24 18:33:27 +05307702 qdf_copy_macaddr(pDstProfile->BSSIDs.bssid, &pSrcProfile->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007703
Yingying Tangd5661072016-10-20 17:53:01 +08007704 if (pSrcProfile->SSID.length > 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007705 pDstProfile->SSIDs.SSIDList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307706 qdf_mem_malloc(sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007707 if (NULL == pDstProfile->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307708 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007709 sme_err("failed to allocate memory for SSID "
7710 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007711 MAC_ADDR_ARRAY(pSrcProfile->bssid.bytes));
7712 goto end;
7713 }
7714 pDstProfile->SSIDs.numOfSSIDs = 1;
7715 pDstProfile->SSIDs.SSIDList[0].handoffPermitted =
7716 pSrcProfile->handoffPermitted;
7717 pDstProfile->SSIDs.SSIDList[0].ssidHidden =
7718 pSrcProfile->ssidHidden;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307719 qdf_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007720 &pSrcProfile->SSID, sizeof(tSirMacSSid));
7721 }
7722 if (pSrcProfile->nAddIEAssocLength) {
7723 pDstProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307724 qdf_mem_malloc(pSrcProfile->nAddIEAssocLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007725 if (NULL == pDstProfile->pAddIEAssoc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307726 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007727 sme_err("failed to allocate mem for additional ie");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007728 goto end;
7729 }
7730 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307731 qdf_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007732 pSrcProfile->nAddIEAssocLength);
7733 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307734 pDstProfile->ChannelInfo.ChannelList = qdf_mem_malloc(1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007735 if (NULL == pDstProfile->ChannelInfo.ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307736 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007737 goto end;
7738 }
7739 pDstProfile->ChannelInfo.numOfChannels = 1;
7740 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
7741 pDstProfile->AuthType.numEntries = 1;
7742 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
7743 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
7744 pDstProfile->EncryptionType.numEntries = 1;
7745 pDstProfile->EncryptionType.encryptionType[0] =
7746 pSrcProfile->EncryptionType;
7747 pDstProfile->negotiatedUCEncryptionType =
7748 pSrcProfile->EncryptionType;
7749 pDstProfile->mcEncryptionType.numEntries = 1;
7750 pDstProfile->mcEncryptionType.encryptionType[0] =
7751 pSrcProfile->mcEncryptionType;
7752 pDstProfile->negotiatedMCEncryptionType =
7753 pSrcProfile->mcEncryptionType;
7754 pDstProfile->BSSType = pSrcProfile->BSSType;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307755 qdf_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007756 sizeof(pDstProfile->Keys));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007757 if (pSrcProfile->MDID.mdiePresent) {
7758 pDstProfile->MDID.mdiePresent = 1;
7759 pDstProfile->MDID.mobilityDomain =
7760 pSrcProfile->MDID.mobilityDomain;
7761 }
Krunal Sonib2f13042015-11-02 18:41:08 -08007762#ifdef WLAN_FEATURE_11W
7763 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
7764 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
7765 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
7766#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007767
7768end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307769 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007770 csr_release_profile(pMac, pDstProfile);
7771 pDstProfile = NULL;
7772 }
7773
7774 return status;
7775}
7776
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307777QDF_STATUS csr_roam_issue_connect(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007778 tCsrRoamProfile *pProfile,
7779 tScanResultHandle hBSSList,
7780 eCsrRoamReason reason, uint32_t roamId,
7781 bool fImediate, bool fClearScan)
7782{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307783 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007784 tSmeCmd *pCommand;
7785
7786 pCommand = csr_get_command_buffer(pMac);
7787 if (NULL == pCommand) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007788 sme_err(" fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307789 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007790 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307791 if (fClearScan)
7792 csr_scan_abort_mac_scan_not_for_connect(pMac,
7793 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007794 pCommand->u.roamCmd.fReleaseProfile = false;
7795 if (NULL == pProfile) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307796 /* We can roam now
7797 * Since pProfile is NULL, we need to build our own
7798 * profile, set everything to default We can only
7799 * support open and no encryption
7800 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007801 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
7802 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] =
7803 eCSR_AUTH_TYPE_OPEN_SYSTEM;
7804 pCommand->u.roamCmd.roamProfile.EncryptionType.
7805 numEntries = 1;
7806 pCommand->u.roamCmd.roamProfile.EncryptionType.
7807 encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7808 pCommand->u.roamCmd.roamProfile.csrPersona =
Anurag Chouhan6d760662016-02-20 16:05:43 +05307809 QDF_STA_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007810 } else {
7811 /* make a copy of the profile */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307812 status = csr_roam_copy_profile(pMac, &pCommand->u.
7813 roamCmd.roamProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007814 pProfile);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307815 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007816 pCommand->u.roamCmd.fReleaseProfile = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007817 }
7818
7819 pCommand->command = eSmeCommandRoam;
7820 pCommand->sessionId = (uint8_t) sessionId;
7821 pCommand->u.roamCmd.hBSSList = hBSSList;
7822 pCommand->u.roamCmd.roamId = roamId;
7823 pCommand->u.roamCmd.roamReason = reason;
7824 /* We need to free the BssList when the command is done */
7825 pCommand->u.roamCmd.fReleaseBssList = true;
7826 pCommand->u.roamCmd.fUpdateCurRoamProfile = true;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007827 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
7828 FL("CSR PERSONA=%d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007829 pCommand->u.roamCmd.roamProfile.csrPersona);
7830 status = csr_queue_sme_command(pMac, pCommand, fImediate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307831 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307832 sme_err("fail to send message status: %d", status);
7833 csr_release_command_roam(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007834 }
7835 }
7836
7837 return status;
7838}
7839
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307840QDF_STATUS csr_roam_issue_reassoc(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007841 tCsrRoamProfile *pProfile,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307842 tCsrRoamModifyProfileFields
7843 *pMmodProfileFields,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007844 eCsrRoamReason reason, uint32_t roamId,
7845 bool fImediate)
7846{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307847 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007848 tSmeCmd *pCommand;
7849
7850 pCommand = csr_get_command_buffer(pMac);
7851 if (NULL == pCommand) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307852 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307853 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007854 } else {
7855 csr_scan_abort_mac_scan_not_for_connect(pMac, sessionId);
7856 if (pProfile) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307857 /* This is likely trying to reassoc to
7858 * different profile
7859 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007860 pCommand->u.roamCmd.fReleaseProfile = false;
7861 /* make a copy of the profile */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307862 status = csr_roam_copy_profile(pMac, &pCommand->u.
7863 roamCmd.roamProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007864 pProfile);
7865 pCommand->u.roamCmd.fUpdateCurRoamProfile = true;
7866 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307867 status = csr_roam_copy_connected_profile(pMac,
7868 sessionId,
7869 &pCommand->u.roamCmd.
7870 roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007871 /* how to update WPA/WPA2 info in roamProfile?? */
7872 pCommand->u.roamCmd.roamProfile.uapsd_mask =
7873 pMmodProfileFields->uapsd_mask;
7874 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307875 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007876 pCommand->u.roamCmd.fReleaseProfile = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007877 pCommand->command = eSmeCommandRoam;
7878 pCommand->sessionId = (uint8_t) sessionId;
7879 pCommand->u.roamCmd.roamId = roamId;
7880 pCommand->u.roamCmd.roamReason = reason;
7881 /* We need to free the BssList when the command is done */
7882 /* For reassoc there is no BSS list, so the bool set to false */
7883 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
7884 pCommand->u.roamCmd.fReleaseBssList = false;
7885 pCommand->u.roamCmd.fReassoc = true;
7886 csr_roam_remove_duplicate_command(pMac, sessionId, pCommand,
7887 reason);
7888 status = csr_queue_sme_command(pMac, pCommand, fImediate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307889 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307890 sme_err("fail to send message status = %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007891 csr_roam_completion(pMac, sessionId, NULL, pCommand,
7892 eCSR_ROAM_RESULT_FAILURE, false);
Krunal Sonidea45952017-02-15 11:58:15 -08007893 csr_release_command(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007894 }
7895 }
7896 return status;
7897}
7898
Krunal Sonif3583022017-02-10 17:18:10 -08007899QDF_STATUS csr_dequeue_roam_command(tpAniSirGlobal pMac, eCsrRoamReason reason,
7900 uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007901{
7902 tListElem *pEntry;
7903 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307904
Krunal Sonia8270f52017-02-23 19:51:25 -08007905 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307906
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007907 if (pEntry) {
7908 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7909 if ((eSmeCommandRoam == pCommand->command) &&
7910 (eCsrPerformPreauth == reason)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007911 sme_debug("DQ-Command = %d, Reason = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007912 pCommand->command,
7913 pCommand->u.roamCmd.roamReason);
Krunal Soni72dba662017-02-15 20:13:17 -08007914 if (csr_nonscan_active_ll_remove_entry(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007915 LL_ACCESS_LOCK)) {
7916 csr_release_command_preauth(pMac, pCommand);
7917 }
7918 } else if ((eSmeCommandRoam == pCommand->command) &&
7919 (eCsrSmeIssuedFTReassoc == reason)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007920 sme_debug("DQ-Command = %d, Reason = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007921 pCommand->command,
7922 pCommand->u.roamCmd.roamReason);
Krunal Soni72dba662017-02-15 20:13:17 -08007923 if (csr_nonscan_active_ll_remove_entry(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007924 LL_ACCESS_LOCK)) {
Krunal Sonidea45952017-02-15 11:58:15 -08007925 csr_release_command(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007926 }
7927 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007928 sme_err("Command = %d, Reason = %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007929 pCommand->command,
7930 pCommand->u.roamCmd.roamReason);
7931 }
7932 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007933 sme_err("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007934 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307935 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007936}
7937
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307938QDF_STATUS csr_roam_connect(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007939 tCsrRoamProfile *pProfile,
7940 uint32_t *pRoamId)
7941{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307942 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007943 tScanResultHandle hBSSList;
7944 tCsrScanResultFilter *pScanFilter;
7945 uint32_t roamId = 0;
7946 bool fCallCallback = false;
7947 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +05307948 tSirBssDescription *first_ap_profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007949
7950 if (NULL == pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007951 sme_err("session does not exist for given sessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007952 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307953 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007954 }
7955
7956 if (NULL == pProfile) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007957 sme_err("No profile specified");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307958 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007959 }
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +05307960
7961 first_ap_profile = qdf_mem_malloc(sizeof(*first_ap_profile));
7962 if (NULL == first_ap_profile) {
7963 sme_err("malloc fails for first_ap_profile");
7964 return QDF_STATUS_E_NOMEM;
7965 }
7966
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007967 /* Initialize the count before proceeding with the Join requests */
7968 pSession->join_bssid_count = 0;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07007969 sme_debug(
7970 "called BSSType = %s (%d) authtype = %d encryType = %d",
Rajeev Kumar43e25b12016-04-15 16:26:36 -07007971 sme_bss_type_to_string(pProfile->BSSType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007972 pProfile->BSSType, pProfile->AuthType.authType[0],
7973 pProfile->EncryptionType.encryptionType[0]);
7974 csr_roam_cancel_roaming(pMac, sessionId);
7975 csr_scan_remove_fresh_scan_command(pMac, sessionId);
Sandeep Puligilladf6454a2016-10-21 16:10:59 -07007976 csr_scan_abort_all_scans(pMac, eCSR_SCAN_ABORT_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007977 csr_roam_remove_duplicate_command(pMac, sessionId, NULL, eCsrHddIssued);
7978 /* Check whether ssid changes */
7979 if (csr_is_conn_state_connected(pMac, sessionId) &&
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307980 pProfile->SSIDs.numOfSSIDs && !csr_is_ssid_in_list(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007981 &pSession->connectedProfile.SSID, &pProfile->SSIDs))
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307982 csr_roam_issue_disassociate_cmd(pMac, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007983 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Abhishek Singhacfdc922015-12-30 17:31:21 +05307984 /*
7985 * If roamSession.connectState is disconnecting that mean
7986 * disconnect was received with scan for ssid in progress
7987 * and dropped. This state will ensure that connect will
7988 * not be issued from scan for ssid completion. Thus
7989 * if this fresh connect also issue scan for ssid the connect
7990 * command will be dropped assuming disconnect is in progress.
7991 * Thus reset connectState here
7992 */
7993 if (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING ==
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05307994 pMac->roam.roamSession[sessionId].connectState)
7995 pMac->roam.roamSession[sessionId].connectState =
7996 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007997#ifdef FEATURE_WLAN_BTAMP_UT_RF
7998 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
7999#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308000 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008001 if (NULL == pScanFilter) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308002 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008003 goto end;
8004 }
8005
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008006 /* Try to connect to any BSS */
8007 if (NULL == pProfile) {
8008 /* No encryption */
8009 pScanFilter->EncryptionType.numEntries = 1;
8010 pScanFilter->EncryptionType.encryptionType[0] =
8011 eCSR_ENCRYPT_TYPE_NONE;
8012 } else {
8013 /* Here is the profile we need to connect to */
8014 status = csr_roam_prepare_filter_from_profile(pMac,
8015 pProfile, pScanFilter);
8016 }
8017 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
8018 if (pRoamId)
8019 *pRoamId = roamId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308020 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308021 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008022 goto end;
8023 }
8024
8025 /*Save the WPS info */
8026 if (NULL != pProfile) {
8027 pScanFilter->bWPSAssociation =
8028 pProfile->bWPSAssociation;
8029 pScanFilter->bOSENAssociation =
8030 pProfile->bOSENAssociation;
8031 } else {
8032 pScanFilter->bWPSAssociation = 0;
8033 pScanFilter->bOSENAssociation = 0;
8034 }
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07008035 if (pProfile && CSR_IS_INFRA_AP(pProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008036 /* This can be started right away */
8037 status = csr_roam_issue_connect(pMac, sessionId, pProfile, NULL,
8038 eCsrHddIssued, roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308039 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308040 sme_err("CSR failed to issue start BSS cmd with status: 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008041 status);
8042 fCallCallback = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308043 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008044 sme_debug("Connect request to proceed for sap mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008045
8046 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308047 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008048 goto end;
8049 }
8050 status = csr_scan_get_result(pMac, pScanFilter, &hBSSList);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308051 sme_debug("csr_scan_get_result Status: %d", status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308052 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008053 /* check if set hw mode needs to be done */
Krunal Soni3091bcc2016-06-23 12:28:21 -07008054 if ((pScanFilter->csrPersona == QDF_STA_MODE) ||
8055 (pScanFilter->csrPersona == QDF_P2P_CLIENT_MODE)) {
Ajit Pal Singh64aff0c2017-06-20 16:35:26 +05308056 bool ok;
8057
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008058 csr_get_bssdescr_from_scan_handle(hBSSList,
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +05308059 first_ap_profile);
Ajit Pal Singh64aff0c2017-06-20 16:35:26 +05308060 status = policy_mgr_is_chan_ok_for_dnbs(pMac->psoc,
8061 first_ap_profile->channelId, &ok);
8062 if (QDF_IS_STATUS_ERROR(status)) {
8063 sme_debug("policy_mgr_is_chan_ok_for_dnbs():error:%d",
8064 status);
8065 csr_scan_result_purge(pMac, hBSSList);
8066 fCallCallback = true;
8067 goto error;
8068 }
8069 if (!ok) {
8070 sme_debug("chan:%d not ok for DNBS",
8071 first_ap_profile->channelId);
8072 csr_scan_result_purge(pMac, hBSSList);
8073 fCallCallback = true;
8074 status = QDF_STATUS_E_INVAL;
8075 goto error;
8076 }
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -08008077 status = policy_mgr_handle_conc_multiport(pMac->psoc,
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +05308078 sessionId, first_ap_profile->channelId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308079 if ((QDF_IS_STATUS_SUCCESS(status)) &&
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05308080 (!csr_wait_for_connection_update(pMac, true))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008081 sme_debug("conn update error");
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05308082 csr_scan_result_purge(pMac, hBSSList);
8083 fCallCallback = true;
Abhishek Singh471652b2017-04-14 12:28:32 +05308084 status = QDF_STATUS_E_TIMEOUT;
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05308085 goto error;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308086 } else if (status == QDF_STATUS_E_FAILURE) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008087 sme_debug("conn update error");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008088 csr_scan_result_purge(pMac, hBSSList);
8089 fCallCallback = true;
8090 goto error;
8091 }
8092 }
8093
8094 status = csr_roam_issue_connect(pMac, sessionId, pProfile,
8095 hBSSList, eCsrHddIssued, roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308096 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308097 sme_err("CSR failed to issue connect cmd with status: 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008098 status);
8099 csr_scan_result_purge(pMac, hBSSList);
8100 fCallCallback = true;
8101 }
8102 } else if (NULL != pProfile) {
8103 /* Check whether it is for start ibss */
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07008104 if (CSR_IS_START_IBSS(pProfile) ||
8105 CSR_IS_NDI(pProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008106 status = csr_roam_issue_connect(pMac, sessionId,
8107 pProfile, NULL, eCsrHddIssued,
8108 roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308109 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008110 sme_err("Failed with status = 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008111 status);
8112 fCallCallback = true;
8113 }
8114 } else {
8115 /* scan for this SSID */
8116 status = csr_scan_for_ssid(pMac, sessionId, pProfile,
8117 roamId, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308118 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308119 sme_err("CSR failed to issue SSID scan cmd with status: 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008120 status);
8121 fCallCallback = true;
8122 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008123 sme_debug("SSID scan requested");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008124 }
8125 }
8126 } else {
8127 fCallCallback = true;
8128 }
8129
8130error:
8131 if (NULL != pProfile)
8132 /*
8133 * we need to free memory for filter
8134 * if profile exists
8135 */
8136 csr_free_scan_filter(pMac, pScanFilter);
8137
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308138 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008139end:
8140 /* tell the caller if we fail to trigger a join request */
8141 if (fCallCallback) {
8142 csr_roam_call_callback(pMac, sessionId, NULL, roamId,
8143 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
8144 }
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +05308145 qdf_mem_free(first_ap_profile);
8146
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008147 return status;
8148}
8149
8150/**
8151 * csr_roam_reassoc() - process reassoc command
8152 * @mac_ctx: mac global context
8153 * @session_id: session id
8154 * @profile: roam profile
8155 * @mod_fields: AC info being modified in reassoc
8156 * @roam_id: roam id to be populated
8157 *
8158 * Return: status of operation
8159 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308160QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008161csr_roam_reassoc(tpAniSirGlobal mac_ctx, uint32_t session_id,
8162 tCsrRoamProfile *profile,
8163 tCsrRoamModifyProfileFields mod_fields,
8164 uint32_t *roam_id)
8165{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308166 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008167 bool fCallCallback = true;
8168 uint32_t roamId = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008169 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308170
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008171 if (NULL == profile) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008172 sme_err("No profile specified");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308173 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008174 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008175 sme_debug(
8176 "called BSSType = %s (%d) authtype = %d encryType = %d",
Rajeev Kumar43e25b12016-04-15 16:26:36 -07008177 sme_bss_type_to_string(profile->BSSType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008178 profile->BSSType, profile->AuthType.authType[0],
8179 profile->EncryptionType.encryptionType[0]);
8180 csr_roam_cancel_roaming(mac_ctx, session_id);
8181 csr_scan_remove_fresh_scan_command(mac_ctx, session_id);
8182 csr_scan_abort_mac_scan_not_for_connect(mac_ctx, session_id);
8183 csr_roam_remove_duplicate_command(mac_ctx, session_id, NULL,
8184 eCsrHddIssuedReassocToSameAP);
8185 if (csr_is_conn_state_connected(mac_ctx, session_id)) {
8186 if (profile) {
8187 if (profile->SSIDs.numOfSSIDs &&
8188 csr_is_ssid_in_list(mac_ctx,
8189 &session->connectedProfile.SSID,
8190 &profile->SSIDs)) {
8191 fCallCallback = false;
8192 } else {
8193 /*
8194 * Connected SSID did not match with what is
8195 * asked in profile
8196 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008197 sme_debug("SSID mismatch");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008198 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308199 } else if (qdf_mem_cmp(&mod_fields,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008200 &session->connectedProfile.modifyProfileFields,
8201 sizeof(tCsrRoamModifyProfileFields))) {
8202 fCallCallback = false;
8203 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008204 sme_debug(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008205 /*
8206 * Either the profile is NULL or none of the
8207 * fields in tCsrRoamModifyProfileFields got
8208 * modified
8209 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008210 "Profile NULL or nothing to modify");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008211 }
8212 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008213 sme_debug("Not connected! No need to reassoc");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008214 }
8215 if (!fCallCallback) {
8216 roamId = GET_NEXT_ROAM_ID(&mac_ctx->roam);
8217 if (roam_id)
8218 *roam_id = roamId;
8219 status = csr_roam_issue_reassoc(mac_ctx, session_id, profile,
8220 &mod_fields, eCsrHddIssuedReassocToSameAP,
8221 roamId, false);
8222 } else {
8223 status = csr_roam_call_callback(mac_ctx, session_id, NULL,
8224 roamId, eCSR_ROAM_FAILED,
8225 eCSR_ROAM_RESULT_FAILURE);
8226 }
8227 return status;
8228}
8229
Jeff Johnson29e2ca12016-10-14 12:50:38 -07008230static QDF_STATUS csr_roam_join_last_profile(tpAniSirGlobal pMac,
8231 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008232{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308233 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008234 tScanResultHandle hBSSList = NULL;
8235 tCsrScanResultFilter *pScanFilter = NULL;
8236 uint32_t roamId;
8237 tCsrRoamProfile *pProfile = NULL;
8238 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
8239
8240 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008241 sme_err("session %d not found ", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308242 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008243 }
8244
8245 if (pSession->pCurRoamProfile) {
8246 csr_scan_abort_mac_scan_not_for_connect(pMac, sessionId);
8247 /* We have to make a copy of pCurRoamProfile because it
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308248 * will be free inside csr_roam_issue_connect
8249 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308250 pProfile = qdf_mem_malloc(sizeof(tCsrRoamProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008251 if (NULL == pProfile) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308252 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008253 goto end;
8254 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008255 status = csr_roam_copy_profile(pMac, pProfile,
8256 pSession->pCurRoamProfile);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308257 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008258 goto end;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308259 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008260 if (NULL == pScanFilter) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308261 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008262 goto end;
8263 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008264 status = csr_roam_prepare_filter_from_profile(pMac, pProfile,
8265 pScanFilter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308266 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008267 goto end;
8268 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
8269 status = csr_scan_get_result(pMac, pScanFilter, &hBSSList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308270 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008271 /* we want to put the last connected BSS to the
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308272 * very beginning, if possible
8273 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008274 csr_move_bss_to_head_from_bssid(pMac,
8275 &pSession->connectedProfile.bssid, hBSSList);
8276 status = csr_roam_issue_connect(pMac, sessionId,
8277 pProfile, hBSSList, eCsrHddIssued,
8278 roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308279 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008280 csr_scan_result_purge(pMac, hBSSList);
8281 goto end;
8282 }
8283 } else {
8284 /* scan for this SSID only incase AP suppresses SSID */
8285 status = csr_scan_for_ssid(pMac, sessionId, pProfile,
8286 roamId, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308287 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008288 goto end;
8289 }
8290 } /* We have a profile */
8291 else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008292 sme_warn("cannot find a roaming profile");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008293 goto end;
8294 }
8295end:
8296 if (pScanFilter) {
8297 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308298 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008299 }
8300 if (NULL != pProfile) {
8301 csr_release_profile(pMac, pProfile);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308302 qdf_mem_free(pProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008303 }
8304 return status;
8305}
8306
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308307QDF_STATUS csr_roam_reconnect(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008308{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308309 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308310
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008311 if (csr_is_conn_state_connected(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308312 status = csr_roam_issue_disassociate_cmd(pMac, sessionId,
8313 eCSR_DISCONNECT_REASON_UNSPECIFIED);
8314 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008315 status = csr_roam_join_last_profile(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008316 }
8317 return status;
8318}
8319
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308320QDF_STATUS csr_roam_connect_to_last_profile(tpAniSirGlobal pMac,
8321 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008322{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308323 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008324
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008325 csr_roam_cancel_roaming(pMac, sessionId);
8326 csr_roam_remove_duplicate_command(pMac, sessionId, NULL, eCsrHddIssued);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308327 if (csr_is_conn_state_disconnected(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008328 status = csr_roam_join_last_profile(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308329
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008330 return status;
8331}
8332
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308333QDF_STATUS csr_roam_process_disassoc_deauth(tpAniSirGlobal pMac,
8334 tSmeCmd *pCommand,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008335 bool fDisassoc, bool fMICFailure)
8336{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308337 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008338 bool fComplete = false;
8339 eCsrRoamSubState NewSubstate;
8340 uint32_t sessionId = pCommand->sessionId;
8341
8342 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308343 sme_debug("Stop Wait for key timer and change substate to eCSR_ROAM_SUBSTATE_NONE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008344 csr_roam_stop_wait_for_key_timer(pMac);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308345 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
8346 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008347 }
8348 /* change state to 'Roaming'... */
8349 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
8350
8351 if (csr_is_conn_state_ibss(pMac, sessionId)) {
8352 /* If we are in an IBSS, then stop the IBSS... */
8353 status =
8354 csr_roam_issue_stop_bss(pMac, sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308355 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308356 fComplete = (!QDF_IS_STATUS_SUCCESS(status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008357 } else if (csr_is_conn_state_infra(pMac, sessionId)) {
8358 /*
8359 * in Infrastructure, we need to disassociate from the
8360 * Infrastructure network...
8361 */
8362 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
8363 if (eCsrSmeIssuedDisassocForHandoff ==
8364 pCommand->u.roamCmd.roamReason) {
8365 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
8366 } else
8367 if ((eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason)
8368 && (eSIR_MAC_DISASSOC_LEAVING_BSS_REASON ==
8369 pCommand->u.roamCmd.reason)) {
8370 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008371 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
8372 "set to substate eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008373 }
Abhishek Singhe0680852015-12-16 14:28:48 +05308374 if (eCsrSmeIssuedDisassocForHandoff !=
8375 pCommand->u.roamCmd.roamReason) {
8376 /*
8377 * If we are in neighbor preauth done state then
8378 * on receiving disassoc or deauth we dont roam
8379 * instead we just disassoc from current ap and
8380 * then go to disconnected state.
8381 * This happens for ESE and 11r FT connections ONLY.
8382 */
Abhishek Singhe0680852015-12-16 14:28:48 +05308383 if (csr_roam_is11r_assoc(pMac, sessionId) &&
8384 (csr_neighbor_roam_state_preauth_done(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308385 sessionId)))
Abhishek Singhe0680852015-12-16 14:28:48 +05308386 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
8387 pMac, sessionId);
Abhishek Singhe0680852015-12-16 14:28:48 +05308388#ifdef FEATURE_WLAN_ESE
8389 if (csr_roam_is_ese_assoc(pMac, sessionId) &&
8390 (csr_neighbor_roam_state_preauth_done(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308391 sessionId)))
Abhishek Singhe0680852015-12-16 14:28:48 +05308392 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
8393 pMac, sessionId);
Abhishek Singhe0680852015-12-16 14:28:48 +05308394#endif
Abhishek Singhe0680852015-12-16 14:28:48 +05308395 if (csr_roam_is_fast_roam_enabled(pMac, sessionId) &&
8396 (csr_neighbor_roam_state_preauth_done(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308397 sessionId)))
Abhishek Singhe0680852015-12-16 14:28:48 +05308398 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
8399 pMac, sessionId);
Abhishek Singhe0680852015-12-16 14:28:48 +05308400 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308401 if (fDisassoc)
8402 status = csr_roam_issue_disassociate(pMac, sessionId,
8403 NewSubstate,
8404 fMICFailure);
8405 else
8406 status = csr_roam_issue_deauth(pMac, sessionId,
8407 eCSR_ROAM_SUBSTATE_DEAUTH_REQ);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308408 fComplete = (!QDF_IS_STATUS_SUCCESS(status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008409 } else {
8410 /* we got a dis-assoc request while not connected to any peer */
8411 /* just complete the command */
8412 fComplete = true;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308413 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008414 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308415 if (fComplete)
Krunal Sonif3583022017-02-10 17:18:10 -08008416 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008417
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308418 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008419 if (csr_is_conn_state_infra(pMac, sessionId)) {
8420 /* Set the state to disconnect here */
8421 pMac->roam.roamSession[sessionId].connectState =
8422 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8423 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308424 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008425 sme_warn(" failed with status %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008426 return status;
8427}
8428
8429/**
8430 * csr_prepare_disconnect_command() - function to prepare disconnect command
8431 * @mac: pointer to global mac structure
8432 * @session_id: sme session index
8433 * @sme_cmd: pointer to sme command being prepared
8434 *
8435 * Function to prepare internal sme disconnect command
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308436 * Return: QDF_STATUS_SUCCESS on success else QDF_STATUS_E_RESOURCES on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008437 */
8438
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308439QDF_STATUS csr_prepare_disconnect_command(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008440 uint32_t session_id, tSmeCmd **sme_cmd)
8441{
8442 tSmeCmd *command;
8443
8444 command = csr_get_command_buffer(mac);
8445 if (!command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008446 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308447 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008448 }
8449
8450 command->command = eSmeCommandRoam;
8451 command->sessionId = (uint8_t)session_id;
8452 command->u.roamCmd.roamReason = eCsrForcedDisassoc;
8453
8454 *sme_cmd = command;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308455 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008456}
8457
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308458QDF_STATUS csr_roam_issue_disassociate_cmd(tpAniSirGlobal pMac,
8459 uint32_t sessionId,
8460 eCsrRoamDisconnectReason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008461{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308462 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008463 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308464
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008465 do {
8466 pCommand = csr_get_command_buffer(pMac);
8467 if (!pCommand) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008468 sme_err(" fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308469 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008470 break;
8471 }
8472 /* Change the substate in case it is wait-for-key */
8473 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
8474 csr_roam_stop_wait_for_key_timer(pMac);
8475 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
8476 sessionId);
8477 }
8478 pCommand->command = eSmeCommandRoam;
8479 pCommand->sessionId = (uint8_t) sessionId;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008480 sme_debug(
8481 "Disassociate reason: %d, sessionId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008482 reason, sessionId);
8483 switch (reason) {
8484 case eCSR_DISCONNECT_REASON_MIC_ERROR:
8485 pCommand->u.roamCmd.roamReason =
8486 eCsrForcedDisassocMICFailure;
8487 break;
8488 case eCSR_DISCONNECT_REASON_DEAUTH:
8489 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
8490 break;
8491 case eCSR_DISCONNECT_REASON_HANDOFF:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008492 pCommand->u.roamCmd.roamReason =
8493 eCsrSmeIssuedDisassocForHandoff;
8494 break;
8495 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
8496 case eCSR_DISCONNECT_REASON_DISASSOC:
8497 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
8498 break;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07008499 case eCSR_DISCONNECT_REASON_ROAM_HO_FAIL:
8500 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
8501 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008502 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
8503 pCommand->u.roamCmd.roamReason =
8504 eCsrSmeIssuedIbssJoinFailure;
8505 break;
8506 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
8507 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
8508 break;
8509 case eCSR_DISCONNECT_REASON_STA_HAS_LEFT:
8510 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
8511 pCommand->u.roamCmd.reason =
8512 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008513 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
8514 "SME convert to internal reason code eCsrStaHasLeft");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008515 break;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07008516 case eCSR_DISCONNECT_REASON_NDI_DELETE:
8517 pCommand->u.roamCmd.roamReason = eCsrStopBss;
8518 pCommand->u.roamCmd.roamProfile.BSSType =
8519 eCSR_BSS_TYPE_NDI;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008520 default:
8521 break;
8522 }
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07008523 pCommand->u.roamCmd.disconnect_reason = reason;
Abhishek Singhb7b2a3b2015-12-03 16:09:38 +05308524 status = csr_queue_sme_command(pMac, pCommand, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308525 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308526 sme_err("fail to send message status: %d", status);
Krunal Sonidea45952017-02-15 11:58:15 -08008527 csr_release_command(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008528 }
8529 } while (0);
8530 return status;
8531}
8532
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308533QDF_STATUS csr_roam_issue_stop_bss_cmd(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008534 bool fHighPriority)
8535{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308536 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008537 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308538
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008539 pCommand = csr_get_command_buffer(pMac);
8540 if (NULL != pCommand) {
8541 /* Change the substate in case it is wait-for-key */
8542 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
8543 csr_roam_stop_wait_for_key_timer(pMac);
8544 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
8545 sessionId);
8546 }
8547 pCommand->command = eSmeCommandRoam;
8548 pCommand->sessionId = (uint8_t) sessionId;
8549 pCommand->u.roamCmd.roamReason = eCsrStopBss;
8550 status = csr_queue_sme_command(pMac, pCommand, fHighPriority);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308551 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308552 sme_err("fail to send message status: %d", status);
Krunal Sonidea45952017-02-15 11:58:15 -08008553 csr_release_command(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008554 }
8555 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308556 sme_err("fail to get command buffer");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308557 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008558 }
8559 return status;
8560}
8561
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308562QDF_STATUS csr_roam_disconnect_internal(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008563 eCsrRoamDisconnectReason reason)
8564{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308565 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008566 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
8567
8568 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308569 sme_err("session: %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308570 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008571 }
8572#ifdef FEATURE_WLAN_BTAMP_UT_RF
8573 /* Stop the retry */
8574 pSession->maxRetryCount = 0;
8575 csr_roam_stop_join_retry_timer(pMac, sessionId);
8576#endif
8577 /* Not to call cancel roaming here */
8578 /* Only issue disconnect when necessary */
8579 if (csr_is_conn_state_connected(pMac, sessionId)
8580 || csr_is_bss_type_ibss(pSession->connectedProfile.BSSType)
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07008581 || csr_is_roam_command_waiting_for_session(pMac, sessionId)
8582 || CSR_IS_CONN_NDI(&pSession->connectedProfile)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008583 sme_debug("called");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008584 status = csr_roam_issue_disassociate_cmd(pMac, sessionId,
8585 reason);
8586 } else {
kaliu154d7892015-12-30 17:27:58 +05308587 pMac->roam.roamSession[sessionId].connectState =
8588 eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008589 csr_scan_abort_scan_for_ssid(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308590 status = QDF_STATUS_CMD_NOT_QUEUED;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308591 sme_debug("Disconnect cmd not queued, Roam command is not present return with status: %d",
8592 status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008593 }
8594 return status;
8595}
8596
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308597QDF_STATUS csr_roam_disconnect(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008598 eCsrRoamDisconnectReason reason)
8599{
8600 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
8601
8602 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308603 sme_err("session: %d not found ", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308604 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008605 }
8606
8607 csr_roam_cancel_roaming(pMac, sessionId);
8608 csr_roam_remove_duplicate_command(pMac, sessionId, NULL,
8609 eCsrForcedDisassoc);
8610
8611 return csr_roam_disconnect_internal(pMac, sessionId, reason);
8612}
8613
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308614QDF_STATUS csr_roam_save_connected_infomation(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008615 uint32_t sessionId,
8616 tCsrRoamProfile *pProfile,
8617 tSirBssDescription *pSirBssDesc,
8618 tDot11fBeaconIEs *pIes)
8619{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308620 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008621 tDot11fBeaconIEs *pIesTemp = pIes;
8622 uint8_t index;
8623 tCsrRoamSession *pSession = NULL;
8624 tCsrRoamConnectedProfile *pConnectProfile = NULL;
8625
8626 pSession = CSR_GET_SESSION(pMac, sessionId);
8627 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308628 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308629 "session: %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308630 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008631 }
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +05308632
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308633 sme_debug("session id: %d", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008634 pConnectProfile = &pSession->connectedProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008635 if (pConnectProfile->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308636 qdf_mem_free(pConnectProfile->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008637 pConnectProfile->pAddIEAssoc = NULL;
8638 }
Varun Reddy Yeturud5216002016-02-03 17:09:09 -08008639 /*
8640 * In case of LFR2.0, the connected profile is copied into a temporary
8641 * profile and cleared and then is copied back. This is not needed for
8642 * LFR3.0, since the profile is not cleared.
8643 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008644 if (!pSession->roam_synch_in_progress) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308645 qdf_mem_set(&pSession->connectedProfile,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008646 sizeof(tCsrRoamConnectedProfile), 0);
8647 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
8648 pConnectProfile->AuthInfo = pProfile->AuthType;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008649 pConnectProfile->EncryptionType =
8650 pProfile->negotiatedUCEncryptionType;
8651 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
8652 pConnectProfile->mcEncryptionType =
8653 pProfile->negotiatedMCEncryptionType;
8654 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
8655 pConnectProfile->BSSType = pProfile->BSSType;
8656 pConnectProfile->modifyProfileFields.uapsd_mask =
8657 pProfile->uapsd_mask;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308658 qdf_mem_copy(&pConnectProfile->Keys, &pProfile->Keys,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008659 sizeof(tCsrKeys));
8660 if (pProfile->nAddIEAssocLength) {
8661 pConnectProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308662 qdf_mem_malloc(pProfile->nAddIEAssocLength);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008663 if (NULL == pConnectProfile->pAddIEAssoc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308664 status = QDF_STATUS_E_NOMEM;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008665 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308666 status = QDF_STATUS_SUCCESS;
8667 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308668 sme_err("Failed to allocate memory for IE");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308669 return QDF_STATUS_E_FAILURE;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008670 }
8671 pConnectProfile->nAddIEAssocLength =
8672 pProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308673 qdf_mem_copy(pConnectProfile->pAddIEAssoc,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008674 pProfile->pAddIEAssoc,
8675 pProfile->nAddIEAssocLength);
8676 }
8677#ifdef WLAN_FEATURE_11W
8678 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
8679 pConnectProfile->MFPRequired = pProfile->MFPRequired;
8680 pConnectProfile->MFPCapable = pProfile->MFPCapable;
8681#endif
8682 }
8683 /* Save bssid */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008684 pConnectProfile->operationChannel = pSirBssDesc->channelId;
8685 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308686 if (!pConnectProfile->beaconInterval)
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008687 sme_err("ERROR: Beacon interval is ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008688 csr_get_bss_id_bss_desc(pMac, pSirBssDesc, &pConnectProfile->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008689 if (pSirBssDesc->mdiePresent) {
8690 pConnectProfile->MDID.mdiePresent = 1;
8691 pConnectProfile->MDID.mobilityDomain =
8692 (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
8693 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308694 if (NULL == pIesTemp)
8695 status = csr_get_parsed_bss_description_ies(pMac, pSirBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008696 &pIesTemp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008697#ifdef FEATURE_WLAN_ESE
8698 if ((csr_is_profile_ese(pProfile) ||
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308699 (QDF_IS_STATUS_SUCCESS(status) && (pIesTemp->ESEVersion.present)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008700 && (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)))
8701 && (pMac->roam.configParam.isEseIniFeatureEnabled)) {
8702 pConnectProfile->isESEAssoc = 1;
8703 }
8704#endif
8705 /* save ssid */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308706 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008707 if (pIesTemp->SSID.present) {
8708 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308709 qdf_mem_copy(pConnectProfile->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008710 pIesTemp->SSID.ssid,
8711 pIesTemp->SSID.num_ssid);
8712 }
8713 /* Save the bss desc */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308714 status = csr_roam_save_connected_bss_desc(pMac, sessionId,
8715 pSirBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008716
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308717 if (CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
8718 /* Some HT AP's dont send WMM IE so in that case we
8719 * assume all HT Ap's are Qos Enabled AP's
8720 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008721 pConnectProfile->qap = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308722 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008723 pConnectProfile->qap = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008724
8725 if (pIesTemp->ExtCap.present) {
8726 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
8727 pIesTemp->ExtCap.bytes;
8728 pConnectProfile->proxyARPService = p_ext_cap->
8729 proxy_arp_service;
8730 }
8731
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308732 if (NULL == pIes)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008733 /* Free memory if it allocated locally */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308734 qdf_mem_free(pIesTemp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008735 }
8736 /* Save Qos connection */
8737 pConnectProfile->qosConnection =
8738 pMac->roam.roamSession[sessionId].fWMMConnection;
8739
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308740 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008741 csr_free_connect_bss_desc(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308742
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008743 for (index = 0; index < pProfile->SSIDs.numOfSSIDs; index++) {
8744 if ((pProfile->SSIDs.SSIDList[index].SSID.length ==
8745 pConnectProfile->SSID.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308746 && (!qdf_mem_cmp(pProfile->SSIDs.SSIDList[index].SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008747 ssId, pConnectProfile->SSID.ssId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308748 pConnectProfile->SSID.length))) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308749 pConnectProfile->handoffPermitted = pProfile->SSIDs.
8750 SSIDList[index].handoffPermitted;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008751 break;
8752 }
8753 pConnectProfile->handoffPermitted = false;
8754 }
8755
8756 return status;
8757}
8758
8759
Abhishek Singhb1d73ab2015-12-03 16:14:00 +05308760bool is_disconnect_pending(tpAniSirGlobal pmac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008761 uint8_t sessionid)
8762{
8763 tListElem *entry = NULL;
8764 tListElem *next_entry = NULL;
8765 tSmeCmd *command = NULL;
8766 bool disconnect_cmd_exist = false;
8767
Krunal Soni20126cb2017-02-15 16:26:57 -08008768 csr_nonscan_pending_ll_lock(pmac);
Krunal Sonia8270f52017-02-23 19:51:25 -08008769 entry = csr_nonscan_pending_ll_peek_head(pmac, LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008770 while (entry) {
Krunal Soni72dba662017-02-15 20:13:17 -08008771 next_entry = csr_nonscan_pending_ll_next(pmac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008772 entry, LL_ACCESS_NOLOCK);
8773
8774 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
8775 if (command && CSR_IS_DISCONNECT_COMMAND(command) &&
8776 command->sessionId == sessionid){
8777 disconnect_cmd_exist = true;
8778 break;
8779 }
8780 entry = next_entry;
8781 }
Krunal Soni20126cb2017-02-15 16:26:57 -08008782 csr_nonscan_pending_ll_unlock(pmac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008783 return disconnect_cmd_exist;
8784}
8785
8786static void csr_roam_join_rsp_processor(tpAniSirGlobal pMac,
8787 tSirSmeJoinRsp *pSmeJoinRsp)
8788{
8789 tListElem *pEntry = NULL;
8790 tSmeCmd *pCommand = NULL;
8791 tCsrRoamSession *session_ptr;
8792
8793 if (pSmeJoinRsp) {
8794 session_ptr = CSR_GET_SESSION(pMac, pSmeJoinRsp->sessionId);
8795 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308796 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008797 FL("Sme Join Response is NULL"));
8798 return;
8799 }
8800 if (!session_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308801 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008802 ("session %d not found"), pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008803 return;
8804 }
8805 /* The head of the active list is the request we sent */
Krunal Sonia8270f52017-02-23 19:51:25 -08008806 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308807 if (pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008808 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308809
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008810 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode) {
8811 if (pCommand
8812 && eCsrSmeIssuedAssocToSimilarAP ==
8813 pCommand->u.roamCmd.roamReason) {
8814#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8815 sme_qos_csr_event_ind(pMac, pSmeJoinRsp->sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308816 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008817#endif
8818 }
Archana Ramachandran20d2e232016-02-11 16:58:40 -08008819
8820 session_ptr->supported_nss_1x1 =
8821 pSmeJoinRsp->supported_nss_1x1;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308822 sme_debug("SME session supported nss: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08008823 session_ptr->supported_nss_1x1);
8824
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308825 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008826 * The join bssid count can be reset as soon as
8827 * we are done with the join requests and returning
8828 * the response to upper layers
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308829 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008830 session_ptr->join_bssid_count = 0;
Krunal Sonif3583022017-02-10 17:18:10 -08008831 csr_roam_complete(pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp,
8832 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008833 } else {
8834 uint32_t roamId = 0;
8835 bool is_dis_pending;
8836
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308837 /* The head of the active list is the request we sent
8838 * Try to get back the same profile and roam again
8839 */
8840 if (pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008841 roamId = pCommand->u.roamCmd.roamId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008842 session_ptr->joinFailStatusCode.statusCode =
8843 pSmeJoinRsp->statusCode;
8844 session_ptr->joinFailStatusCode.reasonCode =
8845 pSmeJoinRsp->protStatusCode;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308846 sme_warn("SmeJoinReq failed with statusCode= 0x%08X [%d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008847 pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308848 /* If Join fails while Handoff is in progress, indicate
8849 * disassociated event to supplicant to reconnect
8850 */
8851 if (csr_roam_is_handoff_in_progress(pMac,
8852 pSmeJoinRsp->sessionId)) {
8853 csr_roam_call_callback(pMac, pSmeJoinRsp->sessionId,
8854 NULL, roamId,
8855 eCSR_ROAM_DISASSOCIATED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008856 eCSR_ROAM_RESULT_FORCED);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308857 /* Should indicate neighbor roam algorithm about the
8858 * connect failure here
8859 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008860 csr_neighbor_roam_indicate_connect(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308861 pSmeJoinRsp->sessionId,
8862 QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008863 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008864 /*
8865 * if userspace has issued disconnection,
8866 * driver should not continue connecting
8867 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308868 is_dis_pending = is_disconnect_pending(pMac,
8869 session_ptr->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008870 if (pCommand && (session_ptr->join_bssid_count <
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308871 CSR_MAX_BSSID_COUNT) && !is_dis_pending)
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07008872 csr_roam(pMac, pCommand);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308873 else {
8874 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008875 * When the upper layers issue a connect command, there
8876 * is a roam command with reason eCsrHddIssued that
8877 * gets enqueued and an associated timer for the SME
8878 * command timeout is started which is currently 120
8879 * seconds. This command would be dequeued only upon
8880 * succesfull connections. In case of join failures, if
8881 * there are too many BSS in the cache, and if we fail
8882 * Join requests with all of them, there is a chance of
8883 * timing out the above timer.
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308884 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008885 if (session_ptr->join_bssid_count >=
8886 CSR_MAX_BSSID_COUNT)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308887 QDF_TRACE(QDF_MODULE_ID_SME,
8888 QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008889 "Excessive Join Req Failures");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008890
8891 if (is_dis_pending)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308892 QDF_TRACE(QDF_MODULE_ID_SME,
8893 QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008894 "disconnect is pending, complete roam");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008895
Abhishek Singh6e4621c2017-03-31 13:13:10 +05308896 if (session_ptr->bRefAssocStartCnt)
8897 session_ptr->bRefAssocStartCnt--;
8898
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008899 session_ptr->join_bssid_count = 0;
Abhishek Singh6e4621c2017-03-31 13:13:10 +05308900
8901 csr_roam_call_callback(pMac, session_ptr->sessionId,
8902 NULL, roamId,
8903 eCSR_ROAM_ASSOCIATION_COMPLETION,
8904 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
8905
Krunal Sonif3583022017-02-10 17:18:10 -08008906 csr_roam_complete(pMac, eCsrNothingToJoin, NULL,
8907 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008908 }
8909 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
8910}
8911
Jeff Johnson29e2ca12016-10-14 12:50:38 -07008912static QDF_STATUS csr_roam_issue_join(tpAniSirGlobal pMac, uint32_t sessionId,
8913 tSirBssDescription *pSirBssDesc,
8914 tDot11fBeaconIEs *pIes,
8915 tCsrRoamProfile *pProfile,
8916 uint32_t roamId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008917{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308918 QDF_STATUS status;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308919
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008920 sme_debug("Attempting to Join Bssid= " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008921 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
8922
8923 /* Set the roaming substate to 'join attempt'... */
8924 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
8925 /* attempt to Join this BSS... */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308926 status = csr_send_join_req_msg(pMac, sessionId, pSirBssDesc, pProfile,
8927 pIes, eWNI_SME_JOIN_REQ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008928 return status;
8929}
8930
Krunal Sonif3583022017-02-10 17:18:10 -08008931static void
8932csr_roam_reissue_roam_command(tpAniSirGlobal pMac, uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008933{
8934 tListElem *pEntry;
8935 tSmeCmd *pCommand;
8936 tCsrRoamInfo roamInfo;
8937 uint32_t sessionId;
8938 tCsrRoamSession *pSession;
8939
Krunal Sonia8270f52017-02-23 19:51:25 -08008940 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008941 if (NULL == pEntry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308942 sme_err("Disassoc rsp can't continue, no active CMD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008943 return;
8944 }
8945 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8946 if (eSmeCommandRoam != pCommand->command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008947 sme_err("Active cmd, is not a roaming CMD");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008948 return;
8949 }
8950 sessionId = pCommand->sessionId;
8951 pSession = CSR_GET_SESSION(pMac, sessionId);
8952
8953 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008954 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008955 return;
8956 }
8957
8958 if (!pCommand->u.roamCmd.fStopWds) {
8959 if (pSession->bRefAssocStartCnt > 0) {
8960 /*
8961 * bRefAssocStartCnt was incremented in
8962 * csr_roam_join_next_bss when the roam command issued
8963 * previously. As part of reissuing the roam command
8964 * again csr_roam_join_next_bss is going increment
8965 * RefAssocStartCnt. So make sure to decrement the
8966 * bRefAssocStartCnt
8967 */
8968 pSession->bRefAssocStartCnt--;
8969 }
8970 if (eCsrStopRoaming == csr_roam_join_next_bss(pMac, pCommand,
8971 true)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008972 sme_warn("Failed to reissue join command");
Krunal Sonif3583022017-02-10 17:18:10 -08008973 csr_roam_complete(pMac, eCsrNothingToJoin, NULL,
8974 session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008975 }
8976 return;
8977 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308978 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008979 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
8980 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
8981 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07008982 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
8983 csr_roam_call_callback(pMac, sessionId, &roamInfo,
8984 pCommand->u.roamCmd.roamId,
8985 eCSR_ROAM_INFRA_IND,
8986 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008987
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308988 if (!QDF_IS_STATUS_SUCCESS(csr_roam_issue_stop_bss(pMac, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008989 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07008990 sme_err("Failed to reissue stop_bss command for WDS");
Krunal Sonif3583022017-02-10 17:18:10 -08008991 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008992 }
8993}
8994
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05308995bool csr_is_roam_command_waiting_for_session(tpAniSirGlobal pMac,
8996 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008997{
8998 bool fRet = false;
8999 tListElem *pEntry;
9000 tSmeCmd *pCommand = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309001
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009002 /* alwasy lock active list before locking pending list */
Krunal Soni20126cb2017-02-15 16:26:57 -08009003 csr_nonscan_active_ll_lock(pMac);
Krunal Sonia8270f52017-02-23 19:51:25 -08009004 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009005 if (pEntry) {
9006 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9007 if ((eSmeCommandRoam == pCommand->command)
9008 && (sessionId == pCommand->sessionId)) {
9009 fRet = true;
9010 }
9011 }
9012 if (false == fRet) {
Krunal Soni20126cb2017-02-15 16:26:57 -08009013 csr_nonscan_pending_ll_lock(pMac);
Krunal Sonia8270f52017-02-23 19:51:25 -08009014 pEntry = csr_nonscan_pending_ll_peek_head(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009015 LL_ACCESS_NOLOCK);
9016 while (pEntry) {
9017 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9018 if ((eSmeCommandRoam == pCommand->command)
9019 && (sessionId == pCommand->sessionId)) {
9020 fRet = true;
9021 break;
9022 }
Krunal Soni72dba662017-02-15 20:13:17 -08009023 pEntry = csr_nonscan_pending_ll_next(pMac, pEntry,
9024 LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009025 }
Krunal Soni20126cb2017-02-15 16:26:57 -08009026 csr_nonscan_pending_ll_unlock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009027 }
Krunal Soni20126cb2017-02-15 16:26:57 -08009028 csr_nonscan_active_ll_unlock(pMac);
9029
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009030 return fRet;
9031}
9032
9033bool csr_is_roam_command_waiting(tpAniSirGlobal pMac)
9034{
9035 bool fRet = false;
9036 uint32_t i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309037
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009038 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
9039 fRet = csr_is_roam_command_waiting_for_session(pMac, i);
9040 if (CSR_IS_SESSION_VALID(pMac, i)
9041 && (fRet)) {
9042 break;
9043 }
9044 }
9045 return fRet;
9046}
9047
Krunal Sonif3583022017-02-10 17:18:10 -08009048bool csr_is_scan_for_roam_command_active(tpAniSirGlobal pMac,
9049 uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009050{
9051 bool fRet = false;
9052 tListElem *pEntry;
Krunal Soni78618d92017-02-14 21:46:31 -08009053 tSmeCmd *pCommand;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009054 /* alwasy lock active list before locking pending list */
Krunal Soni20126cb2017-02-15 16:26:57 -08009055 csr_nonscan_active_ll_lock(pMac);
Krunal Sonia8270f52017-02-23 19:51:25 -08009056 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009057 if (pEntry) {
Krunal Soni78618d92017-02-14 21:46:31 -08009058 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
9059 if ((eSmeCommandScan == pCommand->command) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009060 ((eCsrScanForSsid == pCommand->u.scanCmd.reason) ||
9061 (eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason))) {
9062 fRet = true;
9063 }
9064 }
Krunal Soni20126cb2017-02-15 16:26:57 -08009065 csr_nonscan_active_ll_unlock(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009066 return fRet;
9067}
9068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009069static void
9070csr_roaming_state_config_cnf_processor(tpAniSirGlobal mac_ctx,
Krunal Sonia8270f52017-02-23 19:51:25 -08009071 tSmeCmd *cmd, uint32_t result, uint8_t sme_session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009072{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009073 tCsrScanResult *scan_result = NULL;
9074 tSirBssDescription *bss_desc = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009075 uint32_t session_id;
9076 tCsrRoamSession *session;
9077 tDot11fBeaconIEs *local_ies = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309078 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009079
Krunal Sonia8270f52017-02-23 19:51:25 -08009080 if (NULL == cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009081 sme_err("given sme cmd is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009082 return;
9083 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009084 session_id = cmd->sessionId;
9085 session = CSR_GET_SESSION(mac_ctx, session_id);
9086
9087 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009088 sme_err("session %d not found", session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009089 return;
9090 }
9091
9092 if (CSR_IS_ROAMING(session) && session->fCancelRoaming) {
9093 /* the roaming is cancelled. Simply complete the command */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009094 sme_warn("Roam command canceled");
Krunal Sonif3583022017-02-10 17:18:10 -08009095 csr_roam_complete(mac_ctx, eCsrNothingToJoin, NULL,
9096 sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009097 return;
9098 }
9099
9100 /* If the roaming has stopped, not to continue the roaming command */
9101 if (!CSR_IS_ROAMING(session) && CSR_IS_ROAMING_COMMAND(cmd)) {
9102 /* No need to complete roaming here as it already completes */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009103 sme_warn(
9104 "Roam cmd (reason %d) aborted(roaming completed)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009105 cmd->u.roamCmd.roamReason);
9106 csr_set_abort_roaming_command(mac_ctx, cmd);
Krunal Sonif3583022017-02-10 17:18:10 -08009107 csr_roam_complete(mac_ctx, eCsrNothingToJoin, NULL,
9108 sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009109 return;
9110 }
9111
9112 if (!IS_SIR_STATUS_SUCCESS(result)) {
9113 /*
9114 * In the event the configuration failed, for infra let the roam
9115 * processor attempt to join something else...
9116 */
9117 if (cmd->u.roamCmd.pRoamBssEntry
9118 && CSR_IS_INFRASTRUCTURE(&cmd->u.roamCmd.roamProfile)) {
9119 csr_roam(mac_ctx, cmd);
9120 } else {
9121 /* We need to complete the command */
9122 if (csr_is_bss_type_ibss
9123 (cmd->u.roamCmd.roamProfile.BSSType)) {
9124 csr_roam_complete(mac_ctx, eCsrStartBssFailure,
Krunal Sonif3583022017-02-10 17:18:10 -08009125 NULL, sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009126 } else {
9127 csr_roam_complete(mac_ctx, eCsrNothingToJoin,
Krunal Sonif3583022017-02-10 17:18:10 -08009128 NULL, sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009129 }
9130 }
9131 return;
9132 }
9133
9134 /* we have active entry */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009135 sme_debug("Cfg sequence complete");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009136 /*
9137 * Successfully set the configuration parameters for the new Bss.
9138 * Attempt to join the roaming Bss
9139 */
9140 if (cmd->u.roamCmd.pRoamBssEntry) {
9141 scan_result = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
9142 tCsrScanResult,
9143 Link);
9144 bss_desc = &scan_result->Result.BssDescriptor;
9145 }
9146 if (csr_is_bss_type_ibss(cmd->u.roamCmd.roamProfile.BSSType)
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07009147 || CSR_IS_INFRA_AP(&cmd->u.roamCmd.roamProfile)
9148 || CSR_IS_NDI(&cmd->u.roamCmd.roamProfile)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309149 if (!QDF_IS_STATUS_SUCCESS(csr_roam_issue_start_bss(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009150 session_id, &session->bssParams,
9151 &cmd->u.roamCmd.roamProfile,
9152 bss_desc,
9153 cmd->u.roamCmd.roamId))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009154 sme_err("CSR start BSS failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009155 /* We need to complete the command */
Krunal Sonif3583022017-02-10 17:18:10 -08009156 csr_roam_complete(mac_ctx, eCsrStartBssFailure, NULL,
9157 sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009158 }
9159 return;
9160 }
9161
9162 if (!cmd->u.roamCmd.pRoamBssEntry) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009163 sme_err("pRoamBssEntry is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009164 /* We need to complete the command */
Krunal Sonif3583022017-02-10 17:18:10 -08009165 csr_roam_complete(mac_ctx, eCsrJoinFailure, NULL,
9166 sme_session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009167 return;
9168 }
9169
9170 if (NULL == scan_result) {
9171 /* If we are roaming TO an Infrastructure BSS... */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309172 QDF_ASSERT(scan_result != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009173 return;
9174 }
9175
9176 if (!csr_is_infra_bss_desc(bss_desc)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009177 sme_warn("found BSSType mismatching the one in BSS descp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009178 return;
9179 }
9180
9181 local_ies = (tDot11fBeaconIEs *) scan_result->Result.pvIes;
9182 if (!local_ies) {
9183 status = csr_get_parsed_bss_description_ies(mac_ctx, bss_desc,
9184 &local_ies);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309185 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009186 return;
9187 }
9188
9189 if (csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
9190 if (csr_is_ssid_equal(mac_ctx, session->pConnectBssDesc,
9191 bss_desc, local_ies)) {
9192 cmd->u.roamCmd.fReassoc = true;
9193 csr_roam_issue_reassociate(mac_ctx, session_id,
9194 bss_desc, local_ies,
9195 &cmd->u.roamCmd.roamProfile);
9196 } else {
9197 /*
9198 * otherwise, we have to issue a new Join request to LIM
9199 * because we disassociated from the previously
9200 * associated AP.
9201 */
9202 status = csr_roam_issue_join(mac_ctx, session_id,
9203 bss_desc, local_ies,
9204 &cmd->u.roamCmd.roamProfile,
9205 cmd->u.roamCmd.roamId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309206 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009207 /* try something else */
9208 csr_roam(mac_ctx, cmd);
9209 }
9210 }
9211 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309212 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009213 /*
9214 * We need to come with other way to figure out that this is
9215 * because of HO in BMP The below API will be only available for
9216 * Android as it uses a different HO algorithm. Reassoc request
9217 * will be used only for ESE and 11r handoff whereas other
9218 * legacy roaming should use join request
9219 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009220 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
9221 && csr_roam_is11r_assoc(mac_ctx, session_id)) {
9222 status = csr_roam_issue_reassociate(mac_ctx,
9223 session_id, bss_desc,
Will Huang03b54ee2017-06-21 10:57:05 +08009224 local_ies,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009225 &cmd->u.roamCmd.roamProfile);
9226 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009227#ifdef FEATURE_WLAN_ESE
9228 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
9229 && csr_roam_is_ese_assoc(mac_ctx, session_id)) {
9230 /* Now serialize the reassoc command. */
9231 status = csr_roam_issue_reassociate_cmd(mac_ctx,
9232 session_id);
9233 } else
9234#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009235 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
9236 && csr_roam_is_fast_roam_enabled(mac_ctx, session_id)) {
9237 /* Now serialize the reassoc command. */
9238 status = csr_roam_issue_reassociate_cmd(mac_ctx,
9239 session_id);
Deepak Dhamdhereecce9742015-11-08 01:16:43 -08009240 } else {
9241 /*
9242 * else we are not connected and attempting to Join.
9243 * Issue the Join request.
9244 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009245 status = csr_roam_issue_join(mac_ctx, session_id,
9246 bss_desc,
Will Huang03b54ee2017-06-21 10:57:05 +08009247 local_ies,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009248 &cmd->u.roamCmd.roamProfile,
9249 cmd->u.roamCmd.roamId);
9250 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309251 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009252 /* try something else */
9253 csr_roam(mac_ctx, cmd);
9254 }
9255 }
9256 if (!scan_result->Result.pvIes) {
9257 /* Locally allocated */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309258 qdf_mem_free(local_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009259 }
9260}
9261
9262static void csr_roam_roaming_state_reassoc_rsp_processor(tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309263 tpSirSmeJoinRsp pSmeJoinRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009264{
9265 eCsrRoamCompleteResult result;
9266 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
9267 &pMac->roam.neighborRoamInfo[pSmeJoinRsp->sessionId];
9268 tCsrRoamInfo roamInfo;
9269 uint32_t roamId = 0;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07009270 tCsrRoamSession *csr_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009271
9272 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309273 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009274 "CSR SmeReassocReq Successful");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009275 result = eCsrReassocSuccess;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07009276 csr_session = CSR_GET_SESSION(pMac, pSmeJoinRsp->sessionId);
9277 if (NULL != csr_session) {
9278 csr_session->supported_nss_1x1 =
9279 pSmeJoinRsp->supported_nss_1x1;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009280 sme_debug("SME session supported nss: %d",
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07009281 csr_session->supported_nss_1x1);
9282 }
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -08009283 /*
9284 * Since the neighbor roam algorithm uses reassoc req for
9285 * handoff instead of join, we need the response contents while
9286 * processing the result in csr_roam_process_results()
9287 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309288 if (csr_roam_is_handoff_in_progress(pMac,
9289 pSmeJoinRsp->sessionId)) {
9290 /* Need to dig more on indicating events to
9291 * SME QoS module
9292 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009293 sme_qos_csr_event_ind(pMac, pSmeJoinRsp->sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309294 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
Krunal Sonif3583022017-02-10 17:18:10 -08009295 csr_roam_complete(pMac, result, pSmeJoinRsp,
9296 pSmeJoinRsp->sessionId);
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -08009297 } else {
Krunal Sonif3583022017-02-10 17:18:10 -08009298 csr_roam_complete(pMac, result, NULL,
9299 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009300 }
9301 }
9302 /* Should we handle this similar to handling the join failure? Is it ok
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309303 * to call csr_roam_complete() with state as CsrJoinFailure
9304 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009305 else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009306 sme_warn(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009307 "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]",
9308 pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode);
9309 result = eCsrReassocFailure;
Abhishek Singh5ea86532016-04-27 14:10:53 +05309310 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
9311 WLAN_LOG_INDICATOR_HOST_DRIVER,
9312 WLAN_LOG_REASON_ROAM_FAIL,
9313 true, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009314 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE ==
9315 pSmeJoinRsp->statusCode)
9316 || (eSIR_SME_FT_REASSOC_FAILURE ==
9317 pSmeJoinRsp->statusCode)
9318 || (eSIR_SME_INVALID_PARAMETERS ==
9319 pSmeJoinRsp->statusCode)) {
9320 /* Inform HDD to turn off FT flag in HDD */
9321 if (pNeighborRoamInfo) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309322 qdf_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009323 csr_roam_call_callback(pMac,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -07009324 pSmeJoinRsp->sessionId,
9325 &roamInfo, roamId,
9326 eCSR_ROAM_FT_REASSOC_FAILED,
9327 eCSR_ROAM_RESULT_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009328 /*
9329 * Since the above callback sends a disconnect
9330 * to HDD, we should clean-up our state
9331 * machine as well to be in sync with the upper
9332 * layers. There is no need to send a disassoc
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309333 * since: 1) we will never reassoc to the
9334 * current AP in LFR, and 2) there is no need
9335 * to issue a disassoc to the AP with which we
9336 * were trying to reassoc.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009337 */
Krunal Sonif3583022017-02-10 17:18:10 -08009338 csr_roam_complete(pMac, eCsrJoinFailure, NULL,
9339 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009340 return;
9341 }
9342 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309343 /* In the event that the Reassociation fails, then we need to
9344 * Disassociate the current association and keep roaming. Note
9345 * that we will attempt to Join the AP instead of a Reassoc
9346 * since we may have attempted a 'Reassoc to self', which AP's
9347 * that don't support Reassoc will force a Disassoc. The
9348 * isassoc rsp message will remove the command from active list
9349 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309350 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009351 (csr_roam_issue_disassociate
9352 (pMac, pSmeJoinRsp->sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309353 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE,
9354 false))) {
Krunal Sonif3583022017-02-10 17:18:10 -08009355 csr_roam_complete(pMac, eCsrJoinFailure, NULL,
9356 pSmeJoinRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009357 }
9358 }
9359}
9360
9361static void csr_roam_roaming_state_stop_bss_rsp_processor(tpAniSirGlobal pMac,
9362 tSirSmeRsp *pSmeRsp)
9363{
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07009364 eCsrRoamCompleteResult result_code = eCsrNothingToJoin;
Naveen Rawatefd71c32016-10-25 17:05:47 -07009365 tCsrRoamProfile *profile;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07009366
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009367#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9368 {
9369 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309370
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009371 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
9372 LOG_WLAN_IBSS_C);
9373 if (pIbssLog) {
9374 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309375 if (eSIR_SME_SUCCESS != pSmeRsp->statusCode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009376 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009377 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
9378 }
9379 }
9380#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
9381 pMac->roam.roamSession[pSmeRsp->sessionId].connectState =
9382 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9383 if (CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ(pMac, pSmeRsp->sessionId)) {
Naveen Rawatefd71c32016-10-25 17:05:47 -07009384 profile =
9385 pMac->roam.roamSession[pSmeRsp->sessionId].pCurRoamProfile;
9386 if (profile && CSR_IS_CONN_NDI(profile)) {
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07009387 result_code = eCsrStopBssSuccess;
9388 if (pSmeRsp->statusCode != eSIR_SME_SUCCESS)
9389 result_code = eCsrStopBssFailure;
9390 }
Krunal Sonif3583022017-02-10 17:18:10 -08009391 csr_roam_complete(pMac, result_code, NULL, pSmeRsp->sessionId);
Naveen Rawatefd71c32016-10-25 17:05:47 -07009392 } else if (CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE(pMac,
9393 pSmeRsp->sessionId)) {
Krunal Sonif3583022017-02-10 17:18:10 -08009394 csr_roam_reissue_roam_command(pMac, pSmeRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009395 }
9396}
9397
9398/**
9399 * csr_dequeue_command() - removes a command from active cmd list
9400 * @pMac: mac global context
9401 *
9402 * Return: void
9403 */
9404static void
9405csr_dequeue_command(tpAniSirGlobal mac_ctx)
9406{
9407 bool fRemoveCmd;
9408 tSmeCmd *cmd = NULL;
Krunal Sonia8270f52017-02-23 19:51:25 -08009409 tListElem *entry = csr_nonscan_active_ll_peek_head(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009410 LL_ACCESS_LOCK);
9411 if (!entry) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009412 sme_err("NO commands are active");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009413 return;
9414 }
9415
9416 cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
9417 /*
9418 * If the head of the queue is Active and it is a given cmd type, remove
9419 * and put this on the Free queue.
9420 */
9421 if (eSmeCommandRoam != cmd->command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009422 sme_err("Roam command not active");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009423 return;
9424 }
9425 /*
9426 * we need to process the result first before removing it from active
9427 * list because state changes still happening insides
9428 * roamQProcessRoamResults so no other roam command should be issued.
9429 */
Krunal Soni72dba662017-02-15 20:13:17 -08009430 fRemoveCmd = csr_nonscan_active_ll_remove_entry(mac_ctx, entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009431 LL_ACCESS_LOCK);
9432 if (cmd->u.roamCmd.fReleaseProfile) {
9433 csr_release_profile(mac_ctx, &cmd->u.roamCmd.roamProfile);
9434 cmd->u.roamCmd.fReleaseProfile = false;
9435 }
9436 if (fRemoveCmd)
Krunal Sonidea45952017-02-15 11:58:15 -08009437 csr_release_command(mac_ctx, cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009438 else
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009439 sme_err("fail to remove cmd reason %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009440 cmd->u.roamCmd.roamReason);
9441}
9442
9443/**
9444 * csr_post_roam_failure() - post roam failure back to csr and issues a disassoc
9445 * @pMac: mac global context
9446 * @session_id: session id
9447 * @roam_info: roam info struct
9448 * @scan_filter: scan filter to free
9449 * @cur_roam_profile: current csr roam profile
9450 *
9451 * Return: void
9452 */
9453static void
9454csr_post_roam_failure(tpAniSirGlobal mac_ctx,
9455 uint32_t session_id,
9456 tCsrRoamInfo *roam_info,
9457 tCsrScanResultFilter *scan_filter,
9458 tCsrRoamProfile *cur_roam_profile)
9459{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309460 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009461
9462 if (scan_filter) {
9463 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309464 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009465 }
9466 if (cur_roam_profile)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309467 qdf_mem_free(cur_roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009468
9469#ifdef WLAN_FEATURE_ROAM_OFFLOAD
9470 csr_roam_synch_clean_up(mac_ctx, session_id);
9471#endif
9472 /* Inform the upper layers that the reassoc failed */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309473 qdf_mem_zero(roam_info, sizeof(tCsrRoamInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009474 csr_roam_call_callback(mac_ctx, session_id, roam_info, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -07009475 eCSR_ROAM_FT_REASSOC_FAILED,
9476 eCSR_ROAM_RESULT_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009477 /*
9478 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT
9479 * session. Upon success, we would re-enter this routine after receiving
9480 * the disassoc response and will fall into the reassoc fail sub-state.
9481 * And, eventually call csr_roam_complete which would remove the roam
9482 * command from SME active queue.
9483 */
9484 status = csr_roam_issue_disassociate(mac_ctx, session_id,
9485 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309486 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009487 sme_err(
9488 "csr_roam_issue_disassociate failed, status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009489 status);
Krunal Sonif3583022017-02-10 17:18:10 -08009490 csr_roam_complete(mac_ctx, eCsrJoinFailure, NULL, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009491 }
9492}
9493
9494/**
9495 * csr_check_profile_in_scan_cache() - finds if roam profile is present in scan
9496 * cache or not
9497 * @pMac: mac global context
9498 * @scan_filter: out param, scan filter
9499 * @neighbor_roam_info: roam info struct
9500 * @hBSSList: scan result
9501 *
9502 * Return: true if found else false.
9503 */
9504static bool
9505csr_check_profile_in_scan_cache(tpAniSirGlobal mac_ctx,
9506 tCsrScanResultFilter **scan_filter,
9507 tpCsrNeighborRoamControlInfo neighbor_roam_info,
9508 tScanResultHandle *hBSSList)
9509{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309510 QDF_STATUS status;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309511 *scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009512 if (NULL == *scan_filter) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009513 sme_err("alloc for ScanFilter failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009514 return false;
9515 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009516 (*scan_filter)->scan_filter_for_roam = 1;
9517 status = csr_roam_prepare_filter_from_profile(mac_ctx,
9518 &neighbor_roam_info->csrNeighborRoamProfile,
9519 *scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309520 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009521 sme_err(
9522 "failed to prepare scan filter, status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009523 status);
9524 return false;
9525 }
9526 status = csr_scan_get_result(mac_ctx, *scan_filter, hBSSList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309527 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009528 sme_err(
9529 "csr_scan_get_result failed, status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009530 status);
9531 return false;
9532 }
9533 return true;
9534}
9535
Jeff Johnson29e2ca12016-10-14 12:50:38 -07009536static
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009537void csr_roam_roaming_state_disassoc_rsp_processor(tpAniSirGlobal pMac,
9538 tSirSmeDisassocRsp *pSmeRsp)
9539{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009540 tScanResultHandle hBSSList;
Kapil Guptaffa26022017-08-16 12:20:09 +05309541 tCsrRoamInfo *roamInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009542 tCsrScanResultFilter *pScanFilter = NULL;
9543 uint32_t roamId = 0;
9544 tCsrRoamProfile *pCurRoamProfile = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309545 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009546 uint32_t sessionId;
9547 tCsrRoamSession *pSession;
9548 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
9549 tSirSmeDisassocRsp SmeDisassocRsp;
9550
9551 csr_ser_des_unpack_diassoc_rsp((uint8_t *) pSmeRsp, &SmeDisassocRsp);
9552 sessionId = SmeDisassocRsp.sessionId;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009553 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, "sessionId %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009554 sessionId);
9555
9556 if (csr_is_conn_state_infra(pMac, sessionId)) {
9557 pMac->roam.roamSession[sessionId].connectState =
9558 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9559 }
9560
9561 pSession = CSR_GET_SESSION(pMac, sessionId);
9562 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009563 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009564 return;
9565 }
9566
Kapil Guptaffa26022017-08-16 12:20:09 +05309567 roamInfo = qdf_mem_malloc(sizeof(*roamInfo));
9568
9569 if (!roamInfo) {
9570 sme_err("failed to allocate memory");
9571 return;
9572 }
9573
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009574 if (CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009575 sme_debug("***eCsrNothingToJoin***");
Krunal Sonif3583022017-02-10 17:18:10 -08009576 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009577 } else if (CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED(pMac, sessionId) ||
9578 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ(pMac, sessionId)) {
9579 if (eSIR_SME_SUCCESS == SmeDisassocRsp.statusCode) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009580 sme_debug("CSR force disassociated successful");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009581 /*
9582 * A callback to HDD will be issued from
9583 * csr_roam_complete so no need to do anything here
9584 */
9585 }
Krunal Sonif3583022017-02-10 17:18:10 -08009586 csr_roam_complete(pMac, eCsrNothingToJoin, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009587 } else if (CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309588 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009589 "CSR SmeDisassocReq due to HO on session %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009590 sessionId);
9591 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009592 /*
9593 * First ensure if the roam profile is in the scan cache.
9594 * If not, post a reassoc failure and disconnect.
9595 */
9596 if (!csr_check_profile_in_scan_cache(pMac, &pScanFilter,
9597 pNeighborRoamInfo, &hBSSList))
9598 goto POST_ROAM_FAILURE;
9599
9600 /*
9601 * After ensuring that the roam profile is in the scan result
9602 * list, dequeue the command from the active list.
9603 */
9604 csr_dequeue_command(pMac);
9605
9606 /* notify HDD about handoff and provide the BSSID too */
Kapil Guptaffa26022017-08-16 12:20:09 +05309607 roamInfo->reasonCode = eCsrRoamReasonBetterAP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009608
Kapil Guptaffa26022017-08-16 12:20:09 +05309609 qdf_copy_macaddr(&roamInfo->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009610 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid);
9611
Kapil Guptaffa26022017-08-16 12:20:09 +05309612 csr_roam_call_callback(pMac, sessionId, roamInfo, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009613 eCSR_ROAM_ROAMING_START,
9614 eCSR_ROAM_RESULT_NONE);
9615
9616 /*
9617 * Copy the connected profile to apply the same for this
9618 * connection as well
9619 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309620 pCurRoamProfile = qdf_mem_malloc(sizeof(tCsrRoamProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009621 if (pCurRoamProfile != NULL) {
9622 /*
9623 * notify sub-modules like QoS etc. that handoff
9624 * happening
9625 */
9626 sme_qos_csr_event_ind(pMac, sessionId,
9627 SME_QOS_CSR_HANDOFF_ASSOC_REQ,
9628 NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009629 csr_roam_copy_profile(pMac, pCurRoamProfile,
9630 pSession->pCurRoamProfile);
9631 /* make sure to put it at the head of the cmd queue */
9632 status = csr_roam_issue_connect(pMac, sessionId,
9633 pCurRoamProfile, hBSSList,
9634 eCsrSmeIssuedAssocToSimilarAP,
9635 roamId, true, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309636 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009637 sme_err(
9638 "issue_connect failed. status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009639 status);
9640
9641 csr_release_profile(pMac, pCurRoamProfile);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309642 qdf_mem_free(pCurRoamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009643 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309644 qdf_mem_free(pScanFilter);
Kapil Guptaffa26022017-08-16 12:20:09 +05309645 qdf_mem_free(roamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009646 return;
9647 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309648 csr_scan_result_purge(pMac, hBSSList);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009649
9650POST_ROAM_FAILURE:
Kapil Guptaffa26022017-08-16 12:20:09 +05309651 csr_post_roam_failure(pMac, sessionId, roamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009652 pScanFilter, pCurRoamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009653 } /* else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) ) */
9654 else if (CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL(pMac, sessionId)) {
9655 /* Disassoc due to Reassoc failure falls into this codepath */
Krunal Sonif3583022017-02-10 17:18:10 -08009656 csr_roam_complete(pMac, eCsrJoinFailure, NULL, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009657 } else {
9658 if (eSIR_SME_SUCCESS == SmeDisassocRsp.statusCode) {
9659 /*
9660 * Successfully disassociated from the 'old' Bss.
9661 * We get Disassociate response in three conditions.
9662 * 1) The case where we are disasociating from an Infra
9663 * Bss to start an IBSS.
9664 * 2) When we are disassociating from an Infra Bss to
9665 * join an IBSS or a new infra network.
9666 * 3) Where we are doing an Infra to Infra roam between
9667 * networks with different SSIDs.
9668 * In all cases, we set the new Bss configuration here
9669 * and attempt to join
9670 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009671 sme_debug("Disassociated successfully");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009672 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009673 sme_err(
9674 "DisassocReq failed, statusCode= 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009675 SmeDisassocRsp.statusCode);
9676 }
9677 /* We are not done yet. Get the data and continue roaming */
Krunal Sonif3583022017-02-10 17:18:10 -08009678 csr_roam_reissue_roam_command(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009679 }
Kapil Guptaffa26022017-08-16 12:20:09 +05309680 qdf_mem_free(roamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009681}
9682
9683static void csr_roam_roaming_state_deauth_rsp_processor(tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309684 tSirSmeDeauthRsp *pSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009685{
9686 tSirResultCodes statusCode;
9687 /* No one is sending eWNI_SME_DEAUTH_REQ to PE. */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009688 sme_debug("is no-op");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009689 statusCode = csr_get_de_auth_rsp_status_code(pSmeRsp);
9690 pMac->roam.deauthRspStatus = statusCode;
9691 if (CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ(pMac, pSmeRsp->sessionId)) {
Krunal Sonif3583022017-02-10 17:18:10 -08009692 csr_roam_complete(pMac, eCsrNothingToJoin, NULL,
9693 pSmeRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009694 } else {
9695 if (eSIR_SME_SUCCESS == statusCode) {
9696 /* Successfully deauth from the 'old' Bss... */
9697 /* */
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009698 sme_debug(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009699 "CSR SmeDeauthReq disassociated Successfully");
9700 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009701 sme_warn(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009702 "SmeDeauthReq failed with statusCode= 0x%08X",
9703 statusCode);
9704 }
9705 /* We are not done yet. Get the data and continue roaming */
Krunal Sonif3583022017-02-10 17:18:10 -08009706 csr_roam_reissue_roam_command(pMac, pSmeRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009707 }
9708}
9709
9710static void csr_roam_roaming_state_start_bss_rsp_processor(tpAniSirGlobal pMac,
9711 tSirSmeStartBssRsp *
9712 pSmeStartBssRsp)
9713{
9714 eCsrRoamCompleteResult result;
9715
9716 if (eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009717 sme_debug("SmeStartBssReq Successful");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009718 result = eCsrStartBssSuccess;
9719 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309720 sme_warn("SmeStartBssReq failed with statusCode= 0x%08X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009721 pSmeStartBssRsp->statusCode);
9722 /* Let csr_roam_complete decide what to do */
9723 result = eCsrStartBssFailure;
9724 }
Krunal Sonif3583022017-02-10 17:18:10 -08009725 csr_roam_complete(pMac, result, pSmeStartBssRsp,
9726 pSmeStartBssRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009727}
9728
9729/**
9730 * csr_roaming_state_msg_processor() - process roaming messages
9731 * @pMac: mac global context
9732 * @pMsgBuf: message buffer
9733 *
9734 * We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of
9735 * strucutres. It depends on how the message is constructed. If the message is
9736 * sent by lim_send_sme_rsp, the pMsgBuf is only a generic response and can only
9737 * be used as pointer to tSirSmeRsp. For the messages where sender allocates
9738 * memory for specific structures, then it can be cast accordingly.
9739 *
9740 * Return: status of operation
9741 */
9742void csr_roaming_state_msg_processor(tpAniSirGlobal pMac, void *pMsgBuf)
9743{
9744 tSirSmeRsp *pSmeRsp;
9745 tSmeIbssPeerInd *pIbssPeerInd;
9746 tCsrRoamInfo roamInfo;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309747
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009748 pSmeRsp = (tSirSmeRsp *) pMsgBuf;
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009749 sme_debug("Message %d[0x%04X] received in substate %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009750 pSmeRsp->messageType, pSmeRsp->messageType,
9751 mac_trace_getcsr_roam_sub_state(
9752 pMac->roam.curSubState[pSmeRsp->sessionId]));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009753
9754 switch (pSmeRsp->messageType) {
9755
9756 case eWNI_SME_JOIN_RSP:
9757 /* in Roaming state, process the Join response message... */
9758 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
9759 /* We sent a JOIN_REQ */
9760 csr_roam_join_rsp_processor(pMac,
9761 (tSirSmeJoinRsp *) pSmeRsp);
9762 break;
9763 case eWNI_SME_REASSOC_RSP:
9764 /* or the Reassociation response message... */
9765 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ(pMac, pSmeRsp->sessionId))
9766 csr_roam_roaming_state_reassoc_rsp_processor(pMac,
9767 (tpSirSmeJoinRsp) pSmeRsp);
9768 break;
9769 case eWNI_SME_STOP_BSS_RSP:
9770 /* or the Stop Bss response message... */
9771 csr_roam_roaming_state_stop_bss_rsp_processor(pMac, pSmeRsp);
9772 break;
9773 case eWNI_SME_DISASSOC_RSP:
9774 /* or the Disassociate response message... */
9775 if (CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ(pMac, pSmeRsp->sessionId)
9776 || CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN(pMac,
9777 pSmeRsp->sessionId)
9778 || CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL(pMac,
9779 pSmeRsp->sessionId)
9780 || CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED(pMac,
9781 pSmeRsp->sessionId)
9782 || CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE(pMac,
9783 pSmeRsp->sessionId)
9784 || CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac,
9785 pSmeRsp->sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309786 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009787 "eWNI_SME_DISASSOC_RSP subState = %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009788 mac_trace_getcsr_roam_sub_state(
9789 pMac->roam.curSubState[pSmeRsp->sessionId]));
9790 csr_roam_roaming_state_disassoc_rsp_processor(pMac,
9791 (tSirSmeDisassocRsp *) pSmeRsp);
9792 }
9793 break;
9794 case eWNI_SME_DEAUTH_RSP:
9795 /* or the Deauthentication response message... */
Selvaraj, Sridharfd889b52016-06-24 12:37:04 +05309796 if (CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ(pMac, pSmeRsp->sessionId)) {
Krunal Soni72dba662017-02-15 20:13:17 -08009797 csr_remove_nonscan_cmd_from_pending_list(pMac,
Selvaraj, Sridharfd889b52016-06-24 12:37:04 +05309798 pSmeRsp->sessionId,
Selvaraj, Sridharfd889b52016-06-24 12:37:04 +05309799 eSmeCommandWmStatusChange);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009800 csr_roam_roaming_state_deauth_rsp_processor(pMac,
9801 (tSirSmeDeauthRsp *) pSmeRsp);
Selvaraj, Sridharfd889b52016-06-24 12:37:04 +05309802 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009803 break;
9804 case eWNI_SME_START_BSS_RSP:
9805 /* or the Start BSS response message... */
9806 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ(pMac,
9807 pSmeRsp->sessionId))
9808 csr_roam_roaming_state_start_bss_rsp_processor(pMac,
9809 (tSirSmeStartBssRsp *) pSmeRsp);
9810 break;
9811 /* In case CSR issues STOP_BSS, we need to tell HDD about peer departed
9812 * becasue PE is removing them
9813 */
9814 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9815 pIbssPeerInd = (tSmeIbssPeerInd *) pSmeRsp;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309816 sme_err("Peer departed ntf from LIM in joining state");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309817 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009818 roamInfo.staId = (uint8_t) pIbssPeerInd->staId;
9819 roamInfo.ucastSig = (uint8_t) pIbssPeerInd->ucastSig;
9820 roamInfo.bcastSig = (uint8_t) pIbssPeerInd->bcastSig;
Anurag Chouhanc5548422016-02-24 18:33:27 +05309821 qdf_copy_macaddr(&roamInfo.peerMac, &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009822 csr_roam_call_callback(pMac, pSmeRsp->sessionId, &roamInfo, 0,
9823 eCSR_ROAM_CONNECT_STATUS_UPDATE,
9824 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9825 break;
9826 case eWNI_SME_GET_RSSI_REQ:
9827 {
9828 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq *) pMsgBuf;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309829
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009830 if (NULL != pGetRssiReq->rssiCallback)
9831 ((tCsrRssiCallback) pGetRssiReq->rssiCallback)
9832 (pGetRssiReq->lastRSSI, pGetRssiReq->staId,
9833 pGetRssiReq->pDevContext);
9834 else
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009835 sme_err("pGetRssiReq->rssiCallback is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009836 }
9837 break;
9838 default:
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309839 sme_debug("Unexpected message type: %d[0x%X] received in substate %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009840 pSmeRsp->messageType, pSmeRsp->messageType,
9841 mac_trace_getcsr_roam_sub_state(
9842 pMac->roam.curSubState[pSmeRsp->sessionId]));
9843 /* If we are connected, check the link status change */
9844 if (!csr_is_conn_state_disconnected(pMac, pSmeRsp->sessionId))
9845 csr_roam_check_for_link_status_change(pMac, pSmeRsp);
9846 break;
9847 }
9848}
9849
9850void csr_roam_joined_state_msg_processor(tpAniSirGlobal pMac, void *pMsgBuf)
9851{
9852 tSirSmeRsp *pSirMsg = (tSirSmeRsp *) pMsgBuf;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009854 switch (pSirMsg->messageType) {
9855 case eWNI_SME_GET_STATISTICS_RSP:
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009856 sme_debug("Stats rsp from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009857 csr_roam_stats_rsp_processor(pMac, pSirMsg);
9858 break;
9859 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
9860 {
9861 tCsrRoamSession *pSession;
9862 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
9863 tCsrRoamInfo roamInfo;
9864 tCsrRoamInfo *pRoamInfo = NULL;
9865 uint32_t sessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309866 QDF_STATUS status;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309867
9868 sme_debug("ASSOCIATION confirmation can be given to upper layer ");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309869 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009870 pRoamInfo = &roamInfo;
9871 pUpperLayerAssocCnf =
9872 (tSirSmeAssocIndToUpperLayerCnf *) pMsgBuf;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309873 status = csr_roam_get_session_id_from_bssid(pMac,
9874 (struct qdf_mac_addr *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009875 pUpperLayerAssocCnf->
9876 bssId, &sessionId);
9877 pSession = CSR_GET_SESSION(pMac, sessionId);
9878
9879 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -07009880 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009881 return;
9882 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309883 /* send the status code as Success */
9884 pRoamInfo->statusCode = eSIR_SME_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009885 pRoamInfo->u.pConnectedProfile =
9886 &pSession->connectedProfile;
9887 pRoamInfo->staId = (uint8_t) pUpperLayerAssocCnf->aid;
9888 pRoamInfo->rsnIELen =
9889 (uint8_t) pUpperLayerAssocCnf->rsnIE.length;
9890 pRoamInfo->prsnIE =
9891 pUpperLayerAssocCnf->rsnIE.rsnIEdata;
9892#ifdef FEATURE_WLAN_WAPI
9893 pRoamInfo->wapiIELen =
9894 (uint8_t) pUpperLayerAssocCnf->wapiIE.length;
9895 pRoamInfo->pwapiIE =
9896 pUpperLayerAssocCnf->wapiIE.wapiIEdata;
9897#endif
9898 pRoamInfo->addIELen =
9899 (uint8_t) pUpperLayerAssocCnf->addIE.length;
9900 pRoamInfo->paddIE =
9901 pUpperLayerAssocCnf->addIE.addIEdata;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309902 qdf_mem_copy(pRoamInfo->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009903 pUpperLayerAssocCnf->peerMacAddr,
9904 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309905 qdf_mem_copy(&pRoamInfo->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009906 pUpperLayerAssocCnf->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309907 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009908 pRoamInfo->wmmEnabledSta =
9909 pUpperLayerAssocCnf->wmmEnabledSta;
9910 pRoamInfo->timingMeasCap =
9911 pUpperLayerAssocCnf->timingMeasCap;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309912 qdf_mem_copy(&pRoamInfo->chan_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009913 &pUpperLayerAssocCnf->chan_info,
9914 sizeof(tSirSmeChanInfo));
Will Huang558f8082017-05-31 16:22:24 +08009915 pRoamInfo->ampdu = pUpperLayerAssocCnf->ampdu;
9916 pRoamInfo->sgi_enable = pUpperLayerAssocCnf->sgi_enable;
9917 pRoamInfo->tx_stbc = pUpperLayerAssocCnf->tx_stbc;
9918 pRoamInfo->tx_stbc = pUpperLayerAssocCnf->rx_stbc;
9919 pRoamInfo->ch_width = pUpperLayerAssocCnf->ch_width;
9920 pRoamInfo->mode = pUpperLayerAssocCnf->mode;
9921 pRoamInfo->max_supp_idx = pUpperLayerAssocCnf->max_supp_idx;
9922 pRoamInfo->max_ext_idx = pUpperLayerAssocCnf->max_ext_idx;
9923 pRoamInfo->max_mcs_idx = pUpperLayerAssocCnf->max_mcs_idx;
9924 pRoamInfo->rx_mcs_map = pUpperLayerAssocCnf->rx_mcs_map;
9925 pRoamInfo->tx_mcs_map = pUpperLayerAssocCnf->tx_mcs_map;
gaolez7bb1e742017-03-21 16:37:38 +08009926 pRoamInfo->ecsa_capable = pUpperLayerAssocCnf->ecsa_capable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009927 if (CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile)) {
9928 pMac->roam.roamSession[sessionId].connectState =
9929 eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
9930 pRoamInfo->fReassocReq =
9931 pUpperLayerAssocCnf->reassocReq;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309932 status = csr_roam_call_callback(pMac, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009933 pRoamInfo, 0,
9934 eCSR_ROAM_INFRA_IND,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309935 eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009936 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009937 }
9938 break;
9939 default:
9940 csr_roam_check_for_link_status_change(pMac, pSirMsg);
9941 break;
9942 }
9943}
9944
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309945QDF_STATUS csr_roam_issue_set_context_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009946 uint32_t sessionId,
9947 eCsrEncryptionType EncryptType,
9948 tSirBssDescription *pBssDescription,
9949 tSirMacAddr *bssId, bool addKey,
9950 bool fUnicast,
9951 tAniKeyDirection aniKeyDirection,
9952 uint8_t keyId, uint16_t keyLength,
9953 uint8_t *pKey, uint8_t paeRole)
9954{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309955 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009956 tAniEdType edType;
9957
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309958 sme_debug("sessionId: %d EncryptType: %d", sessionId, EncryptType);
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +05309959
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309960 if (eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009961 EncryptType = eCSR_ENCRYPT_TYPE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009962
9963 edType = csr_translate_encrypt_type_to_ed_type(EncryptType);
9964
9965 /*
9966 * Allow 0 keys to be set for the non-WPA encrypt types. For WPA encrypt
9967 * types, the num keys must be non-zero or LIM will reject the set
9968 * context (assumes the SET_CONTEXT does not occur until the keys are
9969 * distrubuted).
9970 */
9971 if (CSR_IS_ENC_TYPE_STATIC(EncryptType) || addKey) {
9972 tCsrRoamSetKey setKey;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309973
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009974 setKey.encType = EncryptType;
9975 setKey.keyDirection = aniKeyDirection;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309976 qdf_mem_copy(&setKey.peerMac, bssId, sizeof(struct
9977 qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009978 /* 0 for supplicant */
9979 setKey.paeRole = paeRole;
9980 /* Key index */
9981 setKey.keyId = keyId;
9982 setKey.keyLength = keyLength;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +05309983 if (keyLength)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309984 qdf_mem_copy(setKey.Key, pKey, keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009985 status = csr_roam_issue_set_key_command(pMac, sessionId,
9986 &setKey, 0);
9987 }
9988 return status;
9989}
9990
9991/**
9992 * csr_update_key_cmd() - update key info in set key command
9993 * @mac_ctx: mac global context
9994 * @session: roam session
9995 * @set_key: input set key command
9996 * @set_key_cmd: set key command to update
Krunal Sonid3676732017-05-10 14:12:18 -07009997 * @is_key_valid: indicates if key is valid
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009998 *
Krunal Sonid3676732017-05-10 14:12:18 -07009999 * This function will validate the key length, adjust if too long. It will
10000 * update is_key_valid flag to false if some error has occured key are local.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010001 *
10002 * Return: status of operation
10003 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010004static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010005csr_update_key_cmd(tpAniSirGlobal mac_ctx, tCsrRoamSession *session,
Krunal Sonid3676732017-05-10 14:12:18 -070010006 tCsrRoamSetKey *set_key, tSetKeyCmd *set_key_cmd,
10007 bool *is_key_valid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010008{
10009 switch (set_key->encType) {
10010 case eCSR_ENCRYPT_TYPE_WEP40:
10011 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
10012 /* KeyLength maybe 0 for static WEP */
10013 if (set_key->keyLength) {
10014 if (set_key->keyLength < CSR_WEP40_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010015 sme_warn("Invalid WEP40 keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010016 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010017 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010018 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010019 }
10020
Krunal Sonid3676732017-05-10 14:12:18 -070010021 set_key_cmd->keyLength = CSR_WEP40_KEY_LEN;
10022 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010023 CSR_WEP40_KEY_LEN);
10024 }
Krunal Sonid3676732017-05-10 14:12:18 -070010025 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010026 break;
10027 case eCSR_ENCRYPT_TYPE_WEP104:
10028 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
10029 /* KeyLength maybe 0 for static WEP */
10030 if (set_key->keyLength) {
10031 if (set_key->keyLength < CSR_WEP104_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010032 sme_warn("Invalid WEP104 keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010033 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010034 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010035 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010036 }
10037
Krunal Sonid3676732017-05-10 14:12:18 -070010038 set_key_cmd->keyLength = CSR_WEP104_KEY_LEN;
10039 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010040 CSR_WEP104_KEY_LEN);
10041 }
Krunal Sonid3676732017-05-10 14:12:18 -070010042 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010043 break;
10044 case eCSR_ENCRYPT_TYPE_TKIP:
10045 if (set_key->keyLength < CSR_TKIP_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010046 sme_warn("Invalid TKIP keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010047 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010048 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010049 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010050 }
Krunal Sonid3676732017-05-10 14:12:18 -070010051 set_key_cmd->keyLength = CSR_TKIP_KEY_LEN;
10052 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010053 CSR_TKIP_KEY_LEN);
Krunal Sonid3676732017-05-10 14:12:18 -070010054 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010055 break;
10056 case eCSR_ENCRYPT_TYPE_AES:
10057 if (set_key->keyLength < CSR_AES_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010058 sme_warn("Invalid AES/CCMP keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010059 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010060 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010061 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010062 }
Krunal Sonid3676732017-05-10 14:12:18 -070010063 set_key_cmd->keyLength = CSR_AES_KEY_LEN;
10064 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010065 CSR_AES_KEY_LEN);
Krunal Sonid3676732017-05-10 14:12:18 -070010066 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010067 break;
10068#ifdef FEATURE_WLAN_WAPI
10069 case eCSR_ENCRYPT_TYPE_WPI:
10070 if (set_key->keyLength < CSR_WAPI_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010071 sme_warn("Invalid WAPI keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010072 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010073 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010074 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010075 }
Krunal Sonid3676732017-05-10 14:12:18 -070010076 set_key_cmd->keyLength = CSR_WAPI_KEY_LEN;
10077 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010078 CSR_WAPI_KEY_LEN);
10079 if (session->pCurRoamProfile) {
10080 session->pCurRoamProfile->negotiatedUCEncryptionType =
10081 eCSR_ENCRYPT_TYPE_WPI;
10082 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010083 sme_err("pCurRoamProfile is NULL");
Krunal Sonid3676732017-05-10 14:12:18 -070010084 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010085 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010086 }
Krunal Sonid3676732017-05-10 14:12:18 -070010087 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010088 break;
10089#endif /* FEATURE_WLAN_WAPI */
10090#ifdef FEATURE_WLAN_ESE
10091 case eCSR_ENCRYPT_TYPE_KRK:
10092 /* no need to enqueue KRK key request, since they are local */
Krunal Sonid3676732017-05-10 14:12:18 -070010093 *is_key_valid = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010094 if (set_key->keyLength < CSR_KRK_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010095 sme_warn("Invalid KRK keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010096 set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010097 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010098 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010099 qdf_mem_copy(session->eseCckmInfo.krk, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010100 CSR_KRK_KEY_LEN);
10101 session->eseCckmInfo.reassoc_req_num = 1;
10102 session->eseCckmInfo.krk_plumbed = true;
10103 break;
10104#ifdef WLAN_FEATURE_ROAM_OFFLOAD
10105 case eCSR_ENCRYPT_TYPE_BTK:
10106 /* no need to enqueue KRK key request, since they are local */
Krunal Sonid3676732017-05-10 14:12:18 -070010107 *is_key_valid = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010108 if (set_key->keyLength < SIR_BTK_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010109 sme_warn("LFR3:Invalid BTK keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010110 set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010111 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010112 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010113 qdf_mem_copy(session->eseCckmInfo.btk, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010114 SIR_BTK_KEY_LEN);
10115 break;
10116#endif
10117#endif /* FEATURE_WLAN_ESE */
10118#ifdef WLAN_FEATURE_11W
10119 /* Check for 11w BIP */
10120 case eCSR_ENCRYPT_TYPE_AES_CMAC:
10121 if (set_key->keyLength < CSR_AES_KEY_LEN) {
Krunal Sonid3676732017-05-10 14:12:18 -070010122 sme_warn("Invalid AES/CCMP keylength [= %d]",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010123 set_key->keyLength);
Krunal Sonid3676732017-05-10 14:12:18 -070010124 *is_key_valid = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010125 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010126 }
Krunal Sonid3676732017-05-10 14:12:18 -070010127 set_key_cmd->keyLength = CSR_AES_KEY_LEN;
10128 qdf_mem_copy(set_key_cmd->Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010129 CSR_AES_KEY_LEN);
Krunal Sonid3676732017-05-10 14:12:18 -070010130 *is_key_valid = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010131 break;
10132#endif /* WLAN_FEATURE_11W */
10133 default:
10134 /* for open security also we want to enqueue command */
Krunal Sonid3676732017-05-10 14:12:18 -070010135 *is_key_valid = true;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010136 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010137 } /* end of switch */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010138 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010139}
10140
10141
Krunal Sonid3676732017-05-10 14:12:18 -070010142static QDF_STATUS csr_roam_issue_set_key_command(tpAniSirGlobal mac_ctx,
10143 uint32_t session_id,
10144 tCsrRoamSetKey *set_key,
10145 uint32_t roam_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010146{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010147 QDF_STATUS status = QDF_STATUS_E_INVAL;
Krunal Sonid3676732017-05-10 14:12:18 -070010148 bool is_key_valid = true;
10149 tSetKeyCmd set_key_cmd;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010150#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_WAPI)
Krunal Sonid3676732017-05-10 14:12:18 -070010151 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010152
Krunal Sonid3676732017-05-10 14:12:18 -070010153 if (NULL == session) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010154 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Krunal Sonid3676732017-05-10 14:12:18 -070010155 "session %d not found", session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010156 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010157 }
10158#endif /* FEATURE_WLAN_ESE */
10159
Krunal Sonid3676732017-05-10 14:12:18 -070010160 qdf_mem_zero(&set_key_cmd, sizeof(tSetKeyCmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010161 /*
10162 * following function will validate the key length, Adjust if too long.
10163 * for static WEP the keys are not set thru' SetContextReq
10164 *
Krunal Sonid3676732017-05-10 14:12:18 -070010165 * it will update bool is_key_valid, to false if some error has occured
10166 * key are local. enqueue sme command only if is_key_valid is true
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010167 * status is indication of success or failure and will be returned to
10168 * called of current function if command is not enqueued due to key req
10169 * being local
10170 */
Krunal Sonid3676732017-05-10 14:12:18 -070010171 status = csr_update_key_cmd(mac_ctx, session, set_key,
10172 &set_key_cmd, &is_key_valid);
10173 if (is_key_valid) {
10174 set_key_cmd.roamId = roam_id;
10175 set_key_cmd.encType = set_key->encType;
10176 set_key_cmd.keyDirection = set_key->keyDirection;
10177 qdf_copy_macaddr(&set_key_cmd.peermac,
10178 &set_key->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010179 /* 0 for supplicant */
Krunal Sonid3676732017-05-10 14:12:18 -070010180 set_key_cmd.paeRole = set_key->paeRole;
10181 set_key_cmd.keyId = set_key->keyId;
10182 qdf_mem_copy(set_key_cmd.keyRsc, set_key->keyRsc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010183 CSR_MAX_RSC_LEN);
10184 /*
10185 * Always put set key to the head of the Q because it is the
10186 * only thing to get executed in case of WT_KEY state
10187 */
Krunal Sonid3676732017-05-10 14:12:18 -070010188 sme_debug("set key req for session-%d authtype-%d",
10189 session_id, set_key->encType);
10190 status = csr_roam_send_set_key_cmd(mac_ctx, session_id,
10191 &set_key_cmd);
10192 if (!QDF_IS_STATUS_SUCCESS(status))
10193 sme_err("fail to send message status = %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010194 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010195 return status;
10196}
10197
Krunal Sonid3676732017-05-10 14:12:18 -070010198QDF_STATUS csr_roam_send_set_key_cmd(tpAniSirGlobal mac_ctx,
10199 uint32_t session_id, tSetKeyCmd *set_key_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010200{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010201 QDF_STATUS status;
Krunal Sonid3676732017-05-10 14:12:18 -070010202 uint8_t num_keys = (set_key_cmd->keyLength) ? 1 : 0;
10203 tAniEdType ed_type = csr_translate_encrypt_type_to_ed_type(
10204 set_key_cmd->encType);
10205 bool unicast = (set_key_cmd->peermac.bytes[0] == 0xFF) ? false : true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010206#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Krunal Sonid3676732017-05-10 14:12:18 -070010207 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010208
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010209 WLAN_HOST_DIAG_EVENT_DEF(setKeyEvent,
10210 host_event_wlan_security_payload_type);
10211
Krunal Sonid3676732017-05-10 14:12:18 -070010212 if (NULL == session) {
10213 sme_err("session %d not found", session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010214 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010215 }
10216
Krunal Sonid3676732017-05-10 14:12:18 -070010217 if (eSIR_ED_NONE != ed_type) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010218 qdf_mem_set(&setKeyEvent,
Krunal Sonid3676732017-05-10 14:12:18 -070010219 sizeof(host_event_wlan_security_payload_type), 0);
10220 if (qdf_is_macaddr_group(&set_key_cmd->peermac)) {
Abhishek Singh7a995582016-04-27 13:53:36 +053010221 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010222 setKeyEvent.encryptionModeMulticast =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010223 (uint8_t) diag_enc_type_from_csr_type(
Krunal Sonid3676732017-05-10 14:12:18 -070010224 set_key_cmd->encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010225 setKeyEvent.encryptionModeUnicast =
Krunal Sonid3676732017-05-10 14:12:18 -070010226 (uint8_t) diag_enc_type_from_csr_type(session->
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010227 connectedProfile.
10228 EncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010229 } else {
Abhishek Singh7a995582016-04-27 13:53:36 +053010230 setKeyEvent.eventId =
10231 WLAN_SECURITY_EVENT_SET_UNICAST_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010232 setKeyEvent.encryptionModeUnicast =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010233 (uint8_t) diag_enc_type_from_csr_type(
Krunal Sonid3676732017-05-10 14:12:18 -070010234 set_key_cmd->encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010235 setKeyEvent.encryptionModeMulticast =
Krunal Sonid3676732017-05-10 14:12:18 -070010236 (uint8_t) diag_enc_type_from_csr_type(session->
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010237 connectedProfile.
10238 mcEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010239 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010240 qdf_mem_copy(setKeyEvent.bssid,
Krunal Sonid3676732017-05-10 14:12:18 -070010241 session->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010242 QDF_MAC_ADDR_SIZE);
Krunal Sonid3676732017-05-10 14:12:18 -070010243 if (CSR_IS_ENC_TYPE_STATIC(set_key_cmd->encType)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010244 uint32_t defKeyId;
10245 /* It has to be static WEP here */
Krunal Sonid3676732017-05-10 14:12:18 -070010246 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(mac_ctx,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010247 WNI_CFG_WEP_DEFAULT_KEYID,
10248 &defKeyId))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010249 setKeyEvent.keyId = (uint8_t) defKeyId;
10250 }
10251 } else {
Krunal Sonid3676732017-05-10 14:12:18 -070010252 setKeyEvent.keyId = set_key_cmd->keyId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010253 }
10254 setKeyEvent.authMode =
Krunal Sonid3676732017-05-10 14:12:18 -070010255 (uint8_t) diag_auth_type_from_csr_type(session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010256 connectedProfile.
10257 AuthType);
10258 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10259 }
10260#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
Krunal Sonid3676732017-05-10 14:12:18 -070010261 if (csr_is_set_key_allowed(mac_ctx, session_id)) {
10262 status = csr_send_mb_set_context_req_msg(mac_ctx, session_id,
10263 set_key_cmd->peermac,
10264 num_keys, ed_type, unicast,
10265 set_key_cmd->keyDirection,
10266 set_key_cmd->keyId,
10267 set_key_cmd->keyLength,
10268 set_key_cmd->Key,
10269 set_key_cmd->paeRole,
10270 set_key_cmd->keyRsc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010271 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010272 sme_warn(" cannot process not connected");
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010273 /* Set this status so the error handling take
10274 * care of the case.
10275 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010276 status = QDF_STATUS_CSR_WRONG_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010277 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010278 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010279 sme_err(" error status %d", status);
Krunal Sonid3676732017-05-10 14:12:18 -070010280 csr_roam_call_callback(mac_ctx, session_id, NULL,
10281 set_key_cmd->roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010282 eCSR_ROAM_SET_KEY_COMPLETE,
10283 eCSR_ROAM_RESULT_FAILURE);
10284#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Krunal Sonid3676732017-05-10 14:12:18 -070010285 if (eSIR_ED_NONE != ed_type) {
10286 if (qdf_is_macaddr_group(&set_key_cmd->peermac))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010287 setKeyEvent.eventId =
Abhishek Singh7a995582016-04-27 13:53:36 +053010288 WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Krunal Sonid3676732017-05-10 14:12:18 -070010289 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010290 setKeyEvent.eventId =
Abhishek Singh7a995582016-04-27 13:53:36 +053010291 WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010292 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10293 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent,
10294 EVENT_WLAN_SECURITY);
10295 }
10296#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10297 }
10298 return status;
10299}
10300
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010301QDF_STATUS csr_roam_set_key(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010302 tCsrRoamSetKey *pSetKey, uint32_t roamId)
10303{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010304 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010305
10306 if (!csr_is_set_key_allowed(pMac, sessionId)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010307 status = QDF_STATUS_CSR_WRONG_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010308 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010309 status = csr_roam_issue_set_key_command(pMac, sessionId,
10310 pSetKey, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010311 }
10312 return status;
10313}
10314
10315/*
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010316 * Prepare a filter base on a profile for parsing the scan results.
10317 * Upon successful return, caller MUST call csr_free_scan_filter on
10318 *pScanFilter when it is done with the filter.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010319 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010320QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010321csr_roam_prepare_filter_from_profile(tpAniSirGlobal mac_ctx,
10322 tCsrRoamProfile *profile,
10323 tCsrScanResultFilter *scan_fltr)
10324{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010325 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010326 uint32_t size = 0;
10327 uint8_t idx = 0;
10328 tCsrChannelInfo *fltr_ch_info = &scan_fltr->ChannelInfo;
10329 tCsrChannelInfo *profile_ch_info = &profile->ChannelInfo;
10330 struct roam_ext_params *roam_params;
10331 uint8_t i;
10332
10333 roam_params = &mac_ctx->roam.configParam.roam_params;
10334
10335 if (profile->BSSIDs.numOfBSSIDs) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010336 size = sizeof(struct qdf_mac_addr) * profile->BSSIDs.
10337 numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010338 scan_fltr->BSSIDs.bssid = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010339 if (NULL == scan_fltr->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010340 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010341 goto free_filter;
10342 }
10343 scan_fltr->BSSIDs.numOfBSSIDs = profile->BSSIDs.numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010344 qdf_mem_copy(scan_fltr->BSSIDs.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010345 profile->BSSIDs.bssid, size);
10346 }
10347
10348 if (profile->SSIDs.numOfSSIDs) {
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070010349 scan_fltr->SSIDs.numOfSSIDs = profile->SSIDs.numOfSSIDs;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010350 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010351 ("No of Allowed List:%d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010352 roam_params->num_ssid_allowed_list);
10353 if (scan_fltr->scan_filter_for_roam
10354 && roam_params->num_ssid_allowed_list) {
10355 scan_fltr->SSIDs.numOfSSIDs =
10356 roam_params->num_ssid_allowed_list;
10357 size = sizeof(tCsrSSIDInfo) *
10358 scan_fltr->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010359 scan_fltr->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010360 if (NULL == scan_fltr->SSIDs.SSIDList)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010361 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010362 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010363 status = QDF_STATUS_SUCCESS;
10364 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010365 goto free_filter;
10366 for (i = 0;
10367 i < roam_params->num_ssid_allowed_list;
10368 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010369 qdf_mem_copy((void *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010370 scan_fltr->SSIDs.SSIDList[i].SSID.ssId,
10371 roam_params->ssid_allowed_list[i].ssId,
10372 roam_params->ssid_allowed_list[i].length);
10373 scan_fltr->SSIDs.SSIDList[i].SSID.length =
10374 roam_params->ssid_allowed_list[i].length;
10375 scan_fltr->SSIDs.SSIDList[i].handoffPermitted =
10376 1;
10377 scan_fltr->SSIDs.SSIDList[i].ssidHidden = 0;
10378 }
10379 } else {
10380 size = sizeof(tCsrSSIDInfo) *
10381 profile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010382 scan_fltr->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010383 if (NULL == scan_fltr->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010384 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010385 goto free_filter;
10386 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010387 qdf_mem_copy(scan_fltr->SSIDs.SSIDList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010388 profile->SSIDs.SSIDList, size);
10389 }
10390 }
10391
10392 if (!profile_ch_info->ChannelList
10393 || (profile_ch_info->ChannelList[0] == 0)) {
10394 fltr_ch_info->numOfChannels = 0;
10395 fltr_ch_info->ChannelList = NULL;
10396 } else if (profile_ch_info->numOfChannels) {
10397 fltr_ch_info->numOfChannels = 0;
10398 fltr_ch_info->ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010399 qdf_mem_malloc(sizeof(*(fltr_ch_info->ChannelList)) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010400 profile_ch_info->numOfChannels);
10401 if (NULL == fltr_ch_info->ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010402 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010403 goto free_filter;
10404 }
10405
10406 for (idx = 0; idx < profile_ch_info->numOfChannels; idx++) {
10407 if (csr_roam_is_channel_valid(mac_ctx,
10408 profile_ch_info->ChannelList[idx])) {
10409 fltr_ch_info->
10410 ChannelList[fltr_ch_info->numOfChannels]
10411 = profile_ch_info->ChannelList[idx];
10412 fltr_ch_info->numOfChannels++;
10413 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010414 sme_debug(
10415 "Channel (%d) is invalid",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010416 profile_ch_info->ChannelList[idx]);
10417 }
10418 }
10419 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010420 sme_err("Channel list empty");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010421 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010422 goto free_filter;
10423 }
10424 scan_fltr->uapsd_mask = profile->uapsd_mask;
10425 scan_fltr->authType = profile->AuthType;
10426 scan_fltr->EncryptionType = profile->EncryptionType;
10427 scan_fltr->mcEncryptionType = profile->mcEncryptionType;
10428 scan_fltr->BSSType = profile->BSSType;
10429 scan_fltr->phyMode = profile->phyMode;
10430#ifdef FEATURE_WLAN_WAPI
10431 /*
10432 * check if user asked for WAPI with 11n or auto mode, in that
10433 * case modify the phymode to 11g
10434 */
10435 if (csr_is_profile_wapi(profile)) {
10436 if (scan_fltr->phyMode & eCSR_DOT11_MODE_11n)
10437 scan_fltr->phyMode &= ~eCSR_DOT11_MODE_11n;
10438 if (scan_fltr->phyMode & eCSR_DOT11_MODE_AUTO)
10439 scan_fltr->phyMode &= ~eCSR_DOT11_MODE_AUTO;
10440 if (!scan_fltr->phyMode)
10441 scan_fltr->phyMode = eCSR_DOT11_MODE_11g;
10442 }
10443#endif /* FEATURE_WLAN_WAPI */
10444 /*Save the WPS info */
10445 scan_fltr->bWPSAssociation = profile->bWPSAssociation;
10446 scan_fltr->bOSENAssociation = profile->bOSENAssociation;
10447 if (profile->countryCode[0]) {
10448 /*
10449 * This causes the matching function to use countryCode as one
10450 * of the criteria.
10451 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010452 qdf_mem_copy(scan_fltr->countryCode, profile->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010453 WNI_CFG_COUNTRY_CODE_LEN);
10454 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010455 if (profile->MDID.mdiePresent) {
10456 scan_fltr->MDID.mdiePresent = 1;
10457 scan_fltr->MDID.mobilityDomain = profile->MDID.mobilityDomain;
10458 }
Abhishek Singh3c9910e2017-01-06 17:56:47 +053010459 qdf_mem_copy(scan_fltr->bssid_hint.bytes,
10460 profile->bssid_hint.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010461
10462#ifdef WLAN_FEATURE_11W
10463 /* Management Frame Protection */
10464 scan_fltr->MFPEnabled = profile->MFPEnabled;
10465 scan_fltr->MFPRequired = profile->MFPRequired;
10466 scan_fltr->MFPCapable = profile->MFPCapable;
10467#endif
10468 scan_fltr->csrPersona = profile->csrPersona;
10469
10470free_filter:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010471 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010472 csr_free_scan_filter(mac_ctx, scan_fltr);
10473
10474 return status;
10475}
10476
Jeff Johnson29e2ca12016-10-14 12:50:38 -070010477static
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010478bool csr_roam_issue_wm_status_change(tpAniSirGlobal pMac, uint32_t sessionId,
10479 eCsrRoamWmStatusChangeTypes Type,
10480 tSirSmeRsp *pSmeRsp)
10481{
10482 bool fCommandQueued = false;
10483 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010484
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010485 do {
10486 /* Validate the type is ok... */
10487 if ((eCsrDisassociated != Type)
10488 && (eCsrDeauthenticated != Type))
10489 break;
10490 pCommand = csr_get_command_buffer(pMac);
10491 if (!pCommand) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010492 sme_err(" fail to get command buffer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010493 break;
10494 }
10495 /* Change the substate in case it is waiting for key */
10496 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
10497 csr_roam_stop_wait_for_key_timer(pMac);
10498 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
10499 sessionId);
10500 }
10501 pCommand->command = eSmeCommandWmStatusChange;
10502 pCommand->sessionId = (uint8_t) sessionId;
10503 pCommand->u.wmStatusChangeCmd.Type = Type;
10504 if (eCsrDisassociated == Type) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010505 qdf_mem_copy(&pCommand->u.wmStatusChangeCmd.u.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010506 DisassocIndMsg, pSmeRsp,
10507 sizeof(pCommand->u.wmStatusChangeCmd.u.
10508 DisassocIndMsg));
10509 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010510 qdf_mem_copy(&pCommand->u.wmStatusChangeCmd.u.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010511 DeauthIndMsg, pSmeRsp,
10512 sizeof(pCommand->u.wmStatusChangeCmd.u.
10513 DeauthIndMsg));
10514 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010515 if (QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010516 (csr_queue_sme_command(pMac, pCommand, true))) {
10517 fCommandQueued = true;
10518 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010519 sme_err("fail to send message");
Krunal Sonidea45952017-02-15 11:58:15 -080010520 csr_release_command(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010521 }
10522
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010523 /* AP has issued Dissac/Deauth, Set the operating mode
10524 * value to configured value
10525 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010526 csr_set_default_dot11_mode(pMac);
10527 } while (0);
10528 return fCommandQueued;
10529}
10530
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010531static QDF_STATUS csr_send_snr_request(void *pGetRssiReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010532{
10533 void *wma_handle;
10534
Anurag Chouhan6d760662016-02-20 16:05:43 +053010535 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010536 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010537 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010538 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010539 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010540 }
10541
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010542 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010543 wma_send_snr_request(wma_handle, pGetRssiReq)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010544 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010545 "Failed to Trigger wma stats request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010546 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010547 }
10548
10549 /* dont send success, otherwise call back
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010550 * will released with out values
10551 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010552 return QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010553}
10554
10555static void csr_update_rssi(tpAniSirGlobal pMac, void *pMsg)
10556{
10557 int8_t rssi = 0;
10558 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq *) pMsg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010559 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010560
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010561 if (pGetRssiReq) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010562 if (NULL != pGetRssiReq->p_cds_context)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010563 qdf_status = csr_send_snr_request(pGetRssiReq);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010564 else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010565 sme_err("GetRssiReq->p_cds_context is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010566 return;
10567 }
10568
10569 if (NULL != pGetRssiReq->rssiCallback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010570 if (qdf_status != QDF_STATUS_E_BUSY)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010571 ((tCsrRssiCallback) (pGetRssiReq->rssiCallback))
10572 (rssi, pGetRssiReq->staId,
10573 pGetRssiReq->pDevContext);
10574 else
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010575 sme_debug("rssi request is posted. waiting for reply");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010576 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010577 sme_err("GetRssiReq->rssiCallback is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010578 return;
10579 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010580 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010581 sme_err("pGetRssiReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010582
10583}
10584
10585static void csr_update_snr(tpAniSirGlobal pMac, void *pMsg)
10586{
10587 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq *) pMsg;
10588
10589 if (pGetSnrReq) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010590 if (QDF_STATUS_SUCCESS != wma_get_snr(pGetSnrReq)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010591 sme_err("Error in wma_get_snr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010592 return;
10593 }
10594
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010595 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010596 sme_err("pGetSnrReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010597}
10598
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010599static QDF_STATUS csr_send_reset_ap_caps_changed(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010600 struct qdf_mac_addr *bssId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010601{
10602 tpSirResetAPCapsChange pMsg;
10603 uint16_t len;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010604 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010605
10606 /* Create the message and send to lim */
10607 len = sizeof(tSirResetAPCapsChange);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010608 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010609 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010610 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010611 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010612 status = QDF_STATUS_SUCCESS;
Srinivas Girigowda40567b92015-09-24 15:17:25 -070010613
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010614 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010615 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
10616 pMsg->length = len;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010617 qdf_copy_macaddr(&pMsg->bssId, bssId);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010618 sme_debug(
10619 "CSR reset caps change for Bssid= " MAC_ADDRESS_STR,
Srinivas Girigowda40567b92015-09-24 15:17:25 -070010620 MAC_ADDR_ARRAY(pMsg->bssId.bytes));
Rajeev Kumard138ac52017-01-30 18:38:37 -080010621 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010622 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010623 sme_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010624 }
10625 return status;
10626}
10627
10628static void
10629csr_roam_chk_lnk_assoc_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10630{
10631 tCsrRoamSession *session;
10632 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010633 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010634 tCsrRoamInfo *roam_info_ptr = NULL;
10635 tSirSmeAssocInd *pAssocInd;
10636 tCsrRoamInfo roam_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010637
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010638 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010639 sme_debug("Receive WNI_SME_ASSOC_IND from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010640 pAssocInd = (tSirSmeAssocInd *) msg_ptr;
10641 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010642 (struct qdf_mac_addr *) pAssocInd->bssId,
10643 &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010644 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010645 sme_debug("Couldn't find session_id for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010646 return;
10647 }
10648 session = CSR_GET_SESSION(mac_ctx, sessionId);
10649 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010650 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010651 return;
10652 }
10653 roam_info_ptr = &roam_info;
10654 /* Required for indicating the frames to upper layer */
10655 roam_info_ptr->assocReqLength = pAssocInd->assocReqLength;
10656 roam_info_ptr->assocReqPtr = pAssocInd->assocReqPtr;
10657 roam_info_ptr->beaconPtr = pAssocInd->beaconPtr;
10658 roam_info_ptr->beaconLength = pAssocInd->beaconLength;
10659 roam_info_ptr->statusCode = eSIR_SME_SUCCESS;
10660 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
10661 roam_info_ptr->staId = (uint8_t) pAssocInd->staId;
10662 roam_info_ptr->rsnIELen = (uint8_t) pAssocInd->rsnIE.length;
10663 roam_info_ptr->prsnIE = pAssocInd->rsnIE.rsnIEdata;
10664#ifdef FEATURE_WLAN_WAPI
10665 roam_info_ptr->wapiIELen = (uint8_t) pAssocInd->wapiIE.length;
10666 roam_info_ptr->pwapiIE = pAssocInd->wapiIE.wapiIEdata;
10667#endif
10668 roam_info_ptr->addIELen = (uint8_t) pAssocInd->addIE.length;
10669 roam_info_ptr->paddIE = pAssocInd->addIE.addIEdata;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010670 qdf_mem_copy(roam_info_ptr->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010671 pAssocInd->peerMacAddr,
10672 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010673 qdf_mem_copy(roam_info_ptr->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010674 pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010675 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010676 roam_info_ptr->wmmEnabledSta = pAssocInd->wmmEnabledSta;
10677 roam_info_ptr->timingMeasCap = pAssocInd->timingMeasCap;
gaolez7bb1e742017-03-21 16:37:38 +080010678 roam_info_ptr->ecsa_capable = pAssocInd->ecsa_capable;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010679 qdf_mem_copy(&roam_info_ptr->chan_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010680 &pAssocInd->chan_info,
10681 sizeof(tSirSmeChanInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010682 if (CSR_IS_INFRA_AP(roam_info_ptr->u.pConnectedProfile)) {
10683 if (session->pCurRoamProfile &&
10684 CSR_IS_ENC_TYPE_STATIC(
10685 session->pCurRoamProfile->negotiatedUCEncryptionType)) {
10686 /* NO keys... these key parameters don't matter. */
10687 csr_roam_issue_set_context_req(mac_ctx, sessionId,
10688 session->pCurRoamProfile->negotiatedUCEncryptionType,
10689 session->pConnectBssDesc,
10690 &(roam_info_ptr->peerMac.bytes),
10691 false, true, eSIR_TX_RX, 0, 0, NULL, 0);
10692 roam_info_ptr->fAuthRequired = false;
10693 } else {
10694 roam_info_ptr->fAuthRequired = true;
10695 }
10696 status = csr_roam_call_callback(mac_ctx, sessionId,
10697 roam_info_ptr, 0, eCSR_ROAM_INFRA_IND,
10698 eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010699 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010700 /* Refused due to Mac filtering */
10701 roam_info_ptr->statusCode = eSIR_SME_ASSOC_REFUSED;
10702 }
10703
10704 /* Send Association completion message to PE */
10705 status = csr_send_assoc_cnf_msg(mac_ctx, pAssocInd, status);
10706 /*
10707 * send a message to CSR itself just to avoid the EAPOL frames going
10708 * OTA before association response
10709 */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070010710 if (CSR_IS_INFRA_AP(roam_info_ptr->u.pConnectedProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010711 && (roam_info_ptr->statusCode != eSIR_SME_ASSOC_REFUSED)) {
10712 roam_info_ptr->fReassocReq = pAssocInd->reassocReq;
10713 status = csr_send_assoc_ind_to_upper_layer_cnf_msg(mac_ctx,
10714 pAssocInd, status, sessionId);
10715 }
10716}
10717
10718static void
10719csr_roam_chk_lnk_disassoc_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10720{
10721 tCsrRoamSession *session;
10722 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010723 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010724 tSirSmeDisassocInd *pDisassocInd;
Aggarwal Nishank51dece42016-08-24 12:11:19 +053010725 tSmeCmd *cmd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010726
Aggarwal Nishank51dece42016-08-24 12:11:19 +053010727 cmd = qdf_mem_malloc(sizeof(*cmd));
10728 if (NULL == cmd) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010729 sme_err("memory allocation failed for size: %zu", sizeof(*cmd));
Aggarwal Nishank51dece42016-08-24 12:11:19 +053010730 return;
10731 }
10732
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010733 /*
10734 * Check if AP dis-associated us because of MIC failure. If so,
10735 * then we need to take action immediately and not wait till the
10736 * the WmStatusChange requests is pushed and processed
10737 */
10738 pDisassocInd = (tSirSmeDisassocInd *) msg_ptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010739 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010740 &pDisassocInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010741 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010742 sme_err("Session Id not found for BSSID "MAC_ADDRESS_STR,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010743 MAC_ADDR_ARRAY(pDisassocInd->bssid.bytes));
Aggarwal Nishank51dece42016-08-24 12:11:19 +053010744 qdf_mem_free(cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010745 return;
10746 }
10747
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010748 sme_err("DISASSOCIATION from peer =" MAC_ADDRESS_STR "reason: %d status: %d session: %d",
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010749 MAC_ADDR_ARRAY(pDisassocInd->peer_macaddr.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010750 pDisassocInd->reasonCode,
Srinivas Girigowda0ee96442016-08-17 19:10:56 -070010751 pDisassocInd->statusCode, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010752 /*
10753 * If we are in neighbor preauth done state then on receiving
10754 * disassoc or deauth we dont roam instead we just disassoc
10755 * from current ap and then go to disconnected state
10756 * This happens for ESE and 11r FT connections ONLY.
10757 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010758 if (csr_roam_is11r_assoc(mac_ctx, sessionId) &&
10759 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10760 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10761 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010762#ifdef FEATURE_WLAN_ESE
10763 if (csr_roam_is_ese_assoc(mac_ctx, sessionId) &&
10764 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10765 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10766 mac_ctx, sessionId);
10767#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010768 if (csr_roam_is_fast_roam_enabled(mac_ctx, sessionId) &&
10769 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10770 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10771 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010772 session = CSR_GET_SESSION(mac_ctx, sessionId);
10773 if (!session) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053010774 sme_err("session: %d not found", sessionId);
Aggarwal Nishank51dece42016-08-24 12:11:19 +053010775 qdf_mem_free(cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010776 return;
10777 }
10778 if (csr_is_conn_state_infra(mac_ctx, sessionId))
10779 session->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10780#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10781 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
10782 SME_QOS_CSR_DISCONNECT_IND, NULL);
10783#endif
10784 csr_roam_link_down(mac_ctx, sessionId);
10785 csr_roam_issue_wm_status_change(mac_ctx, sessionId,
10786 eCsrDisassociated, msg_ptr);
10787 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010788 /*
10789 * STA/P2P client got disassociated so remove any pending
10790 * deauth commands in sme pending list
10791 */
Aggarwal Nishank51dece42016-08-24 12:11:19 +053010792 cmd->command = eSmeCommandRoam;
10793 cmd->sessionId = (uint8_t) sessionId;
10794 cmd->u.roamCmd.roamReason = eCsrForcedDeauthSta;
10795 qdf_mem_copy(cmd->u.roamCmd.peerMac,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010796 pDisassocInd->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010797 QDF_MAC_ADDR_SIZE);
Aggarwal Nishank51dece42016-08-24 12:11:19 +053010798 csr_roam_remove_duplicate_command(mac_ctx, sessionId, cmd,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010799 eCsrForcedDeauthSta);
10800 }
Aggarwal Nishank51dece42016-08-24 12:11:19 +053010801 qdf_mem_free(cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010802}
10803
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053010804/**
10805 * csr_roam_send_disconnect_done_indication() - Send disconnect ind to HDD.
10806 *
10807 * @mac_ctx: mac global context
10808 * @msg_ptr: incoming message
10809 *
10810 * This function gives final disconnect event to HDD after all cleanup in
10811 * lower layers is done.
10812 *
10813 * Return: None
10814 */
10815static void
10816csr_roam_send_disconnect_done_indication(tpAniSirGlobal mac_ctx, tSirSmeRsp
10817 *msg_ptr)
10818{
10819 struct sir_sme_discon_done_ind *discon_ind =
10820 (struct sir_sme_discon_done_ind *)(msg_ptr);
10821 tCsrRoamInfo roam_info;
10822 tCsrRoamSession *session;
10823
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010824 sme_debug("eWNI_SME_DISCONNECT_DONE_IND RC:%d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053010825 discon_ind->reason_code);
10826
10827 if (CSR_IS_SESSION_VALID(mac_ctx, discon_ind->session_id)) {
10828 roam_info.reasonCode = discon_ind->reason_code;
10829 roam_info.statusCode = eSIR_SME_STA_NOT_ASSOCIATED;
10830 qdf_mem_copy(roam_info.peerMac.bytes, discon_ind->peer_mac,
10831 ETH_ALEN);
10832 csr_roam_call_callback(mac_ctx, discon_ind->session_id,
10833 &roam_info, 0, eCSR_ROAM_LOSTLINK,
10834 eCSR_ROAM_RESULT_DISASSOC_IND);
10835 session = CSR_GET_SESSION(mac_ctx, discon_ind->session_id);
10836 if (session &&
10837 !CSR_IS_INFRA_AP(&session->connectedProfile))
10838 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
10839 discon_ind->session_id);
10840
10841 } else
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010842 sme_err("Inactive session %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053010843 discon_ind->session_id);
10844}
10845
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010846static void
10847csr_roam_chk_lnk_deauth_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10848{
10849 tCsrRoamSession *session;
10850 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010851 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010852 tSirSmeDeauthInd *pDeauthInd;
10853 tCsrRoamInfo roam_info;
10854
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010855 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010856 sme_debug("DEAUTHENTICATION Indication from MAC");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010857 pDeauthInd = (tpSirSmeDeauthInd) msg_ptr;
10858 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080010859 &pDeauthInd->bssid,
10860 &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010861 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010862 return;
10863 /* If we are in neighbor preauth done state then on receiving
10864 * disassoc or deauth we dont roam instead we just disassoc
10865 * from current ap and then go to disconnected state
10866 * This happens for ESE and 11r FT connections ONLY.
10867 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010868 if (csr_roam_is11r_assoc(mac_ctx, sessionId) &&
10869 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10870 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10871 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010872#ifdef FEATURE_WLAN_ESE
10873 if (csr_roam_is_ese_assoc(mac_ctx, sessionId) &&
10874 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10875 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10876 mac_ctx, sessionId);
10877#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010878 if (csr_roam_is_fast_roam_enabled(mac_ctx, sessionId) &&
10879 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10880 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10881 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010882 session = CSR_GET_SESSION(mac_ctx, sessionId);
10883 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010884 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010885 return;
10886 }
10887
10888 if (csr_is_conn_state_infra(mac_ctx, sessionId))
10889 session->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10890#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10891 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
10892 SME_QOS_CSR_DISCONNECT_IND, NULL);
10893#endif
10894 csr_roam_link_down(mac_ctx, sessionId);
10895 csr_roam_issue_wm_status_change(mac_ctx, sessionId,
10896 eCsrDeauthenticated,
10897 msg_ptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010898}
10899
10900static void
10901csr_roam_chk_lnk_swt_ch_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10902{
10903 tCsrRoamSession *session;
10904 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010905 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010906 tpSirSmeSwitchChannelInd pSwitchChnInd;
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +053010907 tCsrRoamInfo roamInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010908
10909 /* in case of STA, the SWITCH_CHANNEL originates from its AP */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010910 sme_debug("eWNI_SME_SWITCH_CHL_IND from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010911 pSwitchChnInd = (tpSirSmeSwitchChannelInd) msg_ptr;
10912 /* Update with the new channel id. The channel id is hidden in the
10913 * statusCode.
10914 */
10915 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda591c5652015-12-30 17:39:50 -080010916 &pSwitchChnInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010917 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010918 session = CSR_GET_SESSION(mac_ctx, sessionId);
10919 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010920 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010921 return;
10922 }
10923 session->connectedProfile.operationChannel =
10924 (uint8_t) pSwitchChnInd->newChannelId;
10925 if (session->pConnectBssDesc) {
10926 session->pConnectBssDesc->channelId =
10927 (uint8_t) pSwitchChnInd->newChannelId;
10928 }
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +053010929
10930 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
10931 roamInfo.chan_info.chan_id = pSwitchChnInd->newChannelId;
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +053010932 roamInfo.chan_info.ch_width =
10933 pSwitchChnInd->chan_params.ch_width;
10934 roamInfo.chan_info.sec_ch_offset =
10935 pSwitchChnInd->chan_params.sec_ch_offset;
10936 roamInfo.chan_info.band_center_freq1 =
10937 pSwitchChnInd->chan_params.center_freq_seg0;
10938 roamInfo.chan_info.band_center_freq2 =
10939 pSwitchChnInd->chan_params.center_freq_seg1;
bings58ce8622017-07-10 15:55:36 +080010940 if (CSR_IS_PHY_MODE_11ac(mac_ctx->roam.configParam.phyMode))
10941 roamInfo.mode = SIR_SME_PHY_MODE_VHT;
10942 else if (CSR_IS_PHY_MODE_11n(mac_ctx->roam.configParam.phyMode))
10943 roamInfo.mode = SIR_SME_PHY_MODE_HT;
10944 else
10945 roamInfo.mode = SIR_SME_PHY_MODE_LEGACY;
10946
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +053010947 status = csr_roam_call_callback(mac_ctx, sessionId,
10948 &roamInfo, 0, eCSR_ROAM_STA_CHANNEL_SWITCH,
10949 eCSR_ROAM_RESULT_NONE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010950 }
10951}
10952
10953static void
10954csr_roam_chk_lnk_deauth_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10955{
10956 tCsrRoamSession *session;
10957 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010958 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010959 tCsrRoamInfo *roam_info_ptr = NULL;
10960 tSirSmeDeauthRsp *pDeauthRsp = (tSirSmeDeauthRsp *) msg_ptr;
10961 tCsrRoamInfo roam_info;
10962
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010963 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010964 sme_debug("eWNI_SME_DEAUTH_RSP from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010965 sessionId = pDeauthRsp->sessionId;
10966 if (!CSR_IS_SESSION_VALID(mac_ctx, sessionId))
10967 return;
10968 session = CSR_GET_SESSION(mac_ctx, sessionId);
10969 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
10970 roam_info_ptr = &roam_info;
10971 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010972 qdf_copy_macaddr(&roam_info_ptr->peerMac,
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -080010973 &pDeauthRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010974 roam_info_ptr->reasonCode = eCSR_ROAM_RESULT_FORCED;
10975 roam_info_ptr->statusCode = pDeauthRsp->statusCode;
10976 status = csr_roam_call_callback(mac_ctx, sessionId,
10977 roam_info_ptr, 0,
10978 eCSR_ROAM_LOSTLINK,
10979 eCSR_ROAM_RESULT_FORCED);
10980 }
10981}
10982
10983static void
10984csr_roam_chk_lnk_disassoc_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10985{
10986 tCsrRoamSession *session;
10987 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010988 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010989 tCsrRoamInfo *roam_info_ptr = NULL;
10990 tCsrRoamInfo roam_info;
10991 /*
10992 * session id is invalid here so cant use it to access the array
10993 * curSubstate as index
10994 */
10995 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *) msg_ptr;
10996
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010997 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070010998 sme_debug("eWNI_SME_DISASSOC_RSP from SME ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010999 sessionId = pDisassocRsp->sessionId;
11000 if (!CSR_IS_SESSION_VALID(mac_ctx, sessionId))
11001 return;
11002 session = CSR_GET_SESSION(mac_ctx, sessionId);
11003 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
11004 roam_info_ptr = &roam_info;
11005 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
Anurag Chouhanc5548422016-02-24 18:33:27 +053011006 qdf_copy_macaddr(&roam_info_ptr->peerMac,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -080011007 &pDisassocRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011008 roam_info_ptr->reasonCode = eCSR_ROAM_RESULT_FORCED;
11009 roam_info_ptr->statusCode = pDisassocRsp->statusCode;
11010 status = csr_roam_call_callback(mac_ctx, sessionId,
11011 roam_info_ptr, 0,
11012 eCSR_ROAM_LOSTLINK,
11013 eCSR_ROAM_RESULT_FORCED);
11014 }
11015}
11016
11017#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11018static void
11019csr_roam_diag_mic_fail(tpAniSirGlobal mac_ctx, uint32_t sessionId)
11020{
11021 WLAN_HOST_DIAG_EVENT_DEF(secEvent,
11022 host_event_wlan_security_payload_type);
11023 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011024
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011025 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011026 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011027 return;
11028 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011029 qdf_mem_set(&secEvent, sizeof(host_event_wlan_security_payload_type),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011030 0);
11031 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
11032 secEvent.encryptionModeMulticast =
11033 (uint8_t) diag_enc_type_from_csr_type(
11034 session->connectedProfile.mcEncryptionType);
11035 secEvent.encryptionModeUnicast =
11036 (uint8_t) diag_enc_type_from_csr_type(
11037 session->connectedProfile.EncryptionType);
11038 secEvent.authMode =
11039 (uint8_t) diag_auth_type_from_csr_type(
11040 session->connectedProfile.AuthType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011041 qdf_mem_copy(secEvent.bssid, session->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053011042 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011043 WLAN_HOST_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11044}
11045#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
11046
11047static void
11048csr_roam_chk_lnk_mic_fail_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11049{
11050 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011051 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011052 tCsrRoamInfo *roam_info_ptr = NULL;
11053 tCsrRoamInfo roam_info;
11054 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd) msg_ptr;
11055 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
11056
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011057 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011058 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda37c133b2015-09-24 16:14:15 -070011059 &pMicInd->bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011060 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011061 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011062 roam_info.u.pMICFailureInfo = &pMicInd->info;
11063 roam_info_ptr = &roam_info;
11064 if (pMicInd->info.multicast)
11065 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
11066 else
11067 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
11068 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
11069 eCSR_ROAM_MIC_ERROR_IND, result);
11070 }
11071#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11072 csr_roam_diag_mic_fail(mac_ctx, sessionId);
11073#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
11074}
11075
11076static void
11077csr_roam_chk_lnk_pbs_probe_req_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11078{
11079 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011080 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011081 tCsrRoamInfo roam_info;
11082 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd) msg_ptr;
11083
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011084 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011085 sme_debug("WPS PBC Probe request Indication from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011086
11087 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowdad6673be2015-11-24 14:18:13 -080011088 &pProbeReqInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011089 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011090 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011091 roam_info.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
11092 csr_roam_call_callback(mac_ctx, sessionId, &roam_info,
11093 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
11094 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
11095 }
11096}
11097
11098#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11099static void
11100csr_roam_diag_joined_new_bss(tpAniSirGlobal mac_ctx,
11101 tSirSmeNewBssInfo *pNewBss)
11102{
11103 host_log_ibss_pkt_type *pIbssLog;
11104 uint32_t bi;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011106 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
11107 LOG_WLAN_IBSS_C);
11108 if (!pIbssLog)
11109 return;
11110 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
11111 if (pNewBss) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053011112 qdf_copy_macaddr(&pIbssLog->bssid, &pNewBss->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011113 if (pNewBss->ssId.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011114 qdf_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011115 pNewBss->ssId.length);
11116 pIbssLog->operatingChannel = pNewBss->channelNumber;
11117 }
11118 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(mac_ctx,
11119 WNI_CFG_BEACON_INTERVAL,
11120 &bi)))
11121 /* U8 is not enough for beacon interval */
11122 pIbssLog->beaconInterval = (uint8_t) bi;
11123 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
11124}
11125#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
11126
11127static void
11128csr_roam_chk_lnk_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
11129 tSirSmeRsp *msg_ptr)
11130{
11131 tCsrRoamSession *session;
11132 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011133 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011134 tCsrRoamInfo *roam_info_ptr = NULL;
11135 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
11136 tCsrRoamInfo roam_info;
11137 tSirSmeApNewCaps *pApNewCaps;
11138 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
11139 tSirMacAddr Broadcastaddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
11140 tSirSmeNewBssInfo *pNewBss;
11141 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
11142
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011143 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011144 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *) msg_ptr;
11145 switch (pStatusChangeMsg->statusChangeCode) {
11146 case eSIR_SME_IBSS_ACTIVE:
11147 sessionId = csr_find_ibss_session(mac_ctx);
11148 if (CSR_SESSION_ID_INVALID == sessionId)
11149 break;
11150 session = CSR_GET_SESSION(mac_ctx, sessionId);
11151 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011152 sme_err("session %d not found",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011153 sessionId);
11154 return;
11155 }
11156 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
11157 if (session->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011158 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011159 session->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053011160 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011161 roam_info.u.pConnectedProfile =
11162 &session->connectedProfile;
11163 roam_info_ptr = &roam_info;
11164 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011165 sme_err("CSR: connected BSS is empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011166 }
11167 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
11168 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
11169 break;
11170
11171 case eSIR_SME_IBSS_INACTIVE:
11172 sessionId = csr_find_ibss_session(mac_ctx);
11173 if (CSR_SESSION_ID_INVALID != sessionId) {
11174 session = CSR_GET_SESSION(mac_ctx, sessionId);
11175 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011176 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011177 return;
11178 }
11179 session->connectState =
11180 eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
11181 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
11182 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
11183 }
11184 break;
11185
11186 case eSIR_SME_JOINED_NEW_BSS:
11187 /* IBSS coalescing. */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011188 sme_debug("CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011189 sessionId = csr_find_ibss_session(mac_ctx);
11190 if (CSR_SESSION_ID_INVALID == sessionId)
11191 break;
11192 session = CSR_GET_SESSION(mac_ctx, sessionId);
11193 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011194 sme_err("session %d not found",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011195 sessionId);
11196 return;
11197 }
11198 /* update the connection state information */
11199 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
11200#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11201 csr_roam_diag_joined_new_bss(mac_ctx, pNewBss);
11202#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
11203 csr_roam_update_connected_profile_from_new_bss(mac_ctx,
11204 sessionId,
11205 pNewBss);
11206
11207 if ((eCSR_ENCRYPT_TYPE_NONE ==
11208 session->connectedProfile.EncryptionType)) {
11209 csr_roam_issue_set_context_req(mac_ctx,
11210 sessionId,
11211 session->connectedProfile.EncryptionType,
11212 session->pConnectBssDesc,
11213 &Broadcastaddr, false, false,
11214 eSIR_TX_RX, 0, 0, NULL, 0);
11215 }
11216 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
11217 roamStatus = eCSR_ROAM_IBSS_IND;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011218 qdf_mem_copy(&roam_info.bssid, &pNewBss->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053011219 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011220 roam_info_ptr = &roam_info;
11221 /* This BSSID is the real BSSID, save it */
11222 if (session->pConnectBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011223 qdf_mem_copy(session->pConnectBssDesc->bssId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011224 &pNewBss->bssId, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011225 break;
11226
11227 /*
11228 * detection by LIM that the capabilities of the associated
11229 * AP have changed.
11230 */
11231 case eSIR_SME_AP_CAPS_CHANGED:
11232 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011233 sme_debug("CSR handling eSIR_SME_AP_CAPS_CHANGED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011234 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda26ebb192015-09-24 15:12:09 -070011235 &pApNewCaps->bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011236 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011237 break;
11238 if (eCSR_ROAMING_STATE_JOINED ==
11239 mac_ctx->roam.curState[sessionId]
11240 && ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC
11241 == mac_ctx->roam.curSubState[sessionId])
11242 || (eCSR_ROAM_SUBSTATE_NONE ==
11243 mac_ctx->roam.curSubState[sessionId])
11244 || (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC
11245 == mac_ctx->roam.curSubState[sessionId])
11246 || (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC ==
11247 mac_ctx->roam.curSubState[sessionId]))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011248 sme_warn("Calling csr_roam_disconnect_internal");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011249 csr_roam_disconnect_internal(mac_ctx, sessionId,
11250 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11251 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011252 sme_warn("Skipping the new scan as CSR is in state: %s and sub-state: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011253 mac_trace_getcsr_roam_state(
11254 mac_ctx->roam.curState[sessionId]),
11255 mac_trace_getcsr_roam_sub_state(
11256 mac_ctx->roam.curSubState[sessionId]));
11257 /* We ignore the caps change event if CSR is not in full
11258 * connected state. Send one event to PE to reset
11259 * limSentCapsChangeNtf Once limSentCapsChangeNtf set
11260 * 0, lim can send sub sequent CAPS change event
11261 * otherwise lim cannot send any CAPS change events to
11262 * SME
11263 */
11264 csr_send_reset_ap_caps_changed(mac_ctx,
11265 &pApNewCaps->bssId);
11266 }
11267 break;
11268
11269 default:
11270 roamStatus = eCSR_ROAM_FAILED;
11271 result = eCSR_ROAM_RESULT_NONE;
11272 break;
11273 } /* end switch on statusChangeCode */
11274 if (eCSR_ROAM_RESULT_NONE != result) {
11275 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
11276 roamStatus, result);
11277 }
11278}
11279
11280static void
11281csr_roam_chk_lnk_ibss_new_peer_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11282{
11283 tCsrRoamSession *session;
11284 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011285 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011286 tCsrRoamInfo *roam_info_ptr = NULL;
11287 tSmeIbssPeerInd *pIbssPeerInd = (tSmeIbssPeerInd *) msg_ptr;
11288 tCsrRoamInfo roam_info;
11289#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11290 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011291
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011292 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
11293 LOG_WLAN_IBSS_C);
11294 if (pIbssLog) {
11295 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Anurag Chouhanc5548422016-02-24 18:33:27 +053011296 qdf_copy_macaddr(&pIbssLog->peer_macaddr,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080011297 &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011298 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
11299 }
11300#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
11301
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011302 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011303 sessionId = csr_find_ibss_session(mac_ctx);
11304 if (CSR_SESSION_ID_INVALID == sessionId)
11305 return;
11306 session = CSR_GET_SESSION(mac_ctx, sessionId);
11307 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011308 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011309 return;
11310 }
11311 /*
11312 * Issue the set Context request to LIM to establish the Unicast STA
11313 * context for the new peer...
11314 */
11315 if (!session->pConnectBssDesc) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011316 sme_warn("CSR: connected BSS is empty");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011317 goto callback_and_free;
11318 }
Anurag Chouhanc5548422016-02-24 18:33:27 +053011319 qdf_copy_macaddr(&roam_info.peerMac, &pIbssPeerInd->peer_addr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011320 qdf_mem_copy(&roam_info.bssid, session->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053011321 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011322 if (pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011323 roam_info.pbFrames = qdf_mem_malloc((pIbssPeerInd->mesgLen -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011324 sizeof(tSmeIbssPeerInd)));
11325 if (NULL == roam_info.pbFrames) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011326 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011327 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011328 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011329 roam_info.nBeaconLength = pIbssPeerInd->mesgLen -
11330 sizeof(tSmeIbssPeerInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011331 qdf_mem_copy(roam_info.pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011332 ((uint8_t *) pIbssPeerInd) +
11333 sizeof(tSmeIbssPeerInd),
11334 roam_info.nBeaconLength);
11335 }
11336 roam_info.staId = (uint8_t) pIbssPeerInd->staId;
11337 roam_info.ucastSig = (uint8_t) pIbssPeerInd->ucastSig;
11338 roam_info.bcastSig = (uint8_t) pIbssPeerInd->bcastSig;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011339 roam_info.pBssDesc = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011340 session->pConnectBssDesc->length);
11341 if (NULL == roam_info.pBssDesc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011342 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011343 if (roam_info.pbFrames)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011344 qdf_mem_free(roam_info.pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011345 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011346 qdf_mem_free(roam_info.pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011347 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011348 status = QDF_STATUS_SUCCESS;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011349 qdf_mem_copy(roam_info.pBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011350 session->pConnectBssDesc,
11351 session->pConnectBssDesc->length);
11352 roam_info_ptr = &roam_info;
11353 }
11354 } else {
11355 roam_info_ptr = &roam_info;
11356 }
11357 if ((eCSR_ENCRYPT_TYPE_NONE ==
11358 session->connectedProfile.EncryptionType)) {
11359 /* NO keys. these key parameters don't matter */
11360 csr_roam_issue_set_context_req(mac_ctx, sessionId,
11361 session->connectedProfile.EncryptionType,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080011362 session->pConnectBssDesc,
11363 &pIbssPeerInd->peer_addr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011364 false, true, eSIR_TX_RX, 0, 0, NULL, 0);
11365 }
11366
11367callback_and_free:
11368 /* send up the sec type for the new peer */
11369 if (roam_info_ptr)
11370 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
11371 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
11372 eCSR_ROAM_CONNECT_STATUS_UPDATE,
11373 eCSR_ROAM_RESULT_IBSS_NEW_PEER);
11374 if (roam_info_ptr) {
11375 if (roam_info.pbFrames)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011376 qdf_mem_free(roam_info.pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011377 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011378 qdf_mem_free(roam_info.pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011379 }
11380}
11381
11382static void
11383csr_roam_chk_lnk_ibss_peer_departed_ind(tpAniSirGlobal mac_ctx,
11384 tSirSmeRsp *msg_ptr)
11385{
11386 uint32_t sessionId = CSR_SESSION_ID_INVALID;
11387 tCsrRoamInfo roam_info;
11388 tSmeIbssPeerInd *pIbssPeerInd;
11389
11390 if (NULL == msg_ptr) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011391 sme_err("IBSS peer ind. message is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011392 return;
11393 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011394 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011395 pIbssPeerInd = (tSmeIbssPeerInd *) msg_ptr;
11396 sessionId = csr_find_ibss_session(mac_ctx);
11397 if (CSR_SESSION_ID_INVALID != sessionId) {
11398#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11399 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011400
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011401 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
11402 LOG_WLAN_IBSS_C);
11403 if (pIbssLog) {
11404 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
11405 if (pIbssPeerInd) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053011406 qdf_copy_macaddr(&pIbssLog->peer_macaddr,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080011407 &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011408 }
11409 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
11410 }
11411#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011412 sme_debug("CSR: Peer departed notification from LIM");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011413 roam_info.staId = (uint8_t) pIbssPeerInd->staId;
11414 roam_info.ucastSig = (uint8_t) pIbssPeerInd->ucastSig;
11415 roam_info.bcastSig = (uint8_t) pIbssPeerInd->bcastSig;
Anurag Chouhanc5548422016-02-24 18:33:27 +053011416 qdf_copy_macaddr(&roam_info.peerMac, &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011417 csr_roam_call_callback(mac_ctx, sessionId, &roam_info, 0,
11418 eCSR_ROAM_CONNECT_STATUS_UPDATE,
11419 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
11420 }
11421}
11422
11423#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11424static void
11425csr_roam_diag_set_ctx_rsp(tpAniSirGlobal mac_ctx,
11426 tCsrRoamSession *session,
11427 tSirSmeSetContextRsp *pRsp)
11428{
11429 WLAN_HOST_DIAG_EVENT_DEF(setKeyEvent,
11430 host_event_wlan_security_payload_type);
11431 if (eCSR_ENCRYPT_TYPE_NONE ==
11432 session->connectedProfile.EncryptionType)
11433 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011434 qdf_mem_set(&setKeyEvent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011435 sizeof(host_event_wlan_security_payload_type), 0);
Anurag Chouhanc5548422016-02-24 18:33:27 +053011436 if (qdf_is_macaddr_group(&pRsp->peer_macaddr))
Abhishek Singh7a995582016-04-27 13:53:36 +053011437 setKeyEvent.eventId =
11438 WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011439 else
Abhishek Singh7a995582016-04-27 13:53:36 +053011440 setKeyEvent.eventId =
11441 WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011442 setKeyEvent.encryptionModeMulticast =
11443 (uint8_t) diag_enc_type_from_csr_type(
11444 session->connectedProfile.mcEncryptionType);
11445 setKeyEvent.encryptionModeUnicast =
11446 (uint8_t) diag_enc_type_from_csr_type(
11447 session->connectedProfile.EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011448 qdf_mem_copy(setKeyEvent.bssid, session->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053011449 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011450 setKeyEvent.authMode =
11451 (uint8_t) diag_auth_type_from_csr_type(
11452 session->connectedProfile.AuthType);
11453 if (eSIR_SME_SUCCESS != pRsp->statusCode)
11454 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
11455 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
11456}
11457#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
11458
11459static void
11460csr_roam_chk_lnk_set_ctx_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11461{
11462 tCsrRoamSession *session;
11463 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011464 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011465 tCsrRoamInfo *roam_info_ptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011466 tCsrRoamInfo roam_info;
11467 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
11468 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *) msg_ptr;
Krunal Sonid3676732017-05-10 14:12:18 -070011469
11470
11471 if (!pRsp) {
11472 sme_err("set key response is NULL");
11473 return;
11474 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011475
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011476 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Krunal Sonid3676732017-05-10 14:12:18 -070011477 sessionId = pRsp->sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011478 session = CSR_GET_SESSION(mac_ctx, sessionId);
11479 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011480 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011481 return;
11482 }
11483#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11484 csr_roam_diag_set_ctx_rsp(mac_ctx, session, pRsp);
11485#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
11486 if (CSR_IS_WAIT_FOR_KEY(mac_ctx, sessionId)) {
11487 csr_roam_stop_wait_for_key_timer(mac_ctx);
11488 /* We are done with authentication, whethere succeed or not */
11489 csr_roam_substate_change(mac_ctx, eCSR_ROAM_SUBSTATE_NONE,
11490 sessionId);
11491 /* We do it here because this linkup function is not called
11492 * after association when a key needs to be set.
11493 */
11494 if (csr_is_conn_state_connected_infra(mac_ctx, sessionId))
11495 csr_roam_link_up(mac_ctx,
11496 session->connectedProfile.bssid);
11497 }
11498 if (eSIR_SME_SUCCESS == pRsp->statusCode) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053011499 qdf_copy_macaddr(&roam_info.peerMac, &pRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011500 /* Make sure we install the GTK before indicating to HDD as
11501 * authenticated. This is to prevent broadcast packets go out
11502 * after PTK and before GTK.
11503 */
Anurag Chouhanc5548422016-02-24 18:33:27 +053011504 if (qdf_is_macaddr_broadcast(&pRsp->peer_macaddr)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011505 tpSirSetActiveModeSetBncFilterReq pMsg;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011506
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011507 pMsg = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011508 sizeof(tSirSetActiveModeSetBncFilterReq));
Naveen Rawat63ad2b62016-11-17 11:38:21 -080011509 if (NULL == pMsg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011510 sme_err("Malloc failed");
Krunal Sonid3676732017-05-10 14:12:18 -070011511 return;
Naveen Rawat63ad2b62016-11-17 11:38:21 -080011512 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011513 pMsg->messageType = eWNI_SME_SET_BCN_FILTER_REQ;
Sreelakshmi Konamki336e16e2016-09-07 14:35:22 +053011514 pMsg->length = sizeof(tSirSetActiveModeSetBncFilterReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011515 pMsg->seesionId = sessionId;
Sreelakshmi Konamki336e16e2016-09-07 14:35:22 +053011516 qdf_copy_macaddr(&pMsg->bssid,
11517 &session->connectedProfile.bssid);
11518
Rajeev Kumard138ac52017-01-30 18:38:37 -080011519 status = umac_send_mb_message_to_mac(pMsg);
Sandeep Puligilla829d6ac2016-08-11 17:27:50 -070011520 /*
11521 * OBSS SCAN Indication will be sent to Firmware
11522 * to start OBSS Scan
11523 */
11524 if (CSR_IS_CHANNEL_24GHZ(
11525 session->connectedProfile.operationChannel)
11526 && (session->connectState ==
11527 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
11528 && session->pCurRoamProfile
11529 && ((QDF_P2P_CLIENT_MODE ==
11530 session->pCurRoamProfile->csrPersona)
11531 || (QDF_STA_MODE ==
11532 session->pCurRoamProfile->csrPersona))) {
11533 struct sme_obss_ht40_scanind_msg *msg;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011534
Sandeep Puligilla829d6ac2016-08-11 17:27:50 -070011535 msg = qdf_mem_malloc(sizeof(
11536 struct sme_obss_ht40_scanind_msg));
Naveen Rawat63ad2b62016-11-17 11:38:21 -080011537 if (NULL == msg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011538 sme_err("Malloc failed");
Krunal Sonid3676732017-05-10 14:12:18 -070011539 return;
Naveen Rawat63ad2b62016-11-17 11:38:21 -080011540 }
Sandeep Puligilla829d6ac2016-08-11 17:27:50 -070011541 msg->msg_type = eWNI_SME_HT40_OBSS_SCAN_IND;
11542 msg->length =
11543 sizeof(struct sme_obss_ht40_scanind_msg);
11544 qdf_copy_macaddr(&msg->mac_addr,
11545 &session->connectedProfile.bssid);
Rajeev Kumard138ac52017-01-30 18:38:37 -080011546 status = umac_send_mb_message_to_mac(msg);
Sandeep Puligilla829d6ac2016-08-11 17:27:50 -070011547 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011548 result = eCSR_ROAM_RESULT_AUTHENTICATED;
11549 } else {
11550 result = eCSR_ROAM_RESULT_NONE;
11551 }
11552 roam_info_ptr = &roam_info;
11553 } else {
11554 result = eCSR_ROAM_RESULT_FAILURE;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011555 sme_err(
11556 "CSR: setkey command failed(err=%d) PeerMac "
11557 MAC_ADDRESS_STR,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080011558 pRsp->statusCode,
11559 MAC_ADDR_ARRAY(pRsp->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011560 }
Krunal Sonid3676732017-05-10 14:12:18 -070011561 /* keeping roam_id = 0 as nobody is using roam_id for set_key */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011562 csr_roam_call_callback(mac_ctx, sessionId, &roam_info,
Krunal Sonid3676732017-05-10 14:12:18 -070011563 0, eCSR_ROAM_SET_KEY_COMPLETE, result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011564 /* Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
11565 * can go ahead and initiate the TSPEC if any are pending
11566 */
11567 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
11568 SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
11569#ifdef FEATURE_WLAN_ESE
11570 /* Send Adjacent AP repot to new AP. */
11571 if (result == eCSR_ROAM_RESULT_AUTHENTICATED
11572 && session->isPrevApInfoValid
11573 && session->connectedProfile.isESEAssoc) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011574 csr_send_ese_adjacent_ap_rep_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011575 session->isPrevApInfoValid = false;
11576 }
11577#endif
Krunal Sonia8270f52017-02-23 19:51:25 -080011578 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011579}
11580
11581
11582static void
11583csr_roam_chk_lnk_max_assoc_exceeded(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
11584{
11585 uint32_t sessionId = CSR_SESSION_ID_INVALID;
11586 tSmeMaxAssocInd *pSmeMaxAssocInd;
11587 tCsrRoamInfo roam_info;
11588
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011589 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011590 pSmeMaxAssocInd = (tSmeMaxAssocInd *) msg_ptr;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011591 sme_debug(
11592 "max assoc have been reached, new peer cannot be accepted");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011593 sessionId = pSmeMaxAssocInd->sessionId;
11594 roam_info.sessionId = sessionId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053011595 qdf_copy_macaddr(&roam_info.peerMac, &pSmeMaxAssocInd->peer_mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011596 csr_roam_call_callback(mac_ctx, sessionId, &roam_info, 0,
11597 eCSR_ROAM_INFRA_IND,
11598 eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
11599}
11600
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011601void csr_roam_check_for_link_status_change(tpAniSirGlobal pMac,
11602 tSirSmeRsp *pSirMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011603{
11604 if (NULL == pSirMsg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011605 sme_err("pSirMsg is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011606 return;
11607 }
11608 switch (pSirMsg->messageType) {
11609 case eWNI_SME_ASSOC_IND:
11610 csr_roam_chk_lnk_assoc_ind(pMac, pSirMsg);
11611 break;
11612 case eWNI_SME_DISASSOC_IND:
11613 csr_roam_chk_lnk_disassoc_ind(pMac, pSirMsg);
11614 break;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +053011615 case eWNI_SME_DISCONNECT_DONE_IND:
11616 csr_roam_send_disconnect_done_indication(pMac, pSirMsg);
11617 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011618 case eWNI_SME_DEAUTH_IND:
11619 csr_roam_chk_lnk_deauth_ind(pMac, pSirMsg);
11620 break;
11621 case eWNI_SME_SWITCH_CHL_IND:
11622 csr_roam_chk_lnk_swt_ch_ind(pMac, pSirMsg);
11623 break;
11624 case eWNI_SME_DEAUTH_RSP:
11625 csr_roam_chk_lnk_deauth_rsp(pMac, pSirMsg);
11626 break;
11627 case eWNI_SME_DISASSOC_RSP:
11628 csr_roam_chk_lnk_disassoc_rsp(pMac, pSirMsg);
11629 break;
11630 case eWNI_SME_MIC_FAILURE_IND:
11631 csr_roam_chk_lnk_mic_fail_ind(pMac, pSirMsg);
11632 break;
11633 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
11634 csr_roam_chk_lnk_pbs_probe_req_ind(pMac, pSirMsg);
11635 break;
11636 case eWNI_SME_WM_STATUS_CHANGE_NTF:
11637 csr_roam_chk_lnk_wm_status_change_ntf(pMac, pSirMsg);
11638 break;
11639 case eWNI_SME_IBSS_NEW_PEER_IND:
11640 csr_roam_chk_lnk_ibss_new_peer_ind(pMac, pSirMsg);
11641 break;
11642 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
11643 csr_roam_chk_lnk_ibss_peer_departed_ind(pMac, pSirMsg);
11644 break;
11645 case eWNI_SME_SETCONTEXT_RSP:
11646 csr_roam_chk_lnk_set_ctx_rsp(pMac, pSirMsg);
11647 break;
11648 case eWNI_SME_GET_STATISTICS_RSP:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011649 sme_debug("Stats rsp from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011650 csr_roam_stats_rsp_processor(pMac, pSirMsg);
11651 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -080011652#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011653 case eWNI_SME_GET_TSM_STATS_RSP:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011654 sme_debug("TSM Stats rsp from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011655 csr_tsm_stats_rsp_processor(pMac, pSirMsg);
11656 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -080011657#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011658 case eWNI_SME_GET_RSSI_REQ:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011659 sme_debug("GetRssiReq from self");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011660 csr_update_rssi(pMac, pSirMsg);
11661 break;
11662 case eWNI_SME_GET_SNR_REQ:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011663 sme_debug("GetSnrReq from self");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011664 csr_update_snr(pMac, pSirMsg);
11665 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011666 case eWNI_SME_FT_PRE_AUTH_RSP:
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011667 csr_roam_ft_pre_auth_rsp_processor(pMac,
11668 (tpSirFTPreAuthRsp) pSirMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011669 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011670 case eWNI_SME_MAX_ASSOC_EXCEEDED:
11671 csr_roam_chk_lnk_max_assoc_exceeded(pMac, pSirMsg);
11672 break;
11673 case eWNI_SME_CANDIDATE_FOUND_IND:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011674 sme_debug("Candidate found indication from PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011675 csr_neighbor_roam_candidate_found_ind_hdlr(pMac, pSirMsg);
11676 break;
11677 case eWNI_SME_HANDOFF_REQ:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011678 sme_debug("Handoff Req from self");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011679 csr_neighbor_roam_handoff_req_hdlr(pMac, pSirMsg);
11680 break;
11681 default:
11682 break;
11683 } /* end switch on message type */
11684}
11685
11686void csr_call_roaming_completion_callback(tpAniSirGlobal pMac,
11687 tCsrRoamSession *pSession,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011688 tCsrRoamInfo *pRoamInfo,
11689 uint32_t roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011690 eCsrRoamResult roamResult)
11691{
11692 if (pSession) {
11693 if (pSession->bRefAssocStartCnt) {
11694 pSession->bRefAssocStartCnt--;
11695
11696 if (0 != pSession->bRefAssocStartCnt) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011697 QDF_ASSERT(pSession->bRefAssocStartCnt == 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011698 return;
11699 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011700 /* Need to call association_completion because there
11701 * is an assoc_start pending.
11702 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011703 csr_roam_call_callback(pMac, pSession->sessionId, NULL,
11704 roamId,
11705 eCSR_ROAM_ASSOCIATION_COMPLETION,
11706 eCSR_ROAM_RESULT_FAILURE);
11707 }
11708 csr_roam_call_callback(pMac, pSession->sessionId, pRoamInfo,
11709 roamId, eCSR_ROAM_ROAMING_COMPLETION,
11710 roamResult);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011711 } else
11712 sme_err("pSession is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011713}
11714
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011715QDF_STATUS csr_roam_start_roaming(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011716 eCsrRoamingReason roamingReason)
11717{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011718 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011719
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011720 if (CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
11721 (false == pMac->roam.roamSession[sessionId].fCancelRoaming)) {
11722 status = csr_scan_request_lost_link1(pMac, sessionId);
11723 }
11724 return status;
11725}
11726
11727/* return a bool to indicate whether roaming completed or continue. */
11728bool csr_roam_complete_roaming(tpAniSirGlobal pMac, uint32_t sessionId,
11729 bool fForce, eCsrRoamResult roamResult)
11730{
11731 bool fCompleted = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011732 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011734 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011735 sme_err("session %d not found ", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011736 return false;
11737 }
11738 /* Check whether time is up */
11739 if (pSession->fCancelRoaming || fForce ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011740 eCsrReassocRoaming == pSession->roamingReason ||
11741 eCsrDynamicRoaming == pSession->roamingReason) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011742 sme_debug("indicates roaming completion");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011743 if (pSession->fCancelRoaming
11744 && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011745 /* roaming is cancelled, tell HDD to indicate disconnect
11746 * Because LIM overload deauth_ind for both deauth frame
11747 * and missed beacon we need to use this logic to
11748 * detinguish it. For missed beacon, LIM set reason to
11749 * be eSIR_BEACON_MISSED
11750 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011751 if (eSIR_BEACON_MISSED == pSession->roamingStatusCode) {
11752 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11753 } else if (eCsrLostlinkRoamingDisassoc ==
11754 pSession->roamingReason) {
11755 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
11756 } else if (eCsrLostlinkRoamingDeauth ==
11757 pSession->roamingReason) {
11758 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
11759 } else {
11760 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11761 }
11762 }
11763 csr_call_roaming_completion_callback(pMac, pSession, NULL, 0,
11764 roamResult);
11765 pSession->roamingReason = eCsrNotRoaming;
11766 } else {
11767 pSession->roamResult = roamResult;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011768 if (!QDF_IS_STATUS_SUCCESS(csr_roam_start_roaming_timer(pMac,
11769 sessionId, QDF_MC_TIMER_TO_SEC_UNIT))) {
11770 csr_call_roaming_completion_callback(pMac, pSession,
11771 NULL, 0, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011772 pSession->roamingReason = eCsrNotRoaming;
11773 } else {
11774 fCompleted = false;
11775 }
11776 }
11777 return fCompleted;
11778}
11779
11780void csr_roam_cancel_roaming(tpAniSirGlobal pMac, uint32_t sessionId)
11781{
11782 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11783
11784 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011785 sme_err("session: %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011786 return;
11787 }
11788
11789 if (CSR_IS_ROAMING(pSession)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011790 sme_debug("Cancel roaming");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011791 pSession->fCancelRoaming = true;
11792 if (CSR_IS_ROAM_JOINING(pMac, sessionId)
11793 && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011794 /* No need to do anything in here because the handler
11795 * takes care of it
11796 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011797 } else {
11798 eCsrRoamResult roamResult =
11799 CSR_IS_LOSTLINK_ROAMING(pSession->
11800 roamingReason) ?
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011801 eCSR_ROAM_RESULT_LOSTLINK :
11802 eCSR_ROAM_RESULT_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011803 /* Roaming is stopped after here */
11804 csr_roam_complete_roaming(pMac, sessionId, true,
11805 roamResult);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011806 /* Since CSR may be in lostlink roaming situation,
11807 * abort all roaming related activities
11808 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011809 csr_scan_abort_mac_scan(pMac, sessionId,
yeshwanth sriram guntuka310b3ac2016-11-15 23:25:26 +053011810 INVALID_SCAN_ID, eCSR_SCAN_ABORT_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011811 csr_roam_stop_roaming_timer(pMac, sessionId);
11812 }
11813 }
11814}
11815
11816void csr_roam_roaming_timer_handler(void *pv)
11817{
11818 tCsrTimerInfo *pInfo = (tCsrTimerInfo *) pv;
11819 tpAniSirGlobal pMac = pInfo->pMac;
11820 uint32_t sessionId = pInfo->sessionId;
11821 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11822
11823 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011824 sme_err(" session %d not found ", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011825 return;
11826 }
11827
11828 if (false == pSession->fCancelRoaming) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011829 if (!QDF_IS_STATUS_SUCCESS(csr_roam_start_roaming(pMac,
11830 sessionId, pSession->roamingReason))) {
11831 csr_call_roaming_completion_callback(pMac, pSession,
11832 NULL, 0,
11833 pSession->roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011834 pSession->roamingReason = eCsrNotRoaming;
11835 }
11836 }
11837}
11838
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070011839/**
11840 * csr_roam_roaming_offload_timeout_handler() - Handler for roaming failure
11841 * @timer_data: Carries the mac_ctx and session info
11842 *
11843 * This function would be invoked when the roaming_offload_timer expires.
11844 * The timer is waiting in anticipation of a related roaming event from
11845 * the firmware after receiving the ROAM_START event.
11846 *
11847 * Return: None
11848 */
11849void csr_roam_roaming_offload_timeout_handler(void *timer_data)
11850{
11851 tCsrTimerInfo *timer_info = (tCsrTimerInfo *) timer_data;
11852
11853 if (timer_info) {
11854 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011855 "LFR3:roaming offload timer expired, session: %d",
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070011856 timer_info->sessionId);
11857 } else {
11858 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011859 "Invalid Session");
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070011860 return;
11861 }
11862 csr_roam_disconnect(timer_info->pMac, timer_info->sessionId,
11863 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11864}
11865
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011866QDF_STATUS csr_roam_start_roaming_timer(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011867 uint32_t interval)
11868{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011869 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011870 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11871
11872 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011873 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011874 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011875 }
11876
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011877 sme_debug("csrScanStartRoamingTimer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011878 pSession->roamingTimerInfo.sessionId = (uint8_t) sessionId;
Anurag Chouhan210db072016-02-22 18:42:15 +053011879 status = qdf_mc_timer_start(&pSession->hTimerRoaming,
11880 interval / QDF_MC_TIMER_TO_MS_UNIT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011881
11882 return status;
11883}
11884
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011885QDF_STATUS csr_roam_stop_roaming_timer(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011886{
Anurag Chouhan210db072016-02-22 18:42:15 +053011887 return qdf_mc_timer_stop
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011888 (&pMac->roam.roamSession[sessionId].hTimerRoaming);
11889}
11890
11891void csr_roam_wait_for_key_time_out_handler(void *pv)
11892{
11893 tCsrTimerInfo *pInfo = (tCsrTimerInfo *) pv;
11894 tpAniSirGlobal pMac = pInfo->pMac;
11895 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, pInfo->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011896 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011897
11898 if (pSession == NULL) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011899 sme_err("session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011900 return;
11901 }
11902
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011903 sme_debug("WaitForKey timer expired in state: %s sub-state: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011904 mac_trace_get_neighbour_roam_state(pMac->roam.
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011905 neighborRoamInfo[pInfo->sessionId].
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011906 neighborRoamState),
11907 mac_trace_getcsr_roam_sub_state(pMac->roam.
11908 curSubState[pInfo->sessionId]));
11909
11910 if (CSR_IS_WAIT_FOR_KEY(pMac, pInfo->sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011911 if (csr_neighbor_roam_is_handoff_in_progress(pMac,
11912 pInfo->sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011913 /*
11914 * Enable heartbeat timer when hand-off is in progress
11915 * and Key Wait timer expired.
11916 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011917 sme_debug("Enabling HB timer after WaitKey expiry nHBCount: %d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011918 pMac->roam.configParam.HeartbeatThresh24);
11919 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011920 pMac->roam.configParam.HeartbeatThresh24);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011921 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011922 sme_debug("SME pre-auth state timeout");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011923
11924 /* Change the substate so command queue is unblocked. */
11925 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId) {
11926 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
11927 pInfo->sessionId);
11928 }
11929
11930 if (csr_is_conn_state_connected_infra(pMac, pInfo->sessionId)) {
11931 csr_roam_link_up(pMac,
11932 pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011933 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011934 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011935 csr_roam_disconnect(pMac, pInfo->sessionId,
11936 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11937 sme_release_global_lock(&pMac->sme);
11938 }
11939 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011940 sme_err("session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011941 }
11942 }
11943
11944}
11945
Yingying Tang87f01392017-03-22 17:29:54 +080011946#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070011947/**
11948 * csr_roam_roaming_offload_timer_action() - API to start/stop the timer
11949 * @mac_ctx: MAC Context
11950 * @interval: Value to be set for the timer
11951 * @session_id: Session on which the timer should be operated
11952 * @action: Start/Stop action for the timer
11953 *
11954 * API to start/stop the roaming offload timer
11955 *
11956 * Return: None
11957 */
11958void csr_roam_roaming_offload_timer_action(tpAniSirGlobal mac_ctx,
11959 uint32_t interval, uint8_t session_id,
11960 uint8_t action)
11961{
11962 tCsrRoamSession *csr_session = CSR_GET_SESSION(mac_ctx, session_id);
11963
11964 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011965 ("LFR3: timer action %d, session %d, intvl %d"),
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070011966 action, session_id, interval);
11967 if (mac_ctx) {
11968 csr_session = CSR_GET_SESSION(mac_ctx, session_id);
11969 } else {
11970 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011971 ("LFR3: Invalid MAC Context"));
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070011972 return;
11973 }
11974 if (!csr_session) {
11975 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070011976 ("LFR3: session %d not found"), session_id);
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070011977 return;
11978 }
11979 csr_session->roamingTimerInfo.sessionId = (uint8_t) session_id;
11980 if (action == ROAMING_OFFLOAD_TIMER_START)
11981 qdf_mc_timer_start(&csr_session->roaming_offload_timer,
11982 interval / QDF_MC_TIMER_TO_MS_UNIT);
11983 if (action == ROAMING_OFFLOAD_TIMER_STOP)
11984 qdf_mc_timer_stop(&csr_session->roaming_offload_timer);
11985
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070011986}
Yingying Tang87f01392017-03-22 17:29:54 +080011987#endif
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070011988
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053011989static QDF_STATUS csr_roam_start_wait_for_key_timer(tpAniSirGlobal pMac,
11990 uint32_t interval)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011991{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011992 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011993 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
11994 &pMac->roam.neighborRoamInfo[pMac->roam.WaitForKeyTimerInfo.
11995 sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011996 if (csr_neighbor_roam_is_handoff_in_progress(pMac,
Deepak Dhamdhereecce9742015-11-08 01:16:43 -080011997 pMac->roam.WaitForKeyTimerInfo.
11998 sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011999 /* Disable heartbeat timer when hand-off is in progress */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012000 sme_debug("disabling HB timer in state: %s sub-state: %s",
Deepak Dhamdhereecce9742015-11-08 01:16:43 -080012001 mac_trace_get_neighbour_roam_state(
12002 pNeighborRoamInfo->neighborRoamState),
12003 mac_trace_getcsr_roam_sub_state(
12004 pMac->roam.curSubState[pMac->roam.
12005 WaitForKeyTimerInfo.sessionId]));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012006 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0);
12007 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012008 sme_debug("csrScanStartWaitForKeyTimer");
Anurag Chouhan210db072016-02-22 18:42:15 +053012009 status = qdf_mc_timer_start(&pMac->roam.hTimerWaitForKey,
12010 interval / QDF_MC_TIMER_TO_MS_UNIT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012011
12012 return status;
12013}
12014
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012015QDF_STATUS csr_roam_stop_wait_for_key_timer(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012016{
12017 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
12018 &pMac->roam.neighborRoamInfo[pMac->roam.WaitForKeyTimerInfo.
12019 sessionId];
12020
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012021 sme_debug("WaitForKey timer stopped in state: %s sub-state: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012022 mac_trace_get_neighbour_roam_state(pNeighborRoamInfo->
12023 neighborRoamState),
12024 mac_trace_getcsr_roam_sub_state(pMac->roam.
12025 curSubState[pMac->roam.
12026 WaitForKeyTimerInfo.
12027 sessionId]));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012028 if (csr_neighbor_roam_is_handoff_in_progress(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012029 pMac->roam.WaitForKeyTimerInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012030 sessionId)) {
12031 /*
12032 * Enable heartbeat timer when hand-off is in progress
12033 * and Key Wait timer got stopped for some reason
12034 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012035 sme_debug("Enabling HB timer after WaitKey stop nHBCount: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012036 pMac->roam.configParam.HeartbeatThresh24);
12037 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
12038 pMac->roam.configParam.HeartbeatThresh24);
12039 }
Anurag Chouhan210db072016-02-22 18:42:15 +053012040 return qdf_mc_timer_stop(&pMac->roam.hTimerWaitForKey);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012041}
12042
12043void csr_roam_completion(tpAniSirGlobal pMac, uint32_t sessionId,
12044 tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
12045 eCsrRoamResult roamResult, bool fSuccess)
12046{
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012047 eRoamCmdStatus roamStatus = csr_get_roam_complete_status(pMac,
12048 sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012049 uint32_t roamId = 0;
12050 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
12051
12052 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012053 sme_err("session: %d not found ", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012054 return;
12055 }
12056
12057 if (pCommand) {
12058 roamId = pCommand->u.roamCmd.roamId;
12059 if (sessionId != pCommand->sessionId) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012060 QDF_ASSERT(sessionId == pCommand->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012061 return;
12062 }
12063 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012064 if (eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012065 /* if success, force roaming completion */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012066 csr_roam_complete_roaming(pMac, sessionId, fSuccess,
12067 roamResult);
12068 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012069 if (pSession->bRefAssocStartCnt != 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012070 QDF_ASSERT(pSession->bRefAssocStartCnt == 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012071 return;
12072 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012073 sme_debug("indicates association completion roamResult: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012074 roamResult);
12075 csr_roam_call_callback(pMac, sessionId, pRoamInfo, roamId,
12076 roamStatus, roamResult);
12077 }
12078}
12079
Jeff Johnson29e2ca12016-10-14 12:50:38 -070012080static
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012081QDF_STATUS csr_roam_lost_link(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012082 uint32_t type, tSirSmeRsp *pSirMsg)
12083{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012084 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012085 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
12086 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
12087 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012088 tCsrRoamInfo roamInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012089 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
12090
12091 if (!pSession) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012092 sme_err("session: %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012093 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012094 }
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -080012095#ifndef NAPIER_SCAN
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012096 pSession->fCancelRoaming = false;
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -080012097#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012098 if (eWNI_SME_DISASSOC_IND == type) {
12099 result = eCSR_ROAM_RESULT_DISASSOC_IND;
12100 pDisassocIndMsg = (tSirSmeDisassocInd *) pSirMsg;
12101 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
12102 pSession->joinFailStatusCode.reasonCode =
12103 pDisassocIndMsg->reasonCode;
12104 } else if (eWNI_SME_DEAUTH_IND == type) {
12105 result = eCSR_ROAM_RESULT_DEAUTH_IND;
12106 pDeauthIndMsg = (tSirSmeDeauthInd *) pSirMsg;
12107 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +053012108 pSession->joinFailStatusCode.reasonCode =
12109 pDeauthIndMsg->reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012110 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012111 sme_warn("gets an unknown type (%d)", type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012112 result = eCSR_ROAM_RESULT_NONE;
12113 pSession->joinFailStatusCode.reasonCode = 1;
12114 }
12115
12116 /* call profile lost link routine here */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012117 if (!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012118 csr_roam_call_callback(pMac, sessionId, NULL, 0,
12119 eCSR_ROAM_LOSTLINK_DETECTED, result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012120
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012121 if (eWNI_SME_DISASSOC_IND == type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012122 status = csr_send_mb_disassoc_cnf_msg(pMac, pDisassocIndMsg);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012123 else if (eWNI_SME_DEAUTH_IND == type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012124 status = csr_send_mb_deauth_cnf_msg(pMac, pDeauthIndMsg);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012125
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012126 /* prepare to tell HDD to disconnect */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012127 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012128 roamInfo.statusCode = (tSirResultCodes) pSession->roamingStatusCode;
12129 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
12130 if (eWNI_SME_DISASSOC_IND == type) {
12131 /* staMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053012132 qdf_copy_macaddr(&roamInfo.peerMac,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080012133 &pDisassocIndMsg->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012134 roamInfo.staId = (uint8_t) pDisassocIndMsg->staId;
12135 roamInfo.reasonCode = pDisassocIndMsg->reasonCode;
12136 } else if (eWNI_SME_DEAUTH_IND == type) {
12137 /* staMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053012138 qdf_copy_macaddr(&roamInfo.peerMac,
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080012139 &pDeauthIndMsg->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012140 roamInfo.staId = (uint8_t) pDeauthIndMsg->staId;
12141 roamInfo.reasonCode = pDeauthIndMsg->reasonCode;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -080012142 roamInfo.rxRssi = pDeauthIndMsg->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012143 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012144 sme_debug("roamInfo.staId: %d", roamInfo.staId);
Sandeep Puligillaa330c8c2017-03-09 18:03:21 -080012145/* Dont initiate internal driver based roaming after disconnection*/
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012146 return status;
12147}
12148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012149
Krunal Sonif3583022017-02-10 17:18:10 -080012150static void csr_roam_wm_status_change_complete(tpAniSirGlobal pMac,
12151 uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012152{
12153 tListElem *pEntry;
12154 tSmeCmd *pCommand;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012155
Krunal Sonia8270f52017-02-23 19:51:25 -080012156 pEntry = csr_nonscan_active_ll_peek_head(pMac, LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012157 if (pEntry) {
12158 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
12159 if (eSmeCommandWmStatusChange == pCommand->command) {
12160 /* Nothing to process in a Lost Link completion.... It just kicks off a */
12161 /* roaming sequence. */
Krunal Soni72dba662017-02-15 20:13:17 -080012162 if (csr_nonscan_active_ll_remove_entry(pMac, pEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012163 LL_ACCESS_LOCK)) {
Krunal Sonidea45952017-02-15 11:58:15 -080012164 csr_release_command(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012165 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012166 sme_err(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012167 " ******csr_roam_wm_status_change_complete fail to release command");
12168 }
12169
12170 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012171 sme_warn(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012172 "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ...");
12173 }
12174 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012175 sme_warn(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012176 "CSR: WmStatusChange Completion called but NO commands are ACTIVE ...");
12177 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012178}
12179
12180void csr_roam_process_wm_status_change_command(tpAniSirGlobal pMac,
12181 tSmeCmd *pCommand)
12182{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012183 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012184 tSirSmeRsp *pSirSmeMsg;
12185 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, pCommand->sessionId);
12186
12187 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012188 sme_err("session %d not found", pCommand->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012189 return;
12190 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012191 sme_debug("session:%d, CmdType : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012192 pCommand->sessionId, pCommand->u.wmStatusChangeCmd.Type);
12193
12194 switch (pCommand->u.wmStatusChangeCmd.Type) {
12195 case eCsrDisassociated:
12196 pSirSmeMsg =
12197 (tSirSmeRsp *) &pCommand->u.wmStatusChangeCmd.u.
12198 DisassocIndMsg;
12199 status =
12200 csr_roam_lost_link(pMac, pCommand->sessionId,
12201 eWNI_SME_DISASSOC_IND, pSirSmeMsg);
12202 break;
12203 case eCsrDeauthenticated:
12204 pSirSmeMsg =
12205 (tSirSmeRsp *) &pCommand->u.wmStatusChangeCmd.u.
12206 DeauthIndMsg;
12207 status =
12208 csr_roam_lost_link(pMac, pCommand->sessionId,
12209 eWNI_SME_DEAUTH_IND, pSirSmeMsg);
12210 break;
12211 default:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012212 sme_warn("gets an unknown command %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012213 pCommand->u.wmStatusChangeCmd.Type);
12214 break;
12215 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012216 /* Lost Link just triggers a roaming sequence. We can complte the
12217 * Lost Link command here since there is nothing else to do.
12218 */
Krunal Sonif3583022017-02-10 17:18:10 -080012219 csr_roam_wm_status_change_complete(pMac, pCommand->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012220}
12221
12222
12223/**
12224 * csr_compute_mode_and_band() - computes dot11mode
12225 * @pMac: mac global context
12226 * @dot11_mode: out param, do11 mode calculated
12227 * @band: out param, band caclculated
12228 * @opr_ch: operating channels
12229 *
12230 * This function finds dot11 mode based on current mode, operating channel and
12231 * fw supported modes.
12232 *
12233 * Return: void
12234 */
12235static void
12236csr_compute_mode_and_band(tpAniSirGlobal mac_ctx,
12237 eCsrCfgDot11Mode *dot11_mode,
12238 eCsrBand *band,
12239 uint8_t opr_ch)
12240{
12241 bool vht_24_ghz = mac_ctx->roam.configParam.enableVhtFor24GHz;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080012242
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012243 switch (mac_ctx->roam.configParam.uCfgDot11Mode) {
12244 case eCSR_CFG_DOT11_MODE_11A:
12245 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
12246 *band = eCSR_BAND_5G;
12247 break;
12248 case eCSR_CFG_DOT11_MODE_11B:
12249 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
12250 *band = eCSR_BAND_24;
12251 break;
12252 case eCSR_CFG_DOT11_MODE_11G:
12253 *dot11_mode = eCSR_CFG_DOT11_MODE_11G;
12254 *band = eCSR_BAND_24;
12255 break;
12256 case eCSR_CFG_DOT11_MODE_11N:
12257 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
12258 *band = CSR_GET_BAND(opr_ch);
12259 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012260 case eCSR_CFG_DOT11_MODE_11AC:
12261 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
12262 /*
12263 * If the operating channel is in 2.4 GHz band, check
12264 * for INI item to disable VHT operation in 2.4 GHz band
12265 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012266 if (WLAN_REG_IS_24GHZ_CH(opr_ch) && !vht_24_ghz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012267 /* Disable 11AC operation */
12268 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
12269 else
12270 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC;
12271 } else {
12272 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
12273 }
12274 *band = CSR_GET_BAND(opr_ch);
12275 break;
12276 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
12277 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
12278 /*
12279 * If the operating channel is in 2.4 GHz band, check
12280 * for INI item to disable VHT operation in 2.4 GHz band
12281 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012282 if (WLAN_REG_IS_24GHZ_CH(opr_ch) && !vht_24_ghz)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012283 /* Disable 11AC operation */
12284 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
12285 else
12286 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
12287 } else {
12288 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
12289 }
12290 *band = CSR_GET_BAND(opr_ch);
12291 break;
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080012292 case eCSR_CFG_DOT11_MODE_11AX:
12293 case eCSR_CFG_DOT11_MODE_11AX_ONLY:
12294 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX)) {
12295 *dot11_mode = mac_ctx->roam.configParam.uCfgDot11Mode;
12296 } else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
12297 /*
12298 * If the operating channel is in 2.4 GHz band, check
12299 * for INI item to disable VHT operation in 2.4 GHz band
12300 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012301 if (WLAN_REG_IS_24GHZ_CH(opr_ch) && !vht_24_ghz)
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080012302 /* Disable 11AC operation */
12303 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
12304 else
12305 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC;
12306 } else {
12307 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
12308 }
12309 *band = CSR_GET_BAND(opr_ch);
12310 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012311 case eCSR_CFG_DOT11_MODE_AUTO:
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -080012312 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AX)) {
12313 *dot11_mode = eCSR_CFG_DOT11_MODE_11AX;
12314 } else if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012315 /*
12316 * If the operating channel is in 2.4 GHz band,
12317 * check for INI item to disable VHT operation
12318 * in 2.4 GHz band
12319 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012320 if (WLAN_REG_IS_24GHZ_CH(opr_ch)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012321 && !vht_24_ghz)
12322 /* Disable 11AC operation */
12323 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
12324 else
12325 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC;
12326 } else {
12327 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
12328 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012329 *band = CSR_GET_BAND(opr_ch);
12330 break;
12331 default:
12332 /*
12333 * Global dot11 Mode setting is 11a/b/g. use the channel number
12334 * to determine the Mode setting.
12335 */
12336 if (eCSR_OPERATING_CHANNEL_AUTO == opr_ch) {
12337 *band = mac_ctx->roam.configParam.eBand;
12338 if (eCSR_BAND_24 == *band) {
12339 /*
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012340 * See reason in else if ( WLAN_REG_IS_24GHZ_CH
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012341 * (opr_ch) ) to pick 11B
12342 */
12343 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
12344 } else {
12345 /* prefer 5GHz */
12346 *band = eCSR_BAND_5G;
12347 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
12348 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012349 } else if (WLAN_REG_IS_24GHZ_CH(opr_ch)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012350 /*
12351 * WiFi tests require IBSS networks to start in 11b mode
12352 * without any change to the default parameter settings
12353 * on the adapter. We use ACU to start an IBSS through
12354 * creation of a startIBSS profile. This startIBSS
12355 * profile has Auto MACProtocol and the adapter property
12356 * setting for dot11Mode is also AUTO. So in this case,
12357 * let's start the IBSS network in 11b mode instead of
12358 * 11g mode. So this is for Auto=profile->MacProtocol &&
12359 * Auto=Global. dot11Mode && profile->channel is < 14,
12360 * then start the IBSS in b mode.
12361 *
12362 * Note: we used to have this start as an 11g IBSS for
12363 * best performance. now to specify that the user will
12364 * have to set the do11Mode in the property page to 11g
12365 * to force it.
12366 */
12367 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
12368 *band = eCSR_BAND_24;
12369 } else {
12370 /* else, it's a 5.0GHz channel. Set mode to 11a. */
12371 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
12372 *band = eCSR_BAND_5G;
12373 }
12374 break;
12375 } /* switch */
12376}
12377
12378/**
12379 * csr_roam_get_phy_mode_band_for_bss() - This function returns band and mode
12380 * information.
12381 * @mac_ctx: mac global context
12382 * @profile: bss profile
12383 * @band: out param, band caclculated
12384 * @opr_ch: operating channels
12385 *
12386 * This function finds dot11 mode based on current mode, operating channel and
12387 * fw supported modes. The only tricky part is that if phyMode is set to 11abg,
12388 * this function may return eCSR_CFG_DOT11_MODE_11B instead of
12389 * eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
12390 *
12391 * Return: dot11mode
12392 */
12393static eCsrCfgDot11Mode
12394csr_roam_get_phy_mode_band_for_bss(tpAniSirGlobal mac_ctx,
12395 tCsrRoamProfile *profile,
12396 uint8_t opr_chn,
12397 eCsrBand *p_band)
12398{
12399 eCsrBand band;
12400 eCsrCfgDot11Mode curr_mode = mac_ctx->roam.configParam.uCfgDot11Mode;
12401 eCsrCfgDot11Mode cfg_dot11_mode =
12402 csr_get_cfg_dot11_mode_from_csr_phy_mode(profile,
12403 (eCsrPhyMode) profile->phyMode,
12404 mac_ctx->roam.configParam.ProprietaryRatesEnabled);
12405
12406 /*
12407 * If the global setting for dot11Mode is set to auto/abg, we overwrite
12408 * the setting in the profile.
12409 */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070012410 if ((!CSR_IS_INFRA_AP(profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012411 && ((eCSR_CFG_DOT11_MODE_AUTO == curr_mode)
12412 || (eCSR_CFG_DOT11_MODE_ABG == curr_mode)))
12413 || (eCSR_CFG_DOT11_MODE_AUTO == cfg_dot11_mode)
12414 || (eCSR_CFG_DOT11_MODE_ABG == cfg_dot11_mode)) {
12415 csr_compute_mode_and_band(mac_ctx, &cfg_dot11_mode,
12416 &band, opr_chn);
12417 } /* if( eCSR_CFG_DOT11_MODE_ABG == cfg_dot11_mode ) */
12418 else {
12419 /* dot11 mode is set, lets pick the band */
12420 if (eCSR_OPERATING_CHANNEL_AUTO == opr_chn) {
12421 /* channel is Auto also. */
12422 band = mac_ctx->roam.configParam.eBand;
12423 if (eCSR_BAND_ALL == band) {
12424 /* prefer 5GHz */
12425 band = eCSR_BAND_5G;
12426 }
12427 } else{
12428 band = CSR_GET_BAND(opr_chn);
12429 }
12430 }
12431 if (p_band)
12432 *p_band = band;
12433
12434 if (opr_chn == 14) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012435 sme_err("Switching to Dot11B mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012436 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11B;
12437 }
12438
Gupta, Kapil76ed25e2016-04-22 15:13:55 +053012439 if (IS_24G_CH(opr_chn) &&
12440 (false == mac_ctx->roam.configParam.enableVhtFor24GHz) &&
12441 (eCSR_CFG_DOT11_MODE_11AC == cfg_dot11_mode ||
12442 eCSR_CFG_DOT11_MODE_11AC_ONLY == cfg_dot11_mode))
12443 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11N;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012444 /*
12445 * Incase of WEP Security encryption type is coming as part of add key.
12446 * So while STart BSS dont have information
12447 */
12448 if ((!CSR_IS_11n_ALLOWED(profile->EncryptionType.encryptionType[0])
12449 || ((profile->privacy == 1)
12450 && (profile->EncryptionType.encryptionType[0] ==
12451 eCSR_ENCRYPT_TYPE_NONE)))
12452 && ((eCSR_CFG_DOT11_MODE_11N == cfg_dot11_mode) ||
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -080012453 (eCSR_CFG_DOT11_MODE_11AC == cfg_dot11_mode))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012454 /* We cannot do 11n here */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012455 if (WLAN_REG_IS_24GHZ_CH(opr_chn))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012456 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11G;
12457 else
12458 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11A;
12459 }
Srinivas Girigowda2c263352017-03-17 17:49:53 -070012460 sme_debug("dot11mode: %d", cfg_dot11_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012461 return cfg_dot11_mode;
12462}
12463
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012464QDF_STATUS csr_roam_issue_stop_bss(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012465 eCsrRoamSubState NewSubstate)
12466{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012467 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012468 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
12469
12470 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012471 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012472 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012473 }
12474#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12475 {
12476 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012477
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012478 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
12479 LOG_WLAN_IBSS_C);
12480 if (pIbssLog) {
12481 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
12482 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
12483 }
12484 }
12485#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12486 /* Set the roaming substate to 'stop Bss request'... */
12487 csr_roam_substate_change(pMac, NewSubstate, sessionId);
12488
12489 /* attempt to stop the Bss (reason code is ignored...) */
12490 status = csr_send_mb_stop_bss_req_msg(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012491 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012492 sme_warn(
12493 "csr_send_mb_stop_bss_req_msg failed with status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012494 status);
12495 }
12496 return status;
12497}
12498
12499/* pNumChan is a caller allocated space with the sizeof pChannels */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012500QDF_STATUS csr_get_cfg_valid_channels(tpAniSirGlobal pMac, uint8_t *pChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012501 uint32_t *pNumChan)
12502{
Edhar, Mahesh Kumareb31abd2016-01-21 17:50:47 +053012503 uint8_t num_chan_temp = 0;
12504 int i;
12505
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012506 if (!IS_SIR_STATUS_SUCCESS(wlan_cfg_get_str(pMac,
12507 WNI_CFG_VALID_CHANNEL_LIST,
12508 (uint8_t *) pChannels, pNumChan)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012509 return QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumareb31abd2016-01-21 17:50:47 +053012510
12511 for (i = 0; i < *pNumChan; i++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012512 if (!WLAN_REG_IS_11P_CH(pChannels[i])) {
Edhar, Mahesh Kumareb31abd2016-01-21 17:50:47 +053012513 pChannels[num_chan_temp] = pChannels[i];
12514 num_chan_temp++;
12515 }
12516 }
12517
12518 *pNumChan = num_chan_temp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012519 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012520}
12521
Amar Singhala297bfa2015-10-15 15:07:29 -070012522int8_t csr_get_cfg_max_tx_power(tpAniSirGlobal pMac, uint8_t channel)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012523{
12524 uint32_t cfgLength = 0;
12525 uint16_t cfgId = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -070012526 int8_t maxTxPwr = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012527 uint8_t *pCountryInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012528 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012529 uint8_t count = 0;
12530 uint8_t firstChannel;
12531 uint8_t maxChannels;
12532
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012533 if (WLAN_REG_IS_5GHZ_CH(channel)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012534 cfgId = WNI_CFG_MAX_TX_POWER_5;
12535 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012536 } else if (WLAN_REG_IS_24GHZ_CH(channel)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012537 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
12538 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
12539 } else
12540 return maxTxPwr;
12541
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012542 pCountryInfo = qdf_mem_malloc(cfgLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012543 if (NULL == pCountryInfo)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012544 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012545 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012546 status = QDF_STATUS_SUCCESS;
12547 if (status != QDF_STATUS_SUCCESS) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012548 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012549 "%s: failed to allocate memory, status = %d",
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012550 __func__, status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012551 goto error;
12552 }
12553 if (wlan_cfg_get_str(pMac, cfgId, (uint8_t *)pCountryInfo,
12554 &cfgLength) != eSIR_SUCCESS) {
12555 goto error;
12556 }
12557 /* Identify the channel and maxtxpower */
12558 while (count <= (cfgLength - (sizeof(tSirMacChanInfo)))) {
12559 firstChannel = pCountryInfo[count++];
12560 maxChannels = pCountryInfo[count++];
12561 maxTxPwr = pCountryInfo[count++];
12562
12563 if ((channel >= firstChannel) &&
12564 (channel < (firstChannel + maxChannels))) {
12565 break;
12566 }
12567 }
12568
12569error:
12570 if (NULL != pCountryInfo)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012571 qdf_mem_free(pCountryInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012572
12573 return maxTxPwr;
12574}
12575
12576bool csr_roam_is_channel_valid(tpAniSirGlobal pMac, uint8_t channel)
12577{
12578 bool fValid = false;
12579 uint32_t idxValidChannels;
12580 uint32_t len = sizeof(pMac->roam.validChannelList);
12581
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012582 if (QDF_IS_STATUS_SUCCESS(csr_get_cfg_valid_channels(pMac,
12583 pMac->roam.validChannelList, &len))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012584 for (idxValidChannels = 0; (idxValidChannels < len);
12585 idxValidChannels++) {
12586 if (channel ==
12587 pMac->roam.validChannelList[idxValidChannels]) {
12588 fValid = true;
12589 break;
12590 }
12591 }
12592 }
12593 pMac->roam.numValidChannels = len;
12594 return fValid;
12595}
12596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012597/* This function check and validate whether the NIC can do CB (40MHz) */
12598static ePhyChanBondState csr_get_cb_mode_from_ies(tpAniSirGlobal pMac,
12599 uint8_t primaryChn,
12600 tDot11fBeaconIEs *pIes)
12601{
12602 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
12603 uint8_t centerChn;
12604 uint32_t ChannelBondingMode;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012605 if (WLAN_REG_IS_24GHZ_CH(primaryChn)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012606 ChannelBondingMode =
12607 pMac->roam.configParam.channelBondingMode24GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012608 } else {
12609 ChannelBondingMode =
12610 pMac->roam.configParam.channelBondingMode5GHz;
12611 }
12612
12613 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE == ChannelBondingMode)
12614 return PHY_SINGLE_CHANNEL_CENTERED;
12615
12616 /* Figure what the other side's CB mode */
12617 if (!(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ ==
12618 pIes->HTCaps.supportedChannelWidthSet))) {
12619 return PHY_SINGLE_CHANNEL_CENTERED;
12620 }
12621
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053012622 /* In Case WPA2 and TKIP is the only one cipher suite in Pairwise */
12623 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012624 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053012625 "\x00\x0f\xac\x02", 4))
Abhishek Singh1e39fc22015-12-18 11:23:44 +053012626 /* In Case only WPA1 is supported and TKIP is
12627 * the only one cipher suite in Unicast.
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053012628 */
Abhishek Singh1e39fc22015-12-18 11:23:44 +053012629 || (!pIes->RSN.present && (pIes->WPA.present &&
12630 (pIes->WPA.unicast_cipher_count == 1) &&
12631 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
12632 "\x00\x50\xf2\x02", 4)))) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012633 sme_debug("No channel bonding in TKIP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012634 return PHY_SINGLE_CHANNEL_CENTERED;
12635 }
12636
12637 if (!pIes->HTInfo.present)
12638 return PHY_SINGLE_CHANNEL_CENTERED;
12639
12640 /*
12641 * This is called during INFRA STA/CLIENT and should use the merged
12642 * value of supported channel width and recommended tx width as per
12643 * standard
12644 */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012645 sme_debug("scws %u rtws %u sco %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012646 pIes->HTCaps.supportedChannelWidthSet,
12647 pIes->HTInfo.recommendedTxWidthSet,
12648 pIes->HTInfo.secondaryChannelOffset);
12649
12650 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
12651 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
12652 else
12653 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12654
12655 switch (eRet) {
12656 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
12657 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
12658 break;
12659 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
12660 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
12661 break;
12662 case PHY_SINGLE_CHANNEL_CENTERED:
12663 default:
12664 centerChn = primaryChn;
12665 break;
12666 }
12667
Amar Singhal7ccdc4f2015-10-30 15:10:05 -070012668 if ((PHY_SINGLE_CHANNEL_CENTERED != eRet) &&
12669 (QDF_STATUS_SUCCESS != sme_check_ch_in_band(pMac,
12670 centerChn - 2, 2))) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012671 sme_err("Invalid center channel (%d), disable 40MHz mode",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012672 centerChn);
12673 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12674 }
12675 return eRet;
12676}
12677
Jeff Johnson29e2ca12016-10-14 12:50:38 -070012678static bool csr_is_encryption_in_list(tpAniSirGlobal pMac,
12679 tCsrEncryptionList *pCipherList,
12680 eCsrEncryptionType encryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012681{
12682 bool fFound = false;
12683 uint32_t idx;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012684
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012685 for (idx = 0; idx < pCipherList->numEntries; idx++) {
12686 if (pCipherList->encryptionType[idx] == encryptionType) {
12687 fFound = true;
12688 break;
12689 }
12690 }
12691 return fFound;
12692}
12693
Jeff Johnson29e2ca12016-10-14 12:50:38 -070012694static bool csr_is_auth_in_list(tpAniSirGlobal pMac, tCsrAuthList *pAuthList,
12695 eCsrAuthType authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012696{
12697 bool fFound = false;
12698 uint32_t idx;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012699
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012700 for (idx = 0; idx < pAuthList->numEntries; idx++) {
12701 if (pAuthList->authType[idx] == authType) {
12702 fFound = true;
12703 break;
12704 }
12705 }
12706 return fFound;
12707}
12708
12709bool csr_is_same_profile(tpAniSirGlobal pMac,
12710 tCsrRoamConnectedProfile *pProfile1,
12711 tCsrRoamProfile *pProfile2)
12712{
12713 uint32_t i;
12714 bool fCheck = false;
12715 tCsrScanResultFilter *pScanFilter = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012716 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012717
12718 if (!(pProfile1 && pProfile2))
12719 return fCheck;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012720 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012721 if (NULL == pScanFilter)
12722 return fCheck;
12723
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012724 status = csr_roam_prepare_filter_from_profile(pMac, pProfile2,
12725 pScanFilter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012726 if (!(QDF_IS_STATUS_SUCCESS(status)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012727 goto free_scan_filter;
12728
12729 for (i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++) {
12730 fCheck = csr_is_ssid_match(pMac,
12731 pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
12732 pScanFilter->SSIDs.SSIDList[i].SSID.length,
12733 pProfile1->SSID.ssId,
12734 pProfile1->SSID.length,
12735 false);
12736 if (fCheck)
12737 break;
12738 }
12739 if (!fCheck)
12740 goto free_scan_filter;
12741
12742 if (!csr_is_auth_in_list(pMac, &pProfile2->AuthType,
12743 pProfile1->AuthType)
12744 || (pProfile2->BSSType != pProfile1->BSSType)
12745 || !csr_is_encryption_in_list(pMac, &pProfile2->EncryptionType,
12746 pProfile1->EncryptionType)) {
12747 fCheck = false;
12748 goto free_scan_filter;
12749 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012750 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent) {
12751 if (pProfile1->MDID.mobilityDomain
12752 != pProfile2->MDID.mobilityDomain) {
12753 fCheck = false;
12754 goto free_scan_filter;
12755 }
12756 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012757 /* Match found */
12758 fCheck = true;
12759free_scan_filter:
12760 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012761 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012762 return fCheck;
12763}
12764
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012765static bool csr_roam_is_same_profile_keys(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012766 tCsrRoamConnectedProfile *pConnProfile,
12767 tCsrRoamProfile *pProfile2)
12768{
12769 bool fCheck = false;
12770 int i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012771
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012772 do {
12773 /* Only check for static WEP */
12774 if (!csr_is_encryption_in_list
12775 (pMac, &pProfile2->EncryptionType,
12776 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY)
12777 && !csr_is_encryption_in_list(pMac,
12778 &pProfile2->EncryptionType,
12779 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
12780 fCheck = true;
12781 break;
12782 }
12783 if (!csr_is_encryption_in_list
12784 (pMac, &pProfile2->EncryptionType,
12785 pConnProfile->EncryptionType))
12786 break;
12787 if (pConnProfile->Keys.defaultIndex !=
12788 pProfile2->Keys.defaultIndex)
12789 break;
12790 for (i = 0; i < CSR_MAX_NUM_KEY; i++) {
12791 if (pConnProfile->Keys.KeyLength[i] !=
12792 pProfile2->Keys.KeyLength[i])
12793 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012794 if (qdf_mem_cmp(&pConnProfile->Keys.KeyMaterial[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012795 &pProfile2->Keys.KeyMaterial[i],
12796 pProfile2->Keys.KeyLength[i])) {
12797 break;
12798 }
12799 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012800 if (i == CSR_MAX_NUM_KEY)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012801 fCheck = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012802 } while (0);
12803 return fCheck;
12804}
12805
12806/* IBSS */
12807
Jeff Johnson29e2ca12016-10-14 12:50:38 -070012808static uint8_t csr_roam_get_ibss_start_channel_number50(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012809{
12810 uint8_t channel = 0;
12811 uint32_t idx;
12812 uint32_t idxValidChannels;
12813 bool fFound = false;
12814 uint32_t len = sizeof(pMac->roam.validChannelList);
12815
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012816 if (eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.
12817 AdHocChannel5G) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012818 channel = pMac->roam.configParam.AdHocChannel5G;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012819 if (!csr_roam_is_channel_valid(pMac, channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012820 channel = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012821 }
12822 if (0 == channel
12823 &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012824 QDF_IS_STATUS_SUCCESS(csr_get_cfg_valid_channels
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012825 (pMac, (uint8_t *) pMac->roam.
12826 validChannelList, &len))) {
Sandeep Puligilla80038de2017-05-10 10:43:29 -070012827 for (idx = 0; (idx < CSR_NUM_IBSS_START_CHAN_50) && !fFound;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012828 idx++) {
12829 for (idxValidChannels = 0;
12830 (idxValidChannels < len) && !fFound;
12831 idxValidChannels++) {
12832 if (csr_start_ibss_channels50[idx] ==
12833 pMac->roam.
12834 validChannelList[idxValidChannels]) {
12835 fFound = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012836 channel =
12837 csr_start_ibss_channels50[idx];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012838 }
12839 }
12840 }
12841 /*
12842 * this is rare, but if it does happen,
12843 * we find anyone in 11a bandwidth and
12844 * return the first 11a channel found!
12845 */
12846 if (!fFound) {
12847 for (idxValidChannels = 0; idxValidChannels < len;
12848 idxValidChannels++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070012849 if (WLAN_REG_IS_5GHZ_CH(pMac->roam.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012850 validChannelList[idxValidChannels])) {
12851 /* the max channel# in 11g is 14 */
12852 if (idxValidChannels <
Sandeep Puligilla80038de2017-05-10 10:43:29 -070012853 CSR_NUM_IBSS_START_CHAN_50) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012854 channel =
12855 pMac->roam.validChannelList
12856 [idxValidChannels];
12857 }
12858 break;
12859 }
12860 }
12861 }
12862 } /* if */
12863
12864 return channel;
12865}
12866
Jeff Johnson29e2ca12016-10-14 12:50:38 -070012867static uint8_t csr_roam_get_ibss_start_channel_number24(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012868{
12869 uint8_t channel = 1;
12870 uint32_t idx;
12871 uint32_t idxValidChannels;
12872 bool fFound = false;
12873 uint32_t len = sizeof(pMac->roam.validChannelList);
12874
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012875 if (eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.
12876 AdHocChannel24) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012877 channel = pMac->roam.configParam.AdHocChannel24;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012878 if (!csr_roam_is_channel_valid(pMac, channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012879 channel = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012880 }
12881
12882 if (0 == channel
12883 &&
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012884 QDF_IS_STATUS_SUCCESS(csr_get_cfg_valid_channels(pMac,
12885 (uint8_t *) pMac->roam.validChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012886 &len))) {
12887 for (idx = 0; (idx < CSR_NUM_IBSS_START_CHANNELS_24) && !fFound;
12888 idx++) {
12889 for (idxValidChannels = 0;
12890 (idxValidChannels < len) && !fFound;
12891 idxValidChannels++) {
12892 if (csr_start_ibss_channels24[idx] ==
12893 pMac->roam.
12894 validChannelList[idxValidChannels]) {
12895 fFound = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053012896 channel =
12897 csr_start_ibss_channels24[idx];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012898 }
12899 }
12900 }
12901 }
12902
12903 return channel;
12904}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012905/**
12906 * csr_populate_basic_rates() - populates OFDM or CCK rates
12907 * @rates: rate struct to populate
Agrawal Ashish06e76d22016-08-18 16:44:48 +053012908 * @is_ofdm_rates: true: ofdm rates, false: cck rates
12909 * @is_basic_rates: indicates if rates are to be masked with
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012910 * CSR_DOT11_BASIC_RATE_MASK
12911 *
12912 * This function will populate OFDM or CCK rates
12913 *
12914 * Return: void
12915 */
12916static void
Agrawal Ashish06e76d22016-08-18 16:44:48 +053012917csr_populate_basic_rates(tSirMacRateSet *rate_set, bool is_ofdm_rates,
12918 bool is_basic_rates)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012919{
Agrawal Ashish06e76d22016-08-18 16:44:48 +053012920 int i = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012921 uint8_t ofdm_rates[8] = {
12922 SIR_MAC_RATE_6,
12923 SIR_MAC_RATE_9,
12924 SIR_MAC_RATE_12,
12925 SIR_MAC_RATE_18,
12926 SIR_MAC_RATE_24,
12927 SIR_MAC_RATE_36,
12928 SIR_MAC_RATE_48,
12929 SIR_MAC_RATE_54
12930 };
12931 uint8_t cck_rates[4] = {
12932 SIR_MAC_RATE_1,
12933 SIR_MAC_RATE_2,
12934 SIR_MAC_RATE_5_5,
12935 SIR_MAC_RATE_11
12936 };
12937
Agrawal Ashish06e76d22016-08-18 16:44:48 +053012938 if (is_ofdm_rates == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012939 rate_set->numRates = 8;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012940 qdf_mem_copy(rate_set->rate, ofdm_rates, sizeof(ofdm_rates));
Agrawal Ashish06e76d22016-08-18 16:44:48 +053012941 if (is_basic_rates) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012942 rate_set->rate[0] |= CSR_DOT11_BASIC_RATE_MASK;
12943 rate_set->rate[2] |= CSR_DOT11_BASIC_RATE_MASK;
12944 rate_set->rate[4] |= CSR_DOT11_BASIC_RATE_MASK;
12945 }
Agrawal Ashish06e76d22016-08-18 16:44:48 +053012946 for (i = 0; i < rate_set->numRates; i++)
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012947 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
12948 ("Default OFDM rate is %2x"), rate_set->rate[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012949 } else {
12950 rate_set->numRates = 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012951 qdf_mem_copy(rate_set->rate, cck_rates, sizeof(cck_rates));
Agrawal Ashish06e76d22016-08-18 16:44:48 +053012952 if (is_basic_rates) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012953 rate_set->rate[0] |= CSR_DOT11_BASIC_RATE_MASK;
12954 rate_set->rate[1] |= CSR_DOT11_BASIC_RATE_MASK;
12955 rate_set->rate[2] |= CSR_DOT11_BASIC_RATE_MASK;
12956 rate_set->rate[3] |= CSR_DOT11_BASIC_RATE_MASK;
12957 }
Agrawal Ashish06e76d22016-08-18 16:44:48 +053012958 for (i = 0; i < rate_set->numRates; i++)
Srinivas Girigowda81aef902017-03-17 09:34:19 -070012959 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
12960 ("Default CCK rate is %2x"), rate_set->rate[i]);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053012961
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012962 }
12963}
12964
12965/**
12966 * csr_convert_mode_to_nw_type() - convert mode into network type
12967 * @dot11_mode: dot11_mode
12968 * @band: 2.4 or 5 GHz
12969 *
12970 * Return: tSirNwType
12971 */
12972static tSirNwType
12973csr_convert_mode_to_nw_type(eCsrCfgDot11Mode dot11_mode, eCsrBand band)
12974{
12975 switch (dot11_mode) {
12976 case eCSR_CFG_DOT11_MODE_11G:
12977 return eSIR_11G_NW_TYPE;
12978 case eCSR_CFG_DOT11_MODE_11B:
12979 return eSIR_11B_NW_TYPE;
12980 case eCSR_CFG_DOT11_MODE_11A:
12981 return eSIR_11A_NW_TYPE;
12982 case eCSR_CFG_DOT11_MODE_11N:
12983 default:
12984 /*
12985 * Because LIM only verifies it against 11a, 11b or 11g, set
12986 * only 11g or 11a here
12987 */
12988 if (eCSR_BAND_24 == band)
12989 return eSIR_11G_NW_TYPE;
12990 else
12991 return eSIR_11A_NW_TYPE;
12992 }
12993 return eSIR_DONOT_USE_NW_TYPE;
12994}
12995
12996/**
lifenge9245fc2017-02-22 17:23:19 +080012997 * csr_merge_supported_and_extended_rates() - merge supported rates and
12998 * extended rates
12999 * @rates: merged rates
13000 * @supported_rates: supported rates
13001 * @extended_rates: extended rates
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013002 *
lifenge9245fc2017-02-22 17:23:19 +080013003 * Return: None
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013004 */
lifenge9245fc2017-02-22 17:23:19 +080013005static void csr_merge_supported_and_extended_rates(
13006 struct merged_mac_rate_set *rates,
13007 tSirMacRateSet *supported_rates,
13008 tSirMacRateSet *extended_rates)
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013009{
lifenge9245fc2017-02-22 17:23:19 +080013010 int i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013011
Ravi Joshib398c852017-07-18 17:55:21 -070013012 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
13013 FL("supported_rates: %d extended_rates: %d"),
13014 supported_rates->numRates, extended_rates->numRates);
13015
13016 if (supported_rates->numRates > SIR_MAC_RATESET_EID_MAX)
13017 supported_rates->numRates = SIR_MAC_RATESET_EID_MAX;
13018
13019 if (extended_rates->numRates > SIR_MAC_RATESET_EID_MAX)
13020 extended_rates->numRates = SIR_MAC_RATESET_EID_MAX;
13021
lifenge9245fc2017-02-22 17:23:19 +080013022 qdf_mem_copy(rates->rate,
13023 supported_rates->rate,
13024 supported_rates->numRates);
13025 rates->num_rates = supported_rates->numRates;
13026
13027 qdf_mem_copy(rates->rate + rates->num_rates,
13028 extended_rates->rate,
13029 extended_rates->numRates);
13030 rates->num_rates += extended_rates->numRates;
13031
13032 for (i = 0; i < rates->num_rates; i++)
13033 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
13034 FL("Merge rate is %2x"), rates->rate[i]);
13035}
13036
13037/**
13038 * csr_populate_intersection_driver_and_hostpd_rates() - populate
13039 * intersection of driver rates and hostapd rates
13040 * @pParam: csr roam start bss params
13041 * @driver_rates: rates generated by driver
13042 * @hostapd_rates: rates generated by hostapd
13043 *
13044 * Return: None
13045 */
13046static void csr_populate_intersection_driver_and_hostpd_rates(
13047 struct tagCsrRoamStartBssParams *param,
13048 struct merged_mac_rate_set *driver_rates,
13049 struct merged_mac_rate_set *hostapd_rates)
13050{
13051 int i, j;
13052 struct merged_mac_rate_set rates;
13053 uint8_t driver_rate, hostapd_rate;
13054 tSirMacRateSet *opr_rates = &param->operationalRateSet;
13055 tSirMacRateSet *ext_rates = &param->extendedRateSet;
13056
13057 rates.num_rates = 0;
13058
13059 for (i = 0; i < driver_rates->num_rates; i++) {
13060 driver_rate = driver_rates->rate[i];
13061 if (CSR_IS_BASIC_RATE(driver_rate))
13062 BITS_OFF(driver_rate,
13063 CSR_DOT11_BASIC_RATE_MASK);
13064
13065 for (j = 0; j < hostapd_rates->num_rates; j++) {
13066 hostapd_rate = hostapd_rates->rate[j];
13067 if (CSR_IS_BASIC_RATE(hostapd_rate))
13068 BITS_OFF(hostapd_rate,
13069 CSR_DOT11_BASIC_RATE_MASK);
13070
13071 if (driver_rate == hostapd_rate) {
13072 if (CSR_IS_BASIC_RATE(driver_rates->rate[i]) ||
13073 CSR_IS_BASIC_RATE(hostapd_rates->rate[j]))
13074 BITS_ON(driver_rate,
13075 CSR_DOT11_BASIC_RATE_MASK);
13076
13077 rates.rate[rates.num_rates++] = driver_rate;
13078 break;
13079 }
13080 }
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013081 }
lifenge9245fc2017-02-22 17:23:19 +080013082
13083 for (i = 0; i < rates.num_rates; i++)
13084 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
13085 FL("Intersection rate is %2x"), rates.rate[i]);
13086
13087 opr_rates->numRates = 0;
13088 ext_rates->numRates = 0;
13089 if (rates.num_rates <= MAX_NUM_SUPPORTED_RATES) {
13090 opr_rates->numRates = rates.num_rates;
13091 qdf_mem_copy(opr_rates->rate,
13092 rates.rate,
13093 opr_rates->numRates);
13094 } else {
13095 opr_rates->numRates = MAX_NUM_SUPPORTED_RATES;
13096 qdf_mem_copy(opr_rates->rate,
13097 rates.rate,
13098 MAX_NUM_SUPPORTED_RATES);
13099 ext_rates->numRates = rates.num_rates - MAX_NUM_SUPPORTED_RATES;
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013100 qdf_mem_copy(ext_rates->rate,
lifenge9245fc2017-02-22 17:23:19 +080013101 rates.rate + MAX_NUM_SUPPORTED_RATES,
13102 ext_rates->numRates);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013103 }
13104}
lifenge9245fc2017-02-22 17:23:19 +080013105
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013106/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013107 * csr_roam_get_bss_start_parms() - get bss start param from profile
13108 * @pMac: mac global context
13109 * @pProfile: roam profile
13110 * @pParam: out param, start bss params
Krunal Soni8f8507c2016-12-20 13:54:34 -080013111 * @skip_hostapd_rate: to skip given hostapd's rate
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013112 *
13113 * This function populates start bss param from roam profile
13114 *
13115 * Return: void
13116 */
13117static void
13118csr_roam_get_bss_start_parms(tpAniSirGlobal pMac,
13119 tCsrRoamProfile *pProfile,
Krunal Soni8f8507c2016-12-20 13:54:34 -080013120 tCsrRoamStartBssParams *pParam,
13121 bool skip_hostapd_rate)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013122{
13123 eCsrBand band;
13124 uint8_t opr_ch = 0;
13125 tSirNwType nw_type;
13126 uint8_t tmp_opr_ch = 0;
13127 tSirMacRateSet *opr_rates = &pParam->operationalRateSet;
13128 tSirMacRateSet *ext_rates = &pParam->extendedRateSet;
13129
13130 if (pProfile->ChannelInfo.numOfChannels
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013131 && pProfile->ChannelInfo.ChannelList)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013132 tmp_opr_ch = pProfile->ChannelInfo.ChannelList[0];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013133
13134 pParam->uCfgDot11Mode = csr_roam_get_phy_mode_band_for_bss(pMac,
13135 pProfile, tmp_opr_ch, &band);
13136
Anurag Chouhan6d760662016-02-20 16:05:43 +053013137 if (((pProfile->csrPersona == QDF_P2P_CLIENT_MODE)
13138 || (pProfile->csrPersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013139 && (pParam->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)) {
13140 /* This should never happen */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013141 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013142 "For P2P (persona %d) dot11_mode is 11B",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013143 pProfile->csrPersona);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013144 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013145 }
13146
13147 nw_type = csr_convert_mode_to_nw_type(pParam->uCfgDot11Mode, band);
13148 ext_rates->numRates = 0;
lifenge9245fc2017-02-22 17:23:19 +080013149
13150 switch (nw_type) {
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013151 default:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013152 sme_err(
13153 "sees an unknown pSirNwType (%d)",
13154 nw_type);
Agrawal Ashish06e76d22016-08-18 16:44:48 +053013155 case eSIR_11A_NW_TYPE:
13156 csr_populate_basic_rates(opr_rates, true, true);
13157 if (eCSR_OPERATING_CHANNEL_ANY != tmp_opr_ch) {
13158 opr_ch = tmp_opr_ch;
13159 break;
13160 }
13161 opr_ch = csr_roam_get_ibss_start_channel_number50(pMac);
13162 if (0 == opr_ch &&
13163 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
13164 CSR_IS_PHY_MODE_DUAL_BAND(
13165 pMac->roam.configParam.phyMode)) {
13166 /*
13167 * We could not find a 5G channel by auto pick,
13168 * let's try 2.4G channels. We only do this here
13169 * because csr_roam_get_phy_mode_band_for_bss
13170 * always picks 11a for AUTO
13171 */
13172 nw_type = eSIR_11B_NW_TYPE;
13173 opr_ch =
13174 csr_roam_get_ibss_start_channel_number24(pMac);
13175 csr_populate_basic_rates(opr_rates, false,
13176 true);
13177 }
13178 break;
13179 case eSIR_11B_NW_TYPE:
13180 csr_populate_basic_rates(opr_rates, false, true);
13181 if (eCSR_OPERATING_CHANNEL_ANY == tmp_opr_ch)
13182 opr_ch =
13183 csr_roam_get_ibss_start_channel_number24(pMac);
13184 else
13185 opr_ch = tmp_opr_ch;
13186 break;
13187 case eSIR_11G_NW_TYPE:
13188 /* For P2P Client and P2P GO, disable 11b rates */
13189 if ((pProfile->csrPersona == QDF_P2P_CLIENT_MODE) ||
13190 (pProfile->csrPersona == QDF_P2P_GO_MODE) ||
13191 (eCSR_CFG_DOT11_MODE_11G_ONLY ==
13192 pParam->uCfgDot11Mode)) {
13193 csr_populate_basic_rates(opr_rates, true, true);
13194 } else {
13195 csr_populate_basic_rates(opr_rates, false,
13196 true);
13197 csr_populate_basic_rates(ext_rates, true,
13198 false);
13199 }
13200 if (eCSR_OPERATING_CHANNEL_ANY == tmp_opr_ch)
13201 opr_ch =
13202 csr_roam_get_ibss_start_channel_number24(pMac);
13203 else
13204 opr_ch = tmp_opr_ch;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013205 break;
13206 }
Ravi Joshib398c852017-07-18 17:55:21 -070013207
13208 pParam->operationChn = opr_ch;
lifenge9245fc2017-02-22 17:23:19 +080013209
13210 if (pProfile->supported_rates.numRates ||
13211 pProfile->extended_rates.numRates) {
13212 struct merged_mac_rate_set rates_driver, rates_hostapd;
13213
Ravi Joshib398c852017-07-18 17:55:21 -070013214 qdf_mem_zero(&rates_driver,
13215 sizeof(struct merged_mac_rate_set));
13216 qdf_mem_zero(&rates_hostapd,
13217 sizeof(struct merged_mac_rate_set));
13218
lifenge9245fc2017-02-22 17:23:19 +080013219 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
13220 "Merge rates driver");
13221 csr_merge_supported_and_extended_rates(&rates_driver,
13222 opr_rates,
13223 ext_rates);
13224
13225 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
13226 "Merge rates hostapd");
13227 csr_merge_supported_and_extended_rates(&rates_hostapd,
13228 &pProfile->supported_rates,
13229 &pProfile->extended_rates);
13230
13231 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
13232 "Populate rates intersection");
13233 csr_populate_intersection_driver_and_hostpd_rates(pParam,
13234 &rates_driver,
13235 &rates_hostapd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013236 }
lifenge9245fc2017-02-22 17:23:19 +080013237
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013238 pParam->sirNwType = nw_type;
13239 pParam->ch_params.ch_width = pProfile->ch_params.ch_width;
13240 pParam->ch_params.center_freq_seg0 =
13241 pProfile->ch_params.center_freq_seg0;
13242 pParam->ch_params.center_freq_seg1 =
13243 pProfile->ch_params.center_freq_seg1;
13244 pParam->ch_params.sec_ch_offset =
13245 pProfile->ch_params.sec_ch_offset;
13246}
13247
13248static void
13249csr_roam_get_bss_start_parms_from_bss_desc(tpAniSirGlobal pMac,
13250 tSirBssDescription *pBssDesc,
13251 tDot11fBeaconIEs *pIes,
13252 tCsrRoamStartBssParams *pParam)
13253{
13254 if (!pParam) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013255 sme_err("BSS param's pointer is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013256 return;
13257 }
13258
13259 pParam->sirNwType = pBssDesc->nwType;
13260 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
13261 pParam->operationChn = pBssDesc->channelId;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013262 qdf_mem_copy(&pParam->bssid, pBssDesc->bssId,
13263 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013264
13265 if (!pIes) {
13266 pParam->ssId.length = 0;
13267 pParam->operationalRateSet.numRates = 0;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013268 sme_err("IEs struct pointer is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013269 return;
13270 }
13271
13272 if (pIes->SuppRates.present) {
13273 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
13274 if (pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013275 sme_err(
13276 "num_rates: %d > max val, resetting",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013277 pIes->SuppRates.num_rates);
13278 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
13279 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013280 qdf_mem_copy(pParam->operationalRateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013281 pIes->SuppRates.rates,
13282 sizeof(*pIes->SuppRates.rates) *
13283 pIes->SuppRates.num_rates);
13284 }
13285 if (pIes->ExtSuppRates.present) {
13286 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
13287 if (pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013288 sme_err(
13289 "num_rates: %d > max val, resetting",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013290 pIes->ExtSuppRates.num_rates);
13291 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
13292 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013293 qdf_mem_copy(pParam->extendedRateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013294 pIes->ExtSuppRates.rates,
13295 sizeof(*pIes->ExtSuppRates.rates) *
13296 pIes->ExtSuppRates.num_rates);
13297 }
13298 if (pIes->SSID.present) {
13299 pParam->ssId.length = pIes->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013300 qdf_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013301 pParam->ssId.length);
13302 }
13303 pParam->cbMode = csr_get_cb_mode_from_ies(pMac, pParam->operationChn,
13304 pIes);
13305}
13306
13307static void csr_roam_determine_max_rate_for_ad_hoc(tpAniSirGlobal pMac,
13308 tSirMacRateSet *pSirRateSet)
13309{
13310 uint8_t MaxRate = 0;
13311 uint32_t i;
13312 uint8_t *pRate;
13313
13314 pRate = pSirRateSet->rate;
13315 for (i = 0; i < pSirRateSet->numRates; i++) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013316 MaxRate = CSR_MAX(MaxRate, (pRate[i] &
13317 (~CSR_DOT11_BASIC_RATE_MASK)));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013318 }
13319
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013320 /* Save the max rate in the connected state information.
13321 * modify LastRates variable as well
13322 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013323
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013324}
13325
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013326QDF_STATUS csr_roam_issue_start_bss(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013327 tCsrRoamStartBssParams *pParam,
13328 tCsrRoamProfile *pProfile,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013329 tSirBssDescription *pBssDesc,
13330 uint32_t roamId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013331{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013332 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013333 eCsrBand eBand;
13334 /* Set the roaming substate to 'Start BSS attempt'... */
13335 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ,
13336 sessionId);
13337#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
13338 /* Need to figure out whether we need to log WDS??? */
13339 if (CSR_IS_IBSS(pProfile)) {
13340 host_log_ibss_pkt_type *pIbssLog;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013341
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013342 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
13343 LOG_WLAN_IBSS_C);
13344 if (pIbssLog) {
13345 if (pBssDesc) {
13346 pIbssLog->eventId =
13347 WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013348 qdf_mem_copy(pIbssLog->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053013349 pBssDesc->bssId, QDF_MAC_ADDR_SIZE);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013350 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013351 pIbssLog->eventId =
13352 WLAN_IBSS_EVENT_START_IBSS_REQ;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013353
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013354 qdf_mem_copy(pIbssLog->ssid, pParam->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013355 pParam->ssId.length);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013356 if (pProfile->ChannelInfo.numOfChannels == 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013357 pIbssLog->channelSetting = AUTO_PICK;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013358 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013359 pIbssLog->channelSetting = SPECIFIED;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013360
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013361 pIbssLog->operatingChannel = pParam->operationChn;
13362 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
13363 }
13364 }
13365#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
13366 /* Put RSN information in for Starting BSS */
13367 pParam->nRSNIELength = (uint16_t) pProfile->nRSNReqIELength;
13368 pParam->pRSNIE = pProfile->pRSNReqIE;
13369
13370 pParam->privacy = pProfile->privacy;
13371 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
13372 pParam->authType = pProfile->csr80211AuthType;
13373 pParam->beaconInterval = pProfile->beaconInterval;
13374 pParam->dtimPeriod = pProfile->dtimPeriod;
13375 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
13376 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
13377 if (CSR_IS_INFRA_AP(pProfile) && (pParam->operationChn != 0)) {
13378 if (csr_is_valid_channel(pMac, pParam->operationChn) !=
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013379 QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013380 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013381 }
13382 pParam->protEnabled = pProfile->protEnabled;
13383 pParam->obssProtEnabled = pProfile->obssProtEnabled;
13384 pParam->ht_protection = pProfile->cfg_protection;
13385 pParam->wps_state = pProfile->wps_state;
13386
13387 pParam->uCfgDot11Mode =
13388 csr_roam_get_phy_mode_band_for_bss(pMac, pProfile,
13389 pParam->
13390 operationChn,
13391 &eBand);
13392 pParam->bssPersona = pProfile->csrPersona;
13393
13394#ifdef WLAN_FEATURE_11W
13395 pParam->mfpCapable = (0 != pProfile->MFPCapable);
13396 pParam->mfpRequired = (0 != pProfile->MFPRequired);
13397#endif
13398
13399 pParam->addIeParams.probeRespDataLen =
13400 pProfile->addIeParams.probeRespDataLen;
13401 pParam->addIeParams.probeRespData_buff =
13402 pProfile->addIeParams.probeRespData_buff;
13403
13404 pParam->addIeParams.assocRespDataLen =
13405 pProfile->addIeParams.assocRespDataLen;
13406 pParam->addIeParams.assocRespData_buff =
13407 pProfile->addIeParams.assocRespData_buff;
13408
13409 if (CSR_IS_IBSS(pProfile)) {
13410 pParam->addIeParams.probeRespBCNDataLen =
13411 pProfile->nWPAReqIELength;
13412 pParam->addIeParams.probeRespBCNData_buff = pProfile->pWPAReqIE;
13413 } else {
13414 pParam->addIeParams.probeRespBCNDataLen =
13415 pProfile->addIeParams.probeRespBCNDataLen;
13416 pParam->addIeParams.probeRespBCNData_buff =
13417 pProfile->addIeParams.probeRespBCNData_buff;
13418 }
13419 pParam->sap_dot11mc = pProfile->sap_dot11mc;
Arif Hussain671a1902017-03-17 09:08:32 -070013420 pParam->cac_duration_ms = pProfile->cac_duration_ms;
13421 pParam->dfs_regdomain = pProfile->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013422
13423 /* When starting an IBSS, start on the channel from the Profile. */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013424 status = csr_send_mb_start_bss_req_msg(pMac, sessionId,
13425 pProfile->BSSType, pParam,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013426 pBssDesc);
13427 return status;
13428}
13429
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -070013430void csr_roam_prepare_bss_params(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013431 tCsrRoamProfile *pProfile,
13432 tSirBssDescription *pBssDesc,
13433 tBssConfigParam *pBssConfig,
13434 tDot11fBeaconIEs *pIes)
13435{
13436 uint8_t Channel;
13437 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
13438 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13439
13440 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013441 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013442 return;
13443 }
13444
13445 if (pBssDesc) {
13446 csr_roam_get_bss_start_parms_from_bss_desc(pMac, pBssDesc, pIes,
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -070013447 &pSession->bssParams);
13448 if (CSR_IS_NDI(pProfile)) {
13449 qdf_copy_macaddr(&pSession->bssParams.bssid,
13450 &pSession->selfMacAddr);
13451 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013452 } else {
Krunal Soni8f8507c2016-12-20 13:54:34 -080013453 csr_roam_get_bss_start_parms(pMac, pProfile,
13454 &pSession->bssParams, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013455 /* Use the first SSID */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070013456 if (pProfile->SSIDs.numOfSSIDs)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013457 qdf_mem_copy(&pSession->bssParams.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013458 pProfile->SSIDs.SSIDList,
13459 sizeof(tSirMacSSid));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070013460 if (pProfile->BSSIDs.numOfBSSIDs)
13461 /* Use the first BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013462 qdf_mem_copy(&pSession->bssParams.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013463 pProfile->BSSIDs.bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053013464 sizeof(struct qdf_mac_addr));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070013465 else
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013466 qdf_mem_set(&pSession->bssParams.bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053013467 sizeof(struct qdf_mac_addr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013468 }
13469 Channel = pSession->bssParams.operationChn;
13470 /* Set operating channel in pProfile which will be used */
13471 /* in csr_roam_set_bss_config_cfg() to determine channel bonding */
13472 /* mode and will be configured in CFG later */
13473 pProfile->operationChannel = Channel;
13474
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013475 if (Channel == 0)
13476 sme_err("CSR cannot find a channel to start IBSS");
13477 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013478 csr_roam_determine_max_rate_for_ad_hoc(pMac,
13479 &pSession->bssParams.
13480 operationalRateSet);
13481 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS(pProfile)) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070013482 if (WLAN_REG_IS_24GHZ_CH(Channel)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013483 cbMode =
13484 pMac->roam.configParam.
13485 channelBondingMode24GHz;
13486 } else {
13487 cbMode =
13488 pMac->roam.configParam.
13489 channelBondingMode5GHz;
13490 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013491 sme_debug("## cbMode %d", cbMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013492 pBssConfig->cbMode = cbMode;
13493 pSession->bssParams.cbMode = cbMode;
13494 }
13495 }
13496}
13497
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013498static QDF_STATUS csr_roam_start_ibss(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013499 tCsrRoamProfile *pProfile,
13500 bool *pfSameIbss)
13501{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013502 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013503 bool fSameIbss = false;
13504
13505 if (csr_is_conn_state_ibss(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013506 /* Check if any profile parameter has changed ? If any profile
13507 * parameter has changed then stop old BSS and start a new one
13508 * with new parameters
13509 */
13510 if (csr_is_same_profile(pMac,
13511 &pMac->roam.roamSession[sessionId].
13512 connectedProfile, pProfile))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013513 fSameIbss = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013514 else
13515 status = csr_roam_issue_stop_bss(pMac, sessionId,
13516 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING);
13517
13518 } else if (csr_is_conn_state_connected_infra(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013519 /* Disassociate from the connected Infrastructure network... */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013520 status = csr_roam_issue_disassociate(pMac, sessionId,
13521 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013522 false);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013523 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013524 tBssConfigParam *pBssConfig;
13525
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013526 pBssConfig = qdf_mem_malloc(sizeof(tBssConfigParam));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013527 if (NULL == pBssConfig)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013528 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013529 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013530 status = QDF_STATUS_SUCCESS;
13531 if (QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013532 /* there is no Bss description before we start an IBSS
13533 * so we need to adopt all Bss configuration parameters
13534 * from the Profile.
13535 */
13536 status = csr_roam_prepare_bss_config_from_profile(pMac,
13537 pProfile,
13538 pBssConfig,
13539 NULL);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013540 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013541 /* save dotMode */
13542 pMac->roam.roamSession[sessionId].bssParams.
13543 uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
13544 /* Prepare some more parameters for this IBSS */
13545 csr_roam_prepare_bss_params(pMac, sessionId,
13546 pProfile, NULL,
13547 pBssConfig, NULL);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013548 status = csr_roam_set_bss_config_cfg(pMac,
13549 sessionId,
13550 pProfile, NULL,
13551 pBssConfig,
13552 NULL, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013553 }
13554
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013555 qdf_mem_free(pBssConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013556 } /* Allocate memory */
13557 }
13558
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013559 if (pfSameIbss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013560 *pfSameIbss = fSameIbss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013561 return status;
13562}
13563
13564static void csr_roam_update_connected_profile_from_new_bss(tpAniSirGlobal pMac,
13565 uint32_t sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013566 tSirSmeNewBssInfo *pNewBss)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013567{
13568 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13569
13570 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013571 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013572 return;
13573 }
13574
13575 if (pNewBss) {
13576 /* Set the operating channel. */
13577 pSession->connectedProfile.operationChannel =
13578 pNewBss->channelNumber;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013579 /* move the BSSId from the BSS description into the connected
13580 * state information.
13581 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013582 qdf_mem_copy(&pSession->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053013583 &(pNewBss->bssId), sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013584 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013585}
13586
13587#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013588QDF_STATUS csr_roam_set_psk_pmk(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013589 uint8_t *pPSK_PMK, size_t pmk_len)
13590{
13591 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013592
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013593 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013594 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013595 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013596 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013597 qdf_mem_copy(pSession->psk_pmk, pPSK_PMK, sizeof(pSession->psk_pmk));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013598 pSession->pmk_len = pmk_len;
Naveen Rawat5f1111b2017-03-31 17:36:20 -070013599 csr_roam_offload_scan(pMac, sessionId,
13600 ROAM_SCAN_OFFLOAD_UPDATE_CFG,
13601 REASON_ROAM_PSK_PMK_CHANGED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013602 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013603}
13604#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
13605
13606#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
13607static void
13608csr_roam_diag_set_pmkid(tCsrRoamSession *pSession)
13609{
13610 WLAN_HOST_DIAG_EVENT_DEF(secEvent,
13611 host_event_wlan_security_payload_type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013612 qdf_mem_set(&secEvent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013613 sizeof(host_event_wlan_security_payload_type), 0);
13614 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
13615 secEvent.encryptionModeMulticast =
13616 (uint8_t) diag_enc_type_from_csr_type(
13617 pSession->connectedProfile.mcEncryptionType);
13618 secEvent.encryptionModeUnicast =
13619 (uint8_t) diag_enc_type_from_csr_type(
13620 pSession->connectedProfile.EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013621 qdf_mem_copy(secEvent.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013622 pSession->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053013623 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013624 secEvent.authMode = (uint8_t) diag_auth_type_from_csr_type(
13625 pSession->connectedProfile.AuthType);
13626 WLAN_HOST_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
13627}
13628#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
13629
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013630QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013631csr_roam_set_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId,
13632 tPmkidCacheInfo *pPMKIDCache, uint32_t numItems,
13633 bool update_entire_cache)
13634{
13635 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13636 uint32_t i = 0;
13637 tPmkidCacheInfo *pmksa;
13638
13639 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013640 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013641 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013642 }
13643
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013644 sme_debug("numItems = %d", numItems);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013645
13646 if (numItems > CSR_MAX_PMKID_ALLOWED)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013647 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013648
13649#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
13650 csr_roam_diag_set_pmkid(pSession);
13651#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
13652
13653 if (update_entire_cache) {
13654 if (numItems && pPMKIDCache) {
13655 pSession->NumPmkidCache = (uint16_t) numItems;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013656 qdf_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013657 sizeof(tPmkidCacheInfo) * numItems);
13658 pSession->curr_cache_idx = (uint16_t)numItems;
13659 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013660 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013661 }
13662
13663 for (i = 0; i < numItems; i++) {
13664 pmksa = &pPMKIDCache[i];
13665
13666 /* Delete the entry if present */
13667 csr_roam_del_pmkid_from_cache(pMac, sessionId,
13668 pmksa->BSSID.bytes, false);
13669
13670 /* Add entry to the cache */
Anurag Chouhanc5548422016-02-24 18:33:27 +053013671 qdf_copy_macaddr(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013672 &pSession->PmkidCacheInfo[pSession->curr_cache_idx].BSSID,
13673 &pmksa->BSSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013674 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013675 pSession->PmkidCacheInfo[pSession->curr_cache_idx].PMKID,
13676 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
13677
13678 /* Increment the CSR local cache index */
13679 if (pSession->curr_cache_idx < (CSR_MAX_PMKID_ALLOWED - 1))
13680 pSession->curr_cache_idx++;
13681 else
13682 pSession->curr_cache_idx = 0;
13683
13684 pSession->NumPmkidCache++;
13685 if (pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
13686 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
13687 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013688 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013689}
13690
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013691QDF_STATUS csr_roam_del_pmkid_from_cache(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013692 uint32_t sessionId,
13693 const uint8_t *pBSSId,
13694 bool flush_cache)
13695{
13696 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13697 bool fMatchFound = false;
13698 uint32_t Index;
13699 uint32_t curr_idx;
13700 uint32_t i;
13701
13702 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013703 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013704 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013705 }
13706
13707 /* Check if there are no entries to delete */
13708 if (0 == pSession->NumPmkidCache) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013709 sme_debug("No entries to delete/Flush");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013710 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013711 }
13712
13713 if (flush_cache) {
13714 /* Flush the entire cache */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013715 qdf_mem_zero(pSession->PmkidCacheInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013716 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
13717 pSession->NumPmkidCache = 0;
13718 pSession->curr_cache_idx = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013719 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013720 }
13721
13722 /* !flush_cache - so look up in the cache */
13723 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013724 if (!qdf_mem_cmp(pSession->PmkidCacheInfo[Index].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053013725 pBSSId, QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013726 fMatchFound = 1;
13727
13728 /* Clear this - the matched entry */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013729 qdf_mem_zero(&pSession->PmkidCacheInfo[Index],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013730 sizeof(tPmkidCacheInfo));
13731 break;
13732 }
13733 }
13734
13735 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013736 sme_debug("No such PMKSA entry exists"
13737 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013738 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013739 }
13740
13741 /* Match Found, Readjust the other entries */
13742 curr_idx = pSession->curr_cache_idx;
13743 if (Index < curr_idx) {
13744 for (i = Index; i < (curr_idx - 1); i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013745 qdf_mem_copy(&pSession->PmkidCacheInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013746 &pSession->PmkidCacheInfo[i + 1],
13747 sizeof(tPmkidCacheInfo));
13748 }
13749
13750 pSession->curr_cache_idx--;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013751 qdf_mem_zero(&pSession->PmkidCacheInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013752 [pSession->curr_cache_idx],
13753 sizeof(tPmkidCacheInfo));
13754 } else if (Index > curr_idx) {
13755 for (i = Index; i > (curr_idx); i--) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013756 qdf_mem_copy(&pSession->PmkidCacheInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013757 &pSession->PmkidCacheInfo[i - 1],
13758 sizeof(tPmkidCacheInfo));
13759 }
13760
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013761 qdf_mem_zero(&pSession->PmkidCacheInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013762 [pSession->curr_cache_idx],
13763 sizeof(tPmkidCacheInfo));
13764 }
13765
13766 /* Decrement the count since an entry has been deleted */
13767 pSession->NumPmkidCache--;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013768 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013769}
13770
13771uint32_t csr_roam_get_num_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId)
13772{
13773 return pMac->roam.roamSession[sessionId].NumPmkidCache;
13774}
13775
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013776QDF_STATUS csr_roam_get_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013777 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013778{
13779 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13780 tPmkidCacheInfo *pmksa;
13781 uint16_t i, j;
13782
13783 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013784 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013785 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013786 }
13787
13788 if (!pNum || !pPmkidCache) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013789 sme_err("Either pNum or pPmkidCache is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013790 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013791 }
13792
13793 if (pSession->NumPmkidCache == 0) {
13794 *pNum = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013795 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013796 }
13797
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013798 if (*pNum < pSession->NumPmkidCache)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013799 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013800
13801 if (pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013802 sme_err("NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013803 pSession->NumPmkidCache);
13804 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
13805 }
13806
13807 for (i = 0, j = 0; ((j < pSession->NumPmkidCache) &&
13808 (i < CSR_MAX_PMKID_ALLOWED)); i++) {
13809 /* Fill the valid entries */
13810 pmksa = &pSession->PmkidCacheInfo[i];
Anurag Chouhanc5548422016-02-24 18:33:27 +053013811 if (!qdf_is_macaddr_zero(&pmksa->BSSID)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013812 qdf_mem_copy(pPmkidCache, pmksa,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013813 sizeof(tPmkidCacheInfo));
13814 pPmkidCache++;
13815 j++;
13816 }
13817 }
13818
13819 *pNum = pSession->NumPmkidCache;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013820 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013821}
13822
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013823QDF_STATUS csr_roam_get_wpa_rsn_req_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013824 uint32_t *pLen, uint8_t *pBuf)
13825{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013826 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013827 uint32_t len;
13828 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13829
13830 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013831 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013832 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013833 }
13834
13835 if (pLen) {
13836 len = *pLen;
13837 *pLen = pSession->nWpaRsnReqIeLength;
13838 if (pBuf) {
13839 if (len >= pSession->nWpaRsnReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013840 qdf_mem_copy(pBuf, pSession->pWpaRsnReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013841 pSession->nWpaRsnReqIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013842 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013843 }
13844 }
13845 }
13846 return status;
13847}
13848
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013849QDF_STATUS csr_roam_get_wpa_rsn_rsp_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013850 uint32_t *pLen, uint8_t *pBuf)
13851{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013852 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013853 uint32_t len;
13854 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13855
13856 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013857 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013858 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013859 }
13860
13861 if (pLen) {
13862 len = *pLen;
13863 *pLen = pSession->nWpaRsnRspIeLength;
13864 if (pBuf) {
13865 if (len >= pSession->nWpaRsnRspIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013866 qdf_mem_copy(pBuf, pSession->pWpaRsnRspIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013867 pSession->nWpaRsnRspIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013868 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013869 }
13870 }
13871 }
13872 return status;
13873}
13874
13875#ifdef FEATURE_WLAN_WAPI
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013876QDF_STATUS csr_roam_get_wapi_req_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013877 uint32_t *pLen, uint8_t *pBuf)
13878{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013879 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013880 uint32_t len;
13881 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13882
13883 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013884 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013885 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013886 }
13887
13888 if (pLen) {
13889 len = *pLen;
13890 *pLen = pSession->nWapiReqIeLength;
13891 if (pBuf) {
13892 if (len >= pSession->nWapiReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013893 qdf_mem_copy(pBuf, pSession->pWapiReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013894 pSession->nWapiReqIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013895 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013896 }
13897 }
13898 }
13899 return status;
13900}
13901
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013902QDF_STATUS csr_roam_get_wapi_rsp_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013903 uint32_t *pLen, uint8_t *pBuf)
13904{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013905 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013906 uint32_t len;
13907 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13908
13909 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013910 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013911 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013912 }
13913
13914 if (pLen) {
13915 len = *pLen;
13916 *pLen = pSession->nWapiRspIeLength;
13917 if (pBuf) {
13918 if (len >= pSession->nWapiRspIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013919 qdf_mem_copy(pBuf, pSession->pWapiRspIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013920 pSession->nWapiRspIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013921 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013922 }
13923 }
13924 }
13925 return status;
13926}
13927#endif /* FEATURE_WLAN_WAPI */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013928eRoamCmdStatus csr_get_roam_complete_status(tpAniSirGlobal pMac,
13929 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013930{
13931 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
13932 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13933
13934 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013935 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013936 return retStatus;
13937 }
13938
13939 if (CSR_IS_ROAMING(pSession)) {
13940 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
13941 pSession->fRoaming = false;
13942 }
13943 return retStatus;
13944}
13945
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013946static QDF_STATUS csr_roam_start_wds(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013947 tCsrRoamProfile *pProfile,
13948 tSirBssDescription *pBssDesc)
13949{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013950 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013951 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13952 tBssConfigParam bssConfig;
13953
13954 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070013955 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013956 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013957 }
13958
13959 if (csr_is_conn_state_ibss(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013960 status = csr_roam_issue_stop_bss(pMac, sessionId,
13961 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013962 } else if (csr_is_conn_state_connected_infra(pMac, sessionId)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013963 /* Disassociate from the connected Infrastructure network.*/
13964 status = csr_roam_issue_disassociate(pMac, sessionId,
13965 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013966 false);
13967 } else {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013968 /* We don't expect Bt-AMP HDD not to disconnect the last
13969 * connection first at this time. Otherwise we need to add
13970 * code to handle the situation just like IBSS. Though for
13971 * WDS station, we need to send disassoc to PE first then
13972 * send stop_bss to PE, before we can continue.
13973 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013974
13975 if (csr_is_conn_state_wds(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013976 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013977 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013978 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013979 qdf_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013980 /* Assume HDD provide bssid in profile */
Anurag Chouhanc5548422016-02-24 18:33:27 +053013981 qdf_copy_macaddr(&pSession->bssParams.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013982 pProfile->BSSIDs.bssid);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053013983 /* there is no Bss description before we start an WDS so we
13984 * need to adopt all Bss configuration parameters from the
13985 * Profile.
13986 */
13987 status = csr_roam_prepare_bss_config_from_profile(pMac,
13988 pProfile,
13989 &bssConfig,
13990 pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013991 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013992 /* Save profile for late use */
13993 csr_free_roam_profile(pMac, sessionId);
13994 pSession->pCurRoamProfile =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013995 qdf_mem_malloc(sizeof(tCsrRoamProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013996 if (pSession->pCurRoamProfile != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013997 csr_roam_copy_profile(pMac,
13998 pSession->pCurRoamProfile,
13999 pProfile);
14000 }
14001 /* Prepare some more parameters for this WDS */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014002 csr_roam_prepare_bss_params(pMac, sessionId, pProfile,
14003 NULL, &bssConfig, NULL);
14004 status = csr_roam_set_bss_config_cfg(pMac, sessionId,
14005 pProfile, NULL,
14006 &bssConfig, NULL,
14007 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014008 }
14009 }
14010
14011 return status;
14012}
14013
14014/**
14015 * csr_add_supported_5Ghz_channels()- Add valid 5Ghz channels
14016 * in Join req.
14017 * @mac_ctx: pointer to global mac structure
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053014018 * @chan_list: Pointer to channel list buffer to populate
14019 * @num_chan: Pointer to number of channels value to update
14020 * @supp_chan_ie: Boolean to check if we need to populate as IE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014021 *
14022 * This function is called to update valid 5Ghz channels
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053014023 * in Join req. If @supp_chan_ie is true, supported channels IE
14024 * format[chan num 1, num of channels 1, chan num 2, num of
14025 * channels 2, ..] is populated. Else, @chan_list would be a list
14026 * of supported channels[chan num 1, chan num 2..]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014027 *
14028 * Return: void
14029 */
14030static void csr_add_supported_5Ghz_channels(tpAniSirGlobal mac_ctx,
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053014031 uint8_t *chan_list,
14032 uint8_t *num_chnl,
14033 bool supp_chan_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014034{
14035 uint16_t i, j;
14036 uint32_t size = 0;
14037
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053014038 if (!chan_list) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014039 sme_err("chan_list buffer NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014040 return;
14041 }
14042
14043 size = sizeof(mac_ctx->roam.validChannelList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014044 if (QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014045 (csr_get_cfg_valid_channels(mac_ctx,
14046 (uint8_t *) mac_ctx->roam.validChannelList,
14047 &size))) {
14048 for (i = 0, j = 0; i < size; i++) {
14049 /* Only add 5ghz channels.*/
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014050 if (WLAN_REG_IS_5GHZ_CH
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014051 (mac_ctx->roam.validChannelList[i])) {
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053014052 chan_list[j]
14053 = mac_ctx->roam.validChannelList[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014054 j++;
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053014055
14056 if (supp_chan_ie) {
14057 chan_list[j] = 1;
14058 j++;
14059 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014060 }
14061 }
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053014062 *num_chnl = (uint8_t)j;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014063 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014064 sme_err("can not find any valid channel");
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053014065 *num_chnl = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014066 }
14067}
14068
14069/**
Krunal Soni0193b6f2016-08-15 15:53:43 -070014070 * csr_set_ldpc_exception() - to set allow any LDPC exception permitted
14071 * @mac_ctx: Pointer to mac context
14072 * @session: Pointer to SME/CSR session
14073 * @channel: Given channel number where connection will go
14074 * @usr_cfg_rx_ldpc: User provided RX LDPC setting
14075 *
14076 * This API will check if hardware allows LDPC to be enabled for provided
14077 * channel and user has enabled the RX LDPC selection
14078 *
14079 * Return: QDF_STATUS
14080 */
14081static QDF_STATUS csr_set_ldpc_exception(tpAniSirGlobal mac_ctx,
14082 tCsrRoamSession *session, uint8_t channel,
14083 bool usr_cfg_rx_ldpc)
14084{
14085 if (!mac_ctx) {
Varun Reddy Yeturu5a183652016-09-09 15:36:00 -070014086 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14087 "mac_ctx is NULL");
Krunal Soni0193b6f2016-08-15 15:53:43 -070014088 return QDF_STATUS_E_FAILURE;
14089 }
14090 if (!session) {
Varun Reddy Yeturu5a183652016-09-09 15:36:00 -070014091 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
14092 "session is NULL");
Krunal Soni0193b6f2016-08-15 15:53:43 -070014093 return QDF_STATUS_E_FAILURE;
14094 }
14095 if (usr_cfg_rx_ldpc && wma_is_rx_ldpc_supported_for_channel(channel)) {
14096 session->htConfig.ht_rx_ldpc = 1;
14097 session->vht_config.ldpc_coding = 1;
14098 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO_HIGH,
14099 "LDPC enable for chnl[%d]", channel);
14100 } else {
14101 session->htConfig.ht_rx_ldpc = 0;
14102 session->vht_config.ldpc_coding = 0;
14103 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO_HIGH,
14104 "LDPC disable for chnl[%d]", channel);
14105 }
14106 return QDF_STATUS_SUCCESS;
14107}
14108
Abhishek Singhcfb44482017-03-10 12:42:37 +053014109#ifdef WLAN_FEATURE_11W
14110/**
Srinivas Girigowda6519b932017-08-03 14:10:57 -070014111 * csr_is_mfpc_capable() - is MFPC capable
14112 * @ies: AP information element
14113 *
14114 * Return: true if MFPC capable, false otherwise
14115 */
14116bool csr_is_mfpc_capable(struct sDot11fIERSN *rsn)
14117{
14118 bool mfpc_capable = false;
14119
14120 if (rsn && rsn->present &&
14121 ((rsn->RSN_Cap[0] >> 7) & 0x01))
14122 mfpc_capable = true;
14123
14124 return mfpc_capable;
14125}
14126
14127/**
Abhishek Singhcfb44482017-03-10 12:42:37 +053014128 * csr_set_mgmt_enc_type() - set mgmt enc type for PMF
14129 * @profile: roam profile
14130 * @ies: AP ie
14131 * @csr_join_req: csr join req
14132 *
14133 * Return: void
14134 */
14135static void csr_set_mgmt_enc_type(tCsrRoamProfile *profile,
14136 tDot11fBeaconIEs *ies, tSirSmeJoinReq *csr_join_req)
14137{
14138 if (profile->MFPEnabled)
14139 csr_join_req->MgmtEncryptionType = eSIR_ED_AES_128_CMAC;
14140 else
14141 csr_join_req->MgmtEncryptionType = eSIR_ED_NONE;
14142 if (profile->MFPEnabled &&
14143 !(profile->MFPRequired) &&
Srinivas Girigowda6519b932017-08-03 14:10:57 -070014144 !csr_is_mfpc_capable(&ies->RSN))
Abhishek Singhcfb44482017-03-10 12:42:37 +053014145 csr_join_req->MgmtEncryptionType = eSIR_ED_NONE;
14146}
14147#else
14148static inline void csr_set_mgmt_enc_type(tCsrRoamProfile *profile,
14149 tDot11fBeaconIEs *pIes, tSirSmeJoinReq *csr_join_req)
14150{
14151}
14152#endif
14153
14154
Krunal Soni0193b6f2016-08-15 15:53:43 -070014155/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014156 * The communication between HDD and LIM is thru mailbox (MB).
14157 * Both sides will access the data structure "tSirSmeJoinReq".
14158 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the
14159 * regular way like tSirSmeJoinReq.assocType, this guideline stops at component
14160 * tSirRSNie;
14161 * any acces to the components after tSirRSNie is forbidden because the space
14162 * from tSirRSNie is squeezed with the component "tSirBssDescription" and since
14163 * the size of actual 'tSirBssDescription' varies, the receiving side should
14164 * keep in mind not to access the components DIRECTLY after tSirRSNie.
14165 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014166QDF_STATUS csr_send_join_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014167 tSirBssDescription *pBssDescription,
14168 tCsrRoamProfile *pProfile,
14169 tDot11fBeaconIEs *pIes, uint16_t messageType)
14170{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014171 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014172 uint8_t acm_mask = 0, uapsd_mask;
14173 uint16_t msgLen, ieLen;
14174 tSirMacRateSet OpRateSet;
14175 tSirMacRateSet ExRateSet;
14176 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14177 uint32_t dwTmp, ucDot11Mode = 0;
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +053014178 uint8_t *wpaRsnIE = NULL;
Prakash Dhavali2aa7f892016-12-02 09:56:09 -080014179 uint8_t txBFCsnValue = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014180 tSirSmeJoinReq *csr_join_req;
14181 tSirMacCapabilityInfo *pAP_capabilityInfo;
Srinivas Girigowda74a66d62017-06-21 23:28:25 -070014182 bool fTmp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014183 int8_t pwrLimit = 0;
14184 struct ps_global_info *ps_global_info = &pMac->sme.ps_global_info;
14185 struct ps_params *ps_param = &ps_global_info->ps_params[sessionId];
14186 uint8_t ese_config = 0;
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070014187 tpCsrNeighborRoamControlInfo neigh_roam_info;
Krunal Soni53993f72016-07-08 18:20:03 -070014188 uint32_t value = 0, value1 = 0;
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053014189 QDF_STATUS packetdump_timer_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014190
14191 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014192 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014193 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014194 }
14195 /* To satisfy klockworks */
14196 if (NULL == pBssDescription) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014197 sme_err(" pBssDescription is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014198 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014199 }
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070014200 neigh_roam_info = &pMac->roam.neighborRoamInfo[sessionId];
14201 if ((eWNI_SME_REASSOC_REQ == messageType) ||
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014202 WLAN_REG_IS_5GHZ_CH(pBssDescription->channelId) ||
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070014203 (abs(pBssDescription->rssi) <
Varun Reddy Yeturuf64252a2016-05-13 15:02:03 -070014204 (neigh_roam_info->cfgParams.neighborLookupThreshold -
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070014205 neigh_roam_info->cfgParams.hi_rssi_scan_rssi_delta))) {
14206 pSession->disable_hi_rssi = true;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014207 sme_debug(
14208 "Disabling HI_RSSI feature, AP channel=%d, rssi=%d",
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070014209 pBssDescription->channelId, pBssDescription->rssi);
14210 } else {
14211 pSession->disable_hi_rssi = false;
14212 }
14213
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014214
14215 do {
14216 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
14217 pSession->joinFailStatusCode.reasonCode = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014218 qdf_mem_copy(&pSession->joinFailStatusCode.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014219 &pBssDescription->bssId, sizeof(tSirMacAddr));
14220 /*
14221 * the tSirSmeJoinReq which includes a single
14222 * bssDescription. it includes a single uint32_t for the
14223 * IE fields, but the length field in the bssDescription
14224 * needs to be interpreted to determine length of IE fields
14225 * So, take the size of the tSirSmeJoinReq, subtract size of
14226 * bssDescription, add the number of bytes indicated by the
14227 * length field of the bssDescription, add the size of length
14228 * field because it not included in the lenghth field.
14229 */
14230 msgLen = sizeof(tSirSmeJoinReq) - sizeof(*pBssDescription) +
14231 pBssDescription->length +
14232 sizeof(pBssDescription->length) +
14233 /*
14234 * add in the size of the WPA IE that
14235 * we may build.
14236 */
14237 sizeof(tCsrWpaIe) + sizeof(tCsrWpaAuthIe) +
14238 sizeof(uint16_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014239 csr_join_req = qdf_mem_malloc(msgLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014240 if (NULL == csr_join_req)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014241 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014242 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014243 status = QDF_STATUS_SUCCESS;
14244 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014245 break;
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +053014246
14247 wpaRsnIE = qdf_mem_malloc(DOT11F_IE_RSN_MAX_LEN);
14248 if (NULL == wpaRsnIE)
14249 status = QDF_STATUS_E_NOMEM;
14250
14251 if (!QDF_IS_STATUS_SUCCESS(status))
14252 break;
14253
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014254 csr_join_req->messageType = messageType;
14255 csr_join_req->length = msgLen;
14256 csr_join_req->sessionId = (uint8_t) sessionId;
14257 csr_join_req->transactionId = 0;
14258 if (pIes->SSID.present && pIes->SSID.num_ssid) {
14259 csr_join_req->ssId.length = pIes->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014260 qdf_mem_copy(&csr_join_req->ssId.ssId, pIes->SSID.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014261 pIes->SSID.num_ssid);
14262 } else
14263 csr_join_req->ssId.length = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014264 qdf_mem_copy(&csr_join_req->selfMacAddr, &pSession->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014265 sizeof(tSirMacAddr));
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014266 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 -080014267 pIes->SSID.num_ssid, pIes->SSID.ssid,
14268 MAC_ADDR_ARRAY(pBssDescription->bssId),
14269 pBssDescription->rssi, pBssDescription->channelId,
14270 pMac->scan.countryCodeCurrent[0],
14271 pMac->scan.countryCodeCurrent[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014272 /* bsstype */
14273 dwTmp = csr_translate_bsstype_to_mac_type
14274 (pProfile->BSSType);
Rajeev Kumarc9a50e72016-04-15 15:18:42 -070014275 csr_join_req->bsstype = dwTmp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014276 /* dot11mode */
14277 ucDot11Mode =
14278 csr_translate_to_wni_cfg_dot11_mode(pMac,
14279 pSession->bssParams.
14280 uCfgDot11Mode);
14281 if (pBssDescription->channelId <= 14
14282 && false == pMac->roam.configParam.enableVhtFor24GHz
14283 && WNI_CFG_DOT11_MODE_11AC == ucDot11Mode) {
14284 /* Need to disable VHT operation in 2.4 GHz band */
14285 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
14286 }
14287 csr_join_req->dot11mode = (uint8_t) ucDot11Mode;
Padma, Santhosh Kumar19f57652017-05-26 18:03:45 +053014288 sme_debug("dot11mode=%d, uCfgDot11Mode=%d",
14289 csr_join_req->dot11mode,
14290 pSession->bssParams.uCfgDot11Mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014291#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
14292 csr_join_req->cc_switch_mode =
14293 pMac->roam.configParam.cc_switch_mode;
14294#endif
14295 csr_join_req->staPersona = (uint8_t) pProfile->csrPersona;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +053014296 csr_join_req->wps_registration = pProfile->bWPSAssociation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014297 csr_join_req->cbMode = (uint8_t) pSession->bssParams.cbMode;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014298 sme_debug("CSR PERSONA: %d CSR CbMode: %d",
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014299 pProfile->csrPersona, pSession->bssParams.cbMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014300 csr_join_req->uapsdPerAcBitmask = pProfile->uapsd_mask;
Naveen Rawatcd118312016-11-22 10:46:21 -080014301 pSession->uapsd_mask = pProfile->uapsd_mask;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014302 status =
14303 csr_get_rate_set(pMac, pProfile,
14304 (eCsrPhyMode) pProfile->phyMode,
14305 pBssDescription, pIes, &OpRateSet,
14306 &ExRateSet);
14307 ps_param->uapsd_per_ac_bit_mask =
14308 pProfile->uapsd_mask;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014309 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014310 /* OperationalRateSet */
14311 if (OpRateSet.numRates) {
14312 csr_join_req->operationalRateSet.numRates =
14313 OpRateSet.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014314 qdf_mem_copy(&csr_join_req->operationalRateSet.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014315 rate, OpRateSet.rate,
14316 OpRateSet.numRates);
14317 } else
14318 csr_join_req->operationalRateSet.numRates = 0;
14319
14320 /* ExtendedRateSet */
14321 if (ExRateSet.numRates) {
14322 csr_join_req->extendedRateSet.numRates =
14323 ExRateSet.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014324 qdf_mem_copy(&csr_join_req->extendedRateSet.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014325 rate, ExRateSet.rate,
14326 ExRateSet.numRates);
14327 } else
14328 csr_join_req->extendedRateSet.numRates = 0;
14329 } else {
14330 csr_join_req->operationalRateSet.numRates = 0;
14331 csr_join_req->extendedRateSet.numRates = 0;
14332 }
14333 /* rsnIE */
14334 if (csr_is_profile_wpa(pProfile)) {
14335 /* Insert the Wpa IE into the join request */
14336 ieLen =
14337 csr_retrieve_wpa_ie(pMac, pProfile,
14338 pBssDescription, pIes,
14339 (tCsrWpaIe *) (wpaRsnIE));
14340 } else if (csr_is_profile_rsn(pProfile)) {
14341 /* Insert the RSN IE into the join request */
14342 ieLen =
14343 csr_retrieve_rsn_ie(pMac, sessionId, pProfile,
14344 pBssDescription, pIes,
14345 (tCsrRSNIe *) (wpaRsnIE));
14346 }
14347#ifdef FEATURE_WLAN_WAPI
14348 else if (csr_is_profile_wapi(pProfile)) {
14349 /* Insert the WAPI IE into the join request */
14350 ieLen =
14351 csr_retrieve_wapi_ie(pMac, sessionId, pProfile,
14352 pBssDescription, pIes,
14353 (tCsrWapiIe *) (wpaRsnIE));
14354 }
14355#endif /* FEATURE_WLAN_WAPI */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014356 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014357 ieLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014358 /* remember the IE for future use */
14359 if (ieLen) {
14360 if (ieLen > DOT11F_IE_RSN_MAX_LEN) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014361 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 -080014362 ieLen, DOT11F_IE_RSN_MAX_LEN);
14363 ieLen = DOT11F_IE_RSN_MAX_LEN;
14364 }
14365#ifdef FEATURE_WLAN_WAPI
14366 if (csr_is_profile_wapi(pProfile)) {
14367 /* Check whether we need to allocate more mem */
14368 if (ieLen > pSession->nWapiReqIeLength) {
14369 if (pSession->pWapiReqIE
14370 && pSession->nWapiReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014371 qdf_mem_free(pSession->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014372 pWapiReqIE);
14373 }
14374 pSession->pWapiReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014375 qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014376 if (NULL == pSession->pWapiReqIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014377 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014378 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014379 status = QDF_STATUS_SUCCESS;
14380 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014381 break;
14382 }
14383 pSession->nWapiReqIeLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014384 qdf_mem_copy(pSession->pWapiReqIE, wpaRsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014385 ieLen);
14386 csr_join_req->rsnIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014387 qdf_mem_copy(&csr_join_req->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014388 wpaRsnIE, ieLen);
14389 } else /* should be WPA/WPA2 otherwise */
14390#endif /* FEATURE_WLAN_WAPI */
14391 {
14392 /* Check whether we need to allocate more mem */
14393 if (ieLen > pSession->nWpaRsnReqIeLength) {
14394 if (pSession->pWpaRsnReqIE
14395 && pSession->nWpaRsnReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014396 qdf_mem_free(pSession->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014397 pWpaRsnReqIE);
14398 }
14399 pSession->pWpaRsnReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014400 qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014401 if (NULL == pSession->pWpaRsnReqIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014402 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014403 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014404 status = QDF_STATUS_SUCCESS;
14405 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014406 break;
14407 }
14408 pSession->nWpaRsnReqIeLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014409 qdf_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014410 ieLen);
14411 csr_join_req->rsnIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014412 qdf_mem_copy(&csr_join_req->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014413 wpaRsnIE, ieLen);
14414 }
14415 } else {
14416 /* free whatever old info */
14417 pSession->nWpaRsnReqIeLength = 0;
14418 if (pSession->pWpaRsnReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014419 qdf_mem_free(pSession->pWpaRsnReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014420 pSession->pWpaRsnReqIE = NULL;
14421 }
14422#ifdef FEATURE_WLAN_WAPI
14423 pSession->nWapiReqIeLength = 0;
14424 if (pSession->pWapiReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014425 qdf_mem_free(pSession->pWapiReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014426 pSession->pWapiReqIE = NULL;
14427 }
14428#endif /* FEATURE_WLAN_WAPI */
14429 csr_join_req->rsnIE.length = 0;
14430 }
14431#ifdef FEATURE_WLAN_ESE
14432 if (eWNI_SME_JOIN_REQ == messageType)
14433 csr_join_req->cckmIE.length = 0;
14434 else if (eWNI_SME_REASSOC_REQ == messageType) {
14435 /* cckmIE */
14436 if (csr_is_profile_ese(pProfile)) {
14437 /* Insert the CCKM IE into the join request */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014438 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014439 qdf_mem_copy((void *)(wpaRsnIE),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014440 pSession->suppCckmIeInfo.cckmIe,
14441 ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014442 } else
14443 ieLen = 0;
14444 /*
14445 * If present, copy the IE into the
14446 * eWNI_SME_REASSOC_REQ message buffer
14447 */
14448 if (ieLen) {
14449 /*
14450 * Copy the CCKM IE over from the temp
14451 * buffer (wpaRsnIE)
14452 */
14453 csr_join_req->cckmIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014454 qdf_mem_copy(&csr_join_req->cckmIE.cckmIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014455 wpaRsnIE, ieLen);
14456 } else
14457 csr_join_req->cckmIE.length = 0;
14458 }
14459#endif /* FEATURE_WLAN_ESE */
14460 /* addIEScan */
14461 if (pProfile->nAddIEScanLength && pProfile->pAddIEScan) {
14462 ieLen = pProfile->nAddIEScanLength;
14463 if (ieLen > pSession->nAddIEScanLength) {
14464 if (pSession->pAddIEScan
14465 && pSession->nAddIEScanLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014466 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014467 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014468 pSession->pAddIEScan = qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014469 if (NULL == pSession->pAddIEScan)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014470 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014471 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014472 status = QDF_STATUS_SUCCESS;
14473 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014474 break;
14475 }
14476 pSession->nAddIEScanLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014477 qdf_mem_copy(pSession->pAddIEScan, pProfile->pAddIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014478 ieLen);
14479 csr_join_req->addIEScan.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014480 qdf_mem_copy(&csr_join_req->addIEScan.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014481 pProfile->pAddIEScan, ieLen);
14482 } else {
14483 pSession->nAddIEScanLength = 0;
14484 if (pSession->pAddIEScan) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014485 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014486 pSession->pAddIEScan = NULL;
14487 }
14488 csr_join_req->addIEScan.length = 0;
14489 }
14490 /* addIEAssoc */
14491 if (pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc) {
14492 ieLen = pProfile->nAddIEAssocLength;
14493 if (ieLen > pSession->nAddIEAssocLength) {
14494 if (pSession->pAddIEAssoc
14495 && pSession->nAddIEAssocLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014496 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014497 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014498 pSession->pAddIEAssoc = qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014499 if (NULL == pSession->pAddIEAssoc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014500 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014501 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014502 status = QDF_STATUS_SUCCESS;
14503 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014504 break;
14505 }
14506 pSession->nAddIEAssocLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014507 qdf_mem_copy(pSession->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014508 pProfile->pAddIEAssoc, ieLen);
14509 csr_join_req->addIEAssoc.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014510 qdf_mem_copy(&csr_join_req->addIEAssoc.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014511 pProfile->pAddIEAssoc, ieLen);
14512 } else {
14513 pSession->nAddIEAssocLength = 0;
14514 if (pSession->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014515 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014516 pSession->pAddIEAssoc = NULL;
14517 }
14518 csr_join_req->addIEAssoc.length = 0;
14519 }
14520
14521 if (eWNI_SME_REASSOC_REQ == messageType) {
14522 /* Unmask any AC in reassoc that is ACM-set */
14523 uapsd_mask = (uint8_t) pProfile->uapsd_mask;
14524 if (uapsd_mask && (NULL != pBssDescription)) {
14525 if (CSR_IS_QOS_BSS(pIes)
14526 && CSR_IS_UAPSD_BSS(pIes))
14527#ifndef WLAN_MDM_CODE_REDUCTION_OPT
14528 acm_mask =
14529 sme_qos_get_acm_mask(pMac,
14530 pBssDescription,
14531 pIes);
14532#endif /* WLAN_MDM_CODE_REDUCTION_OPT */
14533 else
14534 uapsd_mask = 0;
14535 }
14536 }
14537
14538 csr_join_req->UCEncryptionType =
14539 csr_translate_encrypt_type_to_ed_type
14540 (pProfile->negotiatedUCEncryptionType);
14541
14542 csr_join_req->MCEncryptionType =
14543 csr_translate_encrypt_type_to_ed_type
14544 (pProfile->negotiatedMCEncryptionType);
Abhishek Singhcfb44482017-03-10 12:42:37 +053014545 csr_set_mgmt_enc_type(pProfile, pIes, csr_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014546#ifdef FEATURE_WLAN_ESE
14547 ese_config = pMac->roam.configParam.isEseIniFeatureEnabled;
14548#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014549 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
14550 if (csr_is_profile11r(pProfile)
14551#ifdef FEATURE_WLAN_ESE
14552 &&
14553 !((pProfile->negotiatedAuthType ==
14554 eCSR_AUTH_TYPE_OPEN_SYSTEM) && (pIes->ESEVersion.present)
14555 && (ese_config))
14556#endif
14557 )
14558 csr_join_req->is11Rconnection = true;
14559 else
14560 csr_join_req->is11Rconnection = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014561#ifdef FEATURE_WLAN_ESE
14562 if (true == ese_config)
14563 csr_join_req->isESEFeatureIniEnabled = true;
14564 else
14565 csr_join_req->isESEFeatureIniEnabled = false;
14566
14567 /* A profile can not be both ESE and 11R. But an 802.11R AP
14568 * may be advertising support for ESE as well. So if we are
14569 * associating Open or explicitly ESE then we will get ESE.
14570 * If we are associating explictly 11R only then we will get
14571 * 11R.
14572 */
14573 if ((csr_is_profile_ese(pProfile) ||
14574 ((pIes->ESEVersion.present) &&
14575 (pProfile->negotiatedAuthType ==
14576 eCSR_AUTH_TYPE_OPEN_SYSTEM)))
14577 && (ese_config))
14578 csr_join_req->isESEconnection = true;
14579 else
14580 csr_join_req->isESEconnection = false;
14581
14582 if (eWNI_SME_JOIN_REQ == messageType) {
14583 tESETspecInfo eseTspec;
14584 /*
14585 * ESE-Tspec IEs in the ASSOC request is presently not
14586 * supported. so nullify the TSPEC parameters
14587 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014588 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
14589 qdf_mem_copy(&csr_join_req->eseTspecInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014590 &eseTspec, sizeof(tESETspecInfo));
14591 } else if (eWNI_SME_REASSOC_REQ == messageType) {
14592 if ((csr_is_profile_ese(pProfile) ||
14593 ((pIes->ESEVersion.present)
14594 && (pProfile->negotiatedAuthType ==
14595 eCSR_AUTH_TYPE_OPEN_SYSTEM))) &&
14596 (ese_config)) {
14597 tESETspecInfo eseTspec;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014598
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014599 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014600 0);
14601 eseTspec.numTspecs =
14602 sme_qos_ese_retrieve_tspec_info(pMac,
14603 sessionId,
14604 (tTspecInfo *) &eseTspec.
14605 tspec[0]);
14606 csr_join_req->eseTspecInfo.numTspecs =
14607 eseTspec.numTspecs;
14608 if (eseTspec.numTspecs) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014609 qdf_mem_copy(&csr_join_req->eseTspecInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014610 .tspec[0],
14611 &eseTspec.tspec[0],
14612 (eseTspec.numTspecs *
14613 sizeof(tTspecInfo)));
14614 }
14615 } else {
14616 tESETspecInfo eseTspec;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014617 /*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014618 * ESE-Tspec IEs in the ASSOC request is
14619 * presently not supported. so nullify the TSPEC
14620 * parameters
14621 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014622 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014623 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014624 qdf_mem_copy(&csr_join_req->eseTspecInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014625 &eseTspec,
14626 sizeof(tESETspecInfo));
14627 }
14628 }
14629#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014630 if (ese_config
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014631 || csr_roam_is_fast_roam_enabled(pMac, sessionId))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014632 csr_join_req->isFastTransitionEnabled = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014633 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014634 csr_join_req->isFastTransitionEnabled = false;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014635
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014636 if (csr_roam_is_fast_roam_enabled(pMac, sessionId))
14637 csr_join_req->isFastRoamIniFeatureEnabled = true;
14638 else
14639 csr_join_req->isFastRoamIniFeatureEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014640
14641 csr_join_req->txLdpcIniFeatureEnabled =
Krunal Sonia2c0e412017-05-04 14:12:41 +053014642 (uint8_t) pMac->roam.configParam.tx_ldpc_enable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014643
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014644 if ((csr_is11h_supported(pMac)) &&
14645 (WLAN_REG_IS_5GHZ_CH(pBssDescription->channelId)) &&
14646 (pIes->Country.present) &&
14647 (!pMac->roam.configParam.
14648 fSupplicantCountryCodeHasPriority)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014649 csr_save_to_channel_power2_g_5_g(pMac,
14650 pIes->Country.num_triplets *
14651 sizeof(tSirMacChanInfo),
14652 (tSirMacChanInfo *)
14653 (&pIes->Country.triplets[0]));
14654 csr_apply_power2_current(pMac);
14655 }
Krunal Soni0193b6f2016-08-15 15:53:43 -070014656 /*
14657 * If RX LDPC has been disabled for 2.4GHz channels and enabled
Krunal Sonid292a6b2016-10-27 17:25:23 -070014658 * for 5Ghz for STA like persona then here is how to handle
14659 * those cases (by now channel has been decided).
Krunal Soni0193b6f2016-08-15 15:53:43 -070014660 */
Krunal Sonid292a6b2016-10-27 17:25:23 -070014661 if (eSIR_INFRASTRUCTURE_MODE == csr_join_req->bsstype ||
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080014662 !policy_mgr_is_dbs_enable(pMac->psoc))
Krunal Soni0193b6f2016-08-15 15:53:43 -070014663 csr_set_ldpc_exception(pMac, pSession,
14664 pBssDescription->channelId,
Krunal Sonia2c0e412017-05-04 14:12:41 +053014665 pMac->roam.configParam.rx_ldpc_enable);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014666 qdf_mem_copy(&csr_join_req->htConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014667 &pSession->htConfig, sizeof(tSirHTConfig));
Sandeep Puligilla98917432016-06-10 13:50:28 -070014668 qdf_mem_copy(&csr_join_req->vht_config, &pSession->vht_config,
14669 sizeof(pSession->vht_config));
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014670 sme_debug("ht capability 0x%x VHT capability 0x%x",
Sandeep Puligilla98917432016-06-10 13:50:28 -070014671 (unsigned int)(*(uint32_t *) &csr_join_req->htConfig),
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014672 (unsigned int)(*(uint32_t *) &csr_join_req->
14673 vht_config));
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -080014674
14675 if (IS_DOT11_MODE_HE(csr_join_req->dot11mode))
14676 csr_join_req_copy_he_cap(csr_join_req, pSession);
14677
Krunal Soni53993f72016-07-08 18:20:03 -070014678 if (wlan_cfg_get_int(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
14679 &value) != eSIR_SUCCESS)
14680 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014681 ("Failed to get SU beamformee capability"));
Krunal Soni53993f72016-07-08 18:20:03 -070014682 if (wlan_cfg_get_int(pMac,
14683 WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED,
14684 &value1) != eSIR_SUCCESS)
14685 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014686 ("Failed to get CSN beamformee capability"));
Krunal Soni53993f72016-07-08 18:20:03 -070014687
14688 csr_join_req->vht_config.su_beam_formee = value;
Abhishek Singhd8162ca2017-04-11 11:54:54 +053014689
14690 /* Set BF CSN value only if SU Bformee is enabled */
14691 if (csr_join_req->vht_config.su_beam_formee) {
Prakash Dhavali2aa7f892016-12-02 09:56:09 -080014692 txBFCsnValue = (uint8_t)value1;
14693 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps) &&
Arif Hussainc6aa1ce2016-12-01 18:03:17 -080014694 pIes->VHTCaps.csnofBeamformerAntSup)
Prakash Dhavali2aa7f892016-12-02 09:56:09 -080014695 txBFCsnValue = QDF_MIN(txBFCsnValue,
Arif Hussainc6aa1ce2016-12-01 18:03:17 -080014696 pIes->VHTCaps.csnofBeamformerAntSup);
14697 else if (IS_BSS_VHT_CAPABLE(
14698 pIes->vendor_vht_ie.VHTCaps)
14699 && pIes->vendor_vht_ie.VHTCaps.
14700 csnofBeamformerAntSup)
Prakash Dhavali2aa7f892016-12-02 09:56:09 -080014701 txBFCsnValue = QDF_MIN(txBFCsnValue,
14702 pIes->vendor_vht_ie.
Arif Hussainc6aa1ce2016-12-01 18:03:17 -080014703 VHTCaps.csnofBeamformerAntSup);
Prakash Dhavali2aa7f892016-12-02 09:56:09 -080014704 }
14705 csr_join_req->vht_config.csnof_beamformer_antSup = txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014706
Krunal Soni53993f72016-07-08 18:20:03 -070014707 if (wlan_cfg_get_int(pMac,
Abhishek Singhd8162ca2017-04-11 11:54:54 +053014708 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &value)
14709 != eSIR_SUCCESS)
14710 sme_err("Failed to get SU beamformer capability");
14711
14712 /*
14713 * Set SU Bformer only if SU Bformer is enabled in INI
14714 * and AP is SU Bformee capable
14715 */
14716 if (value && !((IS_BSS_VHT_CAPABLE(pIes->VHTCaps) &&
14717 pIes->VHTCaps.suBeamformeeCap) ||
14718 (IS_BSS_VHT_CAPABLE(
14719 pIes->vendor_vht_ie.VHTCaps)
14720 && pIes->vendor_vht_ie.VHTCaps.
14721 suBeamformeeCap)))
14722 value = 0;
14723
14724 csr_join_req->vht_config.su_beam_former = value;
14725
14726 /* Set num soundingdim value to 0 if SU Bformer is disabled */
14727 if (!csr_join_req->vht_config.su_beam_former)
14728 csr_join_req->vht_config.num_soundingdim = 0;
14729
14730 if (wlan_cfg_get_int(pMac,
14731 WNI_CFG_VHT_MU_BEAMFORMEE_CAP, &value)
14732 != eSIR_SUCCESS)
14733 sme_err("Failed to get CSN beamformee capability");
14734 /*
14735 * Set MU Bformee only if SU Bformee is enabled and
14736 * MU Bformee is enabled in INI
14737 */
14738 if (value && csr_join_req->vht_config.su_beam_formee)
14739 csr_join_req->vht_config.mu_beam_formee = 1;
14740 else
14741 csr_join_req->vht_config.mu_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014742
14743 csr_join_req->enableVhtpAid =
14744 (uint8_t) pMac->roam.configParam.enableVhtpAid;
14745
14746 csr_join_req->enableVhtGid =
14747 (uint8_t) pMac->roam.configParam.enableVhtGid;
14748
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014749 csr_join_req->enableAmpduPs =
14750 (uint8_t) pMac->roam.configParam.enableAmpduPs;
14751
14752 csr_join_req->enableHtSmps =
14753 (uint8_t) pMac->roam.configParam.enableHtSmps;
14754
14755 csr_join_req->htSmps = (uint8_t) pMac->roam.configParam.htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -080014756 csr_join_req->send_smps_action =
14757 pMac->roam.configParam.send_smps_action;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014758
Deepak Dhamdhere612392c2016-08-28 02:56:51 -070014759 csr_join_req->max_amsdu_num =
14760 (uint8_t) pMac->roam.configParam.max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014761
14762 if (pMac->roam.roamSession[sessionId].fWMMConnection)
14763 csr_join_req->isWMEenabled = true;
14764 else
14765 csr_join_req->isWMEenabled = false;
14766
14767 if (pMac->roam.roamSession[sessionId].fQOSConnection)
14768 csr_join_req->isQosEnabled = true;
14769 else
14770 csr_join_req->isQosEnabled = false;
14771
14772 if (pProfile->bOSENAssociation)
14773 csr_join_req->isOSENConnection = true;
14774 else
14775 csr_join_req->isOSENConnection = false;
14776
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080014777 /* Fill rrm config parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014778 qdf_mem_copy(&csr_join_req->rrm_config,
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080014779 &pMac->rrm.rrmSmeContext.rrmConfig,
14780 sizeof(struct rrm_config_param));
14781
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014782 pAP_capabilityInfo =
14783 (tSirMacCapabilityInfo *)
14784 &pBssDescription->capabilityInfo;
14785 /*
14786 * tell the target AP my 11H capability only if both AP and STA
14787 * support
14788 * 11H and the channel being used is 11a
14789 */
14790 if (csr_is11h_supported(pMac) && pAP_capabilityInfo->spectrumMgt
14791 && eSIR_11A_NW_TYPE == pBssDescription->nwType) {
Srinivas Girigowda74a66d62017-06-21 23:28:25 -070014792 fTmp = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014793 } else
Srinivas Girigowda74a66d62017-06-21 23:28:25 -070014794 fTmp = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014795
14796 csr_join_req->spectrumMgtIndicator = fTmp;
14797 csr_join_req->powerCap.minTxPower = MIN_TX_PWR_CAP;
14798 /*
14799 * This is required for 11k test VoWiFi Ent: Test 2.
14800 * We need the power capabilities for Assoc Req.
14801 * This macro is provided by the halPhyCfg.h. We pick our
14802 * max and min capability by the halPhy provided macros
Selvaraj, Sridhar94be8ba2017-05-04 17:08:54 +053014803 * Any change in this power cap IE should also be done
14804 * in csr_update_driver_assoc_ies() which would send
14805 * assoc IE's to FW which is used for LFR3 roaming
14806 * ie. used in reassociation requests from FW.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014807 */
14808 pwrLimit = csr_get_cfg_max_tx_power(pMac,
14809 pBssDescription->channelId);
Agrawal Ashish6b48ee22017-02-21 20:54:53 +053014810 if (0 != pwrLimit && pwrLimit < MAX_TX_PWR_CAP)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014811 csr_join_req->powerCap.maxTxPower = pwrLimit;
14812 else
14813 csr_join_req->powerCap.maxTxPower = MAX_TX_PWR_CAP;
14814
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053014815 csr_add_supported_5Ghz_channels(pMac,
14816 csr_join_req->supportedChannels.channelList,
14817 &csr_join_req->supportedChannels.numChnl,
14818 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014819
14820 csr_join_req->uapsdPerAcBitmask = (uint8_t)pProfile->uapsd_mask;
14821 /* Move the entire BssDescription into the join request. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014822 qdf_mem_copy(&csr_join_req->bssDescription, pBssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014823 pBssDescription->length +
14824 sizeof(pBssDescription->length));
14825
14826 /*
14827 * conc_custom_rule1:
14828 * If SAP comes up first and STA comes up later then SAP
14829 * need to follow STA's channel in 2.4Ghz. In following if
14830 * condition we are adding sanity check, just to make sure that
14831 * if this rule is enabled then don't allow STA to connect on
14832 * 5gz channel and also by this time SAP's channel should be the
14833 * same as STA's channel.
14834 */
14835 if (pMac->roam.configParam.conc_custom_rule1) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014836 if ((0 == pMac->roam.configParam.
14837 is_sta_connection_in_5gz_enabled) &&
14838 WLAN_REG_IS_5GHZ_CH(pBssDescription->
14839 channelId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053014840 QDF_TRACE(QDF_MODULE_ID_SME,
14841 QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070014842 "STA-conn on 5G isn't allowed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014843 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014844 break;
14845 }
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014846 if (!WLAN_REG_IS_5GHZ_CH(pBssDescription->channelId) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014847 (false == csr_is_conn_allow_2g_band(pMac,
14848 pBssDescription->channelId))) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014849 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014850 break;
14851 }
14852 }
14853
14854 /*
14855 * conc_custom_rule2:
14856 * If P2PGO comes up first and STA comes up later then P2PGO
14857 * need to follow STA's channel in 5Ghz. In following if
14858 * condition we are just adding sanity check to make sure that
14859 * by this time P2PGO's channel is same as STA's channel.
14860 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070014861 if (pMac->roam.configParam.conc_custom_rule2 &&
14862 !WLAN_REG_IS_24GHZ_CH(pBssDescription->channelId) &&
14863 (!csr_is_conn_allow_5g_band(pMac,
14864 pBssDescription->channelId))) {
14865 status = QDF_STATUS_E_FAILURE;
14866 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014867 }
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +053014868
14869 if (pSession->pCurRoamProfile->csrPersona == QDF_STA_MODE)
14870 csr_join_req->enable_bcast_probe_rsp =
14871 pMac->roam.configParam.enable_bcast_probe_rsp;
14872
Rajeev Kumard138ac52017-01-30 18:38:37 -080014873 status = umac_send_mb_message_to_mac(csr_join_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014874 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014875 /*
Rajeev Kumard138ac52017-01-30 18:38:37 -080014876 * umac_send_mb_message_to_mac would've released the mem
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014877 * allocated by csr_join_req. Let's make it defensive by
14878 * assigning NULL to the pointer.
14879 */
14880 csr_join_req = NULL;
14881 break;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014882 }
14883
14884 if (pProfile->csrPersona == QDF_STA_MODE) {
14885 sme_debug("Invoking packetdump register API");
14886 wlan_register_txrx_packetdump();
14887 packetdump_timer_status = qdf_mc_timer_start(
14888 &pMac->roam.packetdump_timer,
14889 (PKT_DUMP_TIMER_DURATION *
14890 QDF_MC_TIMER_TO_SEC_UNIT)/
14891 QDF_MC_TIMER_TO_MS_UNIT);
14892 if (!QDF_IS_STATUS_SUCCESS(packetdump_timer_status))
14893 sme_err("cannot start packetdump timer status: %d",
14894 packetdump_timer_status);
14895 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014896#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014897 if (eWNI_SME_JOIN_REQ == messageType) {
14898 /* Notify QoS module that join happening */
14899 pSession->join_bssid_count++;
14900 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
14901 "BSSID Count: %d", pSession->join_bssid_count);
14902 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014903 SME_QOS_CSR_JOIN_REQ, NULL);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053014904 } else if (eWNI_SME_REASSOC_REQ == messageType)
14905 /* Notify QoS module that reassoc happening */
14906 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014907 SME_QOS_CSR_REASSOC_REQ,
14908 NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014909#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014910 } while (0);
14911
14912 /* Clean up the memory in case of any failure */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014913 if (!QDF_IS_STATUS_SUCCESS(status) && (NULL != csr_join_req))
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014914 qdf_mem_free(csr_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014915
Selvaraj, Sridhardc2ac8e2017-05-12 15:32:45 +053014916 if (wpaRsnIE)
14917 qdf_mem_free(wpaRsnIE);
14918
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014919 return status;
14920}
14921
14922/* */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014923QDF_STATUS csr_send_mb_disassoc_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014924 tSirMacAddr bssId, uint16_t reasonCode)
14925{
14926 tSirSmeDisassocReq *pMsg;
14927 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14928
14929 if (!CSR_IS_SESSION_VALID(pMac, sessionId))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014930 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014931
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014932 pMsg = qdf_mem_malloc(sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014933 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014934 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014935
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014936 pMsg->messageType = eWNI_SME_DISASSOC_REQ;
14937 pMsg->length = sizeof(tSirSmeDisassocReq);
14938 pMsg->sessionId = sessionId;
14939 pMsg->transactionId = 0;
14940 if ((pSession->pCurRoamProfile != NULL)
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070014941 && (CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014942 qdf_mem_copy(&pMsg->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014943 &pSession->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014944 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014945 qdf_mem_copy(&pMsg->peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014946 bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014947 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014948 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014949 qdf_mem_copy(&pMsg->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014950 bssId, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014951 qdf_mem_copy(&pMsg->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014952 bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014953 }
14954 pMsg->reasonCode = reasonCode;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -070014955 pMsg->process_ho_fail = (pSession->disconnect_reason ==
14956 eCSR_DISCONNECT_REASON_ROAM_HO_FAIL) ? true : false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014957 /*
14958 * The state will be DISASSOC_HANDOFF only when we are doing
14959 * handoff. Here we should not send the disassoc over the air
14960 * to the AP
14961 */
Selvaraj, Sridhar0ab68622017-04-24 14:21:27 +053014962 if ((CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
14963 && csr_roam_is11r_assoc(pMac, sessionId)) ||
14964 pMsg->process_ho_fail) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014965 /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
14966 pMsg->doNotSendOverTheAir = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR;
14967 }
Rajeev Kumard138ac52017-01-30 18:38:37 -080014968 return umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014969}
14970
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014971QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014972csr_send_mb_get_associated_stas_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014973 QDF_MODULE_ID modId,
14974 struct qdf_mac_addr bssid,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014975 void *pUsrContext,
14976 void *pfnSapEventCallback,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014977 uint8_t *pAssocStasBuf)
14978{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014979 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014980 tSirSmeGetAssocSTAsReq *pMsg;
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014981
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014982 pMsg = qdf_mem_malloc(sizeof(*pMsg));
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014983 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014984 return QDF_STATUS_E_NOMEM;
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014985
14986 pMsg->messageType = eWNI_SME_GET_ASSOC_STAS_REQ;
Anurag Chouhanc5548422016-02-24 18:33:27 +053014987 qdf_copy_macaddr(&pMsg->bssid, &bssid);
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014988 pMsg->modId = modId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014989 qdf_mem_copy(pMsg->pUsrContext, pUsrContext, sizeof(void *));
14990 qdf_mem_copy(pMsg->pSapEventCallback,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014991 pfnSapEventCallback, sizeof(void *));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014992 qdf_mem_copy(pMsg->pAssocStasArray, pAssocStasBuf, sizeof(void *));
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014993 pMsg->length = sizeof(*pMsg);
Rajeev Kumard138ac52017-01-30 18:38:37 -080014994 status = umac_send_mb_message_to_mac(pMsg);
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014995
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014996 return status;
14997}
14998
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014999QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015000csr_send_mb_get_wpspbc_sessions(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015001 struct qdf_mac_addr bssid, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015002 void *pfnSapEventCallback,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015003 struct qdf_mac_addr remove_mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015004{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015005 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015006 tSirSmeGetWPSPBCSessionsReq *pMsg;
15007
15008 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015009 pMsg = qdf_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015010 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015011 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015012 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015013 status = QDF_STATUS_SUCCESS;
15014 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015015 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015016 qdf_mem_set(pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015017 pMsg->messageType = eWNI_SME_GET_WPSPBC_SESSION_REQ;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015018 qdf_mem_copy(pMsg->pUsrContext, pUsrContext, sizeof(void *));
15019 qdf_mem_copy(pMsg->pSapEventCallback, pfnSapEventCallback,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015020 sizeof(void *));
Anurag Chouhanc5548422016-02-24 18:33:27 +053015021 qdf_copy_macaddr(&pMsg->bssid, &bssid);
15022 qdf_copy_macaddr(&pMsg->remove_mac, &remove_mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015023 pMsg->length = sizeof(struct sSirSmeGetWPSPBCSessionsReq);
Rajeev Kumard138ac52017-01-30 18:38:37 -080015024 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015025 } while (0);
15026 return status;
15027}
15028
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015029QDF_STATUS csr_send_chng_mcc_beacon_interval(tpAniSirGlobal pMac,
15030 uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015031{
15032 tpSirChangeBIParams pMsg;
15033 uint16_t len = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015034 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015035 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15036
15037 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015038 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015039 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015040 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015041 /* NO need to update the Beacon Params if update beacon parameter flag
15042 * is not set
15043 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015044 if (!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015045 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015046
15047 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval =
15048 false;
15049
15050 /* Create the message and send to lim */
15051 len = sizeof(tSirChangeBIParams);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015052 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015053 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015054 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015055 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015056 status = QDF_STATUS_SUCCESS;
15057 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015058 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
15059 pMsg->length = len;
15060
Anurag Chouhanc5548422016-02-24 18:33:27 +053015061 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015062 sme_debug(
15063 "CSR Attempting to change BI for Bssid= "
15064 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMsg->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015065 pMsg->sessionId = sessionId;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015066 sme_debug("session %d BeaconInterval %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015067 sessionId,
15068 pMac->roam.roamSession[sessionId].bssParams.
15069 beaconInterval);
15070 pMsg->beaconInterval =
15071 pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
Rajeev Kumard138ac52017-01-30 18:38:37 -080015072 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015073 }
15074 return status;
15075}
15076
15077#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015078QDF_STATUS csr_set_ht2040_mode(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015079 ePhyChanBondState cbMode, bool obssEnabled)
15080{
15081 tpSirSetHT2040Mode pMsg;
15082 uint16_t len = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015083 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015084 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15085
15086 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015087 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015088 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015089 }
15090
15091 /* Create the message and send to lim */
15092 len = sizeof(tSirSetHT2040Mode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015093 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015094 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015095 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015096 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015097 status = QDF_STATUS_SUCCESS;
15098 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015099 qdf_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015100 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
15101 pMsg->length = len;
15102
Anurag Chouhanc5548422016-02-24 18:33:27 +053015103 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015104 sme_debug(
15105 "CSR Attempting to set HT20/40 mode for Bssid= "
15106 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMsg->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015107 pMsg->sessionId = sessionId;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015108 sme_debug(" session %d HT20/40 mode %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015109 sessionId, cbMode);
15110 pMsg->cbMode = cbMode;
15111 pMsg->obssEnabled = obssEnabled;
Rajeev Kumard138ac52017-01-30 18:38:37 -080015112 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015113 }
15114 return status;
15115}
15116#endif
15117
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015118QDF_STATUS csr_send_mb_deauth_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015119 tSirMacAddr bssId, uint16_t reasonCode)
15120{
15121 tSirSmeDeauthReq *pMsg;
15122 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15123
15124 if (!CSR_IS_SESSION_VALID(pMac, sessionId))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015125 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015126
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015127 pMsg = qdf_mem_malloc(sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015128 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015129 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015130
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015131 qdf_mem_set(pMsg, sizeof(tSirSmeDeauthReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015132 pMsg->messageType = eWNI_SME_DEAUTH_REQ;
15133 pMsg->length = sizeof(tSirSmeDeauthReq);
15134 pMsg->sessionId = sessionId;
15135 pMsg->transactionId = 0;
15136
15137 if ((pSession->pCurRoamProfile != NULL)
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070015138 && (CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015139 qdf_mem_copy(&pMsg->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015140 &pSession->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015141 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015142 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015143 qdf_mem_copy(&pMsg->bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015144 bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015145 }
15146
15147 /* Set the peer MAC address before sending the message to LIM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015148 qdf_mem_copy(&pMsg->peer_macaddr.bytes, bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015149 pMsg->reasonCode = reasonCode;
15150
Rajeev Kumard138ac52017-01-30 18:38:37 -080015151 return umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015152}
15153
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015154QDF_STATUS csr_send_mb_disassoc_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015155 tpSirSmeDisassocInd pDisassocInd)
15156{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015157 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015158 tSirSmeDisassocCnf *pMsg;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015159
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015160 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015161 pMsg = qdf_mem_malloc(sizeof(tSirSmeDisassocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015162 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015163 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015164 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015165 status = QDF_STATUS_SUCCESS;
15166 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015167 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015168 pMsg->messageType = eWNI_SME_DISASSOC_CNF;
15169 pMsg->statusCode = eSIR_SME_SUCCESS;
15170 pMsg->length = sizeof(tSirSmeDisassocCnf);
Anurag Chouhanc5548422016-02-24 18:33:27 +053015171 qdf_copy_macaddr(&pMsg->peer_macaddr,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080015172 &pDisassocInd->peer_macaddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015173 status = QDF_STATUS_SUCCESS;
15174 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015175 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015176 break;
15177 }
15178
Anurag Chouhanc5548422016-02-24 18:33:27 +053015179 qdf_copy_macaddr(&pMsg->bssid, &pDisassocInd->bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015180 status = QDF_STATUS_SUCCESS;
15181 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015182 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015183 break;
15184 }
15185
Rajeev Kumard138ac52017-01-30 18:38:37 -080015186 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015187 } while (0);
15188 return status;
15189}
15190
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015191QDF_STATUS csr_send_mb_deauth_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015192 tpSirSmeDeauthInd pDeauthInd)
15193{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015194 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015195 tSirSmeDeauthCnf *pMsg;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015196
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015197 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015198 pMsg = qdf_mem_malloc(sizeof(tSirSmeDeauthCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015199 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015200 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015201 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015202 status = QDF_STATUS_SUCCESS;
15203 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015204 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015205 pMsg->messageType = eWNI_SME_DEAUTH_CNF;
15206 pMsg->statusCode = eSIR_SME_SUCCESS;
15207 pMsg->length = sizeof(tSirSmeDeauthCnf);
Anurag Chouhanc5548422016-02-24 18:33:27 +053015208 qdf_copy_macaddr(&pMsg->bssid, &pDeauthInd->bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015209 status = QDF_STATUS_SUCCESS;
15210 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015211 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015212 break;
15213 }
Anurag Chouhanc5548422016-02-24 18:33:27 +053015214 qdf_copy_macaddr(&pMsg->peer_macaddr,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -080015215 &pDeauthInd->peer_macaddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015216 status = QDF_STATUS_SUCCESS;
15217 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015218 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015219 break;
15220 }
Rajeev Kumard138ac52017-01-30 18:38:37 -080015221 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015222 } while (0);
15223 return status;
15224}
15225
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015226QDF_STATUS csr_send_assoc_cnf_msg(tpAniSirGlobal pMac, tpSirSmeAssocInd
15227 pAssocInd, QDF_STATUS Halstatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015228{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015229 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015230 tSirSmeAssocCnf *pMsg;
15231
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015232 sme_debug("Posting eWNI_SME_ASSOC_CNF to LIM.HalStatus: %d", Halstatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015233 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015234 pMsg = qdf_mem_malloc(sizeof(tSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015235 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015236 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015237 pMsg->messageType = eWNI_SME_ASSOC_CNF;
15238 pMsg->length = sizeof(tSirSmeAssocCnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015239 if (QDF_IS_STATUS_SUCCESS(Halstatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015240 pMsg->statusCode = eSIR_SME_SUCCESS;
15241 else
15242 pMsg->statusCode = eSIR_SME_ASSOC_REFUSED;
15243 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015244 qdf_mem_copy(pMsg->bssid.bytes, pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015245 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015246 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015247 qdf_mem_copy(pMsg->peer_macaddr.bytes, pAssocInd->peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015248 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015249 /* aid */
15250 pMsg->aid = pAssocInd->aid;
15251 /* alternateBssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015252 qdf_mem_copy(pMsg->alternate_bssid.bytes, pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015253 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015254 /* alternateChannelId */
15255 pMsg->alternateChannelId = 11;
Rajeev Kumard138ac52017-01-30 18:38:37 -080015256 /* pMsg is freed by umac_send_mb_message_to_mac in anycase*/
15257 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015258 } while (0);
15259 return status;
15260}
15261
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015262QDF_STATUS csr_send_assoc_ind_to_upper_layer_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015263 tpSirSmeAssocInd pAssocInd,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015264 QDF_STATUS Halstatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015265 uint8_t sessionId)
15266{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070015267 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015268 tSirSmeAssocIndToUpperLayerCnf *pMsg;
15269 uint8_t *pBuf;
15270 tSirResultCodes statusCode;
15271 uint16_t wTmp;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015272
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015273 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015274 pMsg = qdf_mem_malloc(sizeof(tSirSmeAssocIndToUpperLayerCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015275 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015276 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015277
15278 pMsg->messageType = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
15279 pMsg->length = sizeof(tSirSmeAssocIndToUpperLayerCnf);
15280
15281 pMsg->sessionId = sessionId;
15282
15283 pBuf = (uint8_t *) &pMsg->statusCode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015284 if (QDF_IS_STATUS_SUCCESS(Halstatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015285 statusCode = eSIR_SME_SUCCESS;
15286 else
15287 statusCode = eSIR_SME_ASSOC_REFUSED;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015288 qdf_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015289 /* bssId */
Will Huang558f8082017-05-31 16:22:24 +080015290 pBuf = (uint8_t *)&pMsg->bssId;
15291 qdf_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId,
15292 sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015293 /* peerMacAddr */
Will Huang558f8082017-05-31 16:22:24 +080015294 pBuf = (uint8_t *)&pMsg->peerMacAddr;
15295 qdf_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
15296 sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015297 /* StaId */
Will Huang558f8082017-05-31 16:22:24 +080015298 pBuf = (uint8_t *)&pMsg->aid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015299 wTmp = pAssocInd->staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015300 qdf_mem_copy(pBuf, &wTmp, sizeof(uint16_t));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015301 /* alternateBssId */
Will Huang558f8082017-05-31 16:22:24 +080015302 pBuf = (uint8_t *)&pMsg->alternateBssId;
15303 qdf_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId,
15304 sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015305 /* alternateChannelId */
Will Huang558f8082017-05-31 16:22:24 +080015306 pBuf = (uint8_t *)&pMsg->alternateChannelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015307 *pBuf = 11;
Will Huang558f8082017-05-31 16:22:24 +080015308 /*
15309 * Instead of copying roam Info,just copy WmmEnabled,
15310 * RsnIE information.
15311 * Wmm
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015312 */
Will Huang558f8082017-05-31 16:22:24 +080015313 pBuf = (uint8_t *)&pMsg->wmmEnabledSta;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015314 *pBuf = pAssocInd->wmmEnabledSta;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015315 /* RSN IE */
Will Huang558f8082017-05-31 16:22:24 +080015316 pBuf = (uint8_t *)&pMsg->rsnIE;
15317 qdf_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE,
15318 sizeof(tSirRSNie));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015319#ifdef FEATURE_WLAN_WAPI
15320 /* WAPI IE */
Will Huang558f8082017-05-31 16:22:24 +080015321 pBuf = (uint8_t *)&pMsg->wapiIE;
15322 qdf_mem_copy((tSirWAPIie *)pBuf, &pAssocInd->wapiIE,
15323 sizeof(tSirWAPIie));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015324#endif
15325 /* Additional IE */
Will Huang558f8082017-05-31 16:22:24 +080015326 pBuf = (uint8_t *)&pMsg->addIE;
15327 qdf_mem_copy((tSirAddie *)pBuf, &pAssocInd->addIE,
15328 sizeof(tSirAddie));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015329 /* reassocReq */
Will Huang558f8082017-05-31 16:22:24 +080015330 pBuf = (uint8_t *)&pMsg->reassocReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015331 *pBuf = pAssocInd->reassocReq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015332 /* timingMeasCap */
Will Huang558f8082017-05-31 16:22:24 +080015333 pBuf = (uint8_t *)&pMsg->timingMeasCap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015334 *pBuf = pAssocInd->timingMeasCap;
Will Huang558f8082017-05-31 16:22:24 +080015335 /* chan_info */
15336 pBuf = (uint8_t *)&pMsg->chan_info;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015337 qdf_mem_copy((void *)pBuf, &pAssocInd->chan_info,
Will Huang558f8082017-05-31 16:22:24 +080015338 sizeof(tSirSmeChanInfo));
15339 /* ampdu */
15340 pBuf = (uint8_t *)&pMsg->ampdu;
15341 *((bool *)pBuf) = pAssocInd->ampdu;
15342 /* sgi_enable */
15343 pBuf = (uint8_t *)&pMsg->sgi_enable;
15344 *((bool *)pBuf) = pAssocInd->sgi_enable;
15345 /* tx stbc */
15346 pBuf = (uint8_t *)&pMsg->tx_stbc;
15347 *((bool *)pBuf) = pAssocInd->tx_stbc;
15348 /* ch_width */
15349 pBuf = (uint8_t *)&pMsg->ch_width;
15350 *((tSirMacHTChannelWidth *)pBuf) = pAssocInd->ch_width;
15351 /* mode */
15352 pBuf = (uint8_t *)&pMsg->mode;
15353 *((enum sir_sme_phy_mode *)pBuf) = pAssocInd->mode;
15354 /* rx stbc */
15355 pBuf = (uint8_t *)&pMsg->rx_stbc;
15356 *((bool *)pBuf) = pAssocInd->rx_stbc;
15357 /* max supported idx */
15358 pBuf = (uint8_t *)&pMsg->max_supp_idx;
15359 *pBuf = pAssocInd->max_supp_idx;
15360 /* max extended idx */
15361 pBuf = (uint8_t *)&pMsg->max_ext_idx;
15362 *pBuf = pAssocInd->max_ext_idx;
15363 /* max ht mcs idx */
15364 pBuf = (uint8_t *)&pMsg->max_mcs_idx;
15365 *pBuf = pAssocInd->max_mcs_idx;
15366 /* vht rx mcs map */
15367 pBuf = (uint8_t *)&pMsg->rx_mcs_map;
15368 *pBuf = pAssocInd->rx_mcs_map;
15369 /* vht tx mcs map */
15370 pBuf = (uint8_t *)&pMsg->tx_mcs_map;
15371 *pBuf = pAssocInd->tx_mcs_map;
15372
gaolez7bb1e742017-03-21 16:37:38 +080015373 pBuf = (uint8_t *)&pMsg->ecsa_capable;
15374 *pBuf = pAssocInd->ecsa_capable;
15375
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015376 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
15377 msgQ.bodyptr = pMsg;
15378 msgQ.bodyval = 0;
15379 sys_process_mmh_msg(pMac, &msgQ);
15380 } while (0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015381 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015382}
15383
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015384QDF_STATUS csr_send_mb_set_context_req_msg(tpAniSirGlobal pMac,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080015385 uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015386 struct qdf_mac_addr peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080015387 uint8_t numKeys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015388 tAniEdType edType, bool fUnicast,
15389 tAniKeyDirection aniKeyDirection,
15390 uint8_t keyId, uint8_t keyLength,
15391 uint8_t *pKey, uint8_t paeRole,
15392 uint8_t *pKeyRsc)
15393{
15394 tSirSmeSetContextReq *pMsg;
Abhishek Singh154637a2017-06-19 18:02:11 +053015395 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015396 uint16_t msgLen;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015397 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015398 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015399
15400 sme_debug("keylength: %d Encry type: %d", keyLength, edType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015401 do {
15402 if ((1 != numKeys) && (0 != numKeys))
15403 break;
15404 /*
15405 * All of these fields appear in every SET_CONTEXT message.
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015406 * Below we'll add in the size for each key set. Since we only
15407 * support up to one key, we always allocate memory for 1 key.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015408 */
15409 msgLen = sizeof(struct sSirSmeSetContextReq);
15410
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015411 pMsg = qdf_mem_malloc(msgLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015412 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015413 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015414 pMsg->messageType = eWNI_SME_SETCONTEXT_REQ;
15415 pMsg->length = msgLen;
15416 pMsg->sessionId = (uint8_t) sessionId;
15417 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053015418 qdf_copy_macaddr(&pMsg->peer_macaddr, &peer_macaddr);
15419 qdf_copy_macaddr(&pMsg->bssid,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080015420 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015421
15422 /**
15423 * Set the pMsg->keyMaterial.length field
15424 * (this length is defined as all data that follows the
15425 * edType field in the tSirKeyMaterial keyMaterial; field).
15426 *
15427 * NOTE: This keyMaterial.length contains the length of a
15428 * MAX size key, though the keyLength can be shorter than this
15429 * max size. Is LIM interpreting this ok ?
15430 */
15431 pMsg->keyMaterial.length =
15432 sizeof(pMsg->keyMaterial.numKeys) +
15433 (numKeys * sizeof(pMsg->keyMaterial.key));
15434 pMsg->keyMaterial.edType = edType;
15435 pMsg->keyMaterial.numKeys = numKeys;
15436 pMsg->keyMaterial.key[0].keyId = keyId;
15437 pMsg->keyMaterial.key[0].unicast = fUnicast;
15438 pMsg->keyMaterial.key[0].keyDirection = aniKeyDirection;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015439 qdf_mem_copy(pMsg->keyMaterial.key[0].keyRsc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015440 pKeyRsc, CSR_MAX_RSC_LEN);
15441 /* 0 is Supplicant */
15442 pMsg->keyMaterial.key[0].paeRole = paeRole;
15443 pMsg->keyMaterial.key[0].keyLength = keyLength;
Sreelakshmi Konamki66ddf3a2017-02-28 17:29:43 +053015444 if (keyLength && pKey)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015445 qdf_mem_copy(pMsg->keyMaterial.key[0].key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015446 pKey, keyLength);
Abhishek Singh154637a2017-06-19 18:02:11 +053015447
15448 msg.type = eWNI_SME_SETCONTEXT_REQ;
15449 msg.bodyptr = pMsg;
15450 status = scheduler_post_msg_by_priority(QDF_MODULE_ID_PE, &msg, true);
15451 if (QDF_IS_STATUS_ERROR(status))
15452 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015453 } while (0);
15454 return status;
15455}
15456
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015457QDF_STATUS csr_send_mb_start_bss_req_msg(tpAniSirGlobal pMac, uint32_t
15458 sessionId, eCsrRoamBssType bssType,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015459 tCsrRoamStartBssParams *pParam,
15460 tSirBssDescription *pBssDesc)
15461{
15462 tSirSmeStartBssReq *pMsg;
15463 uint16_t wTmp;
Krunal Soni53993f72016-07-08 18:20:03 -070015464 uint32_t value = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015465 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15466
15467 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015468 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015469 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015470 }
15471
15472 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
15473 pSession->joinFailStatusCode.reasonCode = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015474 pMsg = qdf_mem_malloc(sizeof(tSirSmeStartBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015475 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015476 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015477
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015478 pMsg->messageType = eWNI_SME_START_BSS_REQ;
15479 pMsg->sessionId = sessionId;
15480 pMsg->length = sizeof(tSirSmeStartBssReq);
15481 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053015482 qdf_copy_macaddr(&pMsg->bssid, &pParam->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015483 /* selfMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053015484 qdf_copy_macaddr(&pMsg->self_macaddr, &pSession->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015485 /* beaconInterval */
15486 if (pBssDesc && pBssDesc->beaconInterval)
15487 wTmp = pBssDesc->beaconInterval;
15488 else if (pParam->beaconInterval)
15489 wTmp = pParam->beaconInterval;
15490 else
15491 wTmp = WNI_CFG_BEACON_INTERVAL_STADEF;
15492
Krunal Sonicbda8552016-07-14 19:39:02 -070015493 csr_validate_mcc_beacon_interval(pMac, pParam->operationChn,
15494 &wTmp, sessionId, pParam->bssPersona);
15495 /* Update the beacon Interval */
15496 pParam->beaconInterval = wTmp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015497 pMsg->beaconInterval = wTmp;
15498 pMsg->dot11mode =
15499 csr_translate_to_wni_cfg_dot11_mode(pMac,
15500 pParam->uCfgDot11Mode);
15501#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
15502 pMsg->cc_switch_mode = pMac->roam.configParam.cc_switch_mode;
15503#endif
15504 pMsg->bssType = csr_translate_bsstype_to_mac_type(bssType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015505 qdf_mem_copy(&pMsg->ssId, &pParam->ssId, sizeof(pParam->ssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015506 pMsg->channelId = pParam->operationChn;
15507 /* What should we really do for the cbmode. */
15508 pMsg->cbMode = (ePhyChanBondState) pParam->cbMode;
15509 pMsg->vht_channel_width = pParam->ch_params.ch_width;
15510 pMsg->center_freq_seg0 = pParam->ch_params.center_freq_seg0;
15511 pMsg->center_freq_seg1 = pParam->ch_params.center_freq_seg1;
15512 pMsg->sec_ch_offset = pParam->ch_params.sec_ch_offset;
15513 pMsg->privacy = pParam->privacy;
15514 pMsg->apUapsdEnable = pParam->ApUapsdEnable;
15515 pMsg->ssidHidden = pParam->ssidHidden;
15516 pMsg->fwdWPSPBCProbeReq = (uint8_t) pParam->fwdWPSPBCProbeReq;
15517 pMsg->protEnabled = (uint8_t) pParam->protEnabled;
15518 pMsg->obssProtEnabled = (uint8_t) pParam->obssProtEnabled;
15519 /* set cfg related to protection */
15520 pMsg->ht_capab = pParam->ht_protection;
15521 pMsg->authType = pParam->authType;
15522 pMsg->dtimPeriod = pParam->dtimPeriod;
15523 pMsg->wps_state = pParam->wps_state;
15524 pMsg->isCoalesingInIBSSAllowed = pMac->isCoalesingInIBSSAllowed;
15525 pMsg->bssPersona = pParam->bssPersona;
Krunal Sonia2c0e412017-05-04 14:12:41 +053015526 pMsg->txLdpcIniFeatureEnabled = pMac->roam.configParam.tx_ldpc_enable;
Krunal Soni53993f72016-07-08 18:20:03 -070015527
jiad4a7a33c2017-08-08 15:32:24 +080015528 /*
15529 * If RX LDPC has been disabled for 2.4GHz channels and enabled
15530 * for 5Ghz for STA like persona then here is how to handle
15531 * those cases (by now channel has been decided).
15532 */
15533 if (eSIR_IBSS_MODE == pMsg->bssType ||
15534 !policy_mgr_is_dbs_enable(pMac->psoc))
15535 csr_set_ldpc_exception(pMac, pSession,
15536 pMsg->channelId,
15537 pMac->roam.configParam.rx_ldpc_enable);
15538
Kiran Kumar Lokere26d05482017-05-17 12:47:49 -070015539 qdf_mem_copy(&pMsg->vht_config,
15540 &pSession->vht_config,
15541 sizeof(pSession->vht_config));
15542 qdf_mem_copy(&pMsg->htConfig,
15543 &pSession->htConfig,
15544 sizeof(tSirHTConfig));
15545
Krunal Soni53993f72016-07-08 18:20:03 -070015546 if (wlan_cfg_get_int(pMac, WNI_CFG_VHT_SU_BEAMFORMEE_CAP, &value)
15547 != eSIR_SUCCESS)
15548 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015549 "could not get SU beam formee capability");
Krunal Soni53993f72016-07-08 18:20:03 -070015550 pMsg->vht_config.su_beam_formee =
15551 (uint8_t)value &&
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -080015552 (uint8_t)pMac->roam.configParam.enable_txbf_sap_mode;
Krunal Soni53993f72016-07-08 18:20:03 -070015553 if (wlan_cfg_get_int(pMac,
15554 WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED,
15555 &value) != eSIR_SUCCESS)
15556 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015557 ("Failed to get CSN beamformee capability"));
Krunal Soni53993f72016-07-08 18:20:03 -070015558 pMsg->vht_config.csnof_beamformer_antSup = (uint8_t)value;
Kiran Kumar Lokere26d05482017-05-17 12:47:49 -070015559 pMsg->vht_config.mu_beam_formee = 0;
Krunal Soni53993f72016-07-08 18:20:03 -070015560
Kiran Kumar Lokere26d05482017-05-17 12:47:49 -070015561 sme_debug("ht capability 0x%x VHT capability 0x%x",
15562 (uint32_t)(*(uint32_t *) &pMsg->htConfig),
15563 (uint32_t)(*(uint32_t *) &pMsg->vht_config));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015564#ifdef WLAN_FEATURE_11W
15565 pMsg->pmfCapable = pParam->mfpCapable;
15566 pMsg->pmfRequired = pParam->mfpRequired;
15567#endif
15568
15569 if (pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015570 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015571 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015572 }
15573 pMsg->rsnIE.length = pParam->nRSNIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015574 qdf_mem_copy(pMsg->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015575 pParam->pRSNIE,
15576 pParam->nRSNIELength);
15577 pMsg->nwType = (tSirNwType)pParam->sirNwType;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015578 qdf_mem_copy(&pMsg->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015579 &pParam->operationalRateSet,
15580 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015581 qdf_mem_copy(&pMsg->extendedRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015582 &pParam->extendedRateSet,
15583 sizeof(tSirMacRateSet));
jiad4a7a33c2017-08-08 15:32:24 +080015584
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -080015585 if (IS_DOT11_MODE_HE(pMsg->dot11mode))
15586 csr_start_bss_copy_he_cap(pMsg, pSession);
15587
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015588 qdf_mem_copy(&pMsg->addIeParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015589 &pParam->addIeParams,
15590 sizeof(pParam->addIeParams));
15591 pMsg->obssEnabled = pMac->roam.configParam.obssEnabled;
15592 pMsg->sap_dot11mc = pParam->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +053015593 pMsg->vendor_vht_sap =
15594 pMac->roam.configParam.vendor_vht_sap;
Arif Hussain671a1902017-03-17 09:08:32 -070015595 pMsg->cac_duration_ms = pParam->cac_duration_ms;
15596 pMsg->dfs_regdomain = pParam->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015597
Rajeev Kumard138ac52017-01-30 18:38:37 -080015598 return umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015599}
15600
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015601QDF_STATUS csr_send_mb_stop_bss_req_msg(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015602{
15603 tSirSmeStopBssReq *pMsg;
15604 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15605
15606 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015607 sme_err("session %d not found", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015608 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015609 }
15610
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015611 pMsg = qdf_mem_malloc(sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015612 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015613 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015614 pMsg->messageType = eWNI_SME_STOP_BSS_REQ;
15615 pMsg->sessionId = sessionId;
15616 pMsg->length = sizeof(tSirSmeStopBssReq);
15617 pMsg->transactionId = 0;
15618 pMsg->reasonCode = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053015619 qdf_copy_macaddr(&pMsg->bssid, &pSession->connectedProfile.bssid);
Rajeev Kumard138ac52017-01-30 18:38:37 -080015620 return umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015621}
15622
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015623QDF_STATUS csr_reassoc(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015624 tCsrRoamModifyProfileFields *pModProfileFields,
15625 uint32_t *pRoamId, bool fForce)
15626{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015627 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015628 uint32_t roamId = 0;
15629 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015630
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015631 if ((csr_is_conn_state_connected(pMac, sessionId)) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015632 (fForce || (qdf_mem_cmp(&pModProfileFields,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015633 &pSession->connectedProfile.
15634 modifyProfileFields,
15635 sizeof(tCsrRoamModifyProfileFields))))) {
15636 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015637 if (pRoamId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015638 *pRoamId = roamId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015639
15640 status =
15641 csr_roam_issue_reassoc(pMac, sessionId, NULL,
15642 pModProfileFields,
15643 eCsrSmeIssuedReassocToSameAP,
15644 roamId, false);
15645 }
15646 return status;
15647}
15648
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015649static QDF_STATUS csr_roam_session_opened(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015650 uint32_t sessionId)
15651{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015652 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015653 tCsrRoamInfo roamInfo;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053015654
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015655 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015656 status = csr_roam_call_callback(pMac, sessionId, &roamInfo, 0,
15657 eCSR_ROAM_SESSION_OPENED,
15658 eCSR_ROAM_RESULT_NONE);
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -070015659
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015660 return status;
15661}
15662
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015663QDF_STATUS csr_process_add_sta_session_rsp(tpAniSirGlobal pMac, uint8_t *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015664{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015665 struct add_sta_self_params *rsp;
15666 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015667 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015668
15669 if (pMsg == NULL) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015670 sme_err("in %s msg ptr is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015671 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015672 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015673 rsp = (struct add_sta_self_params *) pMsg;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015674 sme_debug("Add Sta self rsp status = %d", rsp->status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015675
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015676 if (QDF_STATUS_SUCCESS == rsp->status &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015677 (WMI_VDEV_TYPE_STA == rsp->type ||
15678 (WMI_VDEV_TYPE_AP == rsp->type &&
15679 WMI_UNIFIED_VDEV_SUBTYPE_P2P_DEVICE == rsp->sub_type))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015680 sme_debug("send SET IE msg to PE");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015681 msg = qdf_mem_malloc(sizeof(*msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015682 if (NULL == msg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015683 sme_err("Memory allocation failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015684 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015685 }
15686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015687 msg->msg_type = eWNI_SME_SET_IE_REQ;
15688 msg->session_id = rsp->session_id;
15689 msg->length = sizeof(*msg);
Rajeev Kumard138ac52017-01-30 18:38:37 -080015690 status = umac_send_mb_message_to_mac(msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015691 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015692 sme_err("Failed to send down the set IE req ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015693 }
15694
Krunal Soni985b8132017-02-10 18:49:08 -080015695 csr_roam_session_opened(pMac, rsp->session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015696 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015697}
15698
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070015699/**
15700 * csr_get_vdev_type_nss() - gets the nss value based on vdev type
15701 * @mac_ctx: Pointer to Global MAC structure
15702 * @dev_mode: current device operating mode.
15703 * @nss2g: Pointer to the 2G Nss parameter.
15704 * @nss5g: Pointer to the 5G Nss parameter.
15705 *
15706 * Fills the 2G and 5G Nss values based on device mode.
15707 *
15708 * Return: None
15709 */
15710void csr_get_vdev_type_nss(tpAniSirGlobal mac_ctx,
15711 enum tQDF_ADAPTER_MODE dev_mode,
15712 uint8_t *nss_2g, uint8_t *nss_5g)
15713{
15714 switch (dev_mode) {
15715 case QDF_STA_MODE:
15716 *nss_2g = mac_ctx->vdev_type_nss_2g.sta;
15717 *nss_5g = mac_ctx->vdev_type_nss_5g.sta;
15718 break;
15719 case QDF_SAP_MODE:
15720 *nss_2g = mac_ctx->vdev_type_nss_2g.sap;
15721 *nss_5g = mac_ctx->vdev_type_nss_5g.sap;
15722 break;
15723 case QDF_P2P_CLIENT_MODE:
15724 *nss_2g = mac_ctx->vdev_type_nss_2g.p2p_cli;
15725 *nss_5g = mac_ctx->vdev_type_nss_5g.p2p_cli;
15726 break;
15727 case QDF_P2P_GO_MODE:
15728 *nss_2g = mac_ctx->vdev_type_nss_2g.p2p_go;
15729 *nss_5g = mac_ctx->vdev_type_nss_5g.p2p_go;
15730 break;
15731 case QDF_P2P_DEVICE_MODE:
15732 *nss_2g = mac_ctx->vdev_type_nss_2g.p2p_dev;
15733 *nss_5g = mac_ctx->vdev_type_nss_5g.p2p_dev;
15734 break;
15735 case QDF_IBSS_MODE:
15736 *nss_2g = mac_ctx->vdev_type_nss_2g.ibss;
15737 *nss_5g = mac_ctx->vdev_type_nss_5g.ibss;
15738 break;
15739 case QDF_OCB_MODE:
15740 *nss_2g = mac_ctx->vdev_type_nss_2g.ocb;
15741 *nss_5g = mac_ctx->vdev_type_nss_5g.ocb;
15742 break;
15743 default:
15744 *nss_2g = 1;
15745 *nss_5g = 1;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015746 sme_err("Unknown device mode");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070015747 break;
15748 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015749 sme_debug("mode - %d: nss_2g - %d, 5g - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070015750 dev_mode, *nss_2g, *nss_5g);
15751}
Jeff Johnson29e2ca12016-10-14 12:50:38 -070015752
15753static
15754QDF_STATUS csr_issue_add_sta_for_session_req(tpAniSirGlobal pMac,
15755 uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015756 tSirMacAddr sessionMacAddr,
15757 uint32_t type, uint32_t subType)
15758{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015759 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015760 struct add_sta_self_params *add_sta_self_req;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070015761 uint8_t nss_2g;
15762 uint8_t nss_5g;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070015763 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015764
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015765 add_sta_self_req = qdf_mem_malloc(sizeof(struct add_sta_self_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015766 if (NULL == add_sta_self_req) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015767 sme_err("Unable to allocate memory for tAddSelfStaParams");
Dustin Brownd28772b2017-03-17 14:16:07 -070015768 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015769 }
15770
Krunal Soni985b8132017-02-10 18:49:08 -080015771 csr_get_vdev_type_nss(pMac, pMac->sme.currDeviceMode,
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070015772 &nss_2g, &nss_5g);
Krunal Soni985b8132017-02-10 18:49:08 -080015773 qdf_mem_copy(add_sta_self_req->self_mac_addr, sessionMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015774 sizeof(tSirMacAddr));
Krunal Soni985b8132017-02-10 18:49:08 -080015775 add_sta_self_req->curr_device_mode = pMac->sme.currDeviceMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015776 add_sta_self_req->session_id = sessionId;
Krunal Soni985b8132017-02-10 18:49:08 -080015777 add_sta_self_req->type = type;
15778 add_sta_self_req->sub_type = subType;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -070015779 add_sta_self_req->nss_2g = nss_2g;
15780 add_sta_self_req->nss_5g = nss_5g;
Padma, Santhosh Kumara7119672016-08-16 16:05:14 +053015781 add_sta_self_req->tx_aggregation_size =
15782 pMac->roam.configParam.tx_aggregation_size;
15783 add_sta_self_req->rx_aggregation_size =
15784 pMac->roam.configParam.rx_aggregation_size;
Selvaraj, Sridhar4f684bb2017-01-19 15:59:23 +053015785 add_sta_self_req->enable_bcast_probe_rsp =
15786 pMac->roam.configParam.enable_bcast_probe_rsp;
Selvaraj, Sridhar97ce6582017-01-20 17:06:34 +053015787 add_sta_self_req->fils_max_chan_guard_time =
15788 pMac->roam.configParam.fils_max_chan_guard_time;
Naveen Rawat2b6e3c92017-03-20 13:59:07 -070015789 add_sta_self_req->pkt_err_disconn_th =
15790 pMac->roam.configParam.pkt_err_disconn_th;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015791 msg.type = WMA_ADD_STA_SELF_REQ;
15792 msg.reserved = 0;
15793 msg.bodyptr = add_sta_self_req;
15794 msg.bodyval = 0;
15795
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015796 sme_debug(
15797 "Send WMA_ADD_STA_SELF_REQ for selfMac=" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015798 MAC_ADDR_ARRAY(add_sta_self_req->self_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015799 status = wma_post_ctrl_msg(pMac, &msg);
15800
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015801 if (status != QDF_STATUS_SUCCESS) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015802 sme_err("wma_post_ctrl_msg failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015803 qdf_mem_free(add_sta_self_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015804 add_sta_self_req = NULL;
15805 }
15806 return status;
15807}
15808
Sandeep Puligillaba71da42016-10-04 17:36:32 -070015809QDF_STATUS csr_roam_open_session(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015810 csr_roam_completeCallback callback,
15811 void *pContext,
Dustin Brownd28772b2017-03-17 14:16:07 -070015812 uint8_t *pSelfMacAddr,
15813 uint8_t session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015814 uint32_t type, uint32_t subType)
15815{
Dustin Brownd28772b2017-03-17 14:16:07 -070015816 QDF_STATUS status;
15817 uint32_t existing_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015818 union {
15819 uint16_t nCfgValue16;
15820 tSirMacHTCapabilityInfo htCapInfo;
15821 } uHTCapabilityInfo;
Dustin Brownd28772b2017-03-17 14:16:07 -070015822 uint32_t nCfgValue;
Sandeep Puligillaba71da42016-10-04 17:36:32 -070015823 tCsrRoamSession *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015824
Dustin Brownd28772b2017-03-17 14:16:07 -070015825 /* check to see if the mac address already belongs to a session */
15826 status = csr_roam_get_session_id_from_bssid(mac_ctx,
15827 (struct qdf_mac_addr *)pSelfMacAddr,
15828 &existing_session_id);
15829 if (QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015830 sme_err("Session %d exists with mac address "
15831 MAC_ADDRESS_STR,
Dustin Brownd28772b2017-03-17 14:16:07 -070015832 existing_session_id, MAC_ADDR_ARRAY(pSelfMacAddr));
Sandeep Puligillaba71da42016-10-04 17:36:32 -070015833 return QDF_STATUS_E_FAILURE;
15834 }
15835
Dustin Brownd28772b2017-03-17 14:16:07 -070015836 /* attempt to retrieve session for Id */
15837 session = CSR_GET_SESSION(mac_ctx, session_id);
15838 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015839 sme_err("Session does not exist for interface %d",
Dustin Brownd28772b2017-03-17 14:16:07 -070015840 session_id);
15841 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015842 }
Dustin Brownd28772b2017-03-17 14:16:07 -070015843
15844 /* check to see if the session is already active */
15845 if (session->sessionActive) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015846 sme_err("Cannot re-open active session with Id %d",
Dustin Brownd28772b2017-03-17 14:16:07 -070015847 session_id);
15848 return QDF_STATUS_E_FAILURE;
15849 }
15850
15851 session->sessionActive = true;
15852 session->sessionId = session_id;
15853
15854 /* Initialize FT related data structures only in STA mode */
15855 sme_ft_open(mac_ctx, session->sessionId);
15856
15857 session->callback = callback;
15858 session->pContext = pContext;
15859 qdf_mem_copy(&session->selfMacAddr, pSelfMacAddr,
15860 sizeof(struct qdf_mac_addr));
15861 status = qdf_mc_timer_init(&session->hTimerRoaming,
15862 QDF_TIMER_TYPE_SW,
15863 csr_roam_roaming_timer_handler,
15864 &session->roamingTimerInfo);
15865 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015866 sme_err("cannot allocate memory for Roaming timer");
Dustin Brownd28772b2017-03-17 14:16:07 -070015867 return status;
15868 }
15869
15870 status = qdf_mc_timer_init(&session->roaming_offload_timer,
15871 QDF_TIMER_TYPE_SW,
15872 csr_roam_roaming_offload_timeout_handler,
15873 &session->roamingTimerInfo);
15874 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015875 sme_err("mem fail for roaming timer");
Dustin Brownd28772b2017-03-17 14:16:07 -070015876 return status;
15877 }
15878
15879 /* get the HT capability info */
15880 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_HT_CAP_INFO, &nCfgValue) !=
15881 eSIR_SUCCESS) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015882 sme_err("could not get HT capability info");
Dustin Brownd28772b2017-03-17 14:16:07 -070015883 return QDF_STATUS_SUCCESS;
15884 }
15885
15886 uHTCapabilityInfo.nCfgValue16 = 0xFFFF & nCfgValue;
15887 session->htConfig.ht_rx_ldpc = uHTCapabilityInfo.htCapInfo.advCodingCap;
15888 session->htConfig.ht_tx_stbc = uHTCapabilityInfo.htCapInfo.txSTBC;
15889 session->htConfig.ht_rx_stbc = uHTCapabilityInfo.htCapInfo.rxSTBC;
15890 session->htConfig.ht_sgi20 = uHTCapabilityInfo.htCapInfo.shortGI20MHz;
15891 session->htConfig.ht_sgi40 = uHTCapabilityInfo.htCapInfo.shortGI40MHz;
15892
15893#ifdef FEATURE_WLAN_BTAMP_UT_RF
15894 status = qdf_mc_timer_init(&session->hTimerJoinRetry, QDF_TIMER_TYPE_SW,
15895 csr_roam_join_retry_timer_handler,
15896 &session->joinRetryTimerInfo);
15897 if (QDF_IS_STATUS_ERROR(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015898 sme_err("cannot allocate memory for join retry timer");
Dustin Brownd28772b2017-03-17 14:16:07 -070015899 return status;
15900 }
15901#endif /* FEATURE_WLAN_BTAMP_UT_RF */
15902
15903 nCfgValue = 0;
15904 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_MAX_MPDU_LENGTH, &nCfgValue);
15905 session->vht_config.max_mpdu_len = nCfgValue;
15906
15907 nCfgValue = 0;
15908 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET,
15909 &nCfgValue);
15910 session->vht_config.supported_channel_widthset = nCfgValue;
15911
15912 nCfgValue = 0;
15913 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_LDPC_CODING_CAP, &nCfgValue);
15914 session->vht_config.ldpc_coding = nCfgValue;
15915
15916 nCfgValue = 0;
15917 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SHORT_GI_80MHZ, &nCfgValue);
15918 session->vht_config.shortgi80 = nCfgValue;
15919
15920 nCfgValue = 0;
15921 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ,
15922 &nCfgValue);
15923 session->vht_config.shortgi160and80plus80 = nCfgValue;
15924
15925 nCfgValue = 0;
15926 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_TXSTBC, &nCfgValue);
15927 session->vht_config.tx_stbc = nCfgValue;
15928
15929 nCfgValue = 0;
15930 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_RXSTBC, &nCfgValue);
15931 session->vht_config.rx_stbc = nCfgValue;
15932
15933 nCfgValue = 0;
15934 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMER_CAP, &nCfgValue);
15935 session->vht_config.su_beam_former = nCfgValue;
15936
15937 nCfgValue = 0;
15938 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP, &nCfgValue);
15939 session->vht_config.su_beam_formee = nCfgValue;
15940
15941 nCfgValue = 0;
15942 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED,
15943 &nCfgValue);
15944 session->vht_config.csnof_beamformer_antSup = nCfgValue;
15945
15946 nCfgValue = 0;
15947 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_NUM_SOUNDING_DIMENSIONS,
15948 &nCfgValue);
15949 session->vht_config.num_soundingdim = nCfgValue;
15950
15951 nCfgValue = 0;
15952 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_MU_BEAMFORMER_CAP, &nCfgValue);
15953 session->vht_config.mu_beam_former = nCfgValue;
15954
15955 nCfgValue = 0;
15956 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, &nCfgValue);
15957 session->vht_config.mu_beam_formee = nCfgValue;
15958
15959 nCfgValue = 0;
15960 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_TXOP_PS, &nCfgValue);
15961 session->vht_config.vht_txops = nCfgValue;
15962
15963 nCfgValue = 0;
15964 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_HTC_VHTC_CAP, &nCfgValue);
15965 session->vht_config.htc_vhtcap = nCfgValue;
15966
15967 nCfgValue = 0;
15968 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_RX_ANT_PATTERN, &nCfgValue);
15969 session->vht_config.rx_antpattern = nCfgValue;
15970
15971 nCfgValue = 0;
15972 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_TX_ANT_PATTERN, &nCfgValue);
15973 session->vht_config.tx_antpattern = nCfgValue;
15974
15975 nCfgValue = 0;
15976 wlan_cfg_get_int(mac_ctx, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, &nCfgValue);
15977 session->vht_config.max_ampdu_lenexp = nCfgValue;
15978
15979 csr_update_session_he_cap(mac_ctx, session);
15980
15981 return csr_issue_add_sta_for_session_req(mac_ctx, session_id,
15982 pSelfMacAddr, type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015983}
15984
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015985QDF_STATUS csr_process_del_sta_session_rsp(tpAniSirGlobal pMac, uint8_t *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015986{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015987 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015988 struct del_sta_self_params *rsp;
15989 uint8_t sessionId;
15990
15991 if (pMsg == NULL) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015992 sme_err("msg ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015993 return status;
15994 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015995 rsp = (struct del_sta_self_params *) pMsg;
Krunal Soni985b8132017-02-10 18:49:08 -080015996 sessionId = rsp->session_id;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070015997 sme_debug("Del Sta rsp status = %d", rsp->status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015998 /* This session is done. */
15999 csr_cleanup_session(pMac, sessionId);
Krunal Soni985b8132017-02-10 18:49:08 -080016000 if (rsp->sme_callback) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016001 status = sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016002 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016003 sme_debug("Failed to Release Lock");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016004 else {
Krunal Soni985b8132017-02-10 18:49:08 -080016005 rsp->sme_callback(rsp->sme_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016006 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016007 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016008 sme_debug("Failed to get Lock");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016009 return status;
16010 }
16011 }
16012 }
Krunal Soni985b8132017-02-10 18:49:08 -080016013
16014 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016015}
16016
16017
Jeff Johnson29e2ca12016-10-14 12:50:38 -070016018static QDF_STATUS
16019csr_issue_del_sta_for_session_req(tpAniSirGlobal pMac, uint32_t sessionId,
16020 tSirMacAddr sessionMacAddr,
16021 csr_roamSessionCloseCallback callback,
16022 void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016023{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016024 struct del_sta_self_params *del_sta_self_req;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070016025 struct scheduler_msg msg = {0};
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070016026 tSirRetStatus status;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016027
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016028 del_sta_self_req = qdf_mem_malloc(sizeof(struct del_sta_self_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016029 if (NULL == del_sta_self_req) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016030 sme_err(" mem alloc failed for tDelStaSelfParams");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016031 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016032 }
16033
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016034 qdf_mem_copy(del_sta_self_req->self_mac_addr,
Krunal Soni985b8132017-02-10 18:49:08 -080016035 sessionMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016036
Krunal Soni985b8132017-02-10 18:49:08 -080016037 del_sta_self_req->session_id = sessionId;
16038 del_sta_self_req->sme_callback = callback;
16039 del_sta_self_req->sme_ctx = pContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016040 msg.type = WMA_DEL_STA_SELF_REQ;
16041 msg.reserved = 0;
16042 msg.bodyptr = del_sta_self_req;
16043 msg.bodyval = 0;
16044
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016045 sme_debug("sending WMA_DEL_STA_SELF_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016046 status = wma_post_ctrl_msg(pMac, &msg);
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070016047 if (status != eSIR_SUCCESS) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016048 sme_err("wma_post_ctrl_msg failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016049 qdf_mem_free(del_sta_self_req);
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070016050 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016051 }
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070016052 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016053}
16054
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016055void csr_cleanup_session(tpAniSirGlobal pMac, uint32_t sessionId)
16056{
16057 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
16058 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16059
16060 csr_roam_stop(pMac, sessionId);
16061
16062 /* Clean up FT related data structures */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016063 sme_ft_close(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016064 csr_free_connect_bss_desc(pMac, sessionId);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -080016065 csr_roam_free_connect_profile(&pSession->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016066 csr_roam_free_connected_info(pMac, &pSession->connectedInfo);
Anurag Chouhan210db072016-02-22 18:42:15 +053016067 qdf_mc_timer_destroy(&pSession->hTimerRoaming);
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070016068 qdf_mc_timer_destroy(&pSession->roaming_offload_timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016069#ifdef FEATURE_WLAN_BTAMP_UT_RF
Anurag Chouhan210db072016-02-22 18:42:15 +053016070 qdf_mc_timer_destroy(&pSession->hTimerJoinRetry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016071#endif
Krunal Soni72dba662017-02-15 20:13:17 -080016072 purge_sme_session_pending_cmd_list(pMac, sessionId);
Krunal Soni81f068c2017-02-23 19:51:55 -080016073 purge_sme_session_pending_scan_cmd_list(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016074 csr_init_session(pMac, sessionId);
16075 }
16076}
16077
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016078QDF_STATUS csr_roam_close_session(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016079 bool fSync,
16080 csr_roamSessionCloseCallback callback,
16081 void *pContext)
16082{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016083 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -070016084 tCsrRoamSession *pSession;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016085
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -070016086 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
16087 sme_err("session %d not found", sessionId);
16088 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016089 }
Kiran Kumar Lokere3beeb952017-05-02 18:40:24 -070016090
16091 pSession = CSR_GET_SESSION(pMac, sessionId);
16092 /* Vdev going down stop roaming */
16093 pSession->fCancelRoaming = true;
16094 if (fSync) {
16095 csr_cleanup_session(pMac, sessionId);
16096 return status;
16097 }
16098
16099 purge_sme_session_pending_cmd_list(pMac, sessionId);
16100 purge_sme_session_active_cmd_list(pMac, sessionId);
16101 purge_sme_session_pending_scan_cmd_list(pMac,
16102 sessionId);
16103 status = csr_issue_del_sta_for_session_req(pMac,
16104 sessionId,
16105 pSession->selfMacAddr.bytes,
16106 callback, pContext);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016107 return status;
16108}
16109
16110static void csr_init_session(tpAniSirGlobal pMac, uint32_t sessionId)
16111{
16112 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16113
16114 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016115 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016116 return;
16117 }
16118
16119 pSession->sessionActive = false;
16120 pSession->sessionId = CSR_SESSION_ID_INVALID;
16121 pSession->callback = NULL;
16122 pSession->pContext = NULL;
16123 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
16124 csr_free_roam_profile(pMac, sessionId);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -080016125 csr_roam_free_connect_profile(&pSession->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016126 csr_roam_free_connected_info(pMac, &pSession->connectedInfo);
16127 csr_free_connect_bss_desc(pMac, sessionId);
16128 csr_scan_enable(pMac);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016129 qdf_mem_set(&pSession->selfMacAddr, sizeof(struct qdf_mac_addr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016130 if (pSession->pWpaRsnReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016131 qdf_mem_free(pSession->pWpaRsnReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016132 pSession->pWpaRsnReqIE = NULL;
16133 }
16134 pSession->nWpaRsnReqIeLength = 0;
16135 if (pSession->pWpaRsnRspIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016136 qdf_mem_free(pSession->pWpaRsnRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016137 pSession->pWpaRsnRspIE = NULL;
16138 }
16139 pSession->nWpaRsnRspIeLength = 0;
16140#ifdef FEATURE_WLAN_WAPI
16141 if (pSession->pWapiReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016142 qdf_mem_free(pSession->pWapiReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016143 pSession->pWapiReqIE = NULL;
16144 }
16145 pSession->nWapiReqIeLength = 0;
16146 if (pSession->pWapiRspIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016147 qdf_mem_free(pSession->pWapiRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016148 pSession->pWapiRspIE = NULL;
16149 }
16150 pSession->nWapiRspIeLength = 0;
16151#endif /* FEATURE_WLAN_WAPI */
16152 if (pSession->pAddIEScan) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016153 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016154 pSession->pAddIEScan = NULL;
16155 }
16156 pSession->nAddIEScanLength = 0;
16157 if (pSession->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016158 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016159 pSession->pAddIEAssoc = NULL;
16160 }
16161 pSession->nAddIEAssocLength = 0;
16162}
16163
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016164QDF_STATUS csr_roam_get_session_id_from_bssid(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016165 struct qdf_mac_addr *bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016166 uint32_t *pSessionId)
16167{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016168 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016169 uint32_t i;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016170
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016171 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
16172 if (CSR_IS_SESSION_VALID(pMac, i)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053016173 if (qdf_is_macaddr_equal(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016174 &pMac->roam.roamSession[i].connectedProfile.
16175 bssid)) {
16176 /* Found it */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016177 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016178 *pSessionId = i;
16179 break;
16180 }
16181 }
16182 }
16183 return status;
16184}
16185
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016186/* This function assumes that we only support one IBSS session.
16187 * We cannot use BSSID to identify session because for IBSS,
16188 * the bssid changes.
16189 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016190static uint32_t csr_find_ibss_session(tpAniSirGlobal pMac)
16191{
16192 uint32_t i, nRet = CSR_SESSION_ID_INVALID;
16193 tCsrRoamSession *pSession;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016194
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016195 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
16196 if (CSR_IS_SESSION_VALID(pMac, i)) {
16197 pSession = CSR_GET_SESSION(pMac, i);
16198 if (pSession->pCurRoamProfile
16199 &&
16200 (csr_is_bss_type_ibss
16201 (pSession->connectedProfile.BSSType))) {
16202 /* Found it */
16203 nRet = i;
16204 break;
16205 }
16206 }
16207 }
16208 return nRet;
16209}
16210
Anurag Chouhan6d760662016-02-20 16:05:43 +053016211static void csr_roam_link_up(tpAniSirGlobal pMac, struct qdf_mac_addr bssid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016212{
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080016213 uint32_t sessionId = 0;
16214
16215 /*
16216 * Update the current BSS info in ho control block based on connected
16217 * profile info from pmac global structure
16218 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016219
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016220 sme_debug(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016221 " csr_roam_link_up: WLAN link UP with AP= " MAC_ADDRESS_STR,
16222 MAC_ADDR_ARRAY(bssid.bytes));
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080016223 /* Check for user misconfig of RSSI trigger threshold */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016224 pMac->roam.configParam.vccRssiThreshold =
16225 (0 == pMac->roam.configParam.vccRssiThreshold) ?
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080016226 CSR_VCC_RSSI_THRESHOLD :
16227 pMac->roam.configParam.vccRssiThreshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016228 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080016229 /* Check for user misconfig of UL MAC Loss trigger threshold */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016230 pMac->roam.configParam.vccUlMacLossThreshold =
16231 (0 == pMac->roam.configParam.vccUlMacLossThreshold) ?
16232 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.
16233 vccUlMacLossThreshold;
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080016234 /* Indicate the neighbor roal algorithm about the connect indication */
16235 csr_roam_get_session_id_from_bssid(pMac, &bssid,
16236 &sessionId);
16237 csr_neighbor_roam_indicate_connect(pMac, sessionId,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016238 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016239}
16240
16241static void csr_roam_link_down(tpAniSirGlobal pMac, uint32_t sessionId)
16242{
16243 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16244
16245 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016246 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016247 return;
16248 }
16249 /* Only to handle the case for Handover on infra link */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016250 if (eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016251 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016252 /*
16253 * Incase of station mode, immediately stop data transmission whenever
16254 * link down is detected.
16255 */
16256 if (csr_roam_is_sta_mode(pMac, sessionId)
16257 && !CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -080016258 && !csr_roam_is11r_assoc(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016259 sme_debug("Inform Link lost for session %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016260 sessionId);
16261 csr_roam_call_callback(pMac, sessionId, NULL, 0,
16262 eCSR_ROAM_LOSTLINK,
16263 eCSR_ROAM_RESULT_LOSTLINK);
16264 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016265 /* deregister the clients requesting stats from PE/TL & also stop the
16266 * corresponding timers
16267 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016268 csr_roam_dereg_statistics_req(pMac);
16269 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016270 /* Indicate the neighbor roal algorithm about the disconnect
16271 * indication
16272 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016273 csr_neighbor_roam_indicate_disconnect(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016274
16275 /* Remove this code once SLM_Sessionization is supported */
16276 /* BMPS_WORKAROUND_NOT_NEEDED */
16277 if (!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
16278 csr_is_infra_ap_started(pMac) &&
16279 pMac->roam.configParam.doBMPSWorkaround) {
16280 pMac->roam.configParam.doBMPSWorkaround = 0;
16281 }
16282
16283}
16284
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016285QDF_STATUS csr_send_mb_stats_req_msg(tpAniSirGlobal pMac, uint32_t statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016286 uint8_t staId, uint8_t sessionId)
16287{
16288 tAniGetPEStatsReq *pMsg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016289 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016290
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016291 pMsg = qdf_mem_malloc(sizeof(tAniGetPEStatsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016292 if (NULL == pMsg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016293 sme_err("Failed to allocate mem for stats req ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016294 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016295 }
16296 /* need to initiate a stats request to PE */
16297 pMsg->msgType = eWNI_SME_GET_STATISTICS_REQ;
16298 pMsg->msgLen = (uint16_t) sizeof(tAniGetPEStatsReq);
16299 pMsg->staId = staId;
16300 pMsg->statsMask = statsMask;
16301 pMsg->sessionId = sessionId;
Rajeev Kumard138ac52017-01-30 18:38:37 -080016302 status = umac_send_mb_message_to_mac(pMsg);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016303 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016304 sme_debug("Failed to send down the stats req ");
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016305
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016306 return status;
16307}
16308
16309/**
16310 * csr_update_stats() - updates correct stats struct in mac_ctx
16311 * @mac: mac global context
16312 * @stats_type: stats type
16313 * @sme_stats_rsp: stats rsp msg packet
16314 * @stats: input stats data buffer to fill in mac_ctx struct
16315 * @length: out param - stats length
16316 *
16317 * This function fills corresponding stats struct in mac_cts based on stats type
16318 * passed
16319 *
16320 * Return: void
16321 */
16322static void
16323csr_update_stats(tpAniSirGlobal mac, uint8_t stats_type,
16324 tAniGetPEStatsRsp *sme_stats_rsp,
16325 uint8_t **stats, uint32_t *length)
16326{
16327 switch (stats_type) {
16328 case eCsrSummaryStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016329 sme_debug("summary stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016330 qdf_mem_copy((uint8_t *) &mac->roam.summaryStatsInfo, *stats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016331 sizeof(tCsrSummaryStatsInfo));
16332 *stats += sizeof(tCsrSummaryStatsInfo);
16333 *length -= sizeof(tCsrSummaryStatsInfo);
16334 break;
16335 case eCsrGlobalClassAStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016336 sme_debug("ClassA stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016337 qdf_mem_copy((uint8_t *) &mac->roam.classAStatsInfo, *stats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016338 sizeof(tCsrGlobalClassAStatsInfo));
16339 *stats += sizeof(tCsrGlobalClassAStatsInfo);
16340 *length -= sizeof(tCsrGlobalClassAStatsInfo);
16341 break;
Himanshu Agarwal37e42412016-07-21 14:35:09 +053016342 case csr_per_chain_rssi_stats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016343 sme_debug("csrRoamStatsRspProcessor:Per Chain RSSI stats");
Himanshu Agarwal37e42412016-07-21 14:35:09 +053016344 qdf_mem_copy((uint8_t *)&mac->roam.per_chain_rssi_stats,
16345 *stats, sizeof(struct csr_per_chain_rssi_stats_info));
16346 *stats += sizeof(struct csr_per_chain_rssi_stats_info);
16347 *length -= sizeof(struct csr_per_chain_rssi_stats_info);
16348 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016349 default:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016350 sme_warn("unknown stats type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016351 break;
16352 }
16353}
16354
16355/**
16356 * csr_roam_stats_rsp_processor() - processes stats rsp msg
16357 * @pMac mac global context
16358 * @pSirMsg: incoming message
16359 *
16360 * Return: void
16361 */
16362void csr_roam_stats_rsp_processor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
16363{
16364 tAniGetPEStatsRsp *pSmeStatsRsp;
16365 tListElem *pEntry = NULL;
16366 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16367 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
16368 uint32_t tempMask = 0;
16369 uint8_t counter = 0;
16370 uint8_t *pStats = NULL;
16371 uint32_t length = 0;
16372 void *p_cds_gctx;
16373 int8_t rssi = 0, snr = 0;
16374 uint32_t *pRssi = NULL, *pSnr = NULL;
16375 uint32_t linkCapacity;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016376
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016377 pSmeStatsRsp = (tAniGetPEStatsRsp *) pSirMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016378 if (pSmeStatsRsp->rc) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016379 sme_warn("stats rsp from PE shows failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016380 goto post_update;
16381 }
16382 tempMask = pSmeStatsRsp->statsMask;
16383 pStats = ((uint8_t *) &pSmeStatsRsp->statsMask) +
16384 sizeof(pSmeStatsRsp->statsMask);
16385 /*
16386 * subtract all statistics from this length, and after processing the
16387 * entire 'stat' part of the message, if the length is not zero, then
16388 * rssi is piggy packed in this 'stats' message.
16389 */
16390 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
16391 /* new stats info from PE, fill up the stats strucutres in PMAC */
16392 while (tempMask) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016393 if (tempMask & 1)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016394 csr_update_stats(pMac, counter, pSmeStatsRsp,
16395 &pStats, &length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016396 tempMask >>= 1;
16397 counter++;
16398 }
16399 p_cds_gctx = cds_get_global_context();
16400 if (length != 0) {
16401 pRssi = (uint32_t *) pStats;
16402 rssi = (int8_t) *pRssi;
16403 pStats += sizeof(uint32_t);
16404 length -= sizeof(uint32_t);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016405 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016406 /* If riva is not sending rssi, continue to use the hack */
16407 rssi = RSSI_HACK_BMPS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016408
16409 if (length != 0) {
16410 linkCapacity = *(uint32_t *) pStats;
16411 pStats += sizeof(uint32_t);
16412 length -= sizeof(uint32_t);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016413 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016414 linkCapacity = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016415
16416 if (length != 0) {
16417 pSnr = (uint32_t *) pStats;
16418 snr = (int8_t) *pSnr;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016419 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016420 snr = SNR_HACK_BMPS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016421
16422post_update:
16423 /* make sure to update the pe stats req list */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016424 pEntry = csr_roam_find_in_pe_stats_req_list(pMac,
16425 pSmeStatsRsp->statsMask);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016426 if (pEntry) {
16427 pPeStaEntry = GET_BASE_ADDR(pEntry, tCsrPeStatsReqInfo, link);
16428 pPeStaEntry->rspPending = false;
16429
16430 }
16431 /* check the one timer cases */
16432 pEntry = csr_roam_check_client_req_list(pMac, pSmeStatsRsp->statsMask);
16433 if (pEntry) {
16434 pTempStaEntry =
16435 GET_BASE_ADDR(pEntry, tCsrStatsClientReqInfo, link);
16436 if (pTempStaEntry->timerExpired) {
16437 /* send up the stats report */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016438 csr_roam_report_statistics(pMac,
16439 pTempStaEntry->statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016440 pTempStaEntry->callback,
16441 pTempStaEntry->staId,
16442 pTempStaEntry->pContext);
16443 /* also remove from the client list */
16444 csr_roam_remove_stat_list_entry(pMac, pEntry);
16445 pTempStaEntry = NULL;
16446 }
16447 }
16448}
16449
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016450tListElem *csr_roam_find_in_pe_stats_req_list(tpAniSirGlobal pMac,
16451 uint32_t statsMask)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016452{
16453 tListElem *pEntry = NULL;
16454 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016455
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016456 pEntry = csr_ll_peek_head(&pMac->roam.peStatsReqList, LL_ACCESS_LOCK);
16457 if (!pEntry) {
16458 /* list empty */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016459 sme_debug("csr_roam_find_in_pe_stats_req_list: List empty, no request to PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016460 return NULL;
16461 }
16462 while (pEntry) {
16463 pTempStaEntry = GET_BASE_ADDR(pEntry, tCsrPeStatsReqInfo, link);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016464 if (pTempStaEntry->statsMask == statsMask)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016465 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016466 pEntry =
16467 csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
16468 LL_ACCESS_NOLOCK);
16469 }
16470 return pEntry;
16471}
16472
Jeff Johnson29e2ca12016-10-14 12:50:38 -070016473static
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016474tListElem *csr_roam_checkn_update_client_req_list(tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016475 tCsrStatsClientReqInfo *pStaEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016476 bool update)
16477{
16478 tListElem *pEntry;
16479 tCsrStatsClientReqInfo *pTempStaEntry;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016480
16481 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList,
16482 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016483 if (!pEntry) {
16484 /* list empty */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016485 sme_debug("List empty, no request from upper layer client(s)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016486 return NULL;
16487 }
16488 while (pEntry) {
16489 pTempStaEntry =
16490 GET_BASE_ADDR(pEntry, tCsrStatsClientReqInfo, link);
16491 if ((pTempStaEntry->requesterId == pStaEntry->requesterId)
16492 && (pTempStaEntry->statsMask == pStaEntry->statsMask)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016493 if (update) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016494 pTempStaEntry->callback = pStaEntry->callback;
16495 pTempStaEntry->pContext = pStaEntry->pContext;
16496 }
16497 break;
16498 }
16499 pEntry =
16500 csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
16501 LL_ACCESS_NOLOCK);
16502 }
16503 return pEntry;
16504}
16505
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016506tListElem *csr_roam_check_client_req_list(tpAniSirGlobal pMac,
16507 uint32_t statsMask)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016508{
16509 tListElem *pEntry;
16510 tCsrStatsClientReqInfo *pTempStaEntry;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016511
16512 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList,
16513 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016514 if (!pEntry) {
16515 /* list empty */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016516 sme_debug("List empty, no request from upper layer client(s)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016517 return NULL;
16518 }
16519 while (pEntry) {
16520 pTempStaEntry =
16521 GET_BASE_ADDR(pEntry, tCsrStatsClientReqInfo, link);
16522 if ((pTempStaEntry->
16523 statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016524 break;
16525 }
16526 pEntry =
16527 csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
16528 LL_ACCESS_NOLOCK);
16529 }
16530 return pEntry;
16531}
16532
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016533tCsrStatsClientReqInfo *csr_roam_insert_entry_into_list(tpAniSirGlobal pMac,
16534 tDblLinkList *pStaList,
16535 tCsrStatsClientReqInfo *
16536 pStaEntry)
16537{
16538 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Naveen Rawatd0ca4412017-06-16 14:19:19 -070016539 /*
16540 * if same entity requested for same set of stats with different
16541 * callback update it
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016542 */
16543 if (NULL == csr_roam_checkn_update_client_req_list(pMac, pStaEntry,
16544 true)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016545
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016546 pNewStaEntry = qdf_mem_malloc(sizeof(tCsrStatsClientReqInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016547 if (NULL == pNewStaEntry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016548 sme_err("couldn't allocate memory for the entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016549 return NULL;
16550 }
16551
16552 pNewStaEntry->callback = pStaEntry->callback;
16553 pNewStaEntry->pContext = pStaEntry->pContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016554 pNewStaEntry->requesterId = pStaEntry->requesterId;
16555 pNewStaEntry->statsMask = pStaEntry->statsMask;
16556 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
16557 pNewStaEntry->pMac = pStaEntry->pMac;
16558 pNewStaEntry->staId = pStaEntry->staId;
16559 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
16560
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016561 csr_ll_insert_tail(pStaList, &pNewStaEntry->link,
16562 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016563 }
16564 return pNewStaEntry;
16565}
16566
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016567QDF_STATUS csr_get_rssi(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016568 tCsrRssiCallback callback,
16569 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016570 struct qdf_mac_addr bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016571 int8_t lastRSSI, void *pContext, void *p_cds_context)
16572{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016573 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070016574 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016575 uint32_t sessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016576 tAniGetRssiReq *pMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016577
16578 status = csr_roam_get_session_id_from_bssid(pMac, &bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016579 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016580 callback(lastRSSI, staId, pContext);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016581 sme_err("Failed to get SessionId");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016582 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016583 }
16584
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016585 pMsg = qdf_mem_malloc(sizeof(tAniGetRssiReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016586 if (NULL == pMsg) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016587 sme_err("csr_get_rssi: failed to allocate mem for req ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016588 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016589 }
16590
16591 pMsg->msgType = eWNI_SME_GET_RSSI_REQ;
16592 pMsg->msgLen = (uint16_t) sizeof(tAniGetRssiReq);
16593 pMsg->sessionId = sessionId;
16594 pMsg->staId = staId;
16595 pMsg->rssiCallback = callback;
16596 pMsg->pDevContext = pContext;
16597 pMsg->p_cds_context = p_cds_context;
16598 /*
16599 * store RSSI at time of calling, so that if RSSI request cannot
16600 * be sent to firmware, this value can be used to return immediately
16601 */
16602 pMsg->lastRSSI = lastRSSI;
16603 msg.type = eWNI_SME_GET_RSSI_REQ;
16604 msg.bodyptr = pMsg;
16605 msg.reserved = 0;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080016606 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_SME,
Krunal Soni66c113f2016-12-21 16:46:47 -080016607 &msg)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016608 sme_err("scheduler_post_msg failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016609 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016610 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016611 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016612 return status;
16613}
16614
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016615QDF_STATUS csr_get_snr(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016616 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016617 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016618{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016619 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070016620 struct scheduler_msg msg = {0};
Yuanyuan Liu889167d2017-05-31 16:56:26 -070016621 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016622 tAniGetSnrReq *pMsg;
16623
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016624 pMsg = (tAniGetSnrReq *) qdf_mem_malloc(sizeof(tAniGetSnrReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016625 if (NULL == pMsg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016626 sme_err("failed to allocate mem for req");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016627 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016628 }
16629
Tushnim Bhattacharyya85bedb92017-05-17 13:23:14 -070016630 status = csr_roam_get_session_id_from_bssid(pMac, &bssId, &sessionId);
16631 if (!QDF_IS_STATUS_SUCCESS(status)) {
Houston Hoffman77bf4072017-07-17 01:01:18 -070016632 qdf_mem_free(pMsg);
Srinivas Girigowdaaf0173e2017-06-01 11:50:41 -070016633 sme_err("Couldn't find session_id for given BSSID");
16634 return status;
Tushnim Bhattacharyya85bedb92017-05-17 13:23:14 -070016635 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016636
16637 pMsg->msgType = eWNI_SME_GET_SNR_REQ;
16638 pMsg->msgLen = (uint16_t) sizeof(tAniGetSnrReq);
16639 pMsg->sessionId = sessionId;
16640 pMsg->staId = staId;
16641 pMsg->snrCallback = callback;
16642 pMsg->pDevContext = pContext;
16643 msg.type = eWNI_SME_GET_SNR_REQ;
16644 msg.bodyptr = pMsg;
16645 msg.reserved = 0;
16646
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080016647 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_SME,
Krunal Soni66c113f2016-12-21 16:46:47 -080016648 &msg)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016649 sme_err("failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016650 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016651 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016652 }
16653
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016654 return status;
16655}
16656
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016657/**
16658 * csr_deregister_client_request() - deregisters a get stats request
16659 * @mac_ctx: mac global context
16660 * @sta_entry: stats request entry
16661 *
16662 * Return: status of operation
16663 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016664static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016665csr_deregister_client_request(tpAniSirGlobal mac_ctx,
16666 tCsrStatsClientReqInfo *sta_entry)
16667{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016668 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016669 tListElem *entry = NULL;
16670 tCsrStatsClientReqInfo *ptr_sta_entry = NULL;
16671
16672 entry = csr_roam_checkn_update_client_req_list(mac_ctx, sta_entry,
16673 false);
16674 if (!entry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016675 sme_err("callback is empty in the request & couldn't find any existing request in statsClientReqList");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016676 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016677 }
16678 /* clean up & return */
16679 ptr_sta_entry = GET_BASE_ADDR(entry, tCsrStatsClientReqInfo, link);
16680 if (NULL != ptr_sta_entry->pPeStaEntry) {
16681 ptr_sta_entry->pPeStaEntry->numClient--;
16682 /* check if we need to delete the entry from peStatsReqList */
16683 if (!ptr_sta_entry->pPeStaEntry->numClient)
16684 csr_roam_remove_entry_from_pe_stats_req_list(mac_ctx,
16685 ptr_sta_entry->pPeStaEntry);
16686 }
16687 /* check if we need to stop the tl stats timer too */
16688 mac_ctx->roam.tlStatsReqInfo.numClient--;
Anurag Chouhan210db072016-02-22 18:42:15 +053016689 qdf_mc_timer_stop(&ptr_sta_entry->timer);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053016690 /* Destroy the qdf timer... */
Anurag Chouhan210db072016-02-22 18:42:15 +053016691 status = qdf_mc_timer_destroy(&ptr_sta_entry->timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016692 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016693 sme_err(
16694 "failed to destroy Client req timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016695
16696 csr_roam_remove_stat_list_entry(mac_ctx, entry);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016697 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016698}
16699
16700/**
16701 * csr_insert_stats_request_to_list() - inserts request to existing list
16702 * @mac_ctx: mac global context
16703 * @sta_entry: stats request entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016704 *
16705 * Return: status of operation
16706 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016707static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016708csr_insert_stats_request_to_list(tpAniSirGlobal mac_ctx,
Naveen Rawatd0ca4412017-06-16 14:19:19 -070016709 tCsrStatsClientReqInfo *sta_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016710{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016711 tCsrStatsClientReqInfo *ptr_sta_entry = csr_roam_insert_entry_into_list(
16712 mac_ctx, &mac_ctx->roam.statsClientReqList,
16713 sta_entry);
16714 if (!ptr_sta_entry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016715 sme_err("Failed to insert req in statsClientReqList");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016716 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016717 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016718 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016719}
16720
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016721QDF_STATUS csr_get_statistics(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016722 eCsrStatsRequesterType requesterId,
16723 uint32_t statsMask,
16724 tCsrStatsCallback callback,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016725 uint8_t staId,
16726 void *pContext,
16727 uint8_t sessionId)
16728{
16729 tCsrStatsClientReqInfo staEntry;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016730 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016731 bool insertInClientList = false;
16732 uint32_t temp_mask = 0;
16733
16734 if (csr_is_all_session_disconnected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016735 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016736
16737 if (csr_neighbor_middle_of_roaming(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016738 sme_debug("in the middle of roaming states");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016739 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016740 }
16741
16742 if ((!statsMask) && (!callback)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016743 sme_err("statsMask & callback empty in the request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016744 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016745 }
16746 /* for the search list method for deregister */
16747 staEntry.requesterId = requesterId;
16748 staEntry.statsMask = statsMask;
16749 /* requester wants to deregister or just an error */
16750 if ((statsMask) && (!callback))
16751 return csr_deregister_client_request(pMac, &staEntry);
16752
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016753 /* add the request in the client req list */
16754 staEntry.callback = callback;
16755 staEntry.pContext = pContext;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016756 staEntry.pPeStaEntry = NULL;
16757 staEntry.staId = staId;
16758 staEntry.pMac = pMac;
16759 staEntry.timerExpired = false;
16760 staEntry.sessionId = sessionId;
16761
Naveen Rawatd0ca4412017-06-16 14:19:19 -070016762 temp_mask = statsMask & ~(1 << eCsrGlobalClassDStats);
16763 if (temp_mask) {
16764 /* send down a req */
16765 status = csr_send_mb_stats_req_msg(pMac,
16766 temp_mask, staId, sessionId);
16767 if (!QDF_IS_STATUS_SUCCESS(status))
16768 sme_err("failed to send down stats req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016769 /*
Naveen Rawatd0ca4412017-06-16 14:19:19 -070016770 * so that when the stats rsp comes back from PE we
16771 * respond to upper layer right away
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016772 */
Naveen Rawatd0ca4412017-06-16 14:19:19 -070016773 staEntry.timerExpired = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016774 insertInClientList = true;
16775 }
Naveen Rawatd0ca4412017-06-16 14:19:19 -070016776 /* if looking for stats from TL only */
16777 if (!insertInClientList) {
16778 /* return the stats */
16779 csr_roam_report_statistics(pMac, statsMask, callback,
16780 staId, pContext);
16781 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016782 }
16783 if (insertInClientList)
Naveen Rawatd0ca4412017-06-16 14:19:19 -070016784 return csr_insert_stats_request_to_list(pMac, &staEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016785
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016786 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016787}
16788
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080016789#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070016790/**
16791 * csr_roam_set_key_mgmt_offload() - enable/disable key mgmt offload
16792 * @mac_ctx: mac context.
16793 * @session_id: Session Identifier
16794 * @roam_key_mgmt_offload_enabled: key mgmt enable/disable flag
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080016795 * @pmkid_modes: PMKID modes of PMKSA caching and OKC
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070016796 *
16797 * Return: QDF_STATUS_SUCCESS - CSR updated config successfully.
16798 * Other status means CSR is failed to update.
16799 */
16800
16801QDF_STATUS csr_roam_set_key_mgmt_offload(tpAniSirGlobal mac_ctx,
16802 uint32_t session_id,
16803 bool roam_key_mgmt_offload_enabled,
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080016804 struct pmkid_mode_bits *pmkid_modes)
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080016805{
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070016806 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053016807
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070016808 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016809 sme_err("session %d not found", session_id);
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080016810 return QDF_STATUS_E_FAILURE;
16811 }
Deepak Dhamdheref2a7d8b2016-08-19 16:17:38 -070016812 session->RoamKeyMgmtOffloadEnabled = roam_key_mgmt_offload_enabled;
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080016813 session->pmkid_modes.fw_okc = pmkid_modes->fw_okc;
16814 session->pmkid_modes.fw_pmksa_cache = pmkid_modes->fw_pmksa_cache;
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080016815 return QDF_STATUS_SUCCESS;
16816}
16817
16818/**
16819 * csr_update_roam_scan_offload_request() - updates req msg with roam offload
16820 * paramters
16821 * @pMac: mac global context
16822 * @req_buf: out param, roam offload scan request packet
16823 * @session: roam session
16824 *
16825 * Return: void
16826 */
16827static void
16828csr_update_roam_scan_offload_request(tpAniSirGlobal mac_ctx,
16829 tSirRoamOffloadScanReq *req_buf,
16830 tCsrRoamSession *session)
16831{
16832 qdf_mem_copy(req_buf->PSK_PMK, session->psk_pmk,
16833 sizeof(req_buf->PSK_PMK));
16834 req_buf->pmk_len = session->pmk_len;
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080016835 req_buf->R0KH_ID_Length = session->ftSmeContext.r0kh_id_len;
16836 qdf_mem_copy(req_buf->R0KH_ID,
16837 session->ftSmeContext.r0kh_id,
16838 req_buf->R0KH_ID_Length);
16839 req_buf->Prefer5GHz = mac_ctx->roam.configParam.nRoamPrefer5GHz;
16840 req_buf->RoamRssiCatGap = mac_ctx->roam.configParam.bCatRssiOffset;
16841 req_buf->Select5GHzMargin = mac_ctx->roam.configParam.nSelect5GHzMargin;
16842 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
16843 (uint32_t *) &req_buf->ReassocFailureTimeout)
16844 != eSIR_SUCCESS) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016845 sme_err(
16846 "could not retrieve ReassocFailureTimeout value");
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080016847 req_buf->ReassocFailureTimeout =
16848 DEFAULT_REASSOC_FAILURE_TIMEOUT;
16849 }
16850#ifdef FEATURE_WLAN_ESE
16851 if (csr_is_auth_type_ese(req_buf->ConnectedNetwork.authentication)) {
16852 qdf_mem_copy(req_buf->KRK, session->eseCckmInfo.krk,
16853 SIR_KRK_KEY_LEN);
16854 qdf_mem_copy(req_buf->BTK, session->eseCckmInfo.btk,
16855 SIR_BTK_KEY_LEN);
16856 }
16857#endif
Naveen Rawatcd118312016-11-22 10:46:21 -080016858 req_buf->AcUapsd.acbe_uapsd = SIR_UAPSD_GET(ACBE, session->uapsd_mask);
16859 req_buf->AcUapsd.acbk_uapsd = SIR_UAPSD_GET(ACBK, session->uapsd_mask);
16860 req_buf->AcUapsd.acvi_uapsd = SIR_UAPSD_GET(ACVI, session->uapsd_mask);
16861 req_buf->AcUapsd.acvo_uapsd = SIR_UAPSD_GET(ACVO, session->uapsd_mask);
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080016862}
16863#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
16864
16865#if defined(WLAN_FEATURE_HOST_ROAM) || defined(WLAN_FEATURE_ROAM_OFFLOAD)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016866/**
16867 * csr_check_band_channel_match() - check if passed band and channel match
16868 * paramters
16869 * @band: band to match with channel
16870 * @channel: channel to match with band
16871 *
16872 * Return: bool if match else false
16873 */
16874static bool
16875csr_check_band_channel_match(eCsrBand band, uint8_t channel)
16876{
16877 if (eCSR_BAND_ALL == band)
16878 return true;
16879
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070016880 if (eCSR_BAND_24 == band && WLAN_REG_IS_24GHZ_CH(channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016881 return true;
16882
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070016883 if (eCSR_BAND_5G == band && WLAN_REG_IS_5GHZ_CH(channel))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016884 return true;
16885
16886 return false;
16887}
16888
16889/**
16890 * csr_fetch_ch_lst_from_ini() - fetch channel list from ini and update req msg
16891 * paramters
16892 * @mac_ctx: global mac ctx
16893 * @roam_info: roam info struct
16894 * @req_buf: out param, roam offload scan request packet
16895 *
16896 * Return: result of operation
16897 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016898static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016899csr_fetch_ch_lst_from_ini(tpAniSirGlobal mac_ctx,
16900 tpCsrNeighborRoamControlInfo roam_info,
16901 tSirRoamOffloadScanReq *req_buf)
16902{
16903 eCsrBand band;
16904 uint8_t i = 0;
16905 uint8_t num_channels = 0;
16906 uint8_t *ch_lst = roam_info->cfgParams.channelInfo.ChannelList;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053016907 uint16_t unsafe_chan[NUM_CHANNELS];
16908 uint16_t unsafe_chan_cnt = 0;
16909 uint16_t cnt = 0;
16910 bool is_unsafe_chan;
16911 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
16912
16913 if (!qdf_ctx) {
16914 cds_err("qdf_ctx is NULL");
16915 return QDF_STATUS_E_FAILURE;
16916 }
16917
16918 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
16919 &unsafe_chan_cnt,
16920 sizeof(unsafe_chan));
16921
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016922 /*
16923 * The INI channels need to be filtered with respect to the current band
16924 * that is supported.
16925 */
16926 band = mac_ctx->roam.configParam.bandCapability;
16927 if ((eCSR_BAND_24 != band) && (eCSR_BAND_5G != band)
16928 && (eCSR_BAND_ALL != band)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016929 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016930 "Invalid band(%d), roam scan offload req aborted",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016931 band);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016932 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016933 }
16934
16935 for (i = 0; i < roam_info->cfgParams.channelInfo.numOfChannels; i++) {
16936 if (!csr_check_band_channel_match(band, *ch_lst))
16937 continue;
16938 /* Allow DFS channels only if the DFS roaming is enabled */
Agrawal Ashish21ba2572016-09-03 16:40:10 +053016939 if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
16940 (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
16941 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070016942 (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016943 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
16944 ("ignoring dfs channel %d"), *ch_lst);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053016945 ch_lst++;
16946 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016947 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053016948
16949 if (mac_ctx->roam.configParam.sta_roam_policy.
16950 skip_unsafe_channels &&
16951 unsafe_chan_cnt) {
16952 is_unsafe_chan = false;
16953 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
16954 if (unsafe_chan[cnt] == *ch_lst) {
16955 is_unsafe_chan = true;
16956 break;
16957 }
16958 }
16959 if (is_unsafe_chan) {
16960 QDF_TRACE(QDF_MODULE_ID_SME,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070016961 QDF_TRACE_LEVEL_DEBUG,
16962 ("ignoring unsafe channel %d"),
Agrawal Ashish21ba2572016-09-03 16:40:10 +053016963 *ch_lst);
16964 ch_lst++;
16965 continue;
16966 }
16967 }
16968 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
16969 *ch_lst;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016970 ch_lst++;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053016971
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016972 }
16973 req_buf->ConnectedNetwork.ChannelCount = num_channels;
16974 req_buf->ChannelCacheType = CHANNEL_LIST_STATIC;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016975 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016976}
16977
16978/**
16979 * csr_fetch_ch_lst_from_occupied_lst() - fetch channel list from occupied list
16980 * and update req msg
16981 * paramters
16982 * @mac_ctx: global mac ctx
16983 * @session_id: session id
16984 * @reason: reason to roam
16985 * @req_buf: out param, roam offload scan request packet
16986 * @roam_info: roam info struct
16987 *
16988 * Return: void
16989 */
16990static void
16991csr_fetch_ch_lst_from_occupied_lst(tpAniSirGlobal mac_ctx,
16992 uint8_t session_id,
16993 uint8_t reason,
16994 tSirRoamOffloadScanReq *req_buf,
16995 tpCsrNeighborRoamControlInfo roam_info)
16996{
16997 uint8_t i = 0;
16998 uint8_t num_channels = 0;
16999 uint8_t *ch_lst =
17000 mac_ctx->scan.occupiedChannels[session_id].channelList;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053017001 uint16_t unsafe_chan[NUM_CHANNELS];
17002 uint16_t unsafe_chan_cnt = 0;
17003 uint16_t cnt = 0;
17004 bool is_unsafe_chan;
17005 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
17006
17007 if (!qdf_ctx) {
17008 cds_err("qdf_ctx is NULL");
17009 return;
17010 }
17011
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017012 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017013 "Num of channels before filtering=%d",
17014 mac_ctx->scan.occupiedChannels[session_id].numChannels);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053017015 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
17016 &unsafe_chan_cnt,
17017 sizeof(unsafe_chan));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017018 for (i = 0; i < mac_ctx->scan.occupiedChannels[session_id].numChannels;
17019 i++) {
Agrawal Ashish21ba2572016-09-03 16:40:10 +053017020 if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
17021 (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
17022 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070017023 (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017024 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
17025 ("ignoring dfs channel %d"), *ch_lst);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053017026 ch_lst++;
17027 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017028 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053017029
17030 if (mac_ctx->roam.configParam.sta_roam_policy.
17031 skip_unsafe_channels &&
17032 unsafe_chan_cnt) {
17033 is_unsafe_chan = false;
17034 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
17035 if (unsafe_chan[cnt] == *ch_lst) {
17036 is_unsafe_chan = true;
17037 break;
17038 }
17039 }
17040 if (is_unsafe_chan) {
17041 QDF_TRACE(QDF_MODULE_ID_SME,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017042 QDF_TRACE_LEVEL_DEBUG,
17043 ("ignoring unsafe channel %d"),
Agrawal Ashish21ba2572016-09-03 16:40:10 +053017044 *ch_lst);
17045 ch_lst++;
17046 continue;
17047 }
17048 }
17049 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
17050 *ch_lst;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017051 if (*ch_lst)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017052 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017053 "DFSRoam=%d, ChnlState=%d, Chnl=%d, num_ch=%d",
17054 mac_ctx->roam.configParam.allowDFSChannelRoam,
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070017055 wlan_reg_get_channel_state(mac_ctx->pdev,
17056 *ch_lst),
17057 *ch_lst,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017058 num_channels);
17059 ch_lst++;
17060 }
17061 req_buf->ConnectedNetwork.ChannelCount = num_channels;
17062 /*
17063 * If the profile changes as to what it was earlier, inform the FW
17064 * through FLUSH as ChannelCacheType in which case, the FW will flush
17065 * the occupied channels for the earlier profile and try to learn them
17066 * afresh
17067 */
17068 if (reason == REASON_FLUSH_CHANNEL_LIST)
17069 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
17070 else {
17071 if (csr_neighbor_roam_is_new_connected_profile(mac_ctx,
17072 session_id))
17073 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
17074 else
17075 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
17076 }
17077}
17078
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017079/**
17080 * csr_fetch_valid_ch_lst() - fetch channel list from valid channel list and
17081 * update req msg
17082 * paramters
17083 * @mac_ctx: global mac ctx
17084 * @req_buf: out param, roam offload scan request packet
17085 *
17086 * Return: void
17087 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017088static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017089csr_fetch_valid_ch_lst(tpAniSirGlobal mac_ctx,
17090 tSirRoamOffloadScanReq *req_buf)
17091{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017092 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017093 uint32_t host_channels = 0;
17094 uint8_t *ch_lst = NULL;
17095 uint8_t i = 0, num_channels = 0;
Agrawal Ashish21ba2572016-09-03 16:40:10 +053017096 uint16_t unsafe_chan[NUM_CHANNELS];
17097 uint16_t unsafe_chan_cnt = 0;
17098 uint16_t cnt = 0;
17099 bool is_unsafe_chan;
17100 qdf_device_t qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
17101
17102 if (!qdf_ctx) {
17103 cds_err("qdf_ctx is NULL");
17104 return QDF_STATUS_E_FAILURE;
17105 }
17106
17107 pld_get_wlan_unsafe_channel(qdf_ctx->dev, unsafe_chan,
17108 &unsafe_chan_cnt,
17109 sizeof(unsafe_chan));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017110
17111 host_channels = sizeof(mac_ctx->roam.validChannelList);
17112 status = csr_get_cfg_valid_channels(mac_ctx,
17113 mac_ctx->roam.validChannelList,
17114 &host_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017115 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017116 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017117 "Failed to get the valid channel list");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017118 return status;
17119 }
17120 ch_lst = mac_ctx->roam.validChannelList;
17121 mac_ctx->roam.numValidChannels = host_channels;
17122 for (i = 0; i < mac_ctx->roam.numValidChannels; i++) {
Agrawal Ashish21ba2572016-09-03 16:40:10 +053017123 ch_lst++;
17124 if ((!mac_ctx->roam.configParam.allowDFSChannelRoam ||
17125 (mac_ctx->roam.configParam.sta_roam_policy.dfs_mode ==
17126 CSR_STA_ROAM_POLICY_DFS_DISABLED)) &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070017127 (wlan_reg_is_dfs_ch(mac_ctx->pdev, *ch_lst))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017128 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
17129 ("ignoring dfs channel %d"), *ch_lst);
Agrawal Ashish21ba2572016-09-03 16:40:10 +053017130 ch_lst++;
17131 continue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017132 }
Agrawal Ashish21ba2572016-09-03 16:40:10 +053017133
17134 if (mac_ctx->roam.configParam.
17135 sta_roam_policy.skip_unsafe_channels &&
17136 unsafe_chan_cnt) {
17137 is_unsafe_chan = false;
17138 for (cnt = 0; cnt < unsafe_chan_cnt; cnt++) {
17139 if (unsafe_chan[cnt] == *ch_lst) {
17140 is_unsafe_chan = true;
17141 break;
17142 }
17143 }
17144 if (is_unsafe_chan) {
17145 QDF_TRACE(QDF_MODULE_ID_SME,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017146 QDF_TRACE_LEVEL_DEBUG,
17147 ("ignoring unsafe channel %d"),
Agrawal Ashish21ba2572016-09-03 16:40:10 +053017148 *ch_lst);
17149 ch_lst++;
17150 continue;
17151 }
17152 }
17153 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
17154 *ch_lst;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017155 ch_lst++;
17156 }
17157 req_buf->ValidChannelCount = num_channels;
17158 return status;
17159}
17160
17161/**
17162 * csr_create_roam_scan_offload_request() - init roam offload scan request
17163 *
17164 * paramters
17165 * @mac_ctx: global mac ctx
17166 * @command: roam scan offload command input
17167 * @session_id: session id
17168 * @reason: reason to roam
17169 * @session: roam session
17170 * @roam_info: roam info struct
17171 *
17172 * Return: roam offload scan request packet buffer
17173 */
17174static tSirRoamOffloadScanReq *
17175csr_create_roam_scan_offload_request(tpAniSirGlobal mac_ctx,
17176 uint8_t command,
17177 uint8_t session_id,
17178 uint8_t reason,
17179 tCsrRoamSession *session,
17180 tpCsrNeighborRoamControlInfo roam_info)
17181{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017182 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017183 uint8_t i, j, dot11_mode;
17184 bool ese_neighbor_list_recvd = false;
17185 uint8_t ch_cache_str[128] = { 0 };
17186 tSirRoamOffloadScanReq *req_buf = NULL;
17187 tpCsrChannelInfo curr_ch_lst_info =
17188 &roam_info->roamChannelInfo.currentChannelListInfo;
17189#ifdef FEATURE_WLAN_ESE
17190 /*
17191 * this flag will be true if connection is ESE and no neighbor
17192 * list received or if the connection is not ESE
17193 */
17194 ese_neighbor_list_recvd = ((roam_info->isESEAssoc)
17195 && (roam_info->roamChannelInfo.IAPPNeighborListReceived
17196 == false))
17197 || (roam_info->isESEAssoc == false);
17198#endif /* FEATURE_WLAN_ESE */
17199
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017200 req_buf = qdf_mem_malloc(sizeof(tSirRoamOffloadScanReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017201 if (NULL == req_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017202 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017203 "Mem alloc for roam scan offload req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017204 return NULL;
17205 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017206 req_buf->Command = command;
17207 /*
17208 * If command is STOP, then pass down ScanOffloadEnabled as Zero. This
17209 * will handle the case of host driver reloads, but Riva still up and
17210 * running
17211 */
17212 if (command == ROAM_SCAN_OFFLOAD_STOP) {
17213 /*
17214 * clear the roaming parameters that are per connection.
17215 * For a new connection, they have to be programmed again.
17216 */
17217 if (csr_neighbor_middle_of_roaming((tHalHandle)mac_ctx,
17218 session_id))
17219 req_buf->middle_of_roaming = 1;
17220 else
17221 csr_roam_reset_roam_params(mac_ctx);
17222 req_buf->RoamScanOffloadEnabled = 0;
17223 } else {
17224 req_buf->RoamScanOffloadEnabled =
17225 mac_ctx->roam.configParam.isRoamOffloadScanEnabled;
17226 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017227 qdf_mem_copy(req_buf->ConnectedNetwork.currAPbssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053017228 roam_info->currAPbssid.bytes, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017229 req_buf->ConnectedNetwork.ssId.length =
17230 mac_ctx->roam.roamSession[session_id].
17231 connectedProfile.SSID.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017232 qdf_mem_copy(req_buf->ConnectedNetwork.ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017233 mac_ctx->roam.roamSession[session_id].
17234 connectedProfile.SSID.ssId,
17235 req_buf->ConnectedNetwork.ssId.length);
17236 req_buf->ConnectedNetwork.authentication =
17237 mac_ctx->roam.roamSession[session_id].connectedProfile.AuthType;
17238 req_buf->ConnectedNetwork.encryption =
17239 mac_ctx->roam.roamSession[session_id].
17240 connectedProfile.EncryptionType;
17241 req_buf->ConnectedNetwork.mcencryption =
17242 mac_ctx->roam.roamSession[session_id].
17243 connectedProfile.mcEncryptionType;
17244#ifdef WLAN_FEATURE_11W
17245 req_buf->ConnectedNetwork.mfp_enabled =
17246 mac_ctx->roam.roamSession[session_id].connectedProfile.MFPEnabled;
17247#endif
17248 req_buf->delay_before_vdev_stop =
17249 roam_info->cfgParams.delay_before_vdev_stop;
17250 req_buf->OpportunisticScanThresholdDiff =
17251 roam_info->cfgParams.nOpportunisticThresholdDiff;
17252 req_buf->RoamRescanRssiDiff =
17253 roam_info->cfgParams.nRoamRescanRssiDiff;
17254 req_buf->RoamRssiDiff = mac_ctx->roam.configParam.RoamRssiDiff;
17255 req_buf->reason = reason;
17256 req_buf->NeighborScanTimerPeriod =
17257 roam_info->cfgParams.neighborScanPeriod;
Sridhar Selvaraj1b2330c2017-07-21 15:16:42 +053017258 req_buf->neighbor_scan_min_timer_period =
17259 roam_info->cfgParams.neighbor_scan_min_period;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017260 req_buf->NeighborRoamScanRefreshPeriod =
17261 roam_info->cfgParams.neighborResultsRefreshPeriod;
17262 req_buf->NeighborScanChannelMinTime =
17263 roam_info->cfgParams.minChannelScanTime;
17264 req_buf->NeighborScanChannelMaxTime =
17265 roam_info->cfgParams.maxChannelScanTime;
17266 req_buf->EmptyRefreshScanPeriod =
17267 roam_info->cfgParams.emptyScanRefreshPeriod;
17268 req_buf->RoamBmissFirstBcnt =
17269 roam_info->cfgParams.nRoamBmissFirstBcnt;
17270 req_buf->RoamBmissFinalBcnt =
17271 roam_info->cfgParams.nRoamBmissFinalBcnt;
17272 req_buf->RoamBeaconRssiWeight =
17273 roam_info->cfgParams.nRoamBeaconRssiWeight;
17274 /* MAWC feature */
17275 req_buf->MAWCEnabled = mac_ctx->roam.configParam.MAWCEnabled;
17276#ifdef FEATURE_WLAN_ESE
17277 req_buf->IsESEAssoc =
Srinivas Girigowda18dcf3d2015-12-16 18:11:48 -080017278 csr_roam_is_ese_assoc(mac_ctx, session_id) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017279 ((req_buf->ConnectedNetwork.authentication ==
17280 eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
17281 (csr_is_auth_type_ese(req_buf->
17282 ConnectedNetwork.authentication)));
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017283 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017284 "IsEseAssoc: %d middle of roaming: %d ese_neighbor_list_recvd: %d cur no of chan: %d",
Selvaraj, Sridhar8fe6c672017-01-10 11:37:29 +053017285 req_buf->IsESEAssoc,
17286 req_buf->middle_of_roaming,
17287 ese_neighbor_list_recvd,
17288 curr_ch_lst_info->numOfChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017289#endif
17290 if (ese_neighbor_list_recvd || curr_ch_lst_info->numOfChannels == 0) {
17291 /*
17292 * Retrieve the Channel Cache either from ini or from the
17293 * occupied channels list. Give Preference to INI Channels
17294 */
17295 if (roam_info->cfgParams.channelInfo.numOfChannels) {
17296 status = csr_fetch_ch_lst_from_ini(mac_ctx, roam_info,
17297 req_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017298 if (!QDF_IS_STATUS_SUCCESS(status)) {
Selvaraj, Sridhar8fe6c672017-01-10 11:37:29 +053017299 QDF_TRACE(QDF_MODULE_ID_SME,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017300 QDF_TRACE_LEVEL_DEBUG,
17301 "Fetch channel list from ini failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017302 qdf_mem_free(req_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017303 return NULL;
17304 }
17305 } else {
17306 csr_fetch_ch_lst_from_occupied_lst(mac_ctx, session_id,
17307 reason, req_buf, roam_info);
17308 }
17309 }
17310#ifdef FEATURE_WLAN_ESE
17311 else {
17312 /*
17313 * If ESE is enabled, and a neighbor Report is received,then
17314 * Ignore the INI Channels or the Occupied Channel List.
17315 * Consider the channels in the neighbor list sent by the ESE AP
17316 */
17317 csr_fetch_ch_lst_from_received_list(mac_ctx, roam_info,
17318 curr_ch_lst_info, req_buf);
17319 }
17320#endif
Selvaraj, Sridhar38101832017-05-12 14:23:07 +053017321
17322 if (req_buf->ConnectedNetwork.ChannelCount == 0) {
17323 /* Maintain the Valid Channels List */
17324 status = csr_fetch_valid_ch_lst(mac_ctx, req_buf);
17325 if (!QDF_IS_STATUS_SUCCESS(status)) {
17326 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
17327 "Fetch channel list fail");
17328 qdf_mem_free(req_buf);
17329 return NULL;
17330 }
17331 }
17332
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017333 for (i = 0, j = 0; i < req_buf->ConnectedNetwork.ChannelCount; i++) {
17334 if (j < sizeof(ch_cache_str)) {
17335 j += snprintf(ch_cache_str + j,
17336 sizeof(ch_cache_str) - j, " %d",
17337 req_buf->ConnectedNetwork.
17338 ChannelCache[i]);
17339 } else
17340 break;
17341 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017342 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017343 FL("ChnlCacheType:%d, No of Chnls:%d,Channels: %s"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017344 req_buf->ChannelCacheType,
17345 req_buf->ConnectedNetwork.ChannelCount, ch_cache_str);
17346
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017347 req_buf->MDID.mdiePresent =
17348 mac_ctx->roam.roamSession[session_id].
17349 connectedProfile.MDID.mdiePresent;
17350 req_buf->MDID.mobilityDomain =
17351 mac_ctx->roam.roamSession[session_id].
17352 connectedProfile.MDID.mobilityDomain;
17353 req_buf->sessionId = session_id;
17354 req_buf->nProbes = mac_ctx->roam.configParam.nProbes;
17355 req_buf->HomeAwayTime = mac_ctx->roam.configParam.nRoamScanHomeAwayTime;
17356
17357 /*
17358 * Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
17359 * where RFS is the RF Switching time. It is twice RFS to consider the
17360 * time to go off channel and return to the home channel.
17361 */
17362 if (req_buf->HomeAwayTime < (req_buf->NeighborScanChannelMaxTime +
17363 (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017364 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
17365 "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 -080017366 req_buf->HomeAwayTime,
17367 (req_buf->NeighborScanChannelMaxTime +
17368 (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
17369 req_buf->HomeAwayTime = 0;
17370 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017371
17372 /*Prepare a probe request for 2.4GHz band and one for 5GHz band */
17373 dot11_mode = (uint8_t) csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
17374 csr_find_best_phy_mode(mac_ctx,
17375 mac_ctx->roam.configParam.phyMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017376 req_buf->allowDFSChannelRoam =
17377 mac_ctx->roam.configParam.allowDFSChannelRoam;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -070017378 req_buf->early_stop_scan_enable =
17379 mac_ctx->roam.configParam.early_stop_scan_enable;
17380 req_buf->early_stop_scan_min_threshold =
17381 mac_ctx->roam.configParam.early_stop_scan_min_threshold;
17382 req_buf->early_stop_scan_max_threshold =
17383 mac_ctx->roam.configParam.early_stop_scan_max_threshold;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +053017384 req_buf->roamscan_adaptive_dwell_mode =
17385 mac_ctx->roam.configParam.roamscan_adaptive_dwell_mode;
Selvaraj, Sridhar57ce4df2017-05-29 18:30:49 +053017386 req_buf->lca_config_params.disallow_duration =
17387 mac_ctx->roam.configParam.disallow_duration;
17388 req_buf->lca_config_params.rssi_channel_penalization =
17389 mac_ctx->roam.configParam.rssi_channel_penalization;
17390 req_buf->lca_config_params.num_disallowed_aps =
17391 mac_ctx->roam.configParam.num_disallowed_aps;
17392
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017393#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Selvaraj, Sridhar57ce4df2017-05-29 18:30:49 +053017394 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
17395 FL("HomeAwayTime=%d EarlyStopFeature Enable=%d, MinThresh=%d, MaxThresh=%d PMK len=%d disallow_dur=%d rssi_chan_pen=%d num_disallowed_aps=%d"),
17396 req_buf->HomeAwayTime,
17397 req_buf->early_stop_scan_enable,
17398 req_buf->early_stop_scan_min_threshold,
17399 req_buf->early_stop_scan_max_threshold,
17400 req_buf->pmk_len,
17401 req_buf->lca_config_params.disallow_duration,
17402 req_buf->lca_config_params.rssi_channel_penalization,
17403 req_buf->lca_config_params.num_disallowed_aps);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017404 req_buf->RoamOffloadEnabled = csr_roamIsRoamOffloadEnabled(mac_ctx);
17405 req_buf->RoamKeyMgmtOffloadEnabled = session->RoamKeyMgmtOffloadEnabled;
Deepak Dhamdhere828f1892017-02-09 11:51:19 -080017406 req_buf->pmkid_modes = session->pmkid_modes;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017407 /* Roam Offload piggybacks upon the Roam Scan offload command. */
17408 if (req_buf->RoamOffloadEnabled)
17409 csr_update_roam_scan_offload_request(mac_ctx, req_buf, session);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017410 qdf_mem_copy(&req_buf->roam_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017411 &mac_ctx->roam.configParam.roam_params,
17412 sizeof(req_buf->roam_params));
17413#endif
17414 return req_buf;
17415}
17416/**
17417 * check_allowed_ssid_list() - Check the WhiteList
17418 * @req_buffer: Buffer which contains the connected profile SSID.
17419 * @roam_params: Buffer which contains the whitelist SSID's.
17420 *
17421 * Check if the connected profile SSID exists in the whitelist.
17422 * It is assumed that the framework provides this also in the whitelist.
17423 * If it exists there is no issue. Otherwise add it to the list.
17424 *
17425 * Return: None
17426 */
17427static void check_allowed_ssid_list(tSirRoamOffloadScanReq *req_buffer,
17428 struct roam_ext_params *roam_params)
17429{
17430 int i = 0;
17431 bool match = false;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017432
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017433 for (i = 0; i < roam_params->num_ssid_allowed_list; i++) {
17434 if ((roam_params->ssid_allowed_list[i].length ==
17435 req_buffer->ConnectedNetwork.ssId.length) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017436 (!qdf_mem_cmp(roam_params->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017437 req_buffer->ConnectedNetwork.ssId.ssId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017438 roam_params->ssid_allowed_list[i].length))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017439 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017440 "Whitelist contains connected profile SSID");
17441 match = true;
17442 break;
17443 }
17444 }
17445 if (!match) {
17446 if (roam_params->num_ssid_allowed_list >=
17447 MAX_SSID_ALLOWED_LIST) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017448 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017449 "Whitelist is FULL. Cannot Add another entry");
17450 return;
17451 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017452 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017453 "Adding Connected profile SSID to whitelist");
17454 /* i is the next available index to add the entry.*/
17455 i = roam_params->num_ssid_allowed_list;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017456 qdf_mem_copy(roam_params->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017457 req_buffer->ConnectedNetwork.ssId.ssId,
17458 req_buffer->ConnectedNetwork.ssId.length);
17459 roam_params->ssid_allowed_list[i].length =
17460 req_buffer->ConnectedNetwork.ssId.length;
17461 roam_params->num_ssid_allowed_list++;
17462 }
17463}
17464
Abhishek Singh4db8c152017-07-18 10:40:08 +053017465/**
17466 * csr_add_rssi_reject_ap_list() - add rssi reject AP list to the
17467 * roam params
17468 * @mac_ctx: mac ctx.
17469 * @roam_params: roam params in which reject AP list needs
17470 * to be populated.
17471 *
17472 * Return: None
17473 */
17474static void csr_add_rssi_reject_ap_list(tpAniSirGlobal mac_ctx,
17475 struct roam_ext_params *roam_params)
17476{
17477 int i = 0;
17478 struct sir_rssi_disallow_lst *cur_node;
17479 qdf_list_node_t *cur_list = NULL;
17480 qdf_list_node_t *next_list = NULL;
17481 struct rssi_disallow_bssid *rssi_rejection_ap;
17482 qdf_list_t *list = &mac_ctx->roam.rssi_disallow_bssid;
17483 qdf_time_t cur_time =
17484 qdf_do_div(qdf_get_monotonic_boottime(),
17485 QDF_MC_TIMER_TO_MS_UNIT);
17486
17487 roam_params->num_rssi_rejection_ap = qdf_list_size(list);
17488
17489 if (!qdf_list_size(list))
17490 return;
17491
17492 if (roam_params->num_rssi_rejection_ap > MAX_RSSI_AVOID_BSSID_LIST)
17493 roam_params->num_rssi_rejection_ap = MAX_RSSI_AVOID_BSSID_LIST;
17494
17495 qdf_list_peek_front(list, &cur_list);
17496 while (cur_list) {
17497 int32_t rem_time;
17498
17499 rssi_rejection_ap = &roam_params->rssi_rejection_ap[i];
17500 cur_node = qdf_container_of(cur_list,
17501 struct sir_rssi_disallow_lst, node);
17502 rem_time = cur_node->retry_delay -
17503 (cur_time - cur_node->time_during_rejection);
17504
17505 if (rem_time > 0) {
17506 qdf_copy_macaddr(&rssi_rejection_ap->bssid,
17507 &cur_node->bssid);
17508 rssi_rejection_ap->expected_rssi =
17509 cur_node->expected_rssi;
17510 rssi_rejection_ap->remaining_duration = rem_time;
17511 i++;
17512 }
17513 qdf_list_peek_next(list, cur_list, &next_list);
17514 cur_list = next_list;
17515 next_list = NULL;
17516
17517 if (i >= MAX_RSSI_AVOID_BSSID_LIST)
17518 break;
17519 }
17520 for (i = 0; i < roam_params->num_rssi_rejection_ap; i++) {
17521 sme_debug("BSSID %pM expected rssi %d remaining duration %d",
17522 roam_params->rssi_rejection_ap[i].bssid.bytes,
17523 roam_params->rssi_rejection_ap[i].expected_rssi,
17524 roam_params->rssi_rejection_ap[i].remaining_duration);
17525 }
17526}
17527
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017528/*
17529 * Below Table describe whether RSO command can be send down to fimrware or not.
17530 * Host check it on the basis of previous RSO command sent down to firmware.
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070017531 * ||=========================================================================||
17532 * || New cmd | LAST SENT COMMAND ---> ||
17533 * ||====|====================================================================||
17534 * || V | START | STOP | RESTART | UPDATE_CFG| ABORT_SCAN ||
17535 * || ------------------------------------------------------------------------||
17536 * || RSO_START | NO | YES | NO | YES | NO ||
17537 * || RSO_STOP | YES | YES | YES | YES | YES ||
17538 * || RSO_RESTART | YES | YES | NO | YES | YES ||
17539 * || RSO_UPDATE_CFG | YES | NO | YES | YES | YES ||
17540 * || RSO_ABORT_SCAN | YES | NO | YES | YES | YES ||
17541 * ||=========================================================================||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017542 **/
17543#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
17544#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
17545#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
17546#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080017547#define RSO_ABORT_SCAN_BIT (1<<ROAM_SCAN_OFFLOAD_ABORT_SCAN)
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070017548#define RSO_START_ALLOW_MASK (RSO_STOP_BIT | RSO_UPDATE_CFG_BIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017549#define RSO_STOP_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080017550 RSO_STOP_BIT | RSO_START_BIT | RSO_ABORT_SCAN_BIT)
17551#define RSO_RESTART_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_START_BIT | \
17552 RSO_ABORT_SCAN_BIT | RSO_RESTART_BIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017553#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_STOP_BIT | \
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080017554 RSO_START_BIT | RSO_ABORT_SCAN_BIT)
17555#define RSO_ABORT_SCAN_ALLOW_MASK (RSO_START_BIT | RSO_RESTART_BIT | \
17556 RSO_UPDATE_CFG_BIT | RSO_ABORT_SCAN_BIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017557
Jeff Johnson29e2ca12016-10-14 12:50:38 -070017558static bool csr_is_RSO_cmd_allowed(tpAniSirGlobal mac_ctx, uint8_t command,
17559 uint8_t session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017560{
17561 tpCsrNeighborRoamControlInfo neigh_roam_info =
17562 &mac_ctx->roam.neighborRoamInfo[session_id];
17563 uint8_t desiredMask = 0;
17564 bool ret_val;
17565
17566 switch (command) {
17567 case ROAM_SCAN_OFFLOAD_START:
17568 desiredMask = RSO_START_ALLOW_MASK;
17569 break;
17570 case ROAM_SCAN_OFFLOAD_STOP:
17571 desiredMask = RSO_STOP_ALLOW_MASK;
17572 break;
17573 case ROAM_SCAN_OFFLOAD_RESTART:
17574 desiredMask = RSO_RESTART_ALLOW_MASK;
17575 break;
17576 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
17577 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
17578 break;
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080017579 case ROAM_SCAN_OFFLOAD_ABORT_SCAN:
17580 desiredMask = RSO_ABORT_SCAN_ALLOW_MASK;
17581 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017582 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017583 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017584 ("Wrong RSO command %d, not allowed"), command);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017585 return 0;/*Cmd Not allowed*/
17586 }
17587 ret_val = desiredMask & (1 << neigh_roam_info->last_sent_cmd);
17588 return ret_val;
17589}
17590
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053017591/*
17592 * csr_roam_send_rso_cmd() - API to send RSO command to PE
17593 * @mac_ctx: Pointer to global MAC structure
17594 * @session_id: Session ID
17595 * @request_buf: Pointer to tSirRoamOffloadScanReq
17596 *
17597 * Return: QDF_STATUS
17598 */
Jeff Johnson29e2ca12016-10-14 12:50:38 -070017599static QDF_STATUS csr_roam_send_rso_cmd(tpAniSirGlobal mac_ctx,
17600 uint8_t session_id,
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053017601 tSirRoamOffloadScanReq *request_buf)
17602{
17603 QDF_STATUS status;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017604
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053017605 request_buf->message_type = eWNI_SME_ROAM_SCAN_OFFLOAD_REQ;
17606 request_buf->length = sizeof(*request_buf);
17607
Rajeev Kumard138ac52017-01-30 18:38:37 -080017608 status = umac_send_mb_message_to_mac(request_buf);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053017609 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017610 sme_err("Send RSO from CSR failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053017611 return status;
17612 }
17613 return QDF_STATUS_SUCCESS;
17614}
17615
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017616/**
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053017617 * csr_append_assoc_ies() - Append specific IE to assoc IE's buffer
17618 * @mac_ctx: Pointer to global mac context
17619 * @req_buf: Pointer to Roam offload scan request
17620 * @ie_id: IE ID to be appended
17621 * @ie_len: IE length to be appended
17622 * @ie_data: IE data to be appended
17623 *
17624 * Return: None
17625 */
17626static void csr_append_assoc_ies(tpAniSirGlobal mac_ctx,
17627 tSirRoamOffloadScanReq *req_buf, uint8_t ie_id,
17628 uint8_t ie_len, uint8_t *ie_data)
17629{
17630 tSirAddie *assoc_ie = &req_buf->assoc_ie;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017631
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053017632 if ((SIR_MAC_MAX_ADD_IE_LENGTH - assoc_ie->length) < ie_len) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017633 sme_err("Appending IE id: %d fails", ie_id);
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053017634 return;
17635 }
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053017636 assoc_ie->addIEdata[assoc_ie->length] = ie_id;
17637 assoc_ie->addIEdata[assoc_ie->length + 1] = ie_len;
17638 qdf_mem_copy(&assoc_ie->addIEdata[assoc_ie->length + 2],
17639 ie_data, ie_len);
17640 assoc_ie->length += (ie_len + 2);
17641}
17642
yeshwanth sriram guntuka27e4ffc2016-12-01 18:00:17 +053017643#ifdef FEATURE_WLAN_ESE
17644/**
17645 * ese_populate_addtional_ies() - add IEs to reassoc frame
17646 * @mac_ctx: Pointer to global mac structure
17647 * @session: pointer to CSR session
17648 * @req_buf: Pointer to Roam offload scan request
17649 *
17650 * This function populates the TSPEC ie and appends the info
17651 * to assoc buffer.
17652 *
17653 * Return: None
17654 */
17655static void ese_populate_addtional_ies(tpAniSirGlobal mac_ctx,
17656 tCsrRoamSession *session,
17657 tSirRoamOffloadScanReq *req_buf) {
17658
17659 uint8_t tspec_ie_hdr[SIR_MAC_OUI_WME_HDR_MIN]
17660 = { 0x00, 0x50, 0xf2, 0x02, 0x02, 0x01 };
17661 uint8_t tspec_ie_buf[DOT11F_IE_WMMTSPEC_MAX_LEN], j;
17662 ese_wmm_tspec_ie *tspec_ie;
17663 tESETspecInfo ese_tspec;
17664
17665 tspec_ie = (ese_wmm_tspec_ie *)(tspec_ie_buf + SIR_MAC_OUI_WME_HDR_MIN);
17666 if (csr_is_wmm_supported(mac_ctx) &&
17667 mac_ctx->roam.configParam.isEseIniFeatureEnabled &&
17668 csr_roam_is_ese_assoc(mac_ctx, session->sessionId)) {
17669 ese_tspec.numTspecs = sme_qos_ese_retrieve_tspec_info(mac_ctx,
17670 session->sessionId,
17671 (tTspecInfo *) &ese_tspec.tspec[0]);
17672 qdf_mem_copy(tspec_ie_buf, tspec_ie_hdr,
17673 SIR_MAC_OUI_WME_HDR_MIN);
17674 for (j = 0; j < ese_tspec.numTspecs; j++) {
17675 /* Populate the tspec_ie */
17676 ese_populate_wmm_tspec(&ese_tspec.tspec[j].tspec,
17677 tspec_ie);
17678 csr_append_assoc_ies(mac_ctx, req_buf,
17679 IEEE80211_ELEMID_VENDOR,
17680 DOT11F_IE_WMMTSPEC_MAX_LEN,
17681 tspec_ie_buf);
17682 }
17683 }
17684
17685}
17686#else
17687static inline void ese_populate_addtional_ies(tpAniSirGlobal mac_ctx,
17688 tCsrRoamSession *session, tSirRoamOffloadScanReq *req_buf) {
17689}
17690#endif
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053017691/**
17692 * csr_update_driver_assoc_ies() - Append driver built IE's to assoc IE's
17693 * @mac_ctx: Pointer to global mac structure
17694 * @session: pointer to CSR session
17695 * @req_buf: Pointer to Roam offload scan request
17696 *
17697 * Return: None
17698 */
17699static void csr_update_driver_assoc_ies(tpAniSirGlobal mac_ctx,
17700 tCsrRoamSession *session,
17701 tSirRoamOffloadScanReq *req_buf)
17702{
17703 bool power_caps_populated = false;
17704 uint32_t csr_11henable = WNI_CFG_11H_ENABLED_STADEF;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017705
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053017706 uint8_t *rrm_cap_ie_data
17707 = (uint8_t *) &mac_ctx->rrm.rrmPEContext.rrmEnabledCaps;
17708 uint8_t power_cap_ie_data[DOT11F_IE_POWERCAPS_MAX_LEN]
17709 = {MIN_TX_PWR_CAP, MAX_TX_PWR_CAP};
Naveen Rawat224ae9c2016-10-24 15:36:56 -070017710 uint8_t max_tx_pwr_cap = 0;
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053017711 uint8_t supp_chan_ie[DOT11F_IE_SUPPCHANNELS_MAX_LEN], supp_chan_ie_len;
Yu Wang0477ee32017-02-10 20:02:03 +080017712
17713#ifdef FEATURE_WLAN_ESE
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053017714 uint8_t ese_ie[DOT11F_IE_ESEVERSION_MAX_LEN]
17715 = { 0x0, 0x40, 0x96, 0x3, ESE_VERSION_SUPPORTED};
Yu Wang0477ee32017-02-10 20:02:03 +080017716#endif
Selvaraj, Sridharced57062017-01-30 15:19:07 +053017717 uint8_t qcn_ie[DOT11F_IE_QCN_IE_MAX_LEN]
17718 = {0x8C, 0xFD, 0xF0, 0x1, QCN_IE_VERSION_SUBATTR_ID,
17719 QCN_IE_VERSION_SUBATTR_DATA_LEN,
17720 QCN_IE_VERSION_SUPPORTED,
17721 QCN_IE_SUBVERSION_SUPPORTED};
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053017722
Naveen Rawat224ae9c2016-10-24 15:36:56 -070017723 if (session->pConnectBssDesc)
17724 max_tx_pwr_cap = csr_get_cfg_max_tx_power(mac_ctx,
17725 session->pConnectBssDesc->channelId);
Selvaraj, Sridhar94be8ba2017-05-04 17:08:54 +053017726
17727 if (max_tx_pwr_cap && max_tx_pwr_cap < MAX_TX_PWR_CAP)
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053017728 power_cap_ie_data[1] = max_tx_pwr_cap;
Selvaraj, Sridhar94be8ba2017-05-04 17:08:54 +053017729 else
17730 power_cap_ie_data[1] = MAX_TX_PWR_CAP;
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053017731
17732 wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &csr_11henable);
17733
17734 if (csr_11henable && csr_is11h_supported(mac_ctx)) {
17735 /* Append power cap IE */
17736 csr_append_assoc_ies(mac_ctx, req_buf, IEEE80211_ELEMID_PWRCAP,
17737 DOT11F_IE_POWERCAPS_MAX_LEN,
17738 power_cap_ie_data);
17739 power_caps_populated = true;
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053017740
17741 /* Append Supported channels IE */
17742 csr_add_supported_5Ghz_channels(mac_ctx, supp_chan_ie,
17743 &supp_chan_ie_len, true);
17744
17745 csr_append_assoc_ies(mac_ctx, req_buf,
17746 IEEE80211_ELEMID_SUPPCHAN,
17747 supp_chan_ie_len, supp_chan_ie);
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053017748 }
17749
Yu Wang0477ee32017-02-10 20:02:03 +080017750#ifdef FEATURE_WLAN_ESE
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053017751 /* Append ESE version IE if isEseIniFeatureEnabled INI is enabled */
17752 if (mac_ctx->roam.configParam.isEseIniFeatureEnabled)
17753 csr_append_assoc_ies(mac_ctx, req_buf, IEEE80211_ELEMID_VENDOR,
17754 DOT11F_IE_ESEVERSION_MAX_LEN,
17755 ese_ie);
Yu Wang0477ee32017-02-10 20:02:03 +080017756#endif
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053017757
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053017758 if (mac_ctx->rrm.rrmPEContext.rrmEnable) {
17759 /* Append RRM IE */
17760 csr_append_assoc_ies(mac_ctx, req_buf, IEEE80211_ELEMID_RRM,
17761 DOT11F_IE_RRMENABLEDCAP_MAX_LEN,
17762 rrm_cap_ie_data);
17763 if (!power_caps_populated)
17764 /* Append Power cap IE if not appended already */
17765 csr_append_assoc_ies(mac_ctx, req_buf,
17766 IEEE80211_ELEMID_PWRCAP,
17767 DOT11F_IE_POWERCAPS_MAX_LEN,
17768 power_cap_ie_data);
17769 }
yeshwanth sriram guntuka27e4ffc2016-12-01 18:00:17 +053017770 ese_populate_addtional_ies(mac_ctx, session, req_buf);
17771
Selvaraj, Sridharced57062017-01-30 15:19:07 +053017772 /* Append QCN IE if g_support_qcn_ie INI is enabled */
17773 if (mac_ctx->roam.configParam.qcn_ie_support)
17774 csr_append_assoc_ies(mac_ctx, req_buf, IEEE80211_ELEMID_VENDOR,
17775 DOT11F_IE_QCN_IE_MAX_LEN,
17776 qcn_ie);
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053017777}
17778
17779/**
Kapil Gupta5cda2252016-12-29 18:44:26 +053017780 * csr_create_per_roam_request() - create PER roam offload scan request
17781 *
17782 * parameters
17783 * @mac_ctx: global mac ctx
17784 * @session_id: session id
17785 *
17786 * Return: per roam config request packet buffer
17787 */
17788static struct wmi_per_roam_config_req *
17789csr_create_per_roam_request(tpAniSirGlobal mac_ctx, uint8_t session_id)
17790{
17791 struct wmi_per_roam_config_req *req_buf = NULL;
17792
17793 req_buf = qdf_mem_malloc(sizeof(struct wmi_per_roam_config_req));
17794 if (!req_buf) {
17795 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053017796 "Mem alloc for per roam req failed");
Kapil Gupta5cda2252016-12-29 18:44:26 +053017797 return NULL;
17798 }
17799 req_buf->vdev_id = session_id;
17800 req_buf->per_config.enable =
17801 mac_ctx->roam.configParam.per_roam_config.enable;
17802 req_buf->per_config.tx_high_rate_thresh =
17803 mac_ctx->roam.configParam.per_roam_config.tx_high_rate_thresh;
17804 req_buf->per_config.rx_high_rate_thresh =
17805 mac_ctx->roam.configParam.per_roam_config.rx_high_rate_thresh;
17806 req_buf->per_config.tx_low_rate_thresh =
17807 mac_ctx->roam.configParam.per_roam_config.tx_low_rate_thresh;
17808 req_buf->per_config.rx_low_rate_thresh =
17809 mac_ctx->roam.configParam.per_roam_config.rx_low_rate_thresh;
17810 req_buf->per_config.per_rest_time =
17811 mac_ctx->roam.configParam.per_roam_config.per_rest_time;
Kapil Gupta957827b2017-02-13 15:47:04 +053017812 req_buf->per_config.tx_per_mon_time =
17813 mac_ctx->roam.configParam.per_roam_config.tx_per_mon_time;
17814 req_buf->per_config.rx_per_mon_time =
17815 mac_ctx->roam.configParam.per_roam_config.rx_per_mon_time;
Kapil Gupta5cda2252016-12-29 18:44:26 +053017816 req_buf->per_config.tx_rate_thresh_percnt =
17817 mac_ctx->roam.configParam.per_roam_config.tx_rate_thresh_percnt;
17818 req_buf->per_config.rx_rate_thresh_percnt =
17819 mac_ctx->roam.configParam.per_roam_config.rx_rate_thresh_percnt;
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +053017820 req_buf->per_config.min_candidate_rssi =
17821 mac_ctx->roam.configParam.per_roam_config.min_candidate_rssi;
Kapil Gupta5cda2252016-12-29 18:44:26 +053017822
17823 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +053017824 "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 +053017825 req_buf->per_config.enable, session_id,
17826 req_buf->per_config.tx_high_rate_thresh,
17827 req_buf->per_config.tx_low_rate_thresh,
17828 req_buf->per_config.tx_rate_thresh_percnt,
Kapil Gupta957827b2017-02-13 15:47:04 +053017829 req_buf->per_config.per_rest_time,
Selvaraj, Sridhar0641fab2017-05-17 16:02:00 +053017830 req_buf->per_config.tx_per_mon_time,
17831 req_buf->per_config.min_candidate_rssi);
Kapil Gupta5cda2252016-12-29 18:44:26 +053017832 return req_buf;
17833}
17834
17835/**
17836 * csr_roam_offload_per_scan() - populates roam offload scan request and sends
17837 * to WMA
17838 *
17839 * parameters
17840 * @mac_ctx: global mac ctx
17841 * @session_id: session id
17842 *
17843 * Return: result of operation
17844 */
17845static QDF_STATUS
17846csr_roam_offload_per_scan(tpAniSirGlobal mac_ctx, uint8_t session_id)
17847{
17848 tpCsrNeighborRoamControlInfo roam_info =
17849 &mac_ctx->roam.neighborRoamInfo[session_id];
17850 struct wmi_per_roam_config_req *req_buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070017851 struct scheduler_msg msg = {0};
Kapil Gupta5cda2252016-12-29 18:44:26 +053017852
17853 /*
17854 * No need to update in case of stop command, FW takes care of stopping
17855 * this internally
17856 */
17857 if (roam_info->last_sent_cmd == ROAM_SCAN_OFFLOAD_STOP)
17858 return QDF_STATUS_SUCCESS;
17859
17860 if (!mac_ctx->roam.configParam.per_roam_config.enable) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017861 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
17862 "PER based roaming is disabled in configuration");
Kapil Gupta5cda2252016-12-29 18:44:26 +053017863 return QDF_STATUS_SUCCESS;
17864 }
17865
17866 req_buf = csr_create_per_roam_request(mac_ctx, session_id);
17867 if (!req_buf) {
17868 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017869 "Failed to create req packet");
Kapil Gupta5cda2252016-12-29 18:44:26 +053017870 return QDF_STATUS_E_FAILURE;
17871 }
17872 msg.type = WMA_SET_PER_ROAM_CONFIG_CMD;
17873 msg.reserved = 0;
17874 msg.bodyptr = req_buf;
17875 if (!QDF_IS_STATUS_SUCCESS(scheduler_post_msg(QDF_MODULE_ID_WMA,
17876 &msg))) {
17877 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
17878 "%s: Unable to post WMA_SET_PER_ROAM_CONFIG_CMD to WMA",
17879 __func__);
17880 qdf_mem_free(req_buf);
17881 }
17882 return QDF_STATUS_SUCCESS;
17883}
17884
17885/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017886 * csr_roam_offload_scan() - populates roam offload scan request and sends to
17887 * WMA
17888 *
17889 * paramters
17890 * @mac_ctx: global mac ctx
17891 * @session_id: session id
17892 * @command: roam scan offload command input
17893 * @reason: reason to roam
17894 *
17895 * Return: result of operation
17896 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017897QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017898csr_roam_offload_scan(tpAniSirGlobal mac_ctx, uint8_t session_id,
17899 uint8_t command, uint8_t reason)
17900{
17901 uint8_t *state = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017902 tSirRoamOffloadScanReq *req_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017903 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017904 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
17905 tpCsrNeighborRoamControlInfo roam_info =
17906 &mac_ctx->roam.neighborRoamInfo[session_id];
17907 struct roam_ext_params *roam_params_dst;
17908 struct roam_ext_params *roam_params_src;
17909 uint8_t i;
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080017910 uint8_t op_channel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017911
Selvaraj, Sridhar8fe6c672017-01-10 11:37:29 +053017912 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
17913 "RSO Command %d, Session id %d, Reason %d",
17914 command, session_id, reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017915 if (NULL == session) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017916 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017917 "session is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017918 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017919 }
Sreelakshmi Konamkibda5bbf2016-09-12 18:38:10 +053017920
Selvaraj, Sridhar50566502017-05-15 18:26:47 +053017921 if ((ROAM_SCAN_OFFLOAD_START == command &&
17922 REASON_CTX_INIT != reason) &&
17923 (session->pCurRoamProfile &&
17924 session->pCurRoamProfile->do_not_roam)) {
17925 sme_debug("Supplicant disabled driver roaming");
17926 return QDF_STATUS_E_FAILURE;
17927 }
17928
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017929 if (0 == csr_roam_is_roam_offload_scan_enabled(mac_ctx)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017930 sme_err("isRoamOffloadScanEnabled not set");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017931 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017932 }
17933 if (!csr_is_RSO_cmd_allowed(mac_ctx, command, session_id) &&
17934 reason != REASON_ROAM_SET_BLACKLIST_BSSID) {
Srinivas Girigowda6598eea2017-07-06 19:26:19 -070017935 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017936 ("RSO out-of-sync command %d lastSentCmd %d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017937 command, roam_info->last_sent_cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017938 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017939 }
17940
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070017941 if ((true == roam_info->b_roam_scan_offload_started)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017942 && (ROAM_SCAN_OFFLOAD_START == command)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017943 sme_err("Roam Scan Offload is already started");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017944 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017945 }
17946 /*
17947 * The Dynamic Config Items Update may happen even if the state is in
17948 * INIT. It is important to ensure that the command is passed down to
Naveen Rawat224ae9c2016-10-24 15:36:56 -070017949 * the FW only if the Infra Station is in a connected state. A connected
17950 * station could also be in a PREAUTH or REASSOC states.
17951 * 1) Block all CMDs that are not STOP in INIT State. For STOP always
17952 * inform firmware irrespective of state.
17953 * 2) Block update cfg CMD if its for REASON_ROAM_SET_BLACKLIST_BSSID,
17954 * because we need to inform firmware of blacklisted AP for PNO in
17955 * all states.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017956 */
17957
17958 if ((roam_info->neighborRoamState ==
17959 eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
17960 (command != ROAM_SCAN_OFFLOAD_STOP) &&
17961 (reason != REASON_ROAM_SET_BLACKLIST_BSSID)) {
17962 state = mac_trace_get_neighbour_roam_state(
17963 roam_info->neighborRoamState);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017964 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017965 FL("Scan Command not sent to FW state=%s and cmd=%d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017966 state, command);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017967 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017968 }
17969
17970 req_buf = csr_create_roam_scan_offload_request(mac_ctx, command,
17971 session_id, reason,
17972 session, roam_info);
17973 if (!req_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017974 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070017975 "Failed to create req packet");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017976 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017977 }
17978 roam_params_dst = &req_buf->roam_params;
17979 roam_params_src = &mac_ctx->roam.configParam.roam_params;
17980 if (reason == REASON_ROAM_SET_SSID_ALLOWED)
17981 check_allowed_ssid_list(req_buf, roam_params_src);
Abhishek Singh4db8c152017-07-18 10:40:08 +053017982
17983 /*
17984 * For CTX INT cmd if rssi disallow bssid list have any member
17985 * fill it and send it to firmware so that firmware does not
17986 * try to roam to these BSS untill RSSI OR time condition are
17987 * matched.
17988 */
17989 if (reason == REASON_CTX_INIT)
17990 csr_add_rssi_reject_ap_list(mac_ctx, roam_params_src);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017991 /*
17992 * Configure the lookup threshold either from INI or from framework.
17993 * If both are present, give higher priority to the one from framework.
17994 */
17995 if (roam_params_src->alert_rssi_threshold)
17996 req_buf->LookupThreshold =
17997 roam_params_src->alert_rssi_threshold;
17998 else
17999 req_buf->LookupThreshold =
18000 (int8_t)roam_info->cfgParams.neighborLookupThreshold *
18001 (-1);
Varun Reddy Yeturu168134f2017-06-26 13:46:05 -070018002 req_buf->rssi_thresh_offset_5g =
18003 roam_info->cfgParams.rssi_thresh_offset_5g;
18004 sme_debug("5g offset threshold: %d", req_buf->rssi_thresh_offset_5g);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018005 qdf_mem_copy(roam_params_dst, roam_params_src,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018006 sizeof(struct roam_ext_params));
18007 /*
18008 * rssi_diff which is updated via framework is equivalent to the
18009 * INI RoamRssiDiff parameter and hence should be updated.
18010 */
18011 if (roam_params_src->rssi_diff)
18012 req_buf->RoamRssiDiff = roam_params_src->rssi_diff;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018013 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018014 "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 -080018015 roam_params_dst->num_bssid_avoid_list,
18016 roam_params_dst->num_ssid_allowed_list,
18017 roam_params_dst->num_bssid_favored,
18018 roam_params_dst->raise_rssi_thresh_5g,
18019 roam_params_dst->drop_rssi_thresh_5g,
18020 roam_params_dst->raise_rssi_type_5g,
18021 roam_params_dst->raise_factor_5g,
18022 roam_params_dst->drop_rssi_type_5g,
18023 roam_params_dst->drop_factor_5g,
18024 roam_params_dst->max_raise_rssi_5g,
18025 roam_params_dst->max_drop_rssi_5g,
18026 req_buf->RoamRssiDiff, roam_params_dst->alert_rssi_threshold);
18027
Gupta, Kapil71221252016-06-28 15:35:02 +053018028 /* Set initial dense roam status */
Kapil Gupta0a2477b2016-08-23 18:00:34 +053018029 if (mac_ctx->scan.roam_candidate_count[session_id] >
Gupta, Kapil71221252016-06-28 15:35:02 +053018030 roam_params_dst->dense_min_aps_cnt)
18031 roam_params_dst->initial_dense_status = true;
18032
Kapil Gupta0a2477b2016-08-23 18:00:34 +053018033 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Selvaraj, Sridhard1225e62017-03-17 12:56:58 +053018034 "dense_rssi_thresh_offset: %d, dense_min_aps_cnt:%d, traffic_threshold:%d, "
18035 "initial_dense_status:%d, candidate count:%d",
18036 roam_params_dst->dense_rssi_thresh_offset,
18037 roam_params_dst->dense_min_aps_cnt,
18038 roam_params_dst->traffic_threshold,
18039 roam_params_dst->initial_dense_status,
18040 mac_ctx->scan.roam_candidate_count[session_id]);
Kapil Gupta0a2477b2016-08-23 18:00:34 +053018041
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018042 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018043 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018044 "Blacklist Bssid:"MAC_ADDRESS_STR")",
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018045 MAC_ADDR_ARRAY(roam_params_dst->bssid_avoid_list[i].
18046 bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018047 }
18048 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018049 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018050 "Whitelist: %.*s",
18051 roam_params_dst->ssid_allowed_list[i].length,
18052 roam_params_dst->ssid_allowed_list[i].ssId);
18053 }
18054 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018055 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018056 "Preferred Bssid:"MAC_ADDRESS_STR") score: %d",
Srinivas Girigowdab0532392015-11-24 11:50:16 -080018057 MAC_ADDR_ARRAY(roam_params_dst->bssid_favored[i].bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018058 roam_params_dst->bssid_favored_factor[i]);
18059 }
18060
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080018061 op_channel = session->connectedProfile.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018062 req_buf->hi_rssi_scan_max_count =
18063 roam_info->cfgParams.hi_rssi_scan_max_count;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018064 req_buf->hi_rssi_scan_delay =
18065 roam_info->cfgParams.hi_rssi_scan_delay;
18066 req_buf->hi_rssi_scan_rssi_ub =
18067 roam_info->cfgParams.hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080018068 /*
18069 * If the current operation channel is 5G frequency band, then
18070 * there is no need to enable the HI_RSSI feature. This feature
18071 * is useful only if we are connected to a 2.4 GHz AP and we wish
18072 * to connect to a better 5GHz AP is available.
18073 */
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070018074 if (session->disable_hi_rssi)
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080018075 req_buf->hi_rssi_scan_rssi_delta = 0;
Varun Reddy Yeturu7fc616d2016-04-25 17:03:56 -070018076 else
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080018077 req_buf->hi_rssi_scan_rssi_delta =
18078 roam_info->cfgParams.hi_rssi_scan_rssi_delta;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018079 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080018080 "hi_rssi:delta=%d, max_count=%d, delay=%d, ub=%d",
18081 req_buf->hi_rssi_scan_rssi_delta,
18082 req_buf->hi_rssi_scan_max_count,
18083 req_buf->hi_rssi_scan_delay,
18084 req_buf->hi_rssi_scan_rssi_ub);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018085
Selvaraj, Sridharfb6f4cd2016-09-06 18:57:52 +053018086 if (command != ROAM_SCAN_OFFLOAD_STOP) {
Naveen Rawatf311a5a2016-11-15 23:38:10 -080018087 req_buf->assoc_ie.length = session->nAddIEAssocLength;
Selvaraj, Sridhara7fc7632016-09-04 13:13:38 +053018088 qdf_mem_copy(req_buf->assoc_ie.addIEdata,
18089 session->pAddIEAssoc,
18090 session->nAddIEAssocLength);
Selvaraj, Sridhar57bb4d02016-08-31 16:14:15 +053018091 csr_update_driver_assoc_ies(mac_ctx, session, req_buf);
Selvaraj, Sridhara7fc7632016-09-04 13:13:38 +053018092 }
18093
Selvaraj, Sridhard1225e62017-03-17 12:56:58 +053018094 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
18095 "Assoc IE buffer:");
18096 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
18097 req_buf->assoc_ie.addIEdata, req_buf->assoc_ie.length);
18098
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053018099 if (!QDF_IS_STATUS_SUCCESS(
18100 csr_roam_send_rso_cmd(mac_ctx, session_id, req_buf))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018101 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Selvaraj, Sridhar01741822016-08-30 18:26:19 +053018102 "%s: Not able to post message to PE",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018103 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018104 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018105 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018106 if (ROAM_SCAN_OFFLOAD_START == command)
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070018107 roam_info->b_roam_scan_offload_started = true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018108 else if (ROAM_SCAN_OFFLOAD_STOP == command)
Varun Reddy Yeturu66899fe2017-07-11 14:00:12 -070018109 roam_info->b_roam_scan_offload_started = false;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018110
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018111 /* update the last sent cmd */
18112 roam_info->last_sent_cmd = command;
18113
Kapil Gupta5cda2252016-12-29 18:44:26 +053018114 /* Update PER config to FW after sending the command */
18115 csr_roam_offload_per_scan(mac_ctx, session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018116 return status;
18117}
18118
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018119QDF_STATUS csr_roam_offload_scan_rsp_hdlr(tpAniSirGlobal pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018120 tpSirRoamOffloadScanRsp
18121 scanOffloadRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018122{
18123 switch (scanOffloadRsp->reason) {
18124 case 0:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018125 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018126 "Rsp for Roam Scan Offload with failure status");
18127 break;
18128 case REASON_OS_REQUESTED_ROAMING_NOW:
18129 csr_neighbor_roam_proceed_with_handoff_req(pMac,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018130 scanOffloadRsp->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018131 break;
18132
18133 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018134 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018135 "Rsp for Roam Scan Offload with reason %d",
18136 scanOffloadRsp->reason);
18137 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018138 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018139}
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080018140#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018141
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018142/* pStaEntry is no longer invalid upon the return of this function. */
18143static void csr_roam_remove_stat_list_entry(tpAniSirGlobal pMac,
18144 tListElem *pEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018145{
18146 if (pEntry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018147 if (csr_ll_remove_entry(&pMac->roam.statsClientReqList,
18148 pEntry, LL_ACCESS_LOCK))
18149 qdf_mem_free(GET_BASE_ADDR(pEntry,
18150 tCsrStatsClientReqInfo, link));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018151 }
18152}
18153
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018154static void csr_roam_remove_entry_from_pe_stats_req_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018155 tCsrPeStatsReqInfo *pPeStaEntry)
18156{
18157 tListElem *pEntry;
18158 tCsrPeStatsReqInfo *pTempStaEntry;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018159
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018160 pEntry = csr_ll_peek_head(&pMac->roam.peStatsReqList, LL_ACCESS_LOCK);
18161 if (!pEntry) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018162 sme_err("List empty, no stats req for PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018163 return;
18164 }
18165 while (pEntry) {
18166 pTempStaEntry = GET_BASE_ADDR(pEntry, tCsrPeStatsReqInfo, link);
18167 if (NULL == pTempStaEntry
18168 || (pTempStaEntry->statsMask !=
18169 pPeStaEntry->statsMask)) {
18170 pEntry = csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
18171 LL_ACCESS_NOLOCK);
18172 continue;
18173 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018174 sme_debug("Match found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018175 if (csr_ll_remove_entry(&pMac->roam.peStatsReqList, pEntry,
18176 LL_ACCESS_LOCK)) {
Naveen Rawatd0ca4412017-06-16 14:19:19 -070018177 qdf_mem_free(pTempStaEntry);
18178 pTempStaEntry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018179 break;
18180 }
18181 pEntry = csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
18182 LL_ACCESS_NOLOCK);
18183 } /* end of while loop */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018184}
18185
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018186static void csr_roam_report_statistics(tpAniSirGlobal pMac, uint32_t statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018187 tCsrStatsCallback callback, uint8_t staId,
18188 void *pContext)
18189{
18190 uint8_t stats[500];
18191 uint8_t *pStats = NULL;
18192 uint32_t tempMask = 0;
18193 uint8_t counter = 0;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018194
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018195 if (!callback) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018196 sme_err("Cannot report callback NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018197 return;
18198 }
18199 if (!statsMask) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018200 sme_err("Cannot report statsMask is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018201 return;
18202 }
18203 pStats = stats;
18204 tempMask = statsMask;
18205 while (tempMask) {
18206 if (tempMask & 1) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018207 /* new stats info from PE, fill up the stats
18208 * strucutres in PMAC
18209 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018210 switch (counter) {
18211 case eCsrSummaryStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018212 sme_debug("Summary stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018213 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018214 (uint8_t *) &pMac->roam.
18215 summaryStatsInfo,
18216 sizeof(tCsrSummaryStatsInfo));
18217 pStats += sizeof(tCsrSummaryStatsInfo);
18218 break;
18219 case eCsrGlobalClassAStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018220 sme_debug("ClassA stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018221 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018222 (uint8_t *) &pMac->roam.
18223 classAStatsInfo,
18224 sizeof(tCsrGlobalClassAStatsInfo));
18225 pStats += sizeof(tCsrGlobalClassAStatsInfo);
18226 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018227 case eCsrGlobalClassDStats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018228 sme_debug("ClassD stats");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018229 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018230 (uint8_t *) &pMac->roam.
18231 classDStatsInfo,
18232 sizeof(tCsrGlobalClassDStatsInfo));
18233 pStats += sizeof(tCsrGlobalClassDStatsInfo);
18234 break;
Himanshu Agarwal37e42412016-07-21 14:35:09 +053018235 case csr_per_chain_rssi_stats:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018236 sme_debug("Per Chain RSSI stats");
Himanshu Agarwal37e42412016-07-21 14:35:09 +053018237 qdf_mem_copy(pStats,
18238 (uint8_t *)&pMac->roam.per_chain_rssi_stats,
18239 sizeof(struct csr_per_chain_rssi_stats_info));
18240 pStats += sizeof(
18241 struct csr_per_chain_rssi_stats_info);
18242 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018243 default:
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018244 sme_err(
18245 "Unknown stats type and counter %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018246 counter);
18247 break;
18248 }
18249 }
18250 tempMask >>= 1;
18251 counter++;
18252 }
18253 callback(stats, pContext);
18254}
18255
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018256static QDF_STATUS csr_roam_dereg_statistics_req(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018257{
18258 tListElem *pEntry = NULL;
18259 tListElem *pPrevEntry = NULL;
18260 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018261 QDF_STATUS status = QDF_STATUS_SUCCESS;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018262
18263 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList,
18264 LL_ACCESS_LOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018265 if (!pEntry) {
18266 /* list empty */
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018267 sme_debug("List empty, no request from upper layer client(s)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018268 return status;
18269 }
18270 while (pEntry) {
18271 if (pPrevEntry) {
18272 pTempStaEntry =
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018273 GET_BASE_ADDR(pPrevEntry,
18274 tCsrStatsClientReqInfo, link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018275 /* send up the stats report */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018276 csr_roam_report_statistics(pMac,
18277 pTempStaEntry->statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018278 pTempStaEntry->callback,
18279 pTempStaEntry->staId,
18280 pTempStaEntry->pContext);
18281 csr_roam_remove_stat_list_entry(pMac, pPrevEntry);
18282 }
18283 pTempStaEntry =
18284 GET_BASE_ADDR(pEntry, tCsrStatsClientReqInfo, link);
18285 if (pTempStaEntry->pPeStaEntry) {
18286 /* pPeStaEntry can be NULL */
18287 pTempStaEntry->pPeStaEntry->numClient--;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018288 /* check if we need to delete the entry from
18289 * peStatsReqList too
18290 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018291 if (!pTempStaEntry->pPeStaEntry->numClient) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018292 csr_roam_remove_entry_from_pe_stats_req_list(
18293 pMac,
18294 pTempStaEntry->
18295 pPeStaEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018296 }
18297 }
18298 /* check if we need to stop the tl stats timer too */
18299 pMac->roam.tlStatsReqInfo.numClient--;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018300 pPrevEntry = pEntry;
Naveen Rawatd0ca4412017-06-16 14:19:19 -070018301 pEntry = csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
18302 LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018303 }
18304 /* the last one */
18305 if (pPrevEntry) {
18306 pTempStaEntry =
18307 GET_BASE_ADDR(pPrevEntry, tCsrStatsClientReqInfo, link);
18308 /* send up the stats report */
18309 csr_roam_report_statistics(pMac, pTempStaEntry->statsMask,
18310 pTempStaEntry->callback,
18311 pTempStaEntry->staId,
18312 pTempStaEntry->pContext);
18313 csr_roam_remove_stat_list_entry(pMac, pPrevEntry);
18314 }
18315 return status;
18316
18317}
18318
18319tSmeCmd *csr_get_command_buffer(tpAniSirGlobal pMac)
18320{
18321 tSmeCmd *pCmd = sme_get_command_buffer(pMac);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018322
18323 if (pCmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018324 pMac->roam.sPendingCommands++;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018325
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018326 return pCmd;
18327}
18328
Krunal Sonidea45952017-02-15 11:58:15 -080018329static void csr_free_cmd_memory(tpAniSirGlobal pMac, tSmeCmd *pCommand)
18330{
18331 if (!pCommand) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070018332 sme_err("pCommand is NULL");
Krunal Sonidea45952017-02-15 11:58:15 -080018333 return;
18334 }
18335 switch (pCommand->command) {
18336 case eSmeCommandScan:
Krunal Soni81f068c2017-02-23 19:51:55 -080018337 csr_scan_call_callback(pMac, pCommand,
18338 pCommand->u.scanCmd.status);
Krunal Sonidea45952017-02-15 11:58:15 -080018339 csr_release_command_scan(pMac, pCommand);
18340 break;
18341 case eSmeCommandRoam:
18342 csr_release_command_roam(pMac, pCommand);
18343 break;
18344 case eSmeCommandWmStatusChange:
18345 csr_release_command_wm_status_change(pMac, pCommand);
18346 break;
Krunal Sonidea45952017-02-15 11:58:15 -080018347 case eSmeCommandNdpInitiatorRequest:
18348 csr_release_ndp_initiator_req(pMac, pCommand);
18349 break;
18350 case eSmeCommandNdpResponderRequest:
18351 csr_release_ndp_responder_req(pMac, pCommand);
18352 break;
18353 case eSmeCommandNdpDataEndInitiatorRequest:
18354 csr_release_ndp_data_end_req(pMac, pCommand);
18355 break;
18356 case eSmeCommandRemainOnChannel:
18357 csr_release_roc_req_cmd(pMac, pCommand);
18358 break;
18359 default:
18360 break;
18361 }
18362}
18363
Krunal Sonia8270f52017-02-23 19:51:25 -080018364void csr_release_command_buffer(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018365{
18366 if (pMac->roam.sPendingCommands > 0) {
Krunal Sonidea45952017-02-15 11:58:15 -080018367 /*
18368 * All command allocated through csr_get_command_buffer
18369 * need to decrement the pending count when releasing
18370 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018371 pMac->roam.sPendingCommands--;
Krunal Sonidea45952017-02-15 11:58:15 -080018372 csr_free_cmd_memory(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018373 sme_release_command(pMac, pCommand);
18374 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018375 sme_err("no pending commands");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018376 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018377 }
18378}
18379
Krunal Sonia8270f52017-02-23 19:51:25 -080018380void csr_release_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018381{
Krunal Sonia8270f52017-02-23 19:51:25 -080018382 struct wlan_serialization_queued_cmd_info cmd_info;
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080018383 struct wlan_serialization_command cmd;
Krunal Sonic3c8b8b2017-06-19 13:52:37 -070018384 struct wlan_objmgr_vdev *vdev;
Krunal Sonia8270f52017-02-23 19:51:25 -080018385
18386 if (!sme_cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018387 sme_err("sme_cmd is NULL");
Krunal Sonia8270f52017-02-23 19:51:25 -080018388 return;
18389 }
Krunal Sonic3c8b8b2017-06-19 13:52:37 -070018390 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
18391 sme_cmd->sessionId, WLAN_LEGACY_SME_ID);
18392 if (!vdev) {
18393 sme_err("Invalid vdev");
18394 return;
18395 }
Krunal Soni81f068c2017-02-23 19:51:55 -080018396 qdf_mem_zero(&cmd_info,
18397 sizeof(struct wlan_serialization_queued_cmd_info));
18398 if (sme_cmd->command == eSmeCommandScan ||
18399 sme_cmd->command == eSmeCommandRemainOnChannel) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018400 sme_debug("filled cmd_id[%d]",
Krunal Soni81f068c2017-02-23 19:51:55 -080018401 sme_cmd->u.scanCmd.scanID);
18402 cmd_info.cmd_id = sme_cmd->u.scanCmd.scanID;
18403 cmd_info.req_type = WLAN_SER_CANCEL_SINGLE_SCAN;
Krunal Sonia8270f52017-02-23 19:51:25 -080018404 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018405 sme_debug("filled cmd_id = 0");
Krunal Soni81f068c2017-02-23 19:51:55 -080018406 cmd_info.cmd_id = 0;
18407 cmd_info.req_type = WLAN_SER_CANCEL_NON_SCAN_CMD;
18408 }
18409 cmd_info.cmd_type = csr_get_cmd_type(sme_cmd);
Krunal Sonic3c8b8b2017-06-19 13:52:37 -070018410 cmd_info.vdev = vdev;
18411 qdf_mem_zero(&cmd, sizeof(struct wlan_serialization_command));
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080018412 cmd.cmd_id = cmd_info.cmd_id;
18413 cmd.cmd_type = cmd_info.cmd_type;
18414 cmd.vdev = cmd_info.vdev;
Krunal Soni81f068c2017-02-23 19:51:55 -080018415 if (wlan_serialization_is_cmd_present_in_active_queue(
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080018416 mac_ctx->psoc, &cmd)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018417 sme_debug("Releasing active cmd_id[%d] cmd_type[%d]",
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080018418 cmd_info.cmd_id, cmd_info.cmd_type);
Krunal Soni81f068c2017-02-23 19:51:55 -080018419 wlan_serialization_remove_cmd(&cmd_info);
18420 } else if (wlan_serialization_is_cmd_present_in_pending_queue(
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080018421 mac_ctx->psoc, &cmd)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018422 sme_debug("Releasing pending cmd_id[%d] cmd_type[%d]",
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080018423 cmd_info.cmd_id, cmd_info.cmd_type);
Krunal Soni81f068c2017-02-23 19:51:55 -080018424 wlan_serialization_cancel_request(&cmd_info);
18425 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018426 sme_debug("can't find cmd_id[%d] cmd_type[%d]",
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080018427 cmd_info.cmd_id, cmd_info.cmd_type);
Krunal Sonia8270f52017-02-23 19:51:25 -080018428 }
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080018429 if (cmd_info.vdev)
18430 wlan_objmgr_vdev_release_ref(cmd_info.vdev, WLAN_LEGACY_SME_ID);
Krunal Sonia8270f52017-02-23 19:51:25 -080018431}
18432
18433static enum wlan_serialization_cmd_type csr_get_scan_cmd_type(tSmeCmd *sme_cmd)
18434{
18435 enum wlan_serialization_cmd_type cmd_type = WLAN_SER_CMD_MAX;
18436
18437 switch (sme_cmd->u.scanCmd.reason) {
18438 case eCsrScanOther:
18439 cmd_type = WLAN_SER_CMD_SCAN_OTHER;
18440 break;
18441 case eCsrScanLostLink1:
18442 cmd_type = WLAN_SER_CMD_SCAN_LOST_LINK1;
18443 break;
18444 case eCsrScanLostLink2:
18445 cmd_type = WLAN_SER_CMD_SCAN_LOST_LINK2;
18446 break;
18447 case eCsrScanLostLink3:
18448 cmd_type = WLAN_SER_CMD_SCAN_LOST_LINK3;
18449 break;
18450 case eCsrScan11d1:
18451 cmd_type = WLAN_SER_CMD_SCAN_11D_TYPE1;
18452 break;
18453 case eCsrScan11d2:
18454 cmd_type = WLAN_SER_CMD_SCAN_11D_TYPE2;
18455 break;
18456 case eCsrScan11dDone:
18457 cmd_type = WLAN_SER_CMD_SCAN_11D_DONE;
18458 break;
18459 case eCsrScanUserRequest:
18460 cmd_type = WLAN_SER_CMD_SCAN_USER_REQ;
18461 break;
18462 case eCsrScanForSsid:
18463 cmd_type = WLAN_SER_CMD_SCAN_FOR_SSID;
18464 break;
18465 case eCsrScanIdleScan:
18466 cmd_type = WLAN_SER_CMD_SCAN_IDLE_SCAN;
18467 break;
18468 case eCsrScanProbeBss:
18469 cmd_type = WLAN_SER_CMD_SCAN_PROBE_BSS;
18470 break;
18471 case eCsrScanAbortNormalScan:
18472 cmd_type = WLAN_SER_CMD_SCAN_ABORT_NORMAL_SCAN;
18473 break;
18474 case eCsrScanP2PFindPeer:
18475 cmd_type = WLAN_SER_CMD_SCAN_P2P_FIND_PEER;
18476 break;
18477 case eCsrScanCandidateFound:
18478 cmd_type = WLAN_SER_CMD_SCAN_CANDIDATE_FOUND;
18479 break;
18480 default:
18481 break;
18482 }
18483
18484 return cmd_type;
18485}
18486
18487static enum wlan_serialization_cmd_type csr_get_roam_cmd_type(tSmeCmd *sme_cmd)
18488{
18489 enum wlan_serialization_cmd_type cmd_type = WLAN_SER_CMD_MAX;
18490 switch (sme_cmd->u.roamCmd.roamReason) {
18491 case eCsrForcedDisassoc:
18492 cmd_type = WLAN_SER_CMD_FORCE_DISASSOC;
18493 break;
18494 case eCsrHddIssued:
18495 cmd_type = WLAN_SER_CMD_HDD_ISSUED;
18496 break;
18497 case eCsrLostLink1:
18498 cmd_type = WLAN_SER_CMD_LOST_LINK1;
18499 break;
18500 case eCsrLostLink2:
18501 cmd_type = WLAN_SER_CMD_LOST_LINK2;
18502 break;
18503 case eCsrLostLink3:
18504 cmd_type = WLAN_SER_CMD_LOST_LINK3;
18505 break;
18506 case eCsrForcedDisassocMICFailure:
18507 cmd_type = WLAN_SER_CMD_FORCE_DISASSOC_MIC_FAIL;
18508 break;
18509 case eCsrHddIssuedReassocToSameAP:
18510 cmd_type = WLAN_SER_CMD_HDD_ISSUE_REASSOC_SAME_AP;
18511 break;
18512 case eCsrSmeIssuedReassocToSameAP:
18513 cmd_type = WLAN_SER_CMD_SME_ISSUE_REASSOC_SAME_AP;
18514 break;
18515 case eCsrSmeIssuedReassocToDiffAP:
18516 cmd_type = WLAN_SER_CMD_SME_ISSUE_REASSOC_DIFF_AP;
18517 break;
18518 case eCsrForcedDeauth:
18519 cmd_type = WLAN_SER_CMD_FORCE_DEAUTH;
18520 break;
18521 case eCsrSmeIssuedDisassocForHandoff:
18522 cmd_type =
18523 WLAN_SER_CMD_SME_ISSUE_DISASSOC_FOR_HANDOFF;
18524 break;
18525 case eCsrSmeIssuedAssocToSimilarAP:
18526 cmd_type =
18527 WLAN_SER_CMD_SME_ISSUE_ASSOC_TO_SIMILAR_AP;
18528 break;
18529 case eCsrSmeIssuedIbssJoinFailure:
18530 cmd_type = WLAN_SER_CMD_SME_ISSUE_IBSS_JOIN_FAIL;
18531 break;
18532 case eCsrForcedIbssLeave:
18533 cmd_type = WLAN_SER_CMD_FORCE_IBSS_LEAVE;
18534 break;
18535 case eCsrStopBss:
18536 cmd_type = WLAN_SER_CMD_STOP_BSS;
18537 break;
18538 case eCsrSmeIssuedFTReassoc:
18539 cmd_type = WLAN_SER_CMD_SME_ISSUE_FT_REASSOC;
18540 break;
18541 case eCsrForcedDisassocSta:
18542 cmd_type = WLAN_SER_CMD_FORCE_DISASSOC_STA;
18543 break;
18544 case eCsrForcedDeauthSta:
18545 cmd_type = WLAN_SER_CMD_FORCE_DEAUTH_STA;
18546 break;
18547 case eCsrPerformPreauth:
18548 cmd_type = WLAN_SER_CMD_PERFORM_PRE_AUTH;
18549 break;
Krunal Sonia8270f52017-02-23 19:51:25 -080018550 default:
18551 break;
18552 }
18553
18554 return cmd_type;
18555}
18556
18557enum wlan_serialization_cmd_type csr_get_cmd_type(tSmeCmd *sme_cmd)
18558{
18559 enum wlan_serialization_cmd_type cmd_type = WLAN_SER_CMD_MAX;
18560
18561 switch (sme_cmd->command) {
18562 case eSmeCommandScan:
18563 cmd_type = csr_get_scan_cmd_type(sme_cmd);
18564 break;
18565 case eSmeCommandRoam:
18566 cmd_type = csr_get_roam_cmd_type(sme_cmd);
18567 break;
18568 case eSmeCommandWmStatusChange:
18569 cmd_type = WLAN_SER_CMD_WM_STATUS_CHANGE;
18570 break;
Krunal Sonia8270f52017-02-23 19:51:25 -080018571 case eSmeCommandNdpInitiatorRequest:
18572 cmd_type = WLAN_SER_CMD_NDP_INIT_REQ;
18573 break;
18574 case eSmeCommandNdpResponderRequest:
18575 cmd_type = WLAN_SER_CMD_NDP_RESP_REQ;
18576 break;
18577 case eSmeCommandNdpDataEndInitiatorRequest:
18578 cmd_type = WLAN_SER_CMD_NDP_DATA_END_INIT_REQ;
18579 break;
18580 case eSmeCommandRemainOnChannel:
18581 cmd_type = WLAN_SER_CMD_REMAIN_ON_CHANNEL;
18582 break;
18583 case eSmeCommandEnterStandby:
18584 cmd_type = WLAN_SER_CMD_ENTER_STANDBY;
18585 break;
18586 case eSmeCommandAddTs:
18587 cmd_type = WLAN_SER_CMD_ADDTS;
18588 break;
18589 case eSmeCommandDelTs:
18590 cmd_type = WLAN_SER_CMD_DELTS;
18591 break;
18592 case eSmeCommandTdlsSendMgmt:
18593 cmd_type = WLAN_SER_CMD_TDLS_SEND_MGMT;
18594 break;
18595 case eSmeCommandTdlsAddPeer:
18596 cmd_type = WLAN_SER_CMD_TDLS_ADD_PEER;
18597 break;
18598 case eSmeCommandTdlsDelPeer:
18599 cmd_type = WLAN_SER_CMD_TDLS_DEL_PEER;
18600 break;
18601 case eSmeCommandTdlsLinkEstablish:
18602 cmd_type = WLAN_SER_CMD_TDLS_LINK_EST;
18603 break;
18604 case e_sme_command_set_hw_mode:
18605 cmd_type = WLAN_SER_CMD_SET_HW_MODE;
18606 break;
18607 case e_sme_command_nss_update:
18608 cmd_type = WLAN_SER_CMD_NSS_UPDATE;
18609 break;
18610 case e_sme_command_set_dual_mac_config:
18611 cmd_type = WLAN_SER_CMD_SET_DUAL_MAC_CONFIG;
18612 break;
18613 case e_sme_command_set_antenna_mode:
18614 cmd_type = WLAN_SER_CMD_SET_ANTENNA_MODE;
18615 break;
Krunal Sonia8270f52017-02-23 19:51:25 -080018616 case eSmeCommandEnterBmps:
18617 cmd_type = WLAN_SER_CMD_ENTER_BMPS;
18618 break;
18619 case eSmeCommandExitBmps:
18620 cmd_type = WLAN_SER_CMD_EXIT_BMPS;
18621 break;
18622 case eSmeCommandEnterUapsd:
18623 cmd_type = WLAN_SER_CMD_ENTER_UAPSD;
18624 break;
18625 case eSmeCommandExitUapsd:
18626 cmd_type = WLAN_SER_CMD_EXIT_UAPSD;
18627 break;
18628 case eSmeCommandExitWowl:
18629 cmd_type = WLAN_SER_CMD_EXIT_WOWL;
18630 break;
18631 default:
18632 break;
18633 }
18634
18635 return cmd_type;
18636}
18637
18638QDF_STATUS csr_set_serialization_params_to_cmd(tpAniSirGlobal mac_ctx,
18639 tSmeCmd *sme_cmd, struct wlan_serialization_command *cmd,
18640 uint8_t high_priority)
18641{
18642 QDF_STATUS status = QDF_STATUS_E_FAILURE;
18643
18644 if (!sme_cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018645 sme_err("Invalid sme_cmd");
Krunal Sonia8270f52017-02-23 19:51:25 -080018646 return status;
18647 }
18648 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018649 sme_err("Invalid serialization_cmd");
Krunal Sonia8270f52017-02-23 19:51:25 -080018650 return status;
18651 }
18652
18653 /*
18654 * no need to fill command id for non-scan as they will be
18655 * zero always
18656 */
Krunal Soni81f068c2017-02-23 19:51:55 -080018657 if (sme_cmd->command == eSmeCommandScan ||
18658 sme_cmd->command == eSmeCommandRemainOnChannel) {
18659 cmd->cmd_id = sme_cmd->u.scanCmd.scanID;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018660 sme_debug("cmd_id[%d]", sme_cmd->u.scanCmd.scanID);
Krunal Soni81f068c2017-02-23 19:51:55 -080018661 } else {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018662 sme_debug("cmd_id = 0");
Krunal Soni81f068c2017-02-23 19:51:55 -080018663 cmd->cmd_id = 0;
18664 }
Krunal Sonia8270f52017-02-23 19:51:25 -080018665 cmd->cmd_type = csr_get_cmd_type(sme_cmd);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018666 sme_debug("filled cmd_type[%d] cmd_id[%d]",
Krunal Soni81f068c2017-02-23 19:51:55 -080018667 cmd->cmd_type, cmd->cmd_id);
Krunal Sonia8270f52017-02-23 19:51:25 -080018668 if (cmd->cmd_type == WLAN_SER_CMD_MAX) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070018669 sme_err("serialization enum not found");
Krunal Sonia8270f52017-02-23 19:51:25 -080018670 return status;
18671 }
18672 cmd->vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
18673 sme_cmd->sessionId, WLAN_LEGACY_SME_ID);
18674 cmd->umac_cmd = sme_cmd;
18675 cmd->cmd_timeout_duration = SME_DEFAULT_CMD_TIMEOUT;
18676 cmd->cmd_cb = sme_ser_cmd_callback;
18677 cmd->is_high_priority = high_priority;
18678 return QDF_STATUS_SUCCESS;
18679}
18680
18681QDF_STATUS csr_queue_sme_command(tpAniSirGlobal mac_ctx, tSmeCmd *sme_cmd,
18682 bool high_priority)
18683{
18684 struct wlan_serialization_command cmd;
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080018685 QDF_STATUS status;
Krunal Sonia8270f52017-02-23 19:51:25 -080018686
18687 if (!SME_IS_START(mac_ctx)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018688 sme_err("Sme in stop state");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018689 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018690 return QDF_STATUS_E_PERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018691 }
18692
Krunal Sonia8270f52017-02-23 19:51:25 -080018693 if ((eSmeCommandScan == sme_cmd->command) &&
18694 mac_ctx->scan.fDropScanCmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018695 sme_debug("drop scan (scan reason %d) command",
Krunal Sonia8270f52017-02-23 19:51:25 -080018696 sme_cmd->u.scanCmd.reason);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018697 return QDF_STATUS_CSR_WRONG_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018698 }
18699
Krunal Soni81f068c2017-02-23 19:51:55 -080018700 if (CSR_IS_WAIT_FOR_KEY(mac_ctx, sme_cmd->sessionId)) {
Krunal Sonid3676732017-05-10 14:12:18 -070018701 if (!CSR_IS_DISCONNECT_COMMAND(sme_cmd)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018702 sme_err("Can't process cmd(%d), waiting for key",
Krunal Soni81f068c2017-02-23 19:51:55 -080018703 sme_cmd->command);
18704 return QDF_STATUS_CMD_NOT_QUEUED;
18705 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018706 }
Krunal Soni81f068c2017-02-23 19:51:55 -080018707
yeshwanth sriram guntuka7f4cb342017-04-11 15:39:21 +053018708 if ((eSmeCommandScan == sme_cmd->command) ||
18709 (sme_cmd->command == eSmeCommandRemainOnChannel)) {
18710 if (csr_scan_active_ll_count(mac_ctx) >=
18711 mac_ctx->scan.max_scan_count) {
18712 sme_err("Max scan reached");
18713 csr_scan_call_callback(mac_ctx, sme_cmd,
18714 eCSR_SCAN_ABORT);
18715 return QDF_STATUS_E_FAILURE;
18716 }
18717 }
18718
Krunal Sonia8270f52017-02-23 19:51:25 -080018719 qdf_mem_zero(&cmd, sizeof(struct wlan_serialization_command));
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080018720 status = csr_set_serialization_params_to_cmd(mac_ctx, sme_cmd,
18721 &cmd, high_priority);
18722 if (QDF_STATUS_SUCCESS == status) {
Krunal Sonia8270f52017-02-23 19:51:25 -080018723 if (WLAN_SER_CMD_DENIED_UNSPECIFIED ==
18724 wlan_serialization_request(&cmd)) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070018725 sme_err("failed to enq to req");
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080018726 status = QDF_STATUS_E_FAILURE;
Krunal Sonia8270f52017-02-23 19:51:25 -080018727 }
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080018728 if (cmd.vdev)
18729 wlan_objmgr_vdev_release_ref(cmd.vdev,
18730 WLAN_LEGACY_SME_ID);
Krunal Sonia8270f52017-02-23 19:51:25 -080018731 } else {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070018732 sme_err("failed to set ser params");
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080018733 status = QDF_STATUS_E_FAILURE;
Krunal Sonia8270f52017-02-23 19:51:25 -080018734 }
Krunal Sonid8e8e3d2017-02-23 19:52:28 -080018735 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018736}
18737
Naveen Rawat8029a402017-06-01 10:54:19 -070018738QDF_STATUS csr_roam_update_config(tpAniSirGlobal mac_ctx, uint8_t session_id,
18739 uint16_t capab, uint32_t value)
18740{
18741 struct update_config *msg;
18742 QDF_STATUS status = QDF_STATUS_SUCCESS;
18743 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
18744
18745 sme_debug("update HT config requested");
18746 if (NULL == session) {
18747 sme_err("Session does not exist for session id %d", session_id);
18748 return QDF_STATUS_E_FAILURE;
18749 }
18750
18751 msg = qdf_mem_malloc(sizeof(*msg));
18752 if (NULL == msg) {
18753 sme_err("malloc failed");
18754 return QDF_STATUS_E_NOMEM;
18755 }
18756
18757 msg->messageType = eWNI_SME_UPDATE_CONFIG;
18758 msg->sme_session_id = session_id;
18759 msg->capab = capab;
18760 msg->value = value;
18761 msg->length = sizeof(*msg);
18762 status = umac_send_mb_message_to_mac(msg);
18763
18764 return status;
18765}
18766
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018767QDF_STATUS csr_roam_update_apwpsie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018768 tSirAPWPSIEs *pAPWPSIES)
18769{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018770 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018771 tSirUpdateAPWPSIEsReq *pMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018772 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018773
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018774 if (NULL == pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018775 sme_err("Session does not exist for session id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018776 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018777 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018778 }
18779
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018780 pMsg = qdf_mem_malloc(sizeof(*pMsg));
Srinivas Girigowda5d486002015-11-25 12:18:44 -080018781 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018782 return QDF_STATUS_E_NOMEM;
Srinivas Girigowda5d486002015-11-25 12:18:44 -080018783
18784 pMsg->messageType = eWNI_SME_UPDATE_APWPSIE_REQ;
18785 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053018786 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Srinivas Girigowda5d486002015-11-25 12:18:44 -080018787 pMsg->sessionId = sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018788 qdf_mem_copy(&pMsg->APWPSIEs, pAPWPSIES, sizeof(tSirAPWPSIEs));
Srinivas Girigowda5d486002015-11-25 12:18:44 -080018789 pMsg->length = sizeof(*pMsg);
Rajeev Kumard138ac52017-01-30 18:38:37 -080018790 status = umac_send_mb_message_to_mac(pMsg);
Srinivas Girigowda5d486002015-11-25 12:18:44 -080018791
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018792 return status;
18793}
18794
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018795QDF_STATUS csr_roam_update_wparsni_es(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018796 tSirRSNie *pAPSirRSNie)
18797{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018798 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018799 tSirUpdateAPWPARSNIEsReq *pMsg;
18800 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018801
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018802 if (NULL == pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018803 sme_err("Session does not exist for session id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018804 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018805 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018806 }
18807 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018808 pMsg = qdf_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018809 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018810 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018811 pMsg->messageType = eWNI_SME_SET_APWPARSNIEs_REQ;
18812 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053018813 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018814 pMsg->sessionId = sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018815 qdf_mem_copy(&pMsg->APWPARSNIEs, pAPSirRSNie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018816 sizeof(tSirRSNie));
18817 pMsg->length = sizeof(struct sSirUpdateAPWPARSNIEsReq);
Rajeev Kumard138ac52017-01-30 18:38:37 -080018818 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018819 } while (0);
18820 return status;
18821}
18822
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018823/*
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018824 * pBuf points to the beginning of the message
18825 * LIM packs disassoc rsp as below,
18826 * messageType - 2 bytes
18827 * messageLength - 2 bytes
18828 * sessionId - 1 byte
18829 * transactionId - 2 bytes (uint16_t)
18830 * reasonCode - 4 bytes (sizeof(tSirResultCodes))
18831 * peerMacAddr - 6 bytes
18832 * The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP)
18833 * and not used
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018834 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018835static void csr_ser_des_unpack_diassoc_rsp(uint8_t *pBuf, tSirSmeDisassocRsp
18836 *pRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018837{
18838 if (pBuf && pRsp) {
18839 pBuf += 4; /* skip type and length */
18840 pRsp->sessionId = *pBuf++;
Anurag Chouhanc5548422016-02-24 18:33:27 +053018841 qdf_get_u16(pBuf, (uint16_t *) &pRsp->transactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018842 pBuf += 2;
Anurag Chouhanc5548422016-02-24 18:33:27 +053018843 qdf_get_u32(pBuf, (uint32_t *) &pRsp->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018844 pBuf += 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018845 qdf_mem_copy(pRsp->peer_macaddr.bytes, pBuf, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018846 }
18847}
18848
Anurag Chouhan6d760662016-02-20 16:05:43 +053018849/* Returns whether a session is in QDF_STA_MODE...or not */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018850bool csr_roam_is_sta_mode(tpAniSirGlobal pMac, uint32_t sessionId)
18851{
18852 tCsrRoamSession *pSession = NULL;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018854 pSession = CSR_GET_SESSION(pMac, sessionId);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018855
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018856 if (!pSession) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018857 sme_err("session %d not found", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018858 return false;
18859 }
18860 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018861 sme_err("Inactive session_id: %d", sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018862 return false;
18863 }
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018864 if (eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018865 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018866 /* There is a possibility that the above check may fail,because
18867 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
18868 * when it is connected.So,we may sneak through the above check even
18869 * if we are not a STA mode INFRA station. So, if we sneak through
18870 * the above condition, we can use the following check if we are
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018871 * really in STA Mode.
18872 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018873
18874 if (NULL != pSession->pCurRoamProfile) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018875 if (pSession->pCurRoamProfile->csrPersona == QDF_STA_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018876 return true;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018877 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018878 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018879 }
18880
18881 return false;
18882}
18883
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018884QDF_STATUS csr_handoff_request(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018885 uint8_t sessionId,
18886 tCsrHandoffRequest *pHandoffInfo)
18887{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018888 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070018889 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018890
18891 tAniHandoffReq *pMsg;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018892
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018893 pMsg = qdf_mem_malloc(sizeof(tAniHandoffReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018894 if (NULL == pMsg) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018895 sme_err("csr_handoff_request: failed to allocate mem for req ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018896 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018897 }
18898 pMsg->msgType = eWNI_SME_HANDOFF_REQ;
18899 pMsg->msgLen = (uint16_t) sizeof(tAniHandoffReq);
18900 pMsg->sessionId = sessionId;
18901 pMsg->channel = pHandoffInfo->channel;
18902 pMsg->handoff_src = pHandoffInfo->src;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018903 qdf_mem_copy(pMsg->bssid, pHandoffInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018904 msg.type = eWNI_SME_HANDOFF_REQ;
18905 msg.bodyptr = pMsg;
18906 msg.reserved = 0;
Rajeev Kumar8eaedf62017-01-21 11:03:13 -080018907 if (QDF_STATUS_SUCCESS != scheduler_post_msg(QDF_MODULE_ID_SME,
Krunal Soni66c113f2016-12-21 16:46:47 -080018908 &msg)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070018909 sme_err("scheduler_post_msg failed to post msg to self");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018910 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018911 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018912 }
18913 return status;
18914}
18915
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080018916/**
18917 * csr_roam_channel_change_req() - Post channel change request to LIM
18918 * @pMac: mac context
18919 * @bssid: SAP bssid
18920 * @ch_params: channel information
18921 * @profile: CSR profile
18922 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -080018923 * This API is primarily used to post Channel Change Req for SAP
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080018924 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018925 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018926 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018927QDF_STATUS csr_roam_channel_change_req(tpAniSirGlobal pMac,
Amar Singhale4f28ee2015-10-21 14:36:56 -070018928 struct qdf_mac_addr bssid,
Amar Singhal5cccafe2017-02-15 12:42:58 -080018929 struct ch_params *ch_params,
Amar Singhale4f28ee2015-10-21 14:36:56 -070018930 tCsrRoamProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018931{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018932 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018933 tSirChanChangeRequest *pMsg;
18934 tCsrRoamStartBssParams param;
18935
Krunal Soni8f8507c2016-12-20 13:54:34 -080018936 /*
18937 * while changing the channel, use basic rates given by driver
18938 * and not by hostapd as there is a chance that hostapd might
18939 * give us rates based on original channel which may not be
18940 * suitable for new channel
18941 */
Ravi Joshib398c852017-07-18 17:55:21 -070018942 qdf_mem_zero(&param, sizeof(tCsrRoamStartBssParams));
18943
Krunal Soni8f8507c2016-12-20 13:54:34 -080018944 csr_roam_get_bss_start_parms(pMac, profile, &param, true);
Ravi Joshib398c852017-07-18 17:55:21 -070018945
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018946 pMsg = qdf_mem_malloc(sizeof(tSirChanChangeRequest));
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018947 if (!pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018948 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018950 pMsg->messageType = eWNI_SME_CHANNEL_CHANGE_REQ;
18951 pMsg->messageLen = sizeof(tSirChanChangeRequest);
18952 pMsg->targetChannel = profile->ChannelInfo.ChannelList[0];
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080018953 pMsg->sec_ch_offset = ch_params->sec_ch_offset;
18954 pMsg->ch_width = profile->ch_params.ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018955 pMsg->dot11mode = csr_translate_to_wni_cfg_dot11_mode(pMac,
18956 pMac->roam.configParam.uCfgDot11Mode);
Gupta, Kapil76ed25e2016-04-22 15:13:55 +053018957 if (IS_24G_CH(pMsg->targetChannel) &&
18958 (false == pMac->roam.configParam.enableVhtFor24GHz) &&
18959 (WNI_CFG_DOT11_MODE_11AC == pMsg->dot11mode ||
18960 WNI_CFG_DOT11_MODE_11AC_ONLY == pMsg->dot11mode))
18961 pMsg->dot11mode = WNI_CFG_DOT11_MODE_11N;
18962
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080018963 pMsg->center_freq_seg_0 = ch_params->center_freq_seg0;
18964 pMsg->center_freq_seg_1 = ch_params->center_freq_seg1;
Arif Hussain671a1902017-03-17 09:08:32 -070018965 pMsg->cac_duration_ms = profile->cac_duration_ms;
18966 pMsg->dfs_regdomain = profile->dfs_regdomain;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018967 qdf_mem_copy(pMsg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
18968 qdf_mem_copy(&pMsg->operational_rateset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018969 &param.operationalRateSet, sizeof(pMsg->operational_rateset));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018970 qdf_mem_copy(&pMsg->extended_rateset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018971 &param.extendedRateSet, sizeof(pMsg->extended_rateset));
Rajeev Kumard138ac52017-01-30 18:38:37 -080018972 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018973
18974 return status;
18975}
18976
18977/*
18978 * Post Beacon Tx Start request to LIM
18979 * immediately after SAP CAC WAIT is
18980 * completed without any RADAR indications.
18981 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018982QDF_STATUS csr_roam_start_beacon_req(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +053018983 struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018984 uint8_t dfsCacWaitStatus)
18985{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018986 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018987 tSirStartBeaconIndication *pMsg;
18988
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018989 pMsg = qdf_mem_malloc(sizeof(tSirStartBeaconIndication));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018990
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053018991 if (!pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018992 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018993
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018994 pMsg->messageType = eWNI_SME_START_BEACON_REQ;
18995 pMsg->messageLen = sizeof(tSirStartBeaconIndication);
18996 pMsg->beaconStartStatus = dfsCacWaitStatus;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018997 qdf_mem_copy(pMsg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018998
Rajeev Kumard138ac52017-01-30 18:38:37 -080018999 status = umac_send_mb_message_to_mac(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019000
19001 return status;
19002}
19003
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019004/*
19005 * csr_roam_modify_add_ies -
19006 * This function sends msg to modify the additional IE buffers in PE
19007 *
19008 * @pMac: pMac global structure
19009 * @pModifyIE: pointer to tSirModifyIE structure
19010 * @updateType: Type of buffer
19011 *
19012 *
19013 * Return: QDF_STATUS - Success or failure
19014 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019015QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019016csr_roam_modify_add_ies(tpAniSirGlobal pMac,
19017 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
19018{
19019 tpSirModifyIEsInd pModifyAddIEInd = NULL;
19020 uint8_t *pLocalBuffer = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019021 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019022
19023 /* following buffer will be freed by consumer (PE) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019024 pLocalBuffer = qdf_mem_malloc(pModifyIE->ieBufferlength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019025
19026 if (NULL == pLocalBuffer) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019027 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019028 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019029 }
19030
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019031 pModifyAddIEInd = qdf_mem_malloc(sizeof(tSirModifyIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019032 if (NULL == pModifyAddIEInd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019033 sme_err("Memory Allocation Failure!!!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019034 qdf_mem_free(pLocalBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019035 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019036 }
19037
19038 /*copy the IE buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019039 qdf_mem_copy(pLocalBuffer, pModifyIE->pIEBuffer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019040 pModifyIE->ieBufferlength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019041 qdf_mem_zero(pModifyAddIEInd, sizeof(tSirModifyIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019042
19043 pModifyAddIEInd->msgType = eWNI_SME_MODIFY_ADDITIONAL_IES;
19044 pModifyAddIEInd->msgLen = sizeof(tSirModifyIEsInd);
19045
Anurag Chouhanc5548422016-02-24 18:33:27 +053019046 qdf_copy_macaddr(&pModifyAddIEInd->modifyIE.bssid, &pModifyIE->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019047
19048 pModifyAddIEInd->modifyIE.smeSessionId = pModifyIE->smeSessionId;
19049 pModifyAddIEInd->modifyIE.notify = pModifyIE->notify;
19050 pModifyAddIEInd->modifyIE.ieID = pModifyIE->ieID;
19051 pModifyAddIEInd->modifyIE.ieIDLen = pModifyIE->ieIDLen;
19052 pModifyAddIEInd->modifyIE.pIEBuffer = pLocalBuffer;
19053 pModifyAddIEInd->modifyIE.ieBufferlength = pModifyIE->ieBufferlength;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080019054 pModifyAddIEInd->modifyIE.oui_length = pModifyIE->oui_length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019055
19056 pModifyAddIEInd->updateType = updateType;
19057
Rajeev Kumard138ac52017-01-30 18:38:37 -080019058 status = umac_send_mb_message_to_mac(pModifyAddIEInd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019059 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019060 sme_err("Failed to send eWNI_SME_UPDATE_ADDTIONAL_IES msg status %d",
19061 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019062 qdf_mem_free(pLocalBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019063 }
19064 return status;
19065}
19066
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019067/*
19068 * csr_roam_update_add_ies -
19069 * This function sends msg to updates the additional IE buffers in PE
19070 *
19071 * @pMac: pMac global structure
19072 * @sessionId: SME session id
19073 * @bssid: BSSID
19074 * @additionIEBuffer: buffer containing addition IE from hostapd
19075 * @length: length of buffer
19076 * @updateType: Type of buffer
19077 * @append: append or replace completely
19078 *
19079 *
19080 * Return: QDF_STATUS - Success or failure
19081 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019082QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019083csr_roam_update_add_ies(tpAniSirGlobal pMac,
19084 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
19085{
19086 tpSirUpdateIEsInd pUpdateAddIEs = NULL;
19087 uint8_t *pLocalBuffer = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019088 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019089
19090 if (pUpdateIE->ieBufferlength != 0) {
19091 /* Following buffer will be freed by consumer (PE) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019092 pLocalBuffer = qdf_mem_malloc(pUpdateIE->ieBufferlength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019093 if (NULL == pLocalBuffer) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019094 sme_err("Memory Allocation Failure!!!");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019095 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019096 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019097 qdf_mem_copy(pLocalBuffer, pUpdateIE->pAdditionIEBuffer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019098 pUpdateIE->ieBufferlength);
19099 }
19100
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019101 pUpdateAddIEs = qdf_mem_malloc(sizeof(tSirUpdateIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019102 if (NULL == pUpdateAddIEs) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019103 sme_err("Memory Allocation Failure!!!");
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019104 if (pLocalBuffer != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019105 qdf_mem_free(pLocalBuffer);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019106
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019107 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019108 }
19109
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019110 pUpdateAddIEs->msgType = eWNI_SME_UPDATE_ADDITIONAL_IES;
19111 pUpdateAddIEs->msgLen = sizeof(tSirUpdateIEsInd);
19112
Anurag Chouhanc5548422016-02-24 18:33:27 +053019113 qdf_copy_macaddr(&pUpdateAddIEs->updateIE.bssid, &pUpdateIE->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019114
19115 pUpdateAddIEs->updateIE.smeSessionId = pUpdateIE->smeSessionId;
19116 pUpdateAddIEs->updateIE.append = pUpdateIE->append;
19117 pUpdateAddIEs->updateIE.notify = pUpdateIE->notify;
19118 pUpdateAddIEs->updateIE.ieBufferlength = pUpdateIE->ieBufferlength;
19119 pUpdateAddIEs->updateIE.pAdditionIEBuffer = pLocalBuffer;
19120
19121 pUpdateAddIEs->updateType = updateType;
19122
Rajeev Kumard138ac52017-01-30 18:38:37 -080019123 status = umac_send_mb_message_to_mac(pUpdateAddIEs);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019124 if (!QDF_IS_STATUS_SUCCESS(status)) {
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019125 sme_err("Failed to send eWNI_SME_UPDATE_ADDTIONAL_IES msg status %d",
19126 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019127 qdf_mem_free(pLocalBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019128 }
19129 return status;
19130}
19131
19132/**
Abhishek Singh518323d2015-10-19 17:42:01 +053019133 * csr_send_ext_change_channel()- function to post send ECSA
19134 * action frame to lim.
19135 * @mac_ctx: pointer to global mac structure
19136 * @channel: new channel to switch
19137 * @session_id: senssion it should be sent on.
19138 *
19139 * This function is called to post ECSA frame to lim.
19140 *
19141 * Return: success if msg posted to LIM else return failure
19142 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019143QDF_STATUS csr_send_ext_change_channel(tpAniSirGlobal mac_ctx, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +053019144 uint8_t session_id)
19145{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019146 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +053019147 struct sir_sme_ext_cng_chan_req *msg;
19148
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019149 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh518323d2015-10-19 17:42:01 +053019150 if (NULL == msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019151 return QDF_STATUS_E_NOMEM;
Abhishek Singh518323d2015-10-19 17:42:01 +053019152
Abhishek Singh518323d2015-10-19 17:42:01 +053019153 msg->message_type = eWNI_SME_EXT_CHANGE_CHANNEL;
19154 msg->length = sizeof(*msg);
19155 msg->new_channel = channel;
19156 msg->session_id = session_id;
Rajeev Kumard138ac52017-01-30 18:38:37 -080019157 status = umac_send_mb_message_to_mac(msg);
Abhishek Singh518323d2015-10-19 17:42:01 +053019158 return status;
19159}
19160
19161/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019162 * csr_roam_send_chan_sw_ie_request() - Request to transmit CSA IE
19163 * @mac_ctx: Global MAC context
19164 * @bssid: BSSID
19165 * @target_channel: Channel on which to send the IE
19166 * @csa_ie_reqd: Include/Exclude CSA IE.
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080019167 * @ch_params: operating Channel related information
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019168 *
19169 * This function sends request to transmit channel switch announcement
19170 * IE to lower layers
19171 *
19172 * Return: success or failure
19173 **/
Amar Singhale4f28ee2015-10-21 14:36:56 -070019174QDF_STATUS csr_roam_send_chan_sw_ie_request(tpAniSirGlobal mac_ctx,
19175 struct qdf_mac_addr bssid,
19176 uint8_t target_channel,
19177 uint8_t csa_ie_reqd,
Amar Singhal5cccafe2017-02-15 12:42:58 -080019178 struct ch_params *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019179{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019180 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019181 tSirDfsCsaIeRequest *msg;
19182
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019183 msg = qdf_mem_malloc(sizeof(tSirDfsCsaIeRequest));
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019184 if (!msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019185 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019186
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019187 msg->msgType = eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ;
19188 msg->msgLen = sizeof(tSirDfsCsaIeRequest);
19189
19190 msg->targetChannel = target_channel;
19191 msg->csaIeRequired = csa_ie_reqd;
gaoleze2920bd2017-03-21 17:38:42 +080019192 msg->ch_switch_beacon_cnt =
19193 mac_ctx->sap.SapDfsInfo.sap_ch_switch_beacon_cnt;
gaolez76d2a162017-03-21 19:23:58 +080019194 msg->ch_switch_mode = mac_ctx->sap.SapDfsInfo.sap_ch_switch_mode;
19195 msg->dfs_ch_switch_disable =
19196 mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019197 qdf_mem_copy(msg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
Amar Singhal5cccafe2017-02-15 12:42:58 -080019198 qdf_mem_copy(&msg->ch_params, ch_params, sizeof(struct ch_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019199
Rajeev Kumard138ac52017-01-30 18:38:37 -080019200 status = umac_send_mb_message_to_mac(msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019201
19202 return status;
19203}
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080019204#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
19205/**
19206 * csr_roaming_report_diag_event() - Diag events for LFR3
19207 * @mac_ctx: MAC context
19208 * @roam_synch_ind_ptr: Roam Synch Indication Pointer
19209 * @reason: Reason for this event to happen
19210 *
19211 * The major events in the host for LFR3 roaming such as
19212 * roam synch indication, roam synch completion and
19213 * roam synch handoff fail will be indicated to the
19214 * diag framework using this API.
19215 *
19216 * Return: None
19217 */
19218void csr_roaming_report_diag_event(tpAniSirGlobal mac_ctx,
19219 roam_offload_synch_ind *roam_synch_ind_ptr,
19220 eCsrDiagWlanStatusEventReason reason)
19221{
19222 WLAN_HOST_DIAG_EVENT_DEF(roam_connection,
19223 host_event_wlan_status_payload_type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019224 qdf_mem_set(&roam_connection,
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080019225 sizeof(host_event_wlan_status_payload_type), 0);
19226 switch (reason) {
19227 case eCSR_REASON_ROAM_SYNCH_IND:
19228 roam_connection.eventId = eCSR_WLAN_STATUS_CONNECT;
19229 if (roam_synch_ind_ptr) {
19230 roam_connection.rssi = roam_synch_ind_ptr->rssi;
19231 roam_connection.channel =
19232 cds_freq_to_chan(roam_synch_ind_ptr->chan_freq);
19233 }
19234 break;
19235 case eCSR_REASON_ROAM_SYNCH_CNF:
19236 roam_connection.eventId = eCSR_WLAN_STATUS_CONNECT;
19237 break;
19238 case eCSR_REASON_ROAM_HO_FAIL:
19239 roam_connection.eventId = eCSR_WLAN_STATUS_DISCONNECT;
19240 break;
19241 default:
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019242 sme_err("LFR3: Unsupported reason %d", reason);
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080019243 return;
19244 }
19245 roam_connection.reason = reason;
Abhishek Singh7a995582016-04-27 13:53:36 +053019246 WLAN_HOST_DIAG_EVENT_REPORT(&roam_connection, EVENT_WLAN_STATUS_V2);
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080019247}
19248#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019249
19250#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019251/*
19252 * fn csr_process_ho_fail_ind
19253 * brief This function will process the Hand Off Failure indication
19254 * received from the firmware. It will trigger a disconnect on
19255 * the session which the firmware reported a hand off failure
19256 * param pMac global structure
19257 * param pMsgBuf - Contains the session ID for which the handler should apply
19258 */
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080019259void csr_process_ho_fail_ind(tpAniSirGlobal mac_ctx, void *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019260{
19261 tSirSmeHOFailureInd *pSmeHOFailInd = (tSirSmeHOFailureInd *) pMsgBuf;
19262 uint32_t sessionId;
19263
19264 if (pSmeHOFailInd)
19265 sessionId = pSmeHOFailInd->sessionId;
19266 else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019267 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019268 "LFR3: Hand-Off Failure Ind is NULL");
19269 return;
19270 }
19271 /* Roaming is supported only on Infra STA Mode. */
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080019272 if (!csr_roam_is_sta_mode(mac_ctx, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019273 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019274 "LFR3:HO Fail cannot be handled for session %d",
19275 sessionId);
19276 return;
19277 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080019278 mac_ctx->sme.set_connection_info_cb(false);
19279 csr_roam_roaming_offload_timer_action(mac_ctx, 0, sessionId,
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070019280 ROAMING_OFFLOAD_TIMER_STOP);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080019281 csr_roam_call_callback(mac_ctx, sessionId, NULL, 0,
Abhishek Singh533c9da2017-05-04 10:23:34 +053019282 eCSR_ROAM_NAPI_OFF, eCSR_ROAM_RESULT_FAILURE);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080019283 csr_roam_synch_clean_up(mac_ctx, sessionId);
19284 csr_roaming_report_diag_event(mac_ctx, NULL,
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080019285 eCSR_REASON_ROAM_HO_FAIL);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019286 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019287 "LFR3:Issue Disconnect on session %d", sessionId);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080019288 csr_roam_disconnect(mac_ctx, sessionId,
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -070019289 eCSR_DISCONNECT_REASON_ROAM_HO_FAIL);
Agrawal Ashishc416da62017-04-10 15:12:46 +053019290 if (mac_ctx->roam.configParam.enable_fatal_event)
Agrawal Ashish87ec5d42017-06-15 15:22:19 +053019291 cds_flush_logs(WLAN_LOG_TYPE_FATAL,
Agrawal Ashishc416da62017-04-10 15:12:46 +053019292 WLAN_LOG_INDICATOR_HOST_DRIVER,
19293 WLAN_LOG_REASON_ROAM_HO_FAILURE,
19294 true, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019295}
19296#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
19297
19298/**
19299 * csr_update_op_class_array() - update op class for each band
19300 * @mac_ctx: mac global context
19301 * @op_classes: out param, operating class array to update
19302 * @channel_info: channel info
19303 * @ch_name: channel band name to display in debug messages
19304 * @i: out param, stores number of operating classes
19305 *
19306 * Return: void
19307 */
19308static void
19309csr_update_op_class_array(tpAniSirGlobal mac_ctx,
19310 uint8_t *op_classes,
19311 tCsrChannel *channel_info,
19312 char *ch_name,
19313 uint8_t *i)
19314{
19315 uint8_t j = 0, idx = 0, class = 0;
19316 bool found = false;
19317 uint8_t num_channels = channel_info->numChannels;
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053019318 uint8_t ch_bandwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019319
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019320 sme_debug("Num of %s channels, %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019321 ch_name, num_channels);
19322
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070019323 for (idx = 0; idx < num_channels &&
19324 *i < (REG_MAX_SUPP_OPER_CLASSES - 1); idx++) {
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053019325 for (ch_bandwidth = BW20; ch_bandwidth < BWALL;
19326 ch_bandwidth++) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070019327 class = wlan_reg_dmn_get_opclass_from_channel(
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053019328 mac_ctx->scan.countryCodeCurrent,
19329 channel_info->channelList[idx],
19330 ch_bandwidth);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019331 sme_debug("for chan %d, op class: %d",
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053019332 channel_info->channelList[idx], class);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019333
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053019334 found = false;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070019335 for (j = 0; j < REG_MAX_SUPP_OPER_CLASSES - 1;
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053019336 j++) {
19337 if (op_classes[j] == class) {
19338 found = true;
19339 break;
19340 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019341 }
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053019342
19343 if (!found) {
19344 op_classes[*i] = class;
19345 *i = *i + 1;
19346 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019347 }
19348 }
19349}
19350
19351/**
19352 * csr_update_op_class_array() - update op class for all bands
19353 * @hHal: global hal context
19354 *
19355 * Return: void
19356 */
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019357static void csr_init_operating_classes(tHalHandle hHal)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019358{
19359 uint8_t i = 0;
19360 uint8_t j = 0;
19361 uint8_t swap = 0;
19362 uint8_t numClasses = 0;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070019363 uint8_t opClasses[REG_MAX_SUPP_OPER_CLASSES] = {0,};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019364 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
19365
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019366 sme_debug("Current Country = %c%c",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019367 pMac->scan.countryCodeCurrent[0],
19368 pMac->scan.countryCodeCurrent[1]);
19369
19370 csr_update_op_class_array(pMac, opClasses,
19371 &pMac->scan.base_channels, "20MHz", &i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019372 numClasses = i;
19373
19374 /* As per spec the operating classes should be in ascending order.
19375 * Bubble sort is fine since we don't have many classes
19376 */
19377 for (i = 0; i < (numClasses - 1); i++) {
19378 for (j = 0; j < (numClasses - i - 1); j++) {
19379 /* For decreasing order use < */
19380 if (opClasses[j] > opClasses[j + 1]) {
19381 swap = opClasses[j];
19382 opClasses[j] = opClasses[j + 1];
19383 opClasses[j + 1] = swap;
19384 }
19385 }
19386 }
19387
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019388 sme_debug("Number of unique supported op classes %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019389 numClasses);
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019390 for (i = 0; i < numClasses; i++)
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019391 sme_debug("supported opClasses[%d] = %d", i, opClasses[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019392
19393 /* Set the ordered list of op classes in regdomain
19394 * for use by other modules
19395 */
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070019396 wlan_reg_dmn_set_curr_opclasses(numClasses, &opClasses[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019397}
19398
19399/**
19400 * csr_find_session_by_type() - This function will find given session type from
19401 * all sessions.
19402 * @mac_ctx: pointer to mac context.
19403 * @type: session type
19404 *
19405 * Return: session id for give session type.
19406 **/
19407static uint32_t
Anurag Chouhan6d760662016-02-20 16:05:43 +053019408csr_find_session_by_type(tpAniSirGlobal mac_ctx, enum tQDF_ADAPTER_MODE type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019409{
19410 uint32_t i, session_id = CSR_SESSION_ID_INVALID;
19411 tCsrRoamSession *session_ptr;
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019412
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019413 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
19414 if (!CSR_IS_SESSION_VALID(mac_ctx, i))
19415 continue;
19416
19417 session_ptr = CSR_GET_SESSION(mac_ctx, i);
19418 if (type == session_ptr->bssParams.bssPersona) {
19419 session_id = i;
19420 break;
19421 }
19422 }
19423 return session_id;
19424}
19425/**
19426 * csr_is_conn_allow_2g_band() - This function will check if station's conn
19427 * is allowed in 2.4Ghz band.
19428 * @mac_ctx: pointer to mac context.
19429 * @chnl: station's channel.
19430 *
19431 * This function will check if station's connection is allowed in 5Ghz band
19432 * after comparing it with SAP's operating channel. If SAP's operating
19433 * channel and Station's channel is different than this function will return
19434 * false else true.
19435 *
19436 * Return: true or false.
19437 **/
19438static bool csr_is_conn_allow_2g_band(tpAniSirGlobal mac_ctx, uint32_t chnl)
19439{
19440 uint32_t sap_session_id;
19441 tCsrRoamSession *sap_session;
19442
19443 if (0 == chnl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019444 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019445 FL("channel is zero, connection not allowed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019446
19447 return false;
19448 }
19449
Anurag Chouhan6d760662016-02-20 16:05:43 +053019450 sap_session_id = csr_find_session_by_type(mac_ctx, QDF_SAP_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019451 if (CSR_SESSION_ID_INVALID != sap_session_id) {
19452 sap_session = CSR_GET_SESSION(mac_ctx, sap_session_id);
19453 if ((0 != sap_session->bssParams.operationChn) &&
19454 (sap_session->bssParams.operationChn != chnl)) {
19455
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019456 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019457 "Can't allow STA to connect, chnls not same");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019458 return false;
19459 }
19460 }
19461 return true;
19462}
19463
19464/**
19465 * csr_is_conn_allow_5g_band() - This function will check if station's conn
19466 * is allowed in 5Ghz band.
19467 * @mac_ctx: pointer to mac context.
19468 * @chnl: station's channel.
19469 *
19470 * This function will check if station's connection is allowed in 5Ghz band
19471 * after comparing it with P2PGO's operating channel. If P2PGO's operating
19472 * channel and Station's channel is different than this function will return
19473 * false else true.
19474 *
19475 * Return: true or false.
19476 **/
19477static bool csr_is_conn_allow_5g_band(tpAniSirGlobal mac_ctx, uint32_t chnl)
19478{
19479 uint32_t p2pgo_session_id;
19480 tCsrRoamSession *p2pgo_session;
19481
19482 if (0 == chnl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019483 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019484 FL("channel is zero, connection not allowed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019485 return false;
19486 }
19487
Anurag Chouhan6d760662016-02-20 16:05:43 +053019488 p2pgo_session_id = csr_find_session_by_type(mac_ctx, QDF_P2P_GO_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019489 if (CSR_SESSION_ID_INVALID != p2pgo_session_id) {
19490 p2pgo_session = CSR_GET_SESSION(mac_ctx, p2pgo_session_id);
19491 if ((0 != p2pgo_session->bssParams.operationChn) &&
19492 (eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED !=
19493 p2pgo_session->connectState) &&
19494 (p2pgo_session->bssParams.operationChn !=
19495 chnl)) {
19496
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019497 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Nishank Aggarwalc32eea02017-03-28 18:02:01 +053019498 "Can't allow STA to connect, chnls not same");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019499 return false;
19500 }
19501 }
19502 return true;
19503}
19504
19505/**
19506 * csr_clear_joinreq_param() - This function will clear station's params
19507 * for stored join request to csr.
19508 * @hal_handle: pointer to hal context.
19509 * @session_id: station's session id.
19510 *
19511 * This function will clear station's allocated memory for cached join
19512 * request.
19513 *
19514 * Return: true or false based on function's overall success.
19515 **/
19516bool csr_clear_joinreq_param(tpAniSirGlobal mac_ctx,
19517 uint32_t session_id)
19518{
19519 tCsrRoamSession *sta_session;
19520 tScanResultList *bss_list;
19521
19522 if (NULL == mac_ctx)
19523 return false;
19524
19525 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
19526 if (NULL == sta_session)
19527 return false;
19528
19529 /* Release the memory allocated by previous join request */
19530 bss_list =
19531 (tScanResultList *)&sta_session->stored_roam_profile.
19532 bsslist_handle;
19533 if (NULL != bss_list) {
19534 csr_scan_result_purge(mac_ctx,
19535 sta_session->stored_roam_profile.bsslist_handle);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019536 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019537 FL("bss list is released for session %d"), session_id);
19538 sta_session->stored_roam_profile.bsslist_handle = NULL;
19539 }
19540 sta_session->stored_roam_profile.bsslist_handle = NULL;
19541 csr_release_profile(mac_ctx, &sta_session->stored_roam_profile.profile);
19542 sta_session->stored_roam_profile.reason = 0;
19543 sta_session->stored_roam_profile.roam_id = 0;
19544 sta_session->stored_roam_profile.imediate_flag = false;
19545 sta_session->stored_roam_profile.clear_flag = false;
19546 return true;
19547}
19548
19549/**
19550 * csr_store_joinreq_param() - This function will store station's join
19551 * request to that station's session.
19552 * @mac_ctx: pointer to mac context.
19553 * @profile: pointer to station's roam profile.
19554 * @scan_cache: pointer to station's scan cache.
19555 * @roam_id: reference to roam_id variable being passed.
19556 * @session_id: station's session id.
19557 *
19558 * This function will store station's join request to one of the
19559 * csr structure and add it to station's session.
19560 *
19561 * Return: true or false based on function's overall success.
19562 **/
19563bool csr_store_joinreq_param(tpAniSirGlobal mac_ctx,
19564 tCsrRoamProfile *profile,
19565 tScanResultHandle scan_cache,
19566 uint32_t *roam_id,
19567 uint32_t session_id)
19568{
19569 tCsrRoamSession *sta_session;
19570
19571 if (NULL == mac_ctx)
19572 return false;
19573
19574 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
19575 if (NULL == sta_session)
19576 return false;
19577
19578 sta_session->stored_roam_profile.session_id = session_id;
19579 csr_roam_copy_profile(mac_ctx,
19580 &sta_session->stored_roam_profile.profile, profile);
19581 /* new bsslist_handle's memory will be relased later */
19582 sta_session->stored_roam_profile.bsslist_handle = scan_cache;
19583 sta_session->stored_roam_profile.reason = eCsrHddIssued;
19584 sta_session->stored_roam_profile.roam_id = *roam_id;
19585 sta_session->stored_roam_profile.imediate_flag = false;
19586 sta_session->stored_roam_profile.clear_flag = false;
19587
19588 return true;
19589}
19590
19591/**
19592 * csr_issue_stored_joinreq() - This function will issues station's stored
19593 * the join request.
19594 * @mac_ctx: pointer to mac context.
19595 * @roam_id: reference to roam_id variable being passed.
19596 * @session_id: station's session id.
19597 *
19598 * This function will issue station's stored join request, from this point
19599 * onwards the flow will be just like normal connect request.
19600 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019601 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019602 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019603QDF_STATUS csr_issue_stored_joinreq(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019604 uint32_t *roam_id,
19605 uint32_t session_id)
19606{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019607 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019608 tCsrRoamSession *sta_session;
19609 uint32_t new_roam_id;
19610
19611 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
19612 if (NULL == sta_session)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019613 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019614 new_roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
19615 *roam_id = new_roam_id;
19616 status = csr_roam_issue_connect(mac_ctx,
19617 sta_session->stored_roam_profile.session_id,
19618 &sta_session->stored_roam_profile.profile,
19619 sta_session->stored_roam_profile.bsslist_handle,
19620 sta_session->stored_roam_profile.reason,
19621 new_roam_id,
19622 sta_session->stored_roam_profile.imediate_flag,
19623 sta_session->stored_roam_profile.clear_flag);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019624 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019625 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019626 FL
19627 ("CSR failed issuing connect cmd with status = 0x%08X"),
19628 status);
19629 csr_clear_joinreq_param(mac_ctx, session_id);
19630 }
19631 return status;
19632}
19633
19634/**
19635 * csr_process_set_hw_mode() - Set HW mode command to PE
19636 * @mac: Globacl MAC pointer
19637 * @command: Command received from SME
19638 *
19639 * Posts the set HW mode command to PE. This message passing
19640 * through PE is required for PE's internal management
19641 *
19642 * Return: None
19643 */
19644void csr_process_set_hw_mode(tpAniSirGlobal mac, tSmeCmd *command)
19645{
19646 uint32_t len;
yeshwanth sriram guntukad4b482a2017-03-27 12:51:46 +053019647 struct s_sir_set_hw_mode *cmd = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019648 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070019649 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019650 struct sir_set_hw_mode_resp *param;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080019651 enum policy_mgr_hw_mode_change hw_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019652
19653 /* Setting HW mode is for the entire system.
19654 * So, no need to check session
19655 */
19656
19657 if (!command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019658 sme_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019659 goto fail;
19660 }
19661
19662 len = sizeof(*cmd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019663 cmd = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019664 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019665 sme_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019666 /* Probably the fail response will also fail during malloc.
19667 * Still proceeding to send response!
19668 */
19669 goto fail;
19670 }
19671
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053019672 /* For hidden SSID case, if there is any scan command pending
19673 * it needs to be cleared before issuing set HW mode
19674 */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080019675 if (command->u.set_hw_mode_cmd.reason ==
19676 POLICY_MGR_UPDATE_REASON_HIDDEN_STA) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019677 sme_err("clear any pending scan command");
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053019678 status = csr_scan_abort_mac_scan_not_for_connect(mac,
19679 command->u.set_hw_mode_cmd.session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019680 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019681 sme_err("Failed to clear scan cmd");
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053019682 goto fail;
19683 }
19684 }
19685
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080019686 if ((POLICY_MGR_UPDATE_REASON_OPPORTUNISTIC ==
19687 command->u.set_hw_mode_cmd.reason) &&
19688 (true == mac->sme.get_connection_info_cb(NULL, NULL))) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019689 sme_err("Set HW mode refused: conn in progress");
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080019690 policy_mgr_restart_opportunistic_timer(mac->psoc, false);
Nitesh Shaha3dfea32017-02-09 19:18:57 +053019691 goto fail;
19692 }
19693
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080019694 hw_mode = policy_mgr_get_hw_mode_change_from_hw_mode_index(
19695 mac->psoc, command->u.set_hw_mode_cmd.hw_mode_index);
Nitesh Shaha3dfea32017-02-09 19:18:57 +053019696
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080019697 if (POLICY_MGR_HW_MODE_NOT_IN_PROGRESS == hw_mode) {
Srinivas Girigowda2c263352017-03-17 17:49:53 -070019698 sme_err("hw_mode %d, failing", hw_mode);
Nitesh Shaha3dfea32017-02-09 19:18:57 +053019699 goto fail;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080019700 }
Nitesh Shaha3dfea32017-02-09 19:18:57 +053019701
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080019702 policy_mgr_set_hw_mode_change_in_progress(mac->psoc, hw_mode);
Nitesh Shaha3dfea32017-02-09 19:18:57 +053019703
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019704 cmd->messageType = eWNI_SME_SET_HW_MODE_REQ;
19705 cmd->length = len;
19706 cmd->set_hw.hw_mode_index = command->u.set_hw_mode_cmd.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053019707 cmd->set_hw.reason = command->u.set_hw_mode_cmd.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019708 /*
19709 * Below callback and context info are not needed for PE as of now.
19710 * Storing the passed value in the same s_sir_set_hw_mode format.
19711 */
19712 cmd->set_hw.set_hw_mode_cb = command->u.set_hw_mode_cmd.set_hw_mode_cb;
19713
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019714 sme_debug(
19715 "Posting set hw mode req to PE session:%d reason:%d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053019716 command->u.set_hw_mode_cmd.session_id,
19717 command->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019718
Rajeev Kumard138ac52017-01-30 18:38:37 -080019719 status = umac_send_mb_message_to_mac(cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019720 if (QDF_STATUS_SUCCESS != status) {
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080019721 policy_mgr_set_hw_mode_change_in_progress(mac->psoc,
19722 POLICY_MGR_HW_MODE_NOT_IN_PROGRESS);
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019723 sme_err("Posting to PE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019724 return;
19725 }
19726 return;
19727fail:
yeshwanth sriram guntukad4b482a2017-03-27 12:51:46 +053019728 if (cmd)
19729 qdf_mem_free(cmd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019730 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019731 if (!param) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019732 sme_err(
19733 "Malloc fail: Fail to send response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019734 return;
19735 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019736 sme_err("Sending set HW fail response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019737 param->status = SET_HW_MODE_STATUS_ECANCELED;
19738 param->cfgd_hw_mode_index = 0;
19739 param->num_vdev_mac_entries = 0;
19740 msg.type = eWNI_SME_SET_HW_MODE_RESP;
19741 msg.bodyptr = param;
19742 msg.bodyval = 0;
19743 sys_process_mmh_msg(mac, &msg);
19744}
19745
19746/**
19747 * csr_process_set_dual_mac_config() - Set HW mode command to PE
19748 * @mac: Global MAC pointer
19749 * @command: Command received from SME
19750 *
19751 * Posts the set dual mac config command to PE.
19752 *
19753 * Return: None
19754 */
19755void csr_process_set_dual_mac_config(tpAniSirGlobal mac, tSmeCmd *command)
19756{
19757 uint32_t len;
19758 struct sir_set_dual_mac_cfg *cmd;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019759 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070019760 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019761 struct sir_dual_mac_config_resp *param;
19762
19763 /* Setting MAC configuration is for the entire system.
19764 * So, no need to check session
19765 */
19766
19767 if (!command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019768 sme_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019769 goto fail;
19770 }
19771
19772 len = sizeof(*cmd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019773 cmd = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019774 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019775 sme_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019776 /* Probably the fail response will also fail during malloc.
19777 * Still proceeding to send response!
19778 */
19779 goto fail;
19780 }
19781
19782 cmd->message_type = eWNI_SME_SET_DUAL_MAC_CFG_REQ;
19783 cmd->length = len;
19784 cmd->set_dual_mac.scan_config = command->u.set_dual_mac_cmd.scan_config;
19785 cmd->set_dual_mac.fw_mode_config =
19786 command->u.set_dual_mac_cmd.fw_mode_config;
19787 /*
19788 * Below callback and context info are not needed for PE as of now.
19789 * Storing the passed value in the same sir_set_dual_mac_cfg format.
19790 */
19791 cmd->set_dual_mac.set_dual_mac_cb =
19792 command->u.set_dual_mac_cmd.set_dual_mac_cb;
19793
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019794 sme_debug(
19795 "Posting eWNI_SME_SET_DUAL_MAC_CFG_REQ to PE: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019796 cmd->set_dual_mac.scan_config,
19797 cmd->set_dual_mac.fw_mode_config);
19798
Rajeev Kumard138ac52017-01-30 18:38:37 -080019799 status = umac_send_mb_message_to_mac(cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019800 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019801 sme_err("Posting to PE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019802 return;
19803 }
19804 return;
19805fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019806 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019807 if (!param) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019808 sme_err(
19809 "Malloc fail: Fail to send response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019810 return;
19811 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019812 sme_err("Sending set dual mac fail response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019813 param->status = SET_HW_MODE_STATUS_ECANCELED;
19814 msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
19815 msg.bodyptr = param;
19816 msg.bodyval = 0;
19817 sys_process_mmh_msg(mac, &msg);
19818}
19819
19820/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080019821 * csr_process_set_antenna_mode() - Set antenna mode command to
19822 * PE
19823 * @mac: Global MAC pointer
19824 * @command: Command received from SME
19825 *
19826 * Posts the set dual mac config command to PE.
19827 *
19828 * Return: None
19829 */
19830void csr_process_set_antenna_mode(tpAniSirGlobal mac, tSmeCmd *command)
19831{
19832 uint32_t len;
19833 struct sir_set_antenna_mode *cmd;
19834 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070019835 struct scheduler_msg msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -080019836 struct sir_antenna_mode_resp *param;
19837
19838 /* Setting MAC configuration is for the entire system.
19839 * So, no need to check session
19840 */
19841
19842 if (!command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019843 sme_err("Set antenna mode param is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080019844 goto fail;
19845 }
19846
19847 len = sizeof(*cmd);
19848 cmd = qdf_mem_malloc(len);
19849 if (!cmd) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019850 sme_err("Memory allocation failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080019851 goto fail;
19852 }
19853
19854 cmd->message_type = eWNI_SME_SET_ANTENNA_MODE_REQ;
19855 cmd->length = len;
19856 cmd->set_antenna_mode = command->u.set_antenna_mode_cmd;
19857
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019858 sme_debug(
19859 "Posting eWNI_SME_SET_ANTENNA_MODE_REQ to PE: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -080019860 cmd->set_antenna_mode.num_rx_chains,
19861 cmd->set_antenna_mode.num_tx_chains);
19862
Rajeev Kumard138ac52017-01-30 18:38:37 -080019863 status = umac_send_mb_message_to_mac(cmd);
Archana Ramachandrana20ef812015-11-13 16:12:13 -080019864 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019865 sme_err("Posting to PE failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080019866 /*
Rajeev Kumard138ac52017-01-30 18:38:37 -080019867 * umac_send_mb_message_to_mac would've released the mem
Archana Ramachandrana20ef812015-11-13 16:12:13 -080019868 * allocated by cmd.
19869 */
19870 goto fail;
19871 }
19872
19873 return;
19874fail:
19875 param = qdf_mem_malloc(sizeof(*param));
19876 if (!param) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019877 sme_err(
19878 "Malloc fail: Fail to send response to SME");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080019879 return;
19880 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019881 sme_err("Sending set dual mac fail response to SME");
Archana Ramachandrana20ef812015-11-13 16:12:13 -080019882 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
19883 msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
19884 msg.bodyptr = param;
19885 msg.bodyval = 0;
19886 sys_process_mmh_msg(mac, &msg);
19887}
19888
19889/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019890 * csr_process_nss_update_req() - Update nss command to PE
19891 * @mac: Globacl MAC pointer
19892 * @command: Command received from SME
19893 *
19894 * Posts the nss update command to PE. This message passing
19895 * through PE is required for PE's internal management
19896 *
19897 * Return: None
19898 */
19899void csr_process_nss_update_req(tpAniSirGlobal mac, tSmeCmd *command)
19900{
19901 uint32_t len;
19902 struct sir_nss_update_request *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019903 QDF_STATUS status;
Rajeev Kumar37d478b2017-04-17 16:59:28 -070019904 struct scheduler_msg msg_return = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019905 struct sir_beacon_tx_complete_rsp *param;
Naveen Rawat7ecf53d2016-06-27 15:31:48 -070019906 tCsrRoamSession *session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019907
19908 if (!command) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019909 sme_err("nss update param is NULL");
Naveen Rawat7ecf53d2016-06-27 15:31:48 -070019910 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019911 }
19912
Naveen Rawat7ecf53d2016-06-27 15:31:48 -070019913 if (!CSR_IS_SESSION_VALID(mac, command->sessionId)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019914 sme_err("Invalid session id %d",
Naveen Rawat7ecf53d2016-06-27 15:31:48 -070019915 command->sessionId);
19916 return;
19917 }
19918 session = CSR_GET_SESSION(mac, command->sessionId);
19919
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019920 len = sizeof(*msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019921 msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019922 if (!msg) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019923 sme_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019924 /* Probably the fail response is also fail during malloc.
19925 * Still proceeding to send response!
19926 */
19927 goto fail;
19928 }
19929
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019930 msg->msgType = eWNI_SME_NSS_UPDATE_REQ;
19931 msg->msgLen = sizeof(*msg);
19932
19933 msg->new_nss = command->u.nss_update_cmd.new_nss;
19934 msg->vdev_id = command->u.nss_update_cmd.session_id;
19935
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019936 sme_debug("Posting eWNI_SME_NSS_UPDATE_REQ to PE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019937
Rajeev Kumard138ac52017-01-30 18:38:37 -080019938 status = umac_send_mb_message_to_mac(msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019939 if (QDF_STATUS_SUCCESS != status) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019940 sme_err("Posting to PE failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019941 return;
19942 }
19943 return;
19944fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019945 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019946 if (!param) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019947 sme_err(
19948 "Malloc fail: Fail to send response to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019949 return;
19950 }
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019951 sme_err("Sending nss update fail response to SME");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019952 param->tx_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019953 param->session_id = command->u.nss_update_cmd.session_id;
19954 msg_return.type = eWNI_SME_NSS_UPDATE_RSP;
19955 msg_return.bodyptr = param;
19956 msg_return.bodyval = 0;
19957 sys_process_mmh_msg(mac, &msg_return);
19958}
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019959#ifdef FEATURE_WLAN_TDLS
19960/**
19961 * csr_roam_fill_tdls_info() - Fill TDLS information
19962 * @roam_info: Roaming information buffer
19963 * @join_rsp: Join response which has TDLS info
19964 *
19965 * Return: None
19966 */
Kabilan Kannan32eb5022016-10-04 12:24:50 -070019967void csr_roam_fill_tdls_info(tpAniSirGlobal mac_ctx, tCsrRoamInfo *roam_info,
19968 tpSirSmeJoinRsp join_rsp)
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019969{
19970 roam_info->tdls_prohibited = join_rsp->tdls_prohibited;
19971 roam_info->tdls_chan_swit_prohibited =
19972 join_rsp->tdls_chan_swit_prohibited;
Srinivas Girigowda81aef902017-03-17 09:34:19 -070019973 sme_debug(
19974 "tdls:prohibit: %d, chan_swit_prohibit: %d",
Kabilan Kannan32eb5022016-10-04 12:24:50 -070019975 roam_info->tdls_prohibited,
19976 roam_info->tdls_chan_swit_prohibited);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019977}
19978#endif
19979
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080019980#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Naveen Rawat257386f2017-05-17 11:42:18 -070019981static QDF_STATUS csr_process_roam_sync_callback(tpAniSirGlobal mac_ctx,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019982 roam_offload_synch_ind *roam_synch_data,
Naveen Rawat257386f2017-05-17 11:42:18 -070019983 tpSirBssDescription bss_desc, enum sir_roam_op_code reason)
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019984{
19985 uint8_t session_id = roam_synch_data->roamedVdevId;
19986 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
19987 tDot11fBeaconIEs *ies_local = NULL;
19988 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
19989 tCsrRoamInfo *roam_info;
19990 tCsrRoamConnectedProfile *conn_profile = NULL;
19991 sme_QosAssocInfo assoc_info;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019992 tpAddBssParams add_bss_params;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019993 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -070019994 uint16_t len;
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +053019995#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
19996 tSirSmeHTProfile *src_profile = NULL;
19997 tCsrRoamHTProfile *dst_profile = NULL;
19998#endif
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019999
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020000 if (!session) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020001 sme_err("LFR3: Session not found");
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070020002 return QDF_STATUS_E_FAILURE;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020003 }
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +053020004
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020005 sme_debug("LFR3: reason: %d", reason);
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070020006 switch (reason) {
20007 case SIR_ROAMING_DEREGISTER_STA:
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070020008 /*
20009 * The following is the first thing done in CSR
20010 * after receiving RSI. Hence stopping the timer here.
20011 */
20012 csr_roam_roaming_offload_timer_action(mac_ctx,
20013 0, session_id, ROAMING_OFFLOAD_TIMER_STOP);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070020014 if (!CSR_IS_ROAM_JOINED(mac_ctx, session_id)) {
20015 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
20016 FL("LFR3: Session not in connected state"));
20017 return QDF_STATUS_E_FAILURE;
20018 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020019 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070020020 eCSR_ROAM_FT_START, eCSR_ROAM_RESULT_SUCCESS);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070020021 return status;
Naveen Rawat8cc23b02016-07-14 12:22:56 -070020022 case SIR_ROAMING_START:
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070020023 csr_roam_roaming_offload_timer_action(mac_ctx,
20024 CSR_ROAMING_OFFLOAD_TIMEOUT_PERIOD, session_id,
20025 ROAMING_OFFLOAD_TIMER_START);
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070020026 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070020027 eCSR_ROAM_START, eCSR_ROAM_RESULT_SUCCESS);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070020028 return status;
Naveen Rawat8cc23b02016-07-14 12:22:56 -070020029 case SIR_ROAMING_ABORT:
Varun Reddy Yeturuf86f0522017-03-13 17:10:03 -070020030 csr_roam_roaming_offload_timer_action(mac_ctx,
20031 0, session_id, ROAMING_OFFLOAD_TIMER_STOP);
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070020032 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070020033 eCSR_ROAM_ABORT, eCSR_ROAM_RESULT_SUCCESS);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070020034 return status;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -070020035 case SIR_ROAM_SYNCH_NAPI_OFF:
20036 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
Varun Reddy Yeturu7b2a6572017-06-15 11:07:28 -070020037 eCSR_ROAM_NAPI_OFF, eCSR_ROAM_RESULT_SUCCESS);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070020038 return status;
Arif Hussain43354e62017-05-24 11:24:25 -070020039 case SIR_ROAMING_INVOKE_FAIL:
20040 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
20041 eCSR_ROAM_ASSOCIATION_FAILURE,
20042 eCSR_ROAM_RESULT_INVOKE_FAILED);
20043
20044 /* Userspace roam request failed, disconnect with current AP */
20045 sme_debug("LFR3: roam invoke from user-space fail, dis cur AP");
20046 csr_roam_disconnect(mac_ctx, session_id,
20047 eCSR_DISCONNECT_REASON_DEAUTH);
20048 return status;
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070020049 case SIR_ROAM_SYNCH_PROPAGATION:
20050 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -070020051 case SIR_ROAM_SYNCH_COMPLETE:
20052 /*
20053 * Following operations need to be done once roam sync
20054 * completion is sent to FW, hence called here:
20055 * 1) Firmware has already updated DBS policy. Update connection
20056 * table in the host driver.
20057 * 2) Force SCC switch if needed
20058 * 3) Set connection in progress = false
20059 */
20060 /* first update connection info from wma interface */
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080020061 policy_mgr_update_connection_info(mac_ctx->psoc, session_id);
Naveen Rawat8cc23b02016-07-14 12:22:56 -070020062 /* then update remaining parameters from roam sync ctx */
Srinivas Girigowda6598eea2017-07-06 19:26:19 -070020063 sme_debug("Update DBS hw mode");
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080020064 policy_mgr_hw_mode_transition_cb(
Naveen Rawat8cc23b02016-07-14 12:22:56 -070020065 roam_synch_data->hw_mode_trans_ind.old_hw_mode_index,
20066 roam_synch_data->hw_mode_trans_ind.new_hw_mode_index,
20067 roam_synch_data->hw_mode_trans_ind.num_vdev_mac_entries,
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080020068 roam_synch_data->hw_mode_trans_ind.vdev_mac_map,
20069 mac_ctx->psoc);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -080020070 mac_ctx->sme.set_connection_info_cb(false);
Naveen Rawat8cc23b02016-07-14 12:22:56 -070020071 session->roam_synch_in_progress = false;
Tushnim Bhattacharyya0c4ad2d2017-03-09 15:59:03 -080020072 policy_mgr_check_concurrent_intf_and_restart_sap(mac_ctx->psoc);
Selvaraj, Sridhar50566502017-05-15 18:26:47 +053020073 csr_roam_offload_scan(mac_ctx, session_id,
20074 ROAM_SCAN_OFFLOAD_START,
20075 REASON_CONNECT);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070020076 return status;
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -070020077 default:
Srinivas Girigowda6598eea2017-07-06 19:26:19 -070020078 sme_debug("LFR3: callback reason %d", reason);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070020079 return QDF_STATUS_E_FAILURE;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020080 }
Arif Hussain557920f2016-09-07 16:03:46 -070020081 session->roam_synch_in_progress = true;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020082 session->roam_synch_data = roam_synch_data;
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070020083 status = csr_get_parsed_bss_description_ies(
20084 mac_ctx, bss_desc, &ies_local);
20085 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020086 sme_err("LFR3: fail to parse IEs");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020087 session->roam_synch_in_progress = false;
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070020088 return status;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020089 }
20090 conn_profile = &session->connectedProfile;
20091 csr_roam_stop_network(mac_ctx, session_id,
20092 session->pCurRoamProfile,
20093 bss_desc,
20094 ies_local);
20095 ps_global_info->remain_in_power_active_till_dhcp = false;
20096 session->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020097 roam_info = qdf_mem_malloc(sizeof(tCsrRoamInfo));
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020098 if (NULL == roam_info) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020099 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020100 FL("LFR3: Mem Alloc failed for roam info"));
20101 session->roam_synch_in_progress = false;
Yeshwanth Sriram Guntuka6f8b8752016-12-08 17:33:10 +053020102 qdf_mem_free(ies_local);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070020103 return QDF_STATUS_E_NOMEM;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020104 }
20105 csr_scan_save_roam_offload_ap_to_scan_cache(mac_ctx, roam_synch_data,
20106 bss_desc);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020107 roam_info->sessionId = session_id;
20108 csr_roam_call_callback(mac_ctx, roam_synch_data->roamedVdevId,
20109 roam_info, 0, eCSR_ROAM_TDLS_STATUS_UPDATE,
20110 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020111 qdf_mem_copy(&roam_info->bssid.bytes, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053020112 sizeof(struct qdf_mac_addr));
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020113 csr_roam_save_connected_infomation(mac_ctx, session_id,
20114 session->pCurRoamProfile,
20115 bss_desc,
20116 ies_local);
20117 csr_roam_save_security_rsp_ie(mac_ctx, session_id,
20118 session->pCurRoamProfile->negotiatedAuthType,
20119 bss_desc, ies_local);
Yu Wang0477ee32017-02-10 20:02:03 +080020120
20121#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020122 roam_info->isESEAssoc = conn_profile->isESEAssoc;
Yu Wang0477ee32017-02-10 20:02:03 +080020123#endif
Prakash Dhavalif3287ef2016-11-28 17:56:33 -080020124
20125 /*
20126 * Encryption keys for new connection are obtained as follows:
20127 * authStatus = CSR_ROAM_AUTH_STATUS_AUTHENTICATED
20128 * Open - No keys required.
20129 * Static WEP - Firmware copies keys from old AP to new AP.
20130 * Fast roaming authentications e.g. PSK, FT, CCKM - firmware
20131 * supplicant obtains them through 4-way handshake.
20132 *
20133 * authStatus = CSR_ROAM_AUTH_STATUS_CONNECTED
20134 * All other authentications - Host supplicant performs EAPOL
20135 * with AP after this point and sends new keys to the driver.
20136 * Driver starts wait_for_key timer for that purpose.
20137 */
Srinivas Girigowdaf326dfe2017-08-03 11:28:32 -070020138 if (roam_synch_data->authStatus
20139 == CSR_ROAM_AUTH_STATUS_AUTHENTICATED) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020140 QDF_TRACE(QDF_MODULE_ID_SME,
20141 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020142 FL("LFR3:Don't start waitforkey timer"));
20143 csr_roam_substate_change(mac_ctx,
20144 eCSR_ROAM_SUBSTATE_NONE, session_id);
20145 } else {
20146 roam_info->fAuthRequired = true;
20147 csr_roam_substate_change(mac_ctx,
20148 eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY,
20149 session_id);
20150
20151 ps_global_info->remain_in_power_active_till_dhcp = true;
20152 mac_ctx->roam.WaitForKeyTimerInfo.sessionId = session_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053020153 if (!QDF_IS_STATUS_SUCCESS(csr_roam_start_wait_for_key_timer(
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020154 mac_ctx, CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD))
20155 ) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020156 sme_err("Failed wait for key timer start");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020157 csr_roam_substate_change(mac_ctx,
20158 eCSR_ROAM_SUBSTATE_NONE,
20159 session_id);
20160 }
20161 }
20162 roam_info->nBeaconLength = 0;
20163 roam_info->nAssocReqLength = roam_synch_data->reassoc_req_length -
20164 SIR_MAC_HDR_LEN_3A - SIR_MAC_REASSOC_SSID_OFFSET;
20165 roam_info->nAssocRspLength = roam_synch_data->reassocRespLength -
20166 SIR_MAC_HDR_LEN_3A;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020167 roam_info->pbFrames = qdf_mem_malloc(roam_info->nBeaconLength +
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020168 roam_info->nAssocReqLength + roam_info->nAssocRspLength);
20169 if (NULL == roam_info->pbFrames) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020170 sme_err("no memory available");
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020171 session->roam_synch_in_progress = false;
20172 if (roam_info)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020173 qdf_mem_free(roam_info);
Yeshwanth Sriram Guntuka6f8b8752016-12-08 17:33:10 +053020174 qdf_mem_free(ies_local);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070020175 return QDF_STATUS_E_NOMEM;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020176 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020177 qdf_mem_copy(roam_info->pbFrames,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020178 (uint8_t *)roam_synch_data +
20179 roam_synch_data->reassoc_req_offset +
20180 SIR_MAC_HDR_LEN_3A + SIR_MAC_REASSOC_SSID_OFFSET,
20181 roam_info->nAssocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020182 qdf_mem_copy(roam_info->pbFrames + roam_info->nAssocReqLength,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020183 (uint8_t *)roam_synch_data +
20184 roam_synch_data->reassocRespOffset +
20185 SIR_MAC_HDR_LEN_3A,
20186 roam_info->nAssocRspLength);
20187
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020188 QDF_TRACE(QDF_MODULE_ID_SME,
20189 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020190 FL("LFR3:Clear Connected info"));
20191 csr_roam_free_connected_info(mac_ctx,
20192 &session->connectedInfo);
Yu Wang0477ee32017-02-10 20:02:03 +080020193 len = roam_synch_data->join_rsp->parsedRicRspLen;
20194
20195#ifdef FEATURE_WLAN_ESE
20196 len += roam_synch_data->join_rsp->tspecIeLen;
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -070020197 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Yu Wang0477ee32017-02-10 20:02:03 +080020198 FL("LFR3: tspecLen %d"),
Sreelakshmi Konamki0a942d42017-01-24 14:46:55 +053020199 roam_synch_data->join_rsp->tspecIeLen);
Yu Wang0477ee32017-02-10 20:02:03 +080020200#endif
20201
20202 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
20203 FL("LFR3: RIC length - %d"),
20204 roam_synch_data->join_rsp->parsedRicRspLen);
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -070020205 if (len) {
20206 session->connectedInfo.pbFrames =
20207 qdf_mem_malloc(len);
20208 if (session->connectedInfo.pbFrames != NULL) {
20209 qdf_mem_copy(session->connectedInfo.pbFrames,
20210 roam_synch_data->join_rsp->frames, len);
20211 session->connectedInfo.nRICRspLength =
20212 roam_synch_data->join_rsp->parsedRicRspLen;
Yu Wang0477ee32017-02-10 20:02:03 +080020213
20214#ifdef FEATURE_WLAN_ESE
Sreelakshmi Konamki0a942d42017-01-24 14:46:55 +053020215 session->connectedInfo.nTspecIeLength =
20216 roam_synch_data->join_rsp->tspecIeLen;
Yu Wang0477ee32017-02-10 20:02:03 +080020217#endif
Kiran Kumar Lokereba3b4312016-04-29 16:40:20 -070020218 }
20219 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020220 conn_profile->vht_channel_width =
20221 roam_synch_data->join_rsp->vht_channel_width;
20222 add_bss_params = (tpAddBssParams)roam_synch_data->add_bss_params;
20223 session->connectedInfo.staId = add_bss_params->staContext.staIdx;
20224 roam_info->staId = session->connectedInfo.staId;
20225 roam_info->ucastSig =
20226 (uint8_t) roam_synch_data->join_rsp->ucastSig;
20227 roam_info->bcastSig =
20228 (uint8_t) roam_synch_data->join_rsp->bcastSig;
20229 roam_info->timingMeasCap =
20230 roam_synch_data->join_rsp->timingMeasCap;
20231 roam_info->chan_info.nss = roam_synch_data->join_rsp->nss;
20232 roam_info->chan_info.rate_flags =
20233 roam_synch_data->join_rsp->max_rate_flags;
Kabilan Kannan32eb5022016-10-04 12:24:50 -070020234 csr_roam_fill_tdls_info(mac_ctx, roam_info, roam_synch_data->join_rsp);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020235#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
20236 src_profile = &roam_synch_data->join_rsp->HTProfile;
20237 dst_profile = &conn_profile->HTProfile;
20238 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053020239 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020240 csr_roam_copy_ht_profile(dst_profile,
20241 src_profile);
20242#endif
20243 assoc_info.pBssDesc = bss_desc;
20244 roam_info->statusCode = eSIR_SME_SUCCESS;
20245 roam_info->reasonCode = eSIR_SME_SUCCESS;
20246 assoc_info.pProfile = session->pCurRoamProfile;
20247 mac_ctx->roam.roamSession[session_id].connectState =
20248 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
20249 sme_qos_csr_event_ind(mac_ctx, session_id,
20250 SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
20251 sme_qos_csr_event_ind(mac_ctx, session_id,
20252 SME_QOS_CSR_REASSOC_REQ, NULL);
20253 sme_qos_csr_event_ind(mac_ctx, session_id,
20254 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
20255 mac_ctx->roam.roamSession[session_id].connectState =
20256 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
20257 sme_qos_csr_event_ind(mac_ctx, session_id,
20258 SME_QOS_CSR_REASSOC_COMPLETE, &assoc_info);
20259 roam_info->pBssDesc = bss_desc;
20260 conn_profile->acm_mask = sme_qos_get_acm_mask(mac_ctx,
20261 bss_desc, NULL);
20262 if (conn_profile->modifyProfileFields.uapsd_mask) {
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020263 sme_debug(
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020264 " uapsd_mask (0x%X) set, request UAPSD now",
20265 conn_profile->modifyProfileFields.uapsd_mask);
20266 sme_ps_start_uapsd(mac_ctx, session_id,
20267 NULL, NULL);
20268 }
20269 conn_profile->dot11Mode = session->bssParams.uCfgDot11Mode;
20270 roam_info->u.pConnectedProfile = conn_profile;
20271
Srinivas Girigowda81aef902017-03-17 09:34:19 -070020272 sme_debug(
20273 "vht ch width %d staId %d nss %d rate_flag %d dot11Mode %d",
Padma, Santhosh Kumarcd35f532016-12-27 12:07:39 +053020274 conn_profile->vht_channel_width,
20275 roam_info->staId,
20276 roam_info->chan_info.nss,
20277 roam_info->chan_info.rate_flags,
20278 conn_profile->dot11Mode);
20279
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020280 if (!IS_FEATURE_SUPPORTED_BY_FW
20281 (SLM_SESSIONIZATION) &&
20282 (csr_is_concurrent_session_running(mac_ctx))) {
20283 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
20284 }
20285 roam_info->roamSynchInProgress = true;
20286 roam_info->synchAuthStatus = roam_synch_data->authStatus;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020287 qdf_mem_copy(roam_info->kck, roam_synch_data->kck, SIR_KCK_KEY_LEN);
20288 qdf_mem_copy(roam_info->kek, roam_synch_data->kek, SIR_KEK_KEY_LEN);
20289 qdf_mem_copy(roam_info->replay_ctr, roam_synch_data->replay_ctr,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020290 SIR_REPLAY_CTR_LEN);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020291 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020292 FL("LFR3: Copy KCK, KEK and Replay Ctr"));
20293 roam_info->subnet_change_status =
20294 CSR_GET_SUBNET_STATUS(roam_synch_data->roamReason);
20295 csr_roam_call_callback(mac_ctx, session_id, roam_info, 0,
20296 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
20297 csr_reset_pmkid_candidate_list(mac_ctx, session_id);
20298#ifdef FEATURE_WLAN_WAPI
20299 csr_reset_bkid_candidate_list(mac_ctx, session_id);
20300#endif
20301 if (!CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053020302 QDF_TRACE(QDF_MODULE_ID_SME,
20303 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020304 FL
20305 ("NO CSR_IS_WAIT_FOR_KEY -> csr_roam_link_up"));
20306 csr_roam_link_up(mac_ctx, conn_profile->bssid);
20307 }
Naveen Rawat8cc23b02016-07-14 12:22:56 -070020308
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020309 session->fRoaming = false;
20310 session->roam_synch_in_progress = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053020311 qdf_mem_free(roam_info->pbFrames);
20312 qdf_mem_free(roam_info);
Yeshwanth Sriram Guntuka6f8b8752016-12-08 17:33:10 +053020313 qdf_mem_free(ies_local);
Naveen Rawat257386f2017-05-17 11:42:18 -070020314
20315 return status;
20316}
20317
20318/**
20319 * csr_roam_synch_callback() - SME level callback for roam synch propagation
20320 * @mac_ctx: MAC Context
20321 * @roam_synch_data: Roam synch data buffer pointer
20322 * @bss_desc: BSS descriptor pointer
20323 * @reason: Reason for calling the callback
20324 *
20325 * This callback is registered with WMA and used after roaming happens in
20326 * firmware and the call to this routine completes the roam synch
20327 * propagation at both CSR and HDD levels. The HDD level propagation
20328 * is achieved through the already defined callback for assoc completion
20329 * handler.
20330 *
20331 * Return: Success or Failure.
20332 */
20333QDF_STATUS csr_roam_synch_callback(tpAniSirGlobal mac_ctx,
20334 roam_offload_synch_ind *roam_synch_data,
20335 tpSirBssDescription bss_desc, enum sir_roam_op_code reason)
20336{
20337 QDF_STATUS status;
20338
20339 status = sme_acquire_global_lock(&mac_ctx->sme);
20340 if (!QDF_IS_STATUS_SUCCESS(status)) {
20341 sme_err("LFR3: Locking failed, bailing out");
20342 return status;
20343 }
20344
20345 status = csr_process_roam_sync_callback(mac_ctx, roam_synch_data,
20346 bss_desc, reason);
20347
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020348 sme_release_global_lock(&mac_ctx->sme);
Varun Reddy Yeturu88f123c2017-03-14 18:24:32 -070020349
20350 return status;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080020351}
Varun Reddy Yeturubbbbe232016-02-29 14:01:57 -080020352#endif