blob: 310dd9a251f00d5b4869d29b81d77f0e35f94b99 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
kaliu154d7892015-12-30 17:27:58 +05302 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/** ------------------------------------------------------------------------- *
29 ------------------------------------------------------------------------- *
30
31 \file csr_api_roam.c
32
33 Implementation for the Common Roaming interfaces.
34 ========================================================================== */
35#include "ani_global.h" /* for tpAniSirGlobal */
36#include "wma_types.h"
37#include "wma_if.h" /* for STA_INVALID_IDX. */
38#include "lim_utils.h"
39#include "cds_mq.h"
40#include "csr_inside_api.h"
41#include "sms_debug.h"
42#include "sme_qos_internal.h"
43#include "sme_inside.h"
44#include "host_diag_core_event.h"
45#include "host_diag_core_log.h"
46#include "csr_api.h"
47#include "csr_internal.h"
48#include "cds_reg_service.h"
49#include "mac_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#include "csr_neighbor_roam.h"
Amar Singhale4f28ee2015-10-21 14:36:56 -070051#include "cds_regdomain.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080052#include "cds_utils.h"
53#include "sir_types.h"
54#include "cfg_api.h"
55#include "sme_power_save_api.h"
56#include "wma.h"
57#include "cds_concurrency.h"
58
59#define CSR_NUM_IBSS_START_CHANNELS_50 4
60#define CSR_NUM_IBSS_START_CHANNELS_24 3
61/* 5 seconds, for WPA, WPA2, CCKM */
Anurag Chouhan210db072016-02-22 18:42:15 +053062#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD (15 * QDF_MC_TIMER_TO_SEC_UNIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063/* 120 seconds, for WPS */
Anurag Chouhan210db072016-02-22 18:42:15 +053064#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD (120 * QDF_MC_TIMER_TO_SEC_UNIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065
66/*---------------------------------------------------------------------------
67 OBIWAN recommends [8 10]% : pick 9%
68 ---------------------------------------------------------------------------*/
69#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
70/*---------------------------------------------------------------------------
71 OBIWAN recommends -85dBm
72 ---------------------------------------------------------------------------*/
73#define CSR_VCC_RSSI_THRESHOLD 80
74#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 /* ms */
75#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 /* ms */
76#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 /* ms */
77/* Flag to send/do not send disassoc frame over the air */
78#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
79#define RSSI_HACK_BMPS (-40)
80#define MAX_CB_VALUE_IN_INI (2)
81
82#define MAX_SOCIAL_CHANNELS 3
83/* Choose the largest possible value that can be accomodates in 8 bit signed */
84/* variable. */
85#define SNR_HACK_BMPS (127)
86
87static bool b_roam_scan_offload_started;
88
89/*--------------------------------------------------------------------------
90 Static Type declarations
91 ------------------------------------------------------------------------*/
92static tCsrRoamSession csr_roam_roam_session[CSR_ROAM_SESSION_MAX];
93
94/*--------------------------------------------------------------------------
95 Type declarations
96 ------------------------------------------------------------------------*/
97#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
98int diag_auth_type_from_csr_type(eCsrAuthType authType)
99{
100 int n = AUTH_OPEN;
101 switch (authType) {
102 case eCSR_AUTH_TYPE_SHARED_KEY:
103 n = AUTH_SHARED;
104 break;
105 case eCSR_AUTH_TYPE_WPA:
106 n = AUTH_WPA_EAP;
107 break;
108 case eCSR_AUTH_TYPE_WPA_PSK:
109 n = AUTH_WPA_PSK;
110 break;
111 case eCSR_AUTH_TYPE_RSN:
112#ifdef WLAN_FEATURE_11W
113 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
114#endif
115 n = AUTH_WPA2_EAP;
116 break;
117 case eCSR_AUTH_TYPE_RSN_PSK:
118#ifdef WLAN_FEATURE_11W
119 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
120#endif
121 n = AUTH_WPA2_PSK;
122 break;
123#ifdef FEATURE_WLAN_WAPI
124 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
125 n = AUTH_WAPI_CERT;
126 break;
127 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
128 n = AUTH_WAPI_PSK;
129 break;
130#endif /* FEATURE_WLAN_WAPI */
131 default:
132 break;
133 }
134 return n;
135}
136
137int diag_enc_type_from_csr_type(eCsrEncryptionType encType)
138{
139 int n = ENC_MODE_OPEN;
140 switch (encType) {
141 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
142 case eCSR_ENCRYPT_TYPE_WEP40:
143 n = ENC_MODE_WEP40;
144 break;
145 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
146 case eCSR_ENCRYPT_TYPE_WEP104:
147 n = ENC_MODE_WEP104;
148 break;
149 case eCSR_ENCRYPT_TYPE_TKIP:
150 n = ENC_MODE_TKIP;
151 break;
152 case eCSR_ENCRYPT_TYPE_AES:
153 n = ENC_MODE_AES;
154 break;
155#ifdef FEATURE_WLAN_WAPI
156 case eCSR_ENCRYPT_TYPE_WPI:
157 n = ENC_MODE_SMS4;
158 break;
159#endif /* FEATURE_WLAN_WAPI */
160 default:
161 break;
162 }
163 return n;
164}
165#endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */
166static const uint8_t
167 csr_start_ibss_channels50[CSR_NUM_IBSS_START_CHANNELS_50] = { 36, 40, 44, 48 };
168static const uint8_t
169 csr_start_ibss_channels24[CSR_NUM_IBSS_START_CHANNELS_24] = { 1, 6, 11 };
170static void init_config_param(tpAniSirGlobal pMac);
171static bool csr_roam_process_results(tpAniSirGlobal pMac, tSmeCmd *pCommand,
172 eCsrRoamCompleteResult Result,
173 void *Context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530174static QDF_STATUS csr_roam_start_ibss(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175 tCsrRoamProfile *pProfile,
176 bool *pfSameIbss);
177static void csr_roam_update_connected_profile_from_new_bss(tpAniSirGlobal pMac,
178 uint32_t sessionId,
179 tSirSmeNewBssInfo *
180 pNewBss);
181static void csr_roam_prepare_bss_params(tpAniSirGlobal pMac, uint32_t sessionId,
182 tCsrRoamProfile *pProfile,
183 tSirBssDescription *pBssDesc,
184 tBssConfigParam *pBssConfig,
185 tDot11fBeaconIEs *pIes);
186static ePhyChanBondState csr_get_cb_mode_from_ies(tpAniSirGlobal pMac,
187 uint8_t primaryChn,
188 tDot11fBeaconIEs *pIes);
189
190static void csr_roaming_state_config_cnf_processor(tpAniSirGlobal pMac,
191 uint32_t result);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530192QDF_STATUS csr_roam_open(tpAniSirGlobal pMac);
193QDF_STATUS csr_roam_close(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800194void csr_roamMICErrorTimerHandler(void *pv);
195void csr_roamTKIPCounterMeasureTimerHandler(void *pv);
196bool csr_roam_is_same_profile_keys(tpAniSirGlobal pMac,
197 tCsrRoamConnectedProfile *pConnProfile,
198 tCsrRoamProfile *pProfile2);
199
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530200static QDF_STATUS csr_roam_start_roaming_timer(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800201 uint32_t sessionId,
202 uint32_t interval);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530203static QDF_STATUS csr_roam_stop_roaming_timer(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204 uint32_t sessionId);
205static void csr_roam_roaming_timer_handler(void *pv);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530206QDF_STATUS csr_roam_start_wait_for_key_timer(tpAniSirGlobal pMac, uint32_t interval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207static void csr_roam_wait_for_key_time_out_handler(void *pv);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530208static QDF_STATUS csr_init11d_info(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
209static QDF_STATUS csr_init_channel_power_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800210 tCsr11dinfo *ps11dinfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530211static QDF_STATUS csr_roam_free_connected_info(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212 tCsrRoamConnectedInfo *
213 pConnectedInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530214QDF_STATUS csr_send_mb_set_context_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530215 struct qdf_mac_addr peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -0800216 uint8_t numKeys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800217 tAniEdType edType, bool fUnicast,
218 tAniKeyDirection aniKeyDirection,
219 uint8_t keyId, uint8_t keyLength,
220 uint8_t *pKey, uint8_t paeRole,
221 uint8_t *pKeyRsc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222void csr_roamStatisticsTimerHandler(void *pv);
223void csr_roamStatsGlobalClassDTimerHandler(void *pv);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530224static void csr_roam_link_up(tpAniSirGlobal pMac, struct qdf_mac_addr bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225static void csr_roam_link_down(tpAniSirGlobal pMac, uint32_t sessionId);
226void csr_roam_vcc_trigger(tpAniSirGlobal pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530227QDF_STATUS csr_send_mb_stats_req_msg(tpAniSirGlobal pMac, uint32_t statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 uint8_t staId, uint8_t sessionId);
229/*
230 pStaEntry is no longer invalid upon the return of this function.
231 */
232static void csr_roam_remove_stat_list_entry(tpAniSirGlobal pMac, tListElem *pEntry);
233static eCsrCfgDot11Mode csr_roam_get_phy_mode_band_for_bss(tpAniSirGlobal pMac,
234 tCsrRoamProfile *pProfile,
235 uint8_t operationChn,
236 eCsrBand *pBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530237static QDF_STATUS csr_roam_get_qos_info_from_bss(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238 tSirBssDescription *pBssDesc);
239tCsrStatsClientReqInfo *csr_roam_insert_entry_into_list(tpAniSirGlobal pMac,
240 tDblLinkList *pStaList,
241 tCsrStatsClientReqInfo *
242 pStaEntry);
243void csr_roam_stats_client_timer_handler(void *pv);
244tCsrPeStatsReqInfo *csr_roam_check_pe_stats_req_list(tpAniSirGlobal pMac,
245 uint32_t statsMask,
246 uint32_t periodicity,
247 bool *pFound, uint8_t staId,
248 uint8_t sessionId);
249void csr_roam_report_statistics(tpAniSirGlobal pMac, uint32_t statsMask,
250 tCsrStatsCallback callback, uint8_t staId,
251 void *pContext);
252void csr_roam_tl_stats_timer_handler(void *pv);
253void csr_roam_pe_stats_timer_handler(void *pv);
254tListElem *csr_roam_check_client_req_list(tpAniSirGlobal pMac, uint32_t statsMask);
255void csr_roam_remove_entry_from_pe_stats_req_list(tpAniSirGlobal pMac,
256 tCsrPeStatsReqInfo *pPeStaEntry);
257tListElem *csr_roam_find_in_pe_stats_req_list(tpAniSirGlobal pMac, uint32_t statsMask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530258QDF_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);
274void csr_roam_reissue_roam_command(tpAniSirGlobal pMac);
275static void csr_ser_des_unpack_diassoc_rsp(uint8_t *pBuf,
276 tSirSmeDisassocRsp *pRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800277void csr_init_operating_classes(tHalHandle hHal);
278
279/* Initialize global variables */
280static void csr_roam_init_globals(tpAniSirGlobal pMac)
281{
282 if (pMac) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530283 qdf_mem_zero(&csr_roam_roam_session, sizeof(csr_roam_roam_session));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 pMac->roam.roamSession = csr_roam_roam_session;
285 }
286 return;
287}
288
289static void csr_roam_de_init_globals(tpAniSirGlobal pMac)
290{
291 if (pMac) {
292 pMac->roam.roamSession = NULL;
293 }
294 return;
295}
296
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530297QDF_STATUS csr_open(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530299 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300 uint32_t i;
301
302 do {
303 /* Initialize CSR Roam Globals */
304 csr_roam_init_globals(pMac);
305 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
306 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_STOP, i);
307
308 init_config_param(pMac);
309 status = csr_scan_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530310 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311 break;
312 status = csr_roam_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530313 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800314 break;
315 pMac->roam.nextRoamId = 1; /* Must not be 0 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530316 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800317 (csr_ll_open(pMac->hHdd,
318 &pMac->roam.statsClientReqList)))
319 break;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530320 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800321 (csr_ll_open(pMac->hHdd,
322 &pMac->roam.peStatsReqList)))
323 break;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530324 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325 (csr_ll_open(pMac->hHdd,
326 &pMac->roam.roamCmdPendingList)))
327 break;
328 } while (0);
329
330 return status;
331}
332
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530333QDF_STATUS csr_init_chan_list(tpAniSirGlobal mac, uint8_t *alpha2)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800334{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530335 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336
337 mac->scan.countryCodeDefault[0] = alpha2[0];
338 mac->scan.countryCodeDefault[1] = alpha2[1];
339 mac->scan.countryCodeDefault[2] = alpha2[2];
340
341 sms_log(mac, LOGE, FL("init time country code %.2s"),
342 mac->scan.countryCodeDefault);
343
Amar Singhale4f28ee2015-10-21 14:36:56 -0700344 mac->scan.domainIdDefault = 0;
345 mac->scan.domainIdCurrent = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530347 qdf_mem_copy(mac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348 mac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530349 qdf_mem_copy(mac->scan.countryCodeElected,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350 mac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
351 status = csr_get_channel_and_power_list(mac);
352 csr_clear_votes_for_country_info(mac);
353 return status;
354}
355
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530356QDF_STATUS csr_set_reg_info(tHalHandle hHal, uint8_t *apCntryCode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530358 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
360 v_REGDOMAIN_t regId;
361 uint8_t cntryCodeLength;
362 if (NULL == apCntryCode) {
363 sms_log(pMac, LOGE, FL(" Invalid country Code Pointer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530364 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365 }
366 sms_log(pMac, LOG1, FL(" country Code %.2s"), apCntryCode);
367
368 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
369 status = csr_get_regulatory_domain_for_country(pMac, apCntryCode, &regId,
Amar Singhala297bfa2015-10-15 15:07:29 -0700370 SOURCE_USERSPACE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530371 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800372 sms_log(pMac, LOGE,
373 FL(" fail to get regId for country Code %.2s"),
374 apCntryCode);
375 return status;
376 }
377 status = wma_set_reg_domain(hHal, regId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530378 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379 sms_log(pMac, LOGE,
380 FL(" fail to get regId for country Code %.2s"),
381 apCntryCode);
382 return status;
383 }
384 pMac->scan.domainIdDefault = regId;
385 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
386 /* Clear CC field */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530387 qdf_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388
389 /* Copy 2 or 3 bytes country code */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530390 qdf_mem_copy(pMac->scan.countryCodeDefault, apCntryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800391 cntryCodeLength);
392
393 /* If 2 bytes country code, 3rd byte must be filled with space */
394 if ((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530395 qdf_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530397 qdf_mem_copy(pMac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
399 status = csr_get_channel_and_power_list(pMac);
400 return status;
401}
402
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530403QDF_STATUS csr_set_channels(tHalHandle hHal, tCsrConfigParam *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800404{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530405 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
407 uint8_t index = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530408 qdf_mem_copy(pParam->Csr11dinfo.countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
410 for (index = 0; index < pMac->scan.base_channels.numChannels;
411 index++) {
412 pParam->Csr11dinfo.Channels.channelList[index] =
413 pMac->scan.base_channels.channelList[index];
414 pParam->Csr11dinfo.ChnPower[index].firstChannel =
415 pMac->scan.base_channels.channelList[index];
416 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
417 pParam->Csr11dinfo.ChnPower[index].maxtxPower =
Amar Singhala297bfa2015-10-15 15:07:29 -0700418 pMac->scan.defaultPowerTable[index].power;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800419 }
420 pParam->Csr11dinfo.Channels.numChannels =
421 pMac->scan.base_channels.numChannels;
422
423 return status;
424}
425
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530426QDF_STATUS csr_close(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530428 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429
430 csr_roam_close(pMac);
431 csr_scan_close(pMac);
432 csr_ll_close(&pMac->roam.statsClientReqList);
433 csr_ll_close(&pMac->roam.peStatsReqList);
434 csr_ll_close(&pMac->roam.roamCmdPendingList);
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530435 if (pMac->sme.saved_scan_cmd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530436 qdf_mem_free(pMac->sme.saved_scan_cmd);
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530437 pMac->sme.saved_scan_cmd = NULL;
438 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439 /* DeInit Globals */
440 csr_roam_de_init_globals(pMac);
441 return status;
442}
443
Amar Singhala297bfa2015-10-15 15:07:29 -0700444static int8_t csr_find_channel_pwr(struct channel_power *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800445 pdefaultPowerTable,
446 uint8_t ChannelNum)
447{
448 uint8_t i;
449 /* TODO: if defaultPowerTable is guaranteed to be in ascending */
450 /* order of channel numbers, we can employ binary search */
451 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -0700452 if (pdefaultPowerTable[i].chan_num == ChannelNum)
453 return pdefaultPowerTable[i].power;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800454 }
455 /* could not find the channel list in default list */
456 /* this should not have occured */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530457 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458 return 0;
459}
Naveen Rawat16b82872015-12-14 17:59:16 -0800460
461/**
462 * csr_roam_arrange_ch_list() - Updates the channel list modified with greedy
463 * order for 5 Ghz preference and DFS channels.
464 * @mac_ctx: pointer to mac context.
465 * @chan_list: channel list updated with greedy channel order.
466 * @num_channel: Number of channels in list
467 *
468 * To allow Early Stop Roaming Scan feature to co-exist with 5G preference,
469 * this function moves 5G channels ahead of 2G channels. This function can
470 * also move 2G channels, ahead of DFS channel or vice versa. Order is
471 * maintained among same category channels
472 *
473 * Return: None
474 */
475void csr_roam_arrange_ch_list(tpAniSirGlobal mac_ctx,
476 tSirUpdateChanParam *chan_list, uint8_t num_channel)
477{
478 bool prefer_5g = CSR_IS_ROAM_PREFER_5GHZ(mac_ctx);
479 bool prefer_dfs = CSR_IS_DFS_CH_ROAM_ALLOWED(mac_ctx);
480 int i, j = 0;
481 tSirUpdateChanParam *tmp_list = NULL;
482
483 if (!prefer_5g)
484 return;
485
486 tmp_list = (tSirUpdateChanParam *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530487 qdf_mem_malloc(sizeof(tSirUpdateChanParam) * num_channel);
Naveen Rawat16b82872015-12-14 17:59:16 -0800488 if (tmp_list == NULL) {
489 sms_log(mac_ctx, LOGE, FL("Memory allocation failed"));
490 return;
491 }
492
493 /* Fist copy Non-DFS 5g channels */
494 for (i = 0; i < num_channel; i++) {
495 if (CDS_IS_CHANNEL_5GHZ(chan_list[i].chanId) &&
496 !CDS_IS_DFS_CH(chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530497 qdf_mem_copy(&tmp_list[j++],
Naveen Rawat16b82872015-12-14 17:59:16 -0800498 &chan_list[i], sizeof(tSirUpdateChanParam));
499 chan_list[i].chanId = INVALID_CHANNEL_ID;
500 }
501 }
502 if (prefer_dfs) {
503 /* next copy DFS channels (remaining channels in 5G) */
504 for (i = 0; i < num_channel; i++) {
505 if (CDS_IS_CHANNEL_5GHZ(chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530506 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800507 sizeof(tSirUpdateChanParam));
508 chan_list[i].chanId = INVALID_CHANNEL_ID;
509 }
510 }
511 } else {
512 /* next copy 2G channels */
513 for (i = 0; i < num_channel; i++) {
514 if (CDS_IS_CHANNEL_24GHZ(chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530515 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800516 sizeof(tSirUpdateChanParam));
517 chan_list[i].chanId = INVALID_CHANNEL_ID;
518 }
519 }
520 }
521 /* copy rest of the channels in same order to tmp list */
522 for (i = 0; i < num_channel; i++) {
523 if (chan_list[i].chanId != INVALID_CHANNEL_ID) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530524 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800525 sizeof(tSirUpdateChanParam));
526 chan_list[i].chanId = INVALID_CHANNEL_ID;
527 }
528 }
529 /* copy tmp list to original channel list buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530530 qdf_mem_copy(chan_list, tmp_list,
Naveen Rawat16b82872015-12-14 17:59:16 -0800531 sizeof(tSirUpdateChanParam) * num_channel);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530532 qdf_mem_free(tmp_list);
Naveen Rawat16b82872015-12-14 17:59:16 -0800533}
534
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700535/**
536 * csr_roam_sort_channel_for_early_stop() - Sort the channels
Naveen Rawat16b82872015-12-14 17:59:16 -0800537 * @mac_ctx: mac global context
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700538 * @chan_list: Original channel list from the upper layers
539 * @num_channel: Number of original channels
540 *
541 * For Early stop scan feature, the channel list should be in an order,
542 * where-in there is a maximum chance to detect an AP in the initial
543 * channels in the list so that the scanning can be stopped early as the
544 * feature demands.
545 * Below fixed greedy channel list has been provided
546 * based on most of the enterprise wifi installations across the globe.
547 *
548 * Identify all the greedy channels within the channel list from user space.
549 * Identify all the non-greedy channels in the user space channel list.
550 * Merge greedy channels followed by non-greedy channels back into the
551 * chan_list.
552 *
553 * Return: None
554 */
Naveen Rawat16b82872015-12-14 17:59:16 -0800555void csr_roam_sort_channel_for_early_stop(tpAniSirGlobal mac_ctx,
556 tSirUpdateChanList *chan_list, uint8_t num_channel)
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700557{
558 tSirUpdateChanList *chan_list_greedy, *chan_list_non_greedy;
559 uint8_t i, j;
560 static const uint8_t fixed_greedy_chan_list[] = {1, 6, 11, 36, 48, 40,
561 44, 10, 2, 9, 149, 157, 161, 3, 4, 8, 153, 165, 7, 5, 136, 140,
562 52, 116, 56, 104, 64, 60, 100, 120, 13, 14, 112, 132, 151, 155};
563 uint8_t num_fixed_greedy_chan;
564 uint8_t num_greedy_chan = 0;
565 uint8_t num_non_greedy_chan = 0;
566 uint8_t match_found = false;
567 uint32_t buf_size;
568
569 buf_size = sizeof(tSirUpdateChanList) +
570 (sizeof(tSirUpdateChanParam) * num_channel);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530571 chan_list_greedy = qdf_mem_malloc(buf_size);
572 chan_list_non_greedy = qdf_mem_malloc(buf_size);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700573 if (!chan_list_greedy || !chan_list_non_greedy) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530574 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700575 "Failed to allocate memory for tSirUpdateChanList");
576 return;
577 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530578 qdf_mem_zero(chan_list_greedy, buf_size);
579 qdf_mem_zero(chan_list_non_greedy, buf_size);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700580 /*
581 * fixed_greedy_chan_list is an evaluated channel list based on most of
582 * the enterprise wifi deployments and the order of the channels
583 * determines the highest possibility of finding an AP.
584 * chan_list is the channel list provided by upper layers based on the
585 * regulatory domain.
586 */
587 num_fixed_greedy_chan = sizeof(fixed_greedy_chan_list)/sizeof(uint8_t);
588 /*
589 * Browse through the chan_list and put all the non-greedy channels
590 * into a seperate list by name chan_list_non_greedy
591 */
592 for (i = 0; i < num_channel; i++) {
593 for (j = 0; j < num_fixed_greedy_chan; j++) {
594 if (chan_list->chanParam[i].chanId ==
595 fixed_greedy_chan_list[j]) {
596 match_found = true;
597 break;
598 }
599 }
600 if (!match_found) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530601 qdf_mem_copy(
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700602 &chan_list_non_greedy->chanParam[num_non_greedy_chan],
603 &chan_list->chanParam[i],
604 sizeof(tSirUpdateChanParam));
605 num_non_greedy_chan++;
606 } else {
607 match_found = false;
608 }
609 }
610 /*
611 * Browse through the fixed_greedy_chan_list and put all the greedy
612 * channels in the chan_list into a seperate list by name
613 * chan_list_greedy
614 */
615 for (i = 0; i < num_fixed_greedy_chan; i++) {
616 for (j = 0; j < num_channel; j++) {
617 if (fixed_greedy_chan_list[i] ==
618 chan_list->chanParam[j].chanId) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530619 qdf_mem_copy(
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700620 &chan_list_greedy->chanParam[num_greedy_chan],
621 &chan_list->chanParam[j],
622 sizeof(tSirUpdateChanParam));
623 num_greedy_chan++;
624 break;
625 }
626 }
627 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530628 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700629 "greedy=%d, non-greedy=%d, tot=%d",
630 num_greedy_chan, num_non_greedy_chan, num_channel);
631 if ((num_greedy_chan + num_non_greedy_chan) != num_channel) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530632 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700633 "incorrect sorting of channels");
634 goto scan_list_sort_error;
635 }
636 /* Copy the Greedy channels first */
637 i = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530638 qdf_mem_copy(&chan_list->chanParam[i],
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700639 &chan_list_greedy->chanParam[i],
640 num_greedy_chan * sizeof(tSirUpdateChanParam));
641 /* Copy the remaining Non Greedy channels */
642 i = num_greedy_chan;
643 j = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530644 qdf_mem_copy(&chan_list->chanParam[i],
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700645 &chan_list_non_greedy->chanParam[j],
646 num_non_greedy_chan * sizeof(tSirUpdateChanParam));
Naveen Rawat16b82872015-12-14 17:59:16 -0800647
648 /* Update channel list for 5g preference and allow DFS roam */
649 csr_roam_arrange_ch_list(mac_ctx, chan_list->chanParam, num_channel);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700650scan_list_sort_error:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530651 qdf_mem_free(chan_list_greedy);
652 qdf_mem_free(chan_list_non_greedy);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700653}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800654
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530655QDF_STATUS csr_update_channel_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800656{
657 tSirUpdateChanList *pChanList;
658 tCsrScanStruct *pScan = &pMac->scan;
659 uint8_t numChan = pScan->base_channels.numChannels;
660 uint8_t num_channel = 0;
661 uint32_t bufLen;
662 cds_msg_t msg;
663 uint8_t i, j, social_channel[MAX_SOCIAL_CHANNELS] = { 1, 6, 11 };
664 uint8_t channel_state;
665
666 if (CSR_IS_5G_BAND_ONLY(pMac)) {
667 for (i = 0; i < MAX_SOCIAL_CHANNELS; i++) {
668 if (cds_get_channel_state(social_channel[i])
669 == CHANNEL_STATE_ENABLE)
670 numChan++;
671 }
672 }
673
674 bufLen = sizeof(tSirUpdateChanList) +
675 (sizeof(tSirUpdateChanParam) * (numChan));
676
677 csr_init_operating_classes((tHalHandle) pMac);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530678 pChanList = (tSirUpdateChanList *) qdf_mem_malloc(bufLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800679 if (!pChanList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530680 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 "Failed to allocate memory for tSirUpdateChanList");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530682 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800683 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530684 qdf_mem_zero(pChanList, bufLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685
686 for (i = 0; i < pScan->base_channels.numChannels; i++) {
687 /* Scan is not performed on DSRC channels*/
Amar Singhal7a1726a2015-10-14 16:28:11 -0700688 if (pScan->base_channels.channelList[i] >= CDS_MIN_11P_CHANNEL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689 continue;
690 if (pScan->fcc_constraint) {
691 if (pScan->base_channels.channelList[i] == 12)
692 continue;
693 if (pScan->base_channels.channelList[i] == 13)
694 continue;
695 }
696 channel_state =
697 cds_get_channel_state(
698 pScan->base_channels.channelList[i]);
699 if ((CHANNEL_STATE_ENABLE == channel_state) ||
700 pMac->scan.fEnableDFSChnlScan) {
701 pChanList->chanParam[num_channel].chanId =
702 pScan->base_channels.channelList[i];
703 pChanList->chanParam[num_channel].pwr =
704 csr_find_channel_pwr(pScan->defaultPowerTable,
705 pChanList->chanParam[num_channel].chanId);
706 if (CHANNEL_STATE_ENABLE == channel_state)
707 pChanList->chanParam[num_channel].dfsSet =
708 false;
709 else
710 pChanList->chanParam[num_channel].dfsSet =
711 true;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530712 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700713 "channel:%d, pwr=%d, DFS=%d\n",
714 pChanList->chanParam[num_channel].chanId,
715 pChanList->chanParam[num_channel].pwr,
716 pChanList->chanParam[num_channel].dfsSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800717 num_channel++;
718 }
719 }
720
721 if (CSR_IS_5G_BAND_ONLY(pMac)) {
722 for (j = 0; j < MAX_SOCIAL_CHANNELS; j++) {
723 if (cds_get_channel_state(social_channel[j])
724 == CHANNEL_STATE_ENABLE) {
725 pChanList->chanParam[num_channel].chanId =
726 social_channel[j];
727 pChanList->chanParam[num_channel].pwr =
728 csr_find_channel_pwr(pScan->defaultPowerTable,
729 social_channel[j]);
730 pChanList->chanParam[num_channel].dfsSet = false;
731 num_channel++;
732 }
733 }
734 }
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700735 if (pMac->roam.configParam.early_stop_scan_enable)
Naveen Rawat16b82872015-12-14 17:59:16 -0800736 csr_roam_sort_channel_for_early_stop(pMac, pChanList,
737 num_channel);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700738 else
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530739 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700740 FL("Early Stop Scan Feature not supported"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741
742 msg.type = WMA_UPDATE_CHAN_LIST_REQ;
743 msg.reserved = 0;
744 msg.bodyptr = pChanList;
745 pChanList->numChan = num_channel;
746
Anurag Chouhan6d760662016-02-20 16:05:43 +0530747 if (QDF_STATUS_SUCCESS != cds_mq_post_message(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530748 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749 "%s: Failed to post msg to WMA", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530750 qdf_mem_free(pChanList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530751 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 }
753
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530754 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755}
756
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530757QDF_STATUS csr_start(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530759 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760 uint32_t i;
761
762 do {
763 /* save the global cds context */
764 pMac->roam.g_cds_context = cds_get_global_context();
765 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
766 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_IDLE, i);
767
768 status = csr_roam_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530769 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800770 break;
771
772 pMac->roam.sPendingCommands = 0;
773 csr_scan_enable(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800774 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
775 status = csr_neighbor_roam_init(pMac, i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800776 pMac->roam.tlStatsReqInfo.numClient = 0;
777 pMac->roam.tlStatsReqInfo.periodicity = 0;
778 pMac->roam.tlStatsReqInfo.timerRunning = false;
779 /* init the link quality indication also */
780 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530781 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800782 sms_log(pMac, LOGW,
783 " csr_start: Couldn't Init HO control blk ");
784 break;
785 }
786
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530787 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788 "Scan offload is enabled, update default chan list");
789 status = csr_update_channel_list(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800790 } while (0);
791 return status;
792}
793
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530794QDF_STATUS csr_stop(tpAniSirGlobal pMac, tHalStopType stopType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795{
796 uint32_t sessionId;
797
798 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++) {
799 csr_roam_close_session(pMac, sessionId, true, NULL, NULL);
800 }
801 csr_scan_disable(pMac);
802 pMac->scan.fCancelIdleScan = false;
803 pMac->scan.fRestartIdleScan = false;
804 csr_ll_purge(&pMac->roam.roamCmdPendingList, true);
805
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
807 csr_neighbor_roam_close(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
809 if (CSR_IS_SESSION_VALID(pMac, sessionId))
810 csr_scan_flush_result(pMac);
811
812 /* Reset the domain back to the deault */
813 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
814
815 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++) {
816 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_STOP, sessionId);
817 pMac->roam.curSubState[sessionId] = eCSR_ROAM_SUBSTATE_NONE;
818 }
819
820 /* When HAL resets all the context information
821 * in HAL is lost, so we might need to send the
822 * scan offload request again when it comes
823 * out of reset for scan offload to be functional
824 */
825 if (HAL_STOP_TYPE_SYS_RESET == stopType) {
826 b_roam_scan_offload_started = false;
827 }
828
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530829 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830}
831
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530832QDF_STATUS csr_ready(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800833{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530834 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 /* If the gScanAgingTime is set to '0' then scan results aging timeout
836 based on timer feature is not enabled */
837
838 if (0 != pMac->scan.scanResultCfgAgingTime) {
839 csr_scan_start_result_cfg_aging_timer(pMac);
840 }
841 status = csr_apply_channel_and_power_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530842 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843 sms_log(pMac, LOGE,
844 "csr_apply_channel_and_power_list failed during csr_ready with status=%d",
845 status);
846 }
847 return status;
848}
849
850void csr_set_default_dot11_mode(tpAniSirGlobal pMac)
851{
852 uint32_t wniDot11mode = 0;
853 wniDot11mode =
854 csr_translate_to_wni_cfg_dot11_mode(pMac,
855 pMac->roam.configParam.uCfgDot11Mode);
856 cfg_set_int(pMac, WNI_CFG_DOT11_MODE, wniDot11mode);
857}
858
859void csr_set_global_cfgs(tpAniSirGlobal pMac)
860{
861
862 cfg_set_int(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD,
863 csr_get_frag_thresh(pMac));
864 cfg_set_int(pMac, WNI_CFG_RTS_THRESHOLD, csr_get_rts_thresh(pMac));
865 cfg_set_int(pMac, WNI_CFG_11D_ENABLED,
866 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.
867 configParam.Is11dSupportEnabled : pMac->roam.configParam.
868 Is11dSupportEnabled));
869 cfg_set_int(pMac, WNI_CFG_11H_ENABLED,
870 pMac->roam.configParam.Is11hSupportEnabled);
871 /* For now we will just use the 5GHz CB mode ini parameter to decide whether CB supported or not in Probes when there is no session
872 * Once session is established we will use the session related params stored in PE session for CB mode
873 */
874 cfg_set_int(pMac, WNI_CFG_CHANNEL_BONDING_MODE,
875 !!(pMac->roam.configParam.channelBondingMode5GHz));
876 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
877 pMac->roam.configParam.HeartbeatThresh24);
878
879 /* Update the operating mode to configured value during initialization, */
880 /* So that client can advertise full capabilities in Probe request frame. */
881 csr_set_default_dot11_mode(pMac);
882}
883
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530884QDF_STATUS csr_roam_open(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800885{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530886 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 uint32_t i;
888 tCsrRoamSession *pSession;
889 do {
890 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
891 pSession = CSR_GET_SESSION(pMac, i);
892 pSession->roamingTimerInfo.pMac = pMac;
893 pSession->roamingTimerInfo.sessionId =
894 CSR_SESSION_ID_INVALID;
895 }
896 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
897 pMac->roam.WaitForKeyTimerInfo.sessionId =
898 CSR_SESSION_ID_INVALID;
899 status =
Anurag Chouhan210db072016-02-22 18:42:15 +0530900 qdf_mc_timer_init(&pMac->roam.hTimerWaitForKey,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530901 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902 csr_roam_wait_for_key_time_out_handler,
903 &pMac->roam.WaitForKeyTimerInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530904 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 sms_log(pMac, LOGE,
906 FL
907 ("cannot allocate memory for WaitForKey time out timer"));
908 break;
909 }
910 status =
Anurag Chouhan210db072016-02-22 18:42:15 +0530911 qdf_mc_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530912 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913 csr_roam_tl_stats_timer_handler, pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530914 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 sms_log(pMac, LOGE,
916 FL
917 ("cannot allocate memory for summary Statistics timer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530918 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800919 }
920 } while (0);
921 return status;
922}
923
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530924QDF_STATUS csr_roam_close(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800925{
926 uint32_t sessionId;
927 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++) {
928 csr_roam_close_session(pMac, sessionId, true, NULL, NULL);
929 }
Anurag Chouhan210db072016-02-22 18:42:15 +0530930 qdf_mc_timer_stop(&pMac->roam.hTimerWaitForKey);
931 qdf_mc_timer_destroy(&pMac->roam.hTimerWaitForKey);
932 qdf_mc_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
933 qdf_mc_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530934 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935}
936
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530937QDF_STATUS csr_roam_start(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938{
939 (void)pMac;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530940 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941}
942
943void csr_roam_stop(tpAniSirGlobal pMac, uint32_t sessionId)
944{
945 csr_roam_stop_roaming_timer(pMac, sessionId);
946 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers */
947 csr_roam_dereg_statistics_req(pMac);
948}
949
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530950QDF_STATUS csr_roam_get_connect_state(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951 eCsrConnectState *pState)
952{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530953 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800954 if (CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530955 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 *pState = pMac->roam.roamSession[sessionId].connectState;
957 }
958 return status;
959}
960
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530961QDF_STATUS csr_roam_copy_connect_profile(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962 uint32_t sessionId, tCsrRoamConnectedProfile *pProfile)
963{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530964 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 uint32_t size = 0;
966 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
967 tCsrRoamConnectedProfile *connected_prof;
968
969 if (!pSession) {
970 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530971 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800972 }
973 if (!pProfile) {
974 sms_log(pMac, LOGE, FL("profile not found"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530975 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800976 }
977
978 if (pSession->pConnectBssDesc) {
979 size = pSession->pConnectBssDesc->length +
980 sizeof(pSession->pConnectBssDesc->length);
981 if (size) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530982 pProfile->pBssDesc = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983 if (NULL != pProfile->pBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530984 qdf_mem_copy(pProfile->pBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800985 pSession->pConnectBssDesc,
986 size);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530987 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530989 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 }
991 } else {
992 pProfile->pBssDesc = NULL;
993 }
994 connected_prof = &(pSession->connectedProfile);
995 pProfile->AuthType = connected_prof->AuthType;
996 pProfile->EncryptionType = connected_prof->EncryptionType;
997 pProfile->mcEncryptionType = connected_prof->mcEncryptionType;
998 pProfile->BSSType = connected_prof->BSSType;
999 pProfile->operationChannel = connected_prof->operationChannel;
1000 pProfile->CBMode = connected_prof->CBMode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301001 qdf_mem_copy(&pProfile->bssid, &connected_prof->bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301002 sizeof(struct qdf_mac_addr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301003 qdf_mem_copy(&pProfile->SSID, &connected_prof->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004 sizeof(tSirMacSSid));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005 if (connected_prof->MDID.mdiePresent) {
1006 pProfile->MDID.mdiePresent = 1;
1007 pProfile->MDID.mobilityDomain =
1008 connected_prof->MDID.mobilityDomain;
1009 } else {
1010 pProfile->MDID.mdiePresent = 0;
1011 pProfile->MDID.mobilityDomain = 0;
1012 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013#ifdef FEATURE_WLAN_ESE
1014 pProfile->isESEAssoc = connected_prof->isESEAssoc;
1015 if (csr_is_auth_type_ese(connected_prof->AuthType)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301016 qdf_mem_copy(pProfile->eseCckmInfo.krk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001017 connected_prof->eseCckmInfo.krk,
1018 SIR_KRK_KEY_LEN);
1019#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301020 qdf_mem_copy(pProfile->eseCckmInfo.btk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021 connected_prof->eseCckmInfo.btk,
1022 SIR_BTK_KEY_LEN);
1023#endif
1024 pProfile->eseCckmInfo.reassoc_req_num =
1025 connected_prof->eseCckmInfo.reassoc_req_num;
1026 pProfile->eseCckmInfo.krk_plumbed =
1027 connected_prof->eseCckmInfo.krk_plumbed;
1028 }
1029#endif
Krunal Sonib2f13042015-11-02 18:41:08 -08001030#ifdef WLAN_FEATURE_11W
1031 pProfile->MFPEnabled = connected_prof->MFPEnabled;
1032 pProfile->MFPRequired = connected_prof->MFPRequired;
1033 pProfile->MFPCapable = connected_prof->MFPCapable;
1034#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 }
1036 return status;
1037}
1038
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301039QDF_STATUS csr_roam_get_connect_profile(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 tCsrRoamConnectedProfile *pProfile)
1041{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301042 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043
1044 if ((csr_is_conn_state_connected(pMac, sessionId)) ||
1045 (csr_is_conn_state_ibss(pMac, sessionId))) {
1046 if (pProfile) {
1047 status =
1048 csr_roam_copy_connect_profile(pMac, sessionId,
1049 pProfile);
1050 }
1051 }
1052 return status;
1053}
1054
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001055void csr_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056{
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001057 if (profile->pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301058 qdf_mem_free(profile->pBssDesc);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001059 if (profile->pAddIEAssoc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301060 qdf_mem_free(profile->pAddIEAssoc);
1061 qdf_mem_set(profile, sizeof(tCsrRoamConnectedProfile), 0);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001062 profile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063}
1064
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301065static QDF_STATUS csr_roam_free_connected_info(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066 tCsrRoamConnectedInfo *
1067 pConnectedInfo)
1068{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301069 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070 if (pConnectedInfo->pbFrames) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301071 qdf_mem_free(pConnectedInfo->pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072 pConnectedInfo->pbFrames = NULL;
1073 }
1074 pConnectedInfo->nBeaconLength = 0;
1075 pConnectedInfo->nAssocReqLength = 0;
1076 pConnectedInfo->nAssocRspLength = 0;
1077 pConnectedInfo->staId = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 pConnectedInfo->nRICRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079#ifdef FEATURE_WLAN_ESE
1080 pConnectedInfo->nTspecIeLength = 0;
1081#endif
1082 return status;
1083}
1084
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085void csr_release_command_roam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1086{
1087 csr_reinit_roam_cmd(pMac, pCommand);
1088 csr_release_command(pMac, pCommand);
1089}
1090
1091void csr_release_command_scan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1092{
Anurag Chouhan210db072016-02-22 18:42:15 +05301093 qdf_mc_timer_stop(&pCommand->u.scanCmd.csr_scan_timer);
1094 qdf_mc_timer_destroy(&pCommand->u.scanCmd.csr_scan_timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001095 csr_reinit_scan_cmd(pMac, pCommand);
1096 csr_release_command(pMac, pCommand);
1097}
1098
1099void csr_release_command_wm_status_change(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1100{
1101 csr_reinit_wm_status_change_cmd(pMac, pCommand);
1102 csr_release_command(pMac, pCommand);
1103}
1104
1105void csr_reinit_set_key_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1106{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301107 qdf_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108}
1109
1110void csr_release_command_set_key(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1111{
1112 csr_reinit_set_key_cmd(pMac, pCommand);
1113 csr_release_command(pMac, pCommand);
1114}
1115
1116/**
1117 * csr_release_roc_req_cmd() - Release the command
1118 * @mac_ctx: Global MAC Context
1119 *
1120 * Release the remain on channel request command from the queue
1121 *
1122 * Return: None
1123 */
1124void csr_release_roc_req_cmd(tpAniSirGlobal mac_ctx)
1125{
1126 tListElem *entry;
1127 tSmeCmd *cmd = NULL;
1128
1129 entry = csr_ll_peek_head(&mac_ctx->sme.smeCmdActiveList,
1130 LL_ACCESS_LOCK);
1131 if (entry) {
1132 cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
1133 if (eSmeCommandRemainOnChannel == cmd->command) {
1134 remainOnChanCallback callback =
1135 cmd->u.remainChlCmd.callback;
1136 /* process the msg */
1137 if (callback)
1138 callback(mac_ctx,
1139 cmd->u.remainChlCmd.callbackCtx, 0,
1140 cmd->u.remainChlCmd.scan_id);
1141 sms_log(mac_ctx, LOGE,
1142 FL("Remove RoC Request from Active Cmd List"));
1143 /* Put this cmd back on the available command list */
1144 if (csr_ll_remove_entry(&mac_ctx->sme.smeCmdActiveList,
1145 entry, LL_ACCESS_LOCK))
1146 sme_release_command(mac_ctx, cmd);
1147 }
1148 }
1149}
1150
1151void csr_abort_command(tpAniSirGlobal pMac, tSmeCmd *pCommand, bool fStopping)
1152{
1153
1154 if (eSmeCsrCommandMask & pCommand->command) {
1155 switch (pCommand->command) {
1156 case eSmeCommandScan:
1157 /* We need to inform the requester before dropping the scan command */
1158 sms_log(pMac, LOGW,
1159 "%s: Drop scan reason %d callback %p", __func__,
1160 pCommand->u.scanCmd.reason,
1161 pCommand->u.scanCmd.callback);
1162 if (NULL != pCommand->u.scanCmd.callback) {
1163 sms_log(pMac, LOGW, "%s callback scan requester",
1164 __func__);
1165 csr_scan_call_callback(pMac, pCommand,
1166 eCSR_SCAN_ABORT);
1167 }
1168 csr_release_command_scan(pMac, pCommand);
1169 break;
1170 case eSmeCommandRoam:
1171 csr_release_command_roam(pMac, pCommand);
1172 break;
1173
1174 case eSmeCommandWmStatusChange:
1175 csr_release_command_wm_status_change(pMac, pCommand);
1176 break;
1177
1178 case eSmeCommandSetKey:
1179 csr_release_command_set_key(pMac, pCommand);
1180 break;
1181
1182 default:
1183 sms_log(pMac, LOGW, " CSR abort standard command %d",
1184 pCommand->command);
1185 csr_release_command(pMac, pCommand);
1186 break;
1187 }
1188 }
1189}
1190
1191void csr_roam_substate_change(tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate,
1192 uint32_t sessionId)
1193{
1194 sms_log(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1195 mac_trace_getcsr_roam_sub_state(NewSubstate),
1196 mac_trace_getcsr_roam_sub_state(pMac->roam.curSubState[sessionId]));
1197 if (pMac->roam.curSubState[sessionId] == NewSubstate) {
1198 return;
1199 }
1200 pMac->roam.curSubState[sessionId] = NewSubstate;
1201}
1202
1203eCsrRoamState csr_roam_state_change(tpAniSirGlobal pMac,
1204 eCsrRoamState NewRoamState, uint8_t sessionId)
1205{
1206 eCsrRoamState PreviousState;
1207
1208 sms_log(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1209 mac_trace_getcsr_roam_state(NewRoamState),
1210 mac_trace_getcsr_roam_state(pMac->roam.curState[sessionId]));
1211 PreviousState = pMac->roam.curState[sessionId];
1212
1213 if (NewRoamState != pMac->roam.curState[sessionId]) {
1214 /* Whenever we transition OUT of the Roaming state, clear the Roaming substate... */
1215 if (CSR_IS_ROAM_JOINING(pMac, sessionId)) {
1216 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
1217 sessionId);
1218 }
1219
1220 pMac->roam.curState[sessionId] = NewRoamState;
1221 }
1222 return PreviousState;
1223}
1224
1225void csr_assign_rssi_for_category(tpAniSirGlobal pMac, int8_t bestApRssi,
1226 uint8_t catOffset)
1227{
1228 int i;
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08001229 sms_log(pMac, LOG2, FL("best AP RSSI:%d, cat offset:%d"),
1230 bestApRssi, catOffset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231 if (catOffset) {
1232 pMac->roam.configParam.bCatRssiOffset = catOffset;
1233 for (i = 0; i < CSR_NUM_RSSI_CAT; i++) {
1234 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i -
1235 1] =
1236 (int)bestApRssi -
1237 pMac->roam.configParam.nSelect5GHzMargin -
1238 (int)(i * catOffset);
1239 }
1240 }
1241}
1242
1243static void init_config_param(tpAniSirGlobal pMac)
1244{
1245 int i;
1246 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
1247 pMac->roam.configParam.channelBondingMode24GHz =
1248 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1249 pMac->roam.configParam.channelBondingMode5GHz =
1250 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
1251
1252 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_AUTO;
1253 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1254 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
1255 pMac->roam.configParam.FragmentationThreshold =
1256 eCSR_DOT11_FRAG_THRESH_DEFAULT;
1257 pMac->roam.configParam.HeartbeatThresh24 = 40;
1258 pMac->roam.configParam.HeartbeatThresh50 = 40;
1259 pMac->roam.configParam.Is11dSupportEnabled = false;
1260 pMac->roam.configParam.Is11dSupportEnabledOriginal = false;
1261 pMac->roam.configParam.Is11eSupportEnabled = true;
1262 pMac->roam.configParam.Is11hSupportEnabled = true;
1263 pMac->roam.configParam.RTSThreshold = 2346;
1264 pMac->roam.configParam.shortSlotTime = true;
1265 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1266 pMac->roam.configParam.ProprietaryRatesEnabled = true;
1267 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1268 pMac->roam.configParam.scanAgeTimeNCNPS =
1269 CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1270 pMac->roam.configParam.scanAgeTimeNCPS =
1271 CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1272 pMac->roam.configParam.scanAgeTimeCNPS =
1273 CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1274 pMac->roam.configParam.scanAgeTimeCPS =
1275 CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1276 for (i = 0; i < CSR_NUM_RSSI_CAT; i++) {
1277 pMac->roam.configParam.BssPreferValue[i] = i;
1278 }
1279 csr_assign_rssi_for_category(pMac, CSR_BEST_RSSI_VALUE,
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08001280 CSR_DEFAULT_RSSI_DB_GAP);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1282 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = false;
1283 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1284 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1285 pMac->roam.configParam.nPassiveMaxChnTime =
1286 CSR_PASSIVE_MAX_CHANNEL_TIME;
1287 pMac->roam.configParam.nPassiveMinChnTime =
1288 CSR_PASSIVE_MIN_CHANNEL_TIME;
1289#ifdef WLAN_AP_STA_CONCURRENCY
1290 pMac->roam.configParam.nActiveMaxChnTimeConc =
1291 CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1292 pMac->roam.configParam.nActiveMinChnTimeConc =
1293 CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1294 pMac->roam.configParam.nPassiveMaxChnTimeConc =
1295 CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1296 pMac->roam.configParam.nPassiveMinChnTimeConc =
1297 CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1298 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
1299 pMac->roam.configParam.nNumStaChanCombinedConc =
1300 CSR_NUM_STA_CHAN_COMBINED_CONC;
1301 pMac->roam.configParam.nNumP2PChanCombinedConc =
1302 CSR_NUM_P2P_CHAN_COMBINED_CONC;
1303#endif
1304 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1305 pMac->roam.configParam.statsReqPeriodicity =
1306 CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1307 pMac->roam.configParam.statsReqPeriodicityInPS =
1308 CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1311 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold =
1312 120;
1313 pMac->roam.configParam.neighborRoamConfig.nOpportunisticThresholdDiff =
1314 30;
1315 pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff = 5;
1316 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1317 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1318 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod =
1319 200;
1320 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1321 numChannels = 3;
1322 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1323 channelList[0] = 1;
1324 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1325 channelList[1] = 6;
1326 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1327 channelList[2] = 11;
1328 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; /* 20 seconds */
1329 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
1330 pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt = 10;
1331 pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt = 10;
1332 pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight = 14;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 pMac->roam.configParam.nVhtChannelWidth =
1334 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335
1336 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1337 pMac->roam.configParam.fScanTwice = false;
1338
1339 /* Remove this code once SLM_Sessionization is supported */
1340 /* BMPS_WORKAROUND_NOT_NEEDED */
1341 pMac->roam.configParam.doBMPSWorkaround = 0;
1342
1343 pMac->roam.configParam.nInitialDwellTime = 0;
1344 pMac->roam.configParam.initial_scan_no_dfs_chnl = 0;
1345}
1346
1347eCsrBand csr_get_current_band(tHalHandle hHal)
1348{
1349 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1350 return pMac->roam.configParam.bandCapability;
1351}
1352
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001353#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354/*
1355 This function flushes the roam scan cache
1356 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301357QDF_STATUS csr_flush_cfg_bg_scan_roam_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001358 uint8_t sessionId)
1359{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301360 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001361 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
1362 &pMac->roam.neighborRoamInfo[sessionId];
1363
1364 /* Free up the memory first (if required) */
1365 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301366 qdf_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367 ChannelList);
1368 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
1369 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1370 }
1371 return status;
1372}
1373
1374/*
1375 This function flushes the roam scan cache and creates fresh cache
1376 based on the input channel list
1377 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301378QDF_STATUS csr_create_bg_scan_roam_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379 uint8_t sessionId,
1380 const uint8_t *pChannelList,
1381 const uint8_t numChannels)
1382{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301383 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
1385 &pMac->roam.neighborRoamInfo[sessionId];
1386
1387 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1388
1389 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301390 qdf_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001391 numOfChannels);
1392
1393 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
1394 sms_log(pMac, LOGE,
1395 FL("Memory Allocation for CFG Channel List failed"));
1396 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301397 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 }
1399
1400 /* Update the roam global structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301401 qdf_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 pChannelList,
1403 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1404 return status;
1405}
1406
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001407#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001409#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001410/**
1411 * csr_create_roam_scan_channel_list() - create roam scan channel list
1412 * @pMac: Global mac pointer
1413 * @sessionId: session id
1414 * @pChannelList: pointer to channel list
1415 * @numChannels: number of channels
1416 * @eBand: band enumeration
1417 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001418 * This function modifies the roam scan channel list as per AP neighbor
1419 * report; AP neighbor report may be empty or may include only other AP
1420 * channels; in any case, we merge the channel list with the learned occupied
1421 * channels list.
1422 * if the band is 2.4G, then make sure channel list contains only 2.4G
1423 * valid channels if the band is 5G, then make sure channel list contains
1424 * only 5G valid channels
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001425 *
1426 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301428QDF_STATUS csr_create_roam_scan_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429 uint8_t sessionId,
1430 uint8_t *pChannelList,
1431 uint8_t numChannels,
1432 const eCsrBand eBand)
1433{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301434 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001435 tpCsrNeighborRoamControlInfo pNeighborRoamInfo
1436 = &pMac->roam.neighborRoamInfo[sessionId];
1437 uint8_t outNumChannels = 0;
1438 uint8_t inNumChannels = numChannels;
1439 uint8_t *inPtr = pChannelList;
1440 uint8_t i = 0;
1441 uint8_t ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
1442 uint8_t tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
1443 uint8_t mergedOutputNumOfChannels = 0;
1444 tpCsrChannelInfo currChannelListInfo
1445 = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1446 /*
1447 * Create a Union of occupied channel list learnt by the DUT along
1448 * with the Neighbor report Channels. This increases the chances of
1449 * the DUT to get a candidate AP while roaming even if the Neighbor
1450 * Report is not able to provide sufficient information.
1451 */
1452 if (pMac->scan.occupiedChannels[sessionId].numChannels) {
1453 csr_neighbor_roam_merge_channel_lists(pMac,
1454 &pMac->scan.
1455 occupiedChannels[sessionId].
1456 channelList[0],
1457 pMac->scan.
1458 occupiedChannels[sessionId].
1459 numChannels, inPtr,
1460 inNumChannels,
1461 &mergedOutputNumOfChannels);
1462 inNumChannels = mergedOutputNumOfChannels;
1463 }
1464 if (eCSR_BAND_24 == eBand) {
1465 for (i = 0; i < inNumChannels; i++) {
1466 if (CDS_IS_CHANNEL_24GHZ(inPtr[i])
1467 && csr_roam_is_channel_valid(pMac, inPtr[i])) {
1468 ChannelList[outNumChannels++] = inPtr[i];
1469 }
1470 }
1471 } else if (eCSR_BAND_5G == eBand) {
1472 for (i = 0; i < inNumChannels; i++) {
1473 /* Add 5G Non-DFS channel */
1474 if (CDS_IS_CHANNEL_5GHZ(inPtr[i]) &&
1475 csr_roam_is_channel_valid(pMac, inPtr[i]) &&
1476 !CDS_IS_DFS_CH(inPtr[i])) {
1477 ChannelList[outNumChannels++] = inPtr[i];
1478 }
1479 }
1480 } else if (eCSR_BAND_ALL == eBand) {
1481 for (i = 0; i < inNumChannels; i++) {
1482 if (csr_roam_is_channel_valid(pMac, inPtr[i]) &&
1483 !CDS_IS_DFS_CH(inPtr[i])) {
1484 ChannelList[outNumChannels++] = inPtr[i];
1485 }
1486 }
1487 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301488 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489 "Invalid band, No operation carried out (Band %d)",
1490 eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301491 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492 }
1493 /*
1494 * if roaming within band is enabled, then select only the
1495 * in band channels .
1496 * This is required only if the band capability is set to ALL,
1497 * E.g., if band capability is only 2.4G then all the channels in the
1498 * list are already filtered for 2.4G channels, hence ignore this check
1499 */
1500 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac)) {
1501 csr_neighbor_roam_channels_filter_by_current_band(pMac,
1502 sessionId,
1503 ChannelList,
1504 outNumChannels,
1505 tmpChannelList,
1506 &outNumChannels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301507 qdf_mem_copy(ChannelList, tmpChannelList, outNumChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508 }
1509 /* Prepare final roam scan channel list */
1510 if (outNumChannels) {
1511 /* Clear the channel list first */
1512 if (NULL != currChannelListInfo->ChannelList) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301513 qdf_mem_free(currChannelListInfo->ChannelList);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 currChannelListInfo->ChannelList = NULL;
1515 currChannelListInfo->numOfChannels = 0;
1516 }
1517 currChannelListInfo->ChannelList
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301518 = qdf_mem_malloc(outNumChannels * sizeof(uint8_t));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 if (NULL == currChannelListInfo->ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301520 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 "Failed to allocate memory for roam scan channel list");
1522 currChannelListInfo->numOfChannels = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301523 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301525 qdf_mem_copy(currChannelListInfo->ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 ChannelList, outNumChannels);
1527 }
1528 return status;
1529}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001530
1531/**
1532 * csr_roam_is_ese_assoc() - is this ese association
1533 * @mac_ctx: Global MAC context
1534 * @session_id: session identifier
1535 *
1536 * Returns whether the current association is a ESE assoc or not.
1537 *
1538 * Return: true if ese association; false otherwise
1539 */
1540bool csr_roam_is_ese_assoc(tpAniSirGlobal mac_ctx, uint8_t session_id)
1541{
1542#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srinivas Girigowda18dcf3d2015-12-16 18:11:48 -08001543 return mac_ctx->roam.neighborRoamInfo[session_id].isESEAssoc;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001544#else
1545 return false;
1546#endif
1547}
1548
1549/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001550 * csr_roam_is_roam_offload_scan_enabled() - is roam offload enabled
1551 * @mac_ctx: Global MAC context
1552 *
1553 * Returns whether "FW based BG scan" is currently enabled or not
1554 *
1555 * Return: true if roam offload scan enabled; false otherwise
1556 */
1557bool csr_roam_is_roam_offload_scan_enabled(tpAniSirGlobal pMac)
1558{
1559 return pMac->roam.configParam.isRoamOffloadScanEnabled;
1560}
1561
1562/**
1563 * csr_roam_is_ese_ini_feature_enabled() - is ese feature enabled
1564 * @mac_ctx: Global MAC context
1565 *
1566 * Return: true if ese feature is enabled; false otherwise
1567 */
1568bool csr_roam_is_ese_ini_feature_enabled(tpAniSirGlobal pMac)
1569{
1570 return pMac->roam.configParam.isEseIniFeatureEnabled;
1571}
1572
1573/**
1574 * csr_tsm_stats_rsp_processor() - tsm stats response processor
1575 * @pMac: Global MAC context
1576 * @pMsg: Message pointer
1577 *
1578 * Return: None
1579 */
1580void csr_tsm_stats_rsp_processor(tpAniSirGlobal pMac, void *pMsg)
1581{
1582 tAniGetTsmStatsRsp *pTsmStatsRsp = (tAniGetTsmStatsRsp *) pMsg;
1583
1584 if (NULL != pTsmStatsRsp) {
1585 /*
1586 * Get roam Rssi request is backed up and passed back
1587 * to the response, Extract the request message
1588 * to fetch callback.
1589 */
1590 tpAniGetTsmStatsReq reqBkp
1591 = (tAniGetTsmStatsReq *) pTsmStatsRsp->tsmStatsReq;
1592
1593 if (NULL != reqBkp) {
1594 if (NULL != reqBkp->tsmStatsCallback) {
1595 ((tCsrTsmStatsCallback)
1596 (reqBkp->tsmStatsCallback))(pTsmStatsRsp->
1597 tsmMetrics,
1598 pTsmStatsRsp->
1599 staId,
1600 reqBkp->
1601 pDevContext);
1602 reqBkp->tsmStatsCallback = NULL;
1603 }
1604 qdf_mem_free(reqBkp);
1605 pTsmStatsRsp->tsmStatsReq = NULL;
1606 } else {
1607 sms_log(pMac, LOGE, FL("reqBkp is NULL"));
1608 if (NULL != reqBkp) {
1609 qdf_mem_free(reqBkp);
1610 pTsmStatsRsp->tsmStatsReq = NULL;
1611 }
1612 }
1613 } else {
1614 sms_log(pMac, LOGE, FL("pTsmStatsRsp is NULL"));
1615 }
1616 return;
1617}
1618
1619/**
1620 * csr_send_ese_adjacent_ap_rep_ind() - ese send adjacent ap report
1621 * @pMac: Global MAC context
1622 * @pSession: Session pointer
1623 *
1624 * Return: None
1625 */
1626void csr_send_ese_adjacent_ap_rep_ind(tpAniSirGlobal pMac,
1627 tCsrRoamSession *pSession)
1628{
1629 uint32_t roamTS2 = 0;
1630 tCsrRoamInfo roamInfo;
1631 tpPESession pSessionEntry = NULL;
1632 uint8_t sessionId = CSR_SESSION_ID_INVALID;
1633
1634 if (NULL == pSession) {
1635 sms_log(pMac, LOGE, FL("pSession is NULL"));
1636 return;
1637 }
1638
1639 roamTS2 = qdf_mc_timer_get_system_time();
1640 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
1641 sms_log(pMac, LOG1, "Bssid(" MAC_ADDRESS_STR ") Roaming Delay(%u ms)",
1642 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid.bytes),
1643 roamInfo.tsmRoamDelay);
1644
1645 pSessionEntry = pe_find_session_by_bssid(pMac,
1646 pSession->connectedProfile.bssid.bytes,
1647 &sessionId);
1648 if (NULL == pSessionEntry) {
1649 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
1650 return;
1651 }
1652
1653 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly
1654 = roamInfo.tsmRoamDelay;
1655
1656 csr_roam_call_callback(pMac, pSession->sessionId, &roamInfo,
1657 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
1658}
1659
1660/**
1661 * csr_get_tsm_stats() - get tsm stats
1662 * @pMac: Global MAC context
1663 * @callback: TSM stats callback
1664 * @staId: Station id
1665 * @bssId: bssid
1666 * @pContext: pointer to context
1667 * @p_cds_context: cds context
1668 * @tid: traffic id
1669 *
1670 * Return: QDF_STATUS enumeration
1671 */
1672QDF_STATUS csr_get_tsm_stats(tpAniSirGlobal pMac,
1673 tCsrTsmStatsCallback callback,
1674 uint8_t staId,
1675 struct qdf_mac_addr bssId,
1676 void *pContext, void *p_cds_context, uint8_t tid)
1677{
1678 QDF_STATUS status = QDF_STATUS_SUCCESS;
1679 tAniGetTsmStatsReq *pMsg = NULL;
1680 pMsg = qdf_mem_malloc(sizeof(tAniGetTsmStatsReq));
1681 if (!pMsg) {
1682 sms_log(pMac, LOGE,
1683 "csr_get_tsm_stats: failed to allocate mem for req");
1684 return QDF_STATUS_E_NOMEM;
1685 }
1686 /* need to initiate a stats request to PE */
1687 pMsg->msgType = eWNI_SME_GET_TSM_STATS_REQ;
1688 pMsg->msgLen = (uint16_t) sizeof(tAniGetTsmStatsReq);
1689 pMsg->staId = staId;
1690 pMsg->tid = tid;
1691 qdf_copy_macaddr(&pMsg->bssId, &bssId);
1692 pMsg->tsmStatsCallback = callback;
1693 pMsg->pDevContext = pContext;
1694 pMsg->p_cds_context = p_cds_context;
1695 status = cds_send_mb_message_to_mac(pMsg);
1696 if (!QDF_IS_STATUS_SUCCESS(status)) {
1697 sms_log(pMac, LOG1,
1698 " csr_get_tsm_stats: failed to send down the rssi req");
1699 /* pMsg is freed by cds_send_mb_message_to_mac */
1700 status = QDF_STATUS_E_FAILURE;
1701 }
1702 return status;
1703}
1704
1705/**
1706 * csr_fetch_ch_lst_from_received_list() - fetch channel list from received list
1707 * and update req msg
1708 * paramters
1709 * @mac_ctx: global mac ctx
1710 * @roam_info: roam info struct
1711 * @curr_ch_lst_info: current channel list info
1712 * @req_buf: out param, roam offload scan request packet
1713 *
1714 * Return: void
1715 */
1716static void
1717csr_fetch_ch_lst_from_received_list(tpAniSirGlobal mac_ctx,
1718 tpCsrNeighborRoamControlInfo roam_info,
1719 tpCsrChannelInfo curr_ch_lst_info,
1720 tSirRoamOffloadScanReq *req_buf)
1721{
1722 uint8_t i = 0;
1723 uint8_t num_channels = 0;
1724 uint8_t *ch_lst = NULL;
1725
1726 if (curr_ch_lst_info->numOfChannels == 0)
1727 return;
1728
1729 ch_lst = curr_ch_lst_info->ChannelList;
1730 for (i = 0; i < curr_ch_lst_info->numOfChannels; i++) {
1731 if (((mac_ctx->roam.configParam.allowDFSChannelRoam
1732 != CSR_ROAMING_DFS_CHANNEL_DISABLED) ||
1733 (!CDS_IS_DFS_CH(*ch_lst))) && *ch_lst) {
1734 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
1735 *ch_lst;
1736 }
1737 ch_lst++;
1738 }
1739 req_buf->ConnectedNetwork.ChannelCount = num_channels;
1740 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
1741}
1742
1743/**
1744 * csr_set_cckm_ie() - set CCKM IE
1745 * @pMac: Global MAC context
1746 * @sessionId: session identifier
1747 * @pCckmIe: Pointer to input CCKM IE data
1748 * @ccKmIeLen: Length of @pCckmIe
1749 *
1750 * This function stores the CCKM IE passed by the supplicant
1751 * in a place holder data structure and this IE will be packed inside
1752 * reassociation request
1753 *
1754 * Return: QDF_STATUS enumeration
1755 */
1756QDF_STATUS csr_set_cckm_ie(tpAniSirGlobal pMac, const uint8_t sessionId,
1757 const uint8_t *pCckmIe, const uint8_t ccKmIeLen)
1758{
1759 QDF_STATUS status = QDF_STATUS_SUCCESS;
1760 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
1761 if (!pSession) {
1762 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
1763 return QDF_STATUS_E_FAILURE;
1764 }
1765 qdf_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
1766 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
1767 return status;
1768}
1769
1770/**
1771 * csr_roam_read_tsf() - read TSF
1772 * @pMac: Global MAC context
1773 * @sessionId: session identifier
1774 * @pTimestamp: output TSF timestamp
1775 *
1776 * This function reads the TSF; and also add the time elapsed since
1777 * last beacon or probe response reception from the hand off AP to arrive at
1778 * the latest TSF value.
1779 *
1780 * Return: QDF_STATUS enumeration
1781 */
1782QDF_STATUS csr_roam_read_tsf(tpAniSirGlobal pMac, uint8_t *pTimestamp,
1783 uint8_t sessionId)
1784{
1785 QDF_STATUS status = QDF_STATUS_SUCCESS;
1786 tCsrNeighborRoamBSSInfo handoffNode;
1787 uint32_t timer_diff = 0;
1788 uint32_t timeStamp[2];
1789 tpSirBssDescription pBssDescription = NULL;
1790 csr_neighbor_roam_get_handoff_ap_info(pMac, &handoffNode, sessionId);
1791 pBssDescription = handoffNode.pBssDescription;
1792 /* Get the time diff in milli seconds */
1793 timer_diff = qdf_mc_timer_get_system_time() -
1794 pBssDescription->scanSysTimeMsec;
1795 /* Convert msec to micro sec timer */
1796 timer_diff = (uint32_t) (timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
1797 timeStamp[0] = pBssDescription->timeStamp[0];
1798 timeStamp[1] = pBssDescription->timeStamp[1];
1799 update_cckmtsf(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
1800 qdf_mem_copy(pTimestamp, (void *)&timeStamp[0], sizeof(uint32_t) * 2);
1801 return status;
1802}
1803
1804#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301806QDF_STATUS csr_set_band(tHalHandle hHal, uint8_t sessionId, eCsrBand eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807{
1808 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301809 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 if (CSR_IS_PHY_MODE_A_ONLY(pMac) && (eBand == eCSR_BAND_24)) {
1811 /* DOT11 mode configured to 11a only and received
1812 request to change the band to 2.4 GHz */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301813 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 "failed to set band cfg80211 = %u, band = %u",
1815 pMac->roam.configParam.uCfgDot11Mode, eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301816 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 }
1818 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1819 CSR_IS_PHY_MODE_G_ONLY(pMac)) && (eBand == eCSR_BAND_5G)) {
1820 /* DOT11 mode configured to 11b/11g only and received
1821 request to change the band to 5 GHz */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301822 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823 "failed to set band dot11mode = %u, band = %u",
1824 pMac->roam.configParam.uCfgDot11Mode, eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301825 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301827 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
1829 pMac->roam.configParam.eBand = eBand;
1830 pMac->roam.configParam.bandCapability = eBand;
1831
1832 status = csr_get_channel_and_power_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301833 if (QDF_STATUS_SUCCESS == status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 csr_apply_channel_and_power_list(pMac);
1835 return status;
1836}
1837
1838/* The funcns csr_convert_cb_ini_value_to_phy_cb_state and csr_convert_phy_cb_state_to_ini_value have been
1839 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1840 * Ideally we should have kept the ini value and enum value same and representing the same
1841 * cb values as in 11n standard i.e.
1842 * Set to 1 (SCA) if the secondary channel is above the primary channel
1843 * Set to 3 (SCB) if the secondary channel is below the primary channel
1844 * Set to 0 (SCN) if no secondary channel is present
1845 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1846 * 0 - secondary none
1847 * 1 - secondary LOW
1848 * 2 - secondary HIGH
1849 * and convert to enum value used within the driver in csr_change_default_config_param using this funcn
1850 * The enum values are as follows:
1851 * PHY_SINGLE_CHANNEL_CENTERED = 0
1852 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1853 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1854 */
1855ePhyChanBondState csr_convert_cb_ini_value_to_phy_cb_state(uint32_t cbIniValue)
1856{
1857
1858 ePhyChanBondState phyCbState;
1859 switch (cbIniValue) {
1860 /* secondary none */
1861 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
1862 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1863 break;
1864 /* secondary LOW */
1865 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
1866 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1867 break;
1868 /* secondary HIGH */
1869 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
1870 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1871 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1873 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1874 break;
1875 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1876 phyCbState =
1877 PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1878 break;
1879 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1880 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1881 break;
1882 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1883 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1884 break;
1885 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1886 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1887 break;
1888 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1889 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1890 break;
1891 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1892 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1893 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894 default:
1895 /* If an invalid value is passed, disable CHANNEL BONDING */
1896 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1897 break;
1898 }
1899 return phyCbState;
1900}
1901
1902uint32_t csr_convert_phy_cb_state_to_ini_value(ePhyChanBondState phyCbState)
1903{
1904
1905 uint32_t cbIniValue;
1906 switch (phyCbState) {
1907 /* secondary none */
1908 case PHY_SINGLE_CHANNEL_CENTERED:
1909 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
1910 break;
1911 /* secondary LOW */
1912 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1913 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
1914 break;
1915 /* secondary HIGH */
1916 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1917 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
1918 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001919 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1920 cbIniValue =
1921 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1922 break;
1923 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1924 cbIniValue =
1925 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1926 break;
1927 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1928 cbIniValue =
1929 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1930 break;
1931 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1932 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1933 break;
1934 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1935 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1936 break;
1937 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1938 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1939 break;
1940 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1941 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1942 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001943 default:
1944 /* return some invalid value */
1945 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
1946 break;
1947 }
1948 return cbIniValue;
1949}
1950
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301951QDF_STATUS csr_change_default_config_param(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952 tCsrConfigParam *pParam)
1953{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301954 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955
1956 if (pParam) {
1957 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1958 cfg_set_int(pMac, WNI_CFG_WME_ENABLED,
1959 (pParam->WMMSupportMode == eCsrRoamWmmNoQos) ? 0 : 1);
1960 pMac->roam.configParam.Is11eSupportEnabled =
1961 pParam->Is11eSupportEnabled;
1962 pMac->roam.configParam.FragmentationThreshold =
1963 pParam->FragmentationThreshold;
1964 pMac->roam.configParam.Is11dSupportEnabled =
1965 pParam->Is11dSupportEnabled;
1966 pMac->roam.configParam.Is11dSupportEnabledOriginal =
1967 pParam->Is11dSupportEnabled;
1968 pMac->roam.configParam.Is11hSupportEnabled =
1969 pParam->Is11hSupportEnabled;
1970
1971 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
1972 pMac->roam.configParam.mcc_rts_cts_prot_enable =
1973 pParam->mcc_rts_cts_prot_enable;
1974 pMac->roam.configParam.mcc_bcast_prob_resp_enable =
1975 pParam->mcc_bcast_prob_resp_enable;
1976 pMac->roam.configParam.fAllowMCCGODiffBI =
1977 pParam->fAllowMCCGODiffBI;
1978
1979 /* channelBondingMode5GHz plays a dual role right now
1980 * INFRA STA will use this non zero value as CB enabled and SOFTAP will use this non-zero value to determine the secondary channel offset
1981 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1982 */
1983 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI) {
1984 sms_log(pMac, LOGW,
1985 "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED",
1986 pParam->channelBondingMode24GHz);
1987 }
1988 pMac->roam.configParam.channelBondingMode24GHz =
1989 csr_convert_cb_ini_value_to_phy_cb_state(pParam->
1990 channelBondingMode24GHz);
1991 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI) {
1992 sms_log(pMac, LOGW,
1993 "Invalid CB value from ini in 5GHz band %d, CB DISABLED",
1994 pParam->channelBondingMode5GHz);
1995 }
1996 pMac->roam.configParam.channelBondingMode5GHz =
1997 csr_convert_cb_ini_value_to_phy_cb_state(pParam->
1998 channelBondingMode5GHz);
1999 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
2000 pMac->roam.configParam.phyMode = pParam->phyMode;
2001 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
2002 pMac->roam.configParam.HeartbeatThresh24 =
2003 pParam->HeartbeatThresh24;
2004 pMac->roam.configParam.HeartbeatThresh50 =
2005 pParam->HeartbeatThresh50;
2006 pMac->roam.configParam.ProprietaryRatesEnabled =
2007 pParam->ProprietaryRatesEnabled;
2008 pMac->roam.configParam.TxRate = pParam->TxRate;
2009 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
2010 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
2011 pMac->roam.configParam.bandCapability = pParam->bandCapability;
2012 pMac->roam.configParam.cbChoice = pParam->cbChoice;
2013 pMac->roam.configParam.neighborRoamConfig.
2014 delay_before_vdev_stop =
2015 pParam->neighborRoamConfig.delay_before_vdev_stop;
2016
2017 /* if HDD passed down non zero values then only update, */
2018 /* otherwise keep using the defaults */
2019 if (pParam->initial_scan_no_dfs_chnl) {
2020 pMac->roam.configParam.initial_scan_no_dfs_chnl =
2021 pParam->initial_scan_no_dfs_chnl;
2022 }
2023 if (pParam->nInitialDwellTime) {
2024 pMac->roam.configParam.nInitialDwellTime =
2025 pParam->nInitialDwellTime;
2026 }
2027 if (pParam->nActiveMaxChnTime) {
2028 pMac->roam.configParam.nActiveMaxChnTime =
2029 pParam->nActiveMaxChnTime;
2030 cfg_set_int(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
2031 pParam->nActiveMaxChnTime);
2032 }
2033 if (pParam->nActiveMinChnTime) {
2034 pMac->roam.configParam.nActiveMinChnTime =
2035 pParam->nActiveMinChnTime;
2036 cfg_set_int(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
2037 pParam->nActiveMinChnTime);
2038 }
2039 if (pParam->nPassiveMaxChnTime) {
2040 pMac->roam.configParam.nPassiveMaxChnTime =
2041 pParam->nPassiveMaxChnTime;
2042 cfg_set_int(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
2043 pParam->nPassiveMaxChnTime);
2044 }
2045 if (pParam->nPassiveMinChnTime) {
2046 pMac->roam.configParam.nPassiveMinChnTime =
2047 pParam->nPassiveMinChnTime;
2048 cfg_set_int(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
2049 pParam->nPassiveMinChnTime);
2050 }
2051#ifdef WLAN_AP_STA_CONCURRENCY
2052 if (pParam->nActiveMaxChnTimeConc) {
2053 pMac->roam.configParam.nActiveMaxChnTimeConc =
2054 pParam->nActiveMaxChnTimeConc;
2055 }
2056 if (pParam->nActiveMinChnTimeConc) {
2057 pMac->roam.configParam.nActiveMinChnTimeConc =
2058 pParam->nActiveMinChnTimeConc;
2059 }
2060 if (pParam->nPassiveMaxChnTimeConc) {
2061 pMac->roam.configParam.nPassiveMaxChnTimeConc =
2062 pParam->nPassiveMaxChnTimeConc;
2063 }
2064 if (pParam->nPassiveMinChnTimeConc) {
2065 pMac->roam.configParam.nPassiveMinChnTimeConc =
2066 pParam->nPassiveMinChnTimeConc;
2067 }
2068 if (pParam->nRestTimeConc) {
2069 pMac->roam.configParam.nRestTimeConc =
2070 pParam->nRestTimeConc;
2071 }
2072 if (pParam->nNumStaChanCombinedConc) {
2073 pMac->roam.configParam.nNumStaChanCombinedConc =
2074 pParam->nNumStaChanCombinedConc;
2075 }
2076 if (pParam->nNumP2PChanCombinedConc) {
2077 pMac->roam.configParam.nNumP2PChanCombinedConc =
2078 pParam->nNumP2PChanCombinedConc;
2079 }
2080#endif
2081 pMac->roam.configParam.eBand = pParam->eBand;
2082 pMac->roam.configParam.uCfgDot11Mode =
2083 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
2084 pMac->roam.configParam.
2085 phyMode,
2086 pMac->roam.configParam.
2087 ProprietaryRatesEnabled);
2088 /* if HDD passed down non zero values for age params, then only update, */
2089 /* otherwise keep using the defaults */
2090 if (pParam->nScanResultAgeCount) {
2091 pMac->roam.configParam.agingCount =
2092 pParam->nScanResultAgeCount;
2093 }
2094 if (pParam->scanAgeTimeNCNPS) {
2095 pMac->roam.configParam.scanAgeTimeNCNPS =
2096 pParam->scanAgeTimeNCNPS;
2097 }
2098 if (pParam->scanAgeTimeNCPS) {
2099 pMac->roam.configParam.scanAgeTimeNCPS =
2100 pParam->scanAgeTimeNCPS;
2101 }
2102 if (pParam->scanAgeTimeCNPS) {
2103 pMac->roam.configParam.scanAgeTimeCNPS =
2104 pParam->scanAgeTimeCNPS;
2105 }
2106 if (pParam->scanAgeTimeCPS) {
2107 pMac->roam.configParam.scanAgeTimeCPS =
2108 pParam->scanAgeTimeCPS;
2109 }
Sandeep Puligillae0875662016-02-12 16:09:21 -08002110 if (pParam->obss_width_interval) {
2111 pMac->roam.configParam.obss_width_interval =
2112 pParam->obss_width_interval;
2113 cfg_set_int(pMac,
2114 WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
2115 pParam->obss_width_interval);
2116 }
2117 if (pParam->obss_active_dwelltime) {
2118 pMac->roam.configParam.obss_active_dwelltime =
2119 pParam->obss_active_dwelltime;
2120 cfg_set_int(pMac,
2121 WNI_CFG_OBSS_HT40_SCAN_ACTIVE_DWELL_TIME,
2122 pParam->obss_active_dwelltime);
2123 }
2124 if (pParam->obss_passive_dwelltime) {
2125 pMac->roam.configParam.obss_passive_dwelltime =
2126 pParam->obss_passive_dwelltime;
2127 cfg_set_int(pMac,
2128 WNI_CFG_OBSS_HT40_SCAN_PASSIVE_DWELL_TIME,
2129 pParam->obss_passive_dwelltime);
2130 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08002132 pMac->first_scan_bucket_threshold =
2133 pParam->first_scan_bucket_threshold;
2134 csr_assign_rssi_for_category(pMac,
2135 pMac->first_scan_bucket_threshold,
2136 pParam->bCatRssiOffset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
2138 pMac->roam.configParam.fSupplicantCountryCodeHasPriority =
2139 pParam->fSupplicantCountryCodeHasPriority;
2140 pMac->roam.configParam.vccRssiThreshold =
2141 pParam->vccRssiThreshold;
2142 pMac->roam.configParam.vccUlMacLossThreshold =
2143 pParam->vccUlMacLossThreshold;
2144 pMac->roam.configParam.statsReqPeriodicity =
2145 pParam->statsReqPeriodicity;
2146 pMac->roam.configParam.statsReqPeriodicityInPS =
2147 pParam->statsReqPeriodicityInPS;
2148 /* Assign this before calling csr_init11d_info */
2149 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
2150 if (csr_is11d_supported(pMac)) {
2151 status = csr_init11d_info(pMac, &pParam->Csr11dinfo);
2152 } else {
2153 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
2154 }
2155
2156 /* Initialize the power + channel information if 11h is enabled.
2157 If 11d is enabled this information has already been initialized */
2158 if (csr_is11h_supported(pMac) && !csr_is11d_supported(pMac)) {
2159 csr_init_channel_power_list(pMac, &pParam->Csr11dinfo);
2160 }
2161
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302162 qdf_mem_copy(&pMac->roam.configParam.csr11rConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002163 &pParam->csr11rConfig,
2164 sizeof(tCsr11rConfigParams));
2165 sms_log(pMac, LOG1, "IsFTResourceReqSupp = %d",
2166 pMac->roam.configParam.csr11rConfig.
2167 IsFTResourceReqSupported);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168 pMac->roam.configParam.isFastTransitionEnabled =
2169 pParam->isFastTransitionEnabled;
2170 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
2171 pMac->roam.configParam.nRoamPrefer5GHz =
2172 pParam->nRoamPrefer5GHz;
2173 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
2174 pMac->roam.configParam.isWESModeEnabled =
2175 pParam->isWESModeEnabled;
2176 pMac->roam.configParam.nProbes = pParam->nProbes;
2177 pMac->roam.configParam.nRoamScanHomeAwayTime =
2178 pParam->nRoamScanHomeAwayTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179 pMac->roam.configParam.isRoamOffloadScanEnabled =
2180 pParam->isRoamOffloadScanEnabled;
2181 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
2182 pParam->bFastRoamInConIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
2184 pParam->isFastRoamIniFeatureEnabled;
2185 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186
2187#ifdef FEATURE_WLAN_ESE
2188 pMac->roam.configParam.isEseIniFeatureEnabled =
2189 pParam->isEseIniFeatureEnabled;
2190#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302191 qdf_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002192 &pParam->neighborRoamConfig,
2193 sizeof(tCsrNeighborRoamConfigParams));
2194 sms_log(pMac, LOG1, "nNeighborScanTimerPerioid = %d",
2195 pMac->roam.configParam.neighborRoamConfig.
2196 nNeighborScanTimerPeriod);
2197 sms_log(pMac, LOG1, "nNeighborLookupRssiThreshold = %d",
2198 pMac->roam.configParam.neighborRoamConfig.
2199 nNeighborLookupRssiThreshold);
2200 sms_log(pMac, LOG1, "nOpportunisticThresholdDiff = %d",
2201 pMac->roam.configParam.neighborRoamConfig.
2202 nOpportunisticThresholdDiff);
2203 sms_log(pMac, LOG1, "nRoamRescanRssiDiff = %d",
2204 pMac->roam.configParam.neighborRoamConfig.
2205 nRoamRescanRssiDiff);
2206 sms_log(pMac, LOG1, "nNeighborScanMinChanTime = %d",
2207 pMac->roam.configParam.neighborRoamConfig.
2208 nNeighborScanMinChanTime);
2209 sms_log(pMac, LOG1, "nNeighborScanMaxChanTime = %d",
2210 pMac->roam.configParam.neighborRoamConfig.
2211 nNeighborScanMaxChanTime);
2212 sms_log(pMac, LOG1, "nMaxNeighborRetries = %d",
2213 pMac->roam.configParam.neighborRoamConfig.
2214 nMaxNeighborRetries);
2215 sms_log(pMac, LOG1, "nNeighborResultsRefreshPeriod = %d",
2216 pMac->roam.configParam.neighborRoamConfig.
2217 nNeighborResultsRefreshPeriod);
2218 sms_log(pMac, LOG1, "nEmptyScanRefreshPeriod = %d",
2219 pMac->roam.configParam.neighborRoamConfig.
2220 nEmptyScanRefreshPeriod);
2221 {
2222 int i;
2223 sms_log(pMac, LOG1,
2224 FL("Num of Channels in CFG Channel List: %d"),
2225 pMac->roam.configParam.neighborRoamConfig.
2226 neighborScanChanList.numChannels);
2227 for (i = 0;
2228 i <
2229 pMac->roam.configParam.neighborRoamConfig.
2230 neighborScanChanList.numChannels; i++) {
2231 sms_log(pMac, LOG1, "%d ",
2232 pMac->roam.configParam.
2233 neighborRoamConfig.neighborScanChanList.
2234 channelList[i]);
2235 }
2236 }
2237 sms_log(pMac, LOG1, "nRoamBmissFirstBcnt = %d",
2238 pMac->roam.configParam.neighborRoamConfig.
2239 nRoamBmissFirstBcnt);
2240 sms_log(pMac, LOG1, "nRoamBmissFinalBcnt = %d",
2241 pMac->roam.configParam.neighborRoamConfig.
2242 nRoamBmissFinalBcnt);
2243 sms_log(pMac, LOG1, "nRoamBeaconRssiWeight = %d",
2244 pMac->roam.configParam.neighborRoamConfig.
2245 nRoamBeaconRssiWeight);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002246 pMac->roam.configParam.addTSWhenACMIsOff =
2247 pParam->addTSWhenACMIsOff;
2248 pMac->scan.fValidateList = pParam->fValidateList;
2249 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
2250 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
2251 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
2252 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
2253 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
2254 pMac->scan.max_scan_count = pParam->max_scan_count;
2255 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
2256 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
2257 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
2258 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
2259 * single session
2260 */
2261 /* Remove this code once SLM_Sessionization is supported */
2262 /* BMPS_WORKAROUND_NOT_NEEDED */
2263 pMac->roam.configParam.doBMPSWorkaround = 0;
2264
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265 pMac->roam.configParam.nVhtChannelWidth =
2266 pParam->nVhtChannelWidth;
2267 pMac->roam.configParam.txBFEnable = pParam->enableTxBF;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08002268 pMac->roam.configParam.enable_txbf_sap_mode =
2269 pParam->enable_txbf_sap_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
2271 pMac->roam.configParam.enable2x2 = pParam->enable2x2;
2272 pMac->roam.configParam.enableVhtFor24GHz =
2273 pParam->enableVhtFor24GHz;
2274 pMac->roam.configParam.txMuBformee = pParam->enableMuBformee;
2275 pMac->roam.configParam.enableVhtpAid = pParam->enableVhtpAid;
2276 pMac->roam.configParam.enableVhtGid = pParam->enableVhtGid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277 pMac->roam.configParam.enableAmpduPs = pParam->enableAmpduPs;
2278 pMac->roam.configParam.enableHtSmps = pParam->enableHtSmps;
2279 pMac->roam.configParam.htSmps = pParam->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002280 pMac->roam.configParam.send_smps_action =
2281 pParam->send_smps_action;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
2283 pMac->roam.configParam.ignore_peer_erp_info =
2284 pParam->ignore_peer_erp_info;
2285 pMac->roam.configParam.isAmsduSupportInAMPDU =
2286 pParam->isAmsduSupportInAMPDU;
2287 pMac->roam.configParam.nSelect5GHzMargin =
2288 pParam->nSelect5GHzMargin;
2289 pMac->roam.configParam.isCoalesingInIBSSAllowed =
2290 pParam->isCoalesingInIBSSAllowed;
2291#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
2292 pMac->roam.configParam.cc_switch_mode = pParam->cc_switch_mode;
2293#endif
2294 pMac->roam.configParam.allowDFSChannelRoam =
2295 pParam->allowDFSChannelRoam;
2296#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2297 pMac->roam.configParam.isRoamOffloadEnabled =
2298 pParam->isRoamOffloadEnabled;
2299#endif
2300 pMac->roam.configParam.obssEnabled = pParam->obssEnabled;
2301 pMac->roam.configParam.conc_custom_rule1 =
2302 pParam->conc_custom_rule1;
2303 pMac->roam.configParam.conc_custom_rule2 =
2304 pParam->conc_custom_rule2;
2305 pMac->roam.configParam.is_sta_connection_in_5gz_enabled =
2306 pParam->is_sta_connection_in_5gz_enabled;
2307 pMac->roam.configParam.sendDeauthBeforeCon =
2308 pParam->sendDeauthBeforeCon;
2309
2310 pMac->enable_dot11p = pParam->enable_dot11p;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07002311 pMac->roam.configParam.early_stop_scan_enable =
2312 pParam->early_stop_scan_enable;
2313 pMac->roam.configParam.early_stop_scan_min_threshold =
2314 pParam->early_stop_scan_min_threshold;
2315 pMac->roam.configParam.early_stop_scan_max_threshold =
2316 pParam->early_stop_scan_max_threshold;
Krunal Soni1878d3a2016-01-14 13:00:44 -08002317 pMac->isCoalesingInIBSSAllowed =
2318 pParam->isCoalesingInIBSSAllowed;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07002319
Gupta, Kapilc68ad462016-02-01 19:17:23 +05302320 pMac->roam.configParam.roam_params.dense_rssi_thresh_offset =
2321 pParam->roam_dense_rssi_thresh_offset;
2322 pMac->roam.configParam.roam_params.dense_min_aps_cnt =
2323 pParam->roam_dense_min_aps;
2324 pMac->roam.configParam.roam_params.traffic_threshold =
2325 pParam->roam_dense_traffic_thresh;
2326
Krunal Soni1878d3a2016-01-14 13:00:44 -08002327 /* update p2p offload status */
2328 pMac->pnoOffload = pParam->pnoOffload;
2329
2330 pMac->fEnableDebugLog = pParam->fEnableDebugLog;
2331
2332 /* update interface configuration */
2333 pMac->sme.max_intf_count = pParam->max_intf_count;
2334
2335 pMac->enable5gEBT = pParam->enable5gEBT;
2336 pMac->sme.enableSelfRecovery = pParam->enableSelfRecovery;
2337
2338 pMac->f_sta_miracast_mcc_rest_time_val =
2339 pParam->f_sta_miracast_mcc_rest_time_val;
2340#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
2341 pMac->sap.sap_channel_avoidance =
2342 pParam->sap_channel_avoidance;
2343#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
2344
2345 pMac->f_prefer_non_dfs_on_radar =
2346 pParam->f_prefer_non_dfs_on_radar;
2347
2348 pMac->sme.ps_global_info.ps_enabled =
2349 pParam->is_ps_enabled;
2350
2351 pMac->policy_manager_enabled = pParam->policy_manager_enabled;
2352 pMac->fine_time_meas_cap = pParam->fine_time_meas_cap;
2353 pMac->dual_mac_feature_disable =
2354 pParam->dual_mac_feature_disable;
2355 sme_update_roam_pno_channel_prediction_config(pMac, pParam,
2356 SME_CONFIG_TO_ROAM_CONFIG);
2357 pMac->roam.configParam.early_stop_scan_enable =
2358 pParam->early_stop_scan_enable;
2359 pMac->roam.configParam.early_stop_scan_min_threshold =
2360 pParam->early_stop_scan_min_threshold;
2361 pMac->roam.configParam.early_stop_scan_max_threshold =
2362 pParam->early_stop_scan_max_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363
Gupta, Kapilc68ad462016-02-01 19:17:23 +05302364 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365 return status;
2366}
2367
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302368QDF_STATUS csr_get_config_param(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002369{
2370 int i;
2371 tCsrConfig *cfg_params = &pMac->roam.configParam;
2372
2373 if (!pParam)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302374 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375
2376 pParam->WMMSupportMode = cfg_params->WMMSupportMode;
2377 pParam->Is11eSupportEnabled = cfg_params->Is11eSupportEnabled;
2378 pParam->FragmentationThreshold = cfg_params->FragmentationThreshold;
2379 pParam->Is11dSupportEnabled = cfg_params->Is11dSupportEnabled;
2380 pParam->Is11dSupportEnabledOriginal =
2381 cfg_params->Is11dSupportEnabledOriginal;
2382 pParam->Is11hSupportEnabled = cfg_params->Is11hSupportEnabled;
2383 pParam->channelBondingMode24GHz = csr_convert_phy_cb_state_to_ini_value(
2384 cfg_params->channelBondingMode24GHz);
2385 pParam->channelBondingMode5GHz = csr_convert_phy_cb_state_to_ini_value(
2386 cfg_params->channelBondingMode5GHz);
2387 pParam->RTSThreshold = cfg_params->RTSThreshold;
2388 pParam->phyMode = cfg_params->phyMode;
2389 pParam->shortSlotTime = cfg_params->shortSlotTime;
2390 pParam->HeartbeatThresh24 = cfg_params->HeartbeatThresh24;
2391 pParam->HeartbeatThresh50 = cfg_params->HeartbeatThresh50;
2392 pParam->ProprietaryRatesEnabled = cfg_params->ProprietaryRatesEnabled;
2393 pParam->TxRate = cfg_params->TxRate;
2394 pParam->AdHocChannel24 = cfg_params->AdHocChannel24;
2395 pParam->AdHocChannel5G = cfg_params->AdHocChannel5G;
2396 pParam->bandCapability = cfg_params->bandCapability;
2397 pParam->cbChoice = cfg_params->cbChoice;
2398 pParam->nActiveMaxChnTime = cfg_params->nActiveMaxChnTime;
2399 pParam->nActiveMinChnTime = cfg_params->nActiveMinChnTime;
2400 pParam->nPassiveMaxChnTime = cfg_params->nPassiveMaxChnTime;
2401 pParam->nPassiveMinChnTime = cfg_params->nPassiveMinChnTime;
2402#ifdef WLAN_AP_STA_CONCURRENCY
2403 pParam->nActiveMaxChnTimeConc = cfg_params->nActiveMaxChnTimeConc;
2404 pParam->nActiveMinChnTimeConc = cfg_params->nActiveMinChnTimeConc;
2405 pParam->nPassiveMaxChnTimeConc = cfg_params->nPassiveMaxChnTimeConc;
2406 pParam->nPassiveMinChnTimeConc = cfg_params->nPassiveMinChnTimeConc;
2407 pParam->nRestTimeConc = cfg_params->nRestTimeConc;
2408 pParam->nNumStaChanCombinedConc = cfg_params->nNumStaChanCombinedConc;
2409 pParam->nNumP2PChanCombinedConc = cfg_params->nNumP2PChanCombinedConc;
2410#endif
2411 pParam->eBand = cfg_params->eBand;
2412 pParam->nScanResultAgeCount = cfg_params->agingCount;
2413 pParam->scanAgeTimeNCNPS = cfg_params->scanAgeTimeNCNPS;
2414 pParam->scanAgeTimeNCPS = cfg_params->scanAgeTimeNCPS;
2415 pParam->scanAgeTimeCNPS = cfg_params->scanAgeTimeCNPS;
2416 pParam->scanAgeTimeCPS = cfg_params->scanAgeTimeCPS;
2417 pParam->bCatRssiOffset = cfg_params->bCatRssiOffset;
2418 pParam->nRoamingTime = cfg_params->nRoamingTime;
2419 pParam->fSupplicantCountryCodeHasPriority =
2420 cfg_params->fSupplicantCountryCodeHasPriority;
2421 pParam->vccRssiThreshold = cfg_params->vccRssiThreshold;
2422 pParam->vccUlMacLossThreshold = cfg_params->vccUlMacLossThreshold;
2423 pParam->nTxPowerCap = cfg_params->nTxPowerCap;
2424 pParam->statsReqPeriodicity = cfg_params->statsReqPeriodicity;
2425 pParam->statsReqPeriodicityInPS = cfg_params->statsReqPeriodicityInPS;
2426 pParam->addTSWhenACMIsOff = cfg_params->addTSWhenACMIsOff;
2427 pParam->fValidateList = cfg_params->fValidateList;
2428 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
2429 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
2430 pParam->fScanTwice = cfg_params->fScanTwice;
2431 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
2432 pParam->fEnableMCCMode = cfg_params->fenableMCCMode;
2433 pParam->fAllowMCCGODiffBI = cfg_params->fAllowMCCGODiffBI;
2434 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302435 qdf_mem_copy(&pParam->neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436 &cfg_params->neighborRoamConfig,
2437 sizeof(tCsrNeighborRoamConfigParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 pParam->nVhtChannelWidth = cfg_params->nVhtChannelWidth;
2439 pParam->enableTxBF = cfg_params->txBFEnable;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08002440 pParam->enable_txbf_sap_mode =
2441 cfg_params->enable_txbf_sap_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002442 pParam->txBFCsnValue = cfg_params->txBFCsnValue;
2443 pParam->enableMuBformee = cfg_params->txMuBformee;
2444 pParam->enableVhtFor24GHz = cfg_params->enableVhtFor24GHz;
2445 pParam->ignore_peer_erp_info = cfg_params->ignore_peer_erp_info;
2446 pParam->enable2x2 = cfg_params->enable2x2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302447 qdf_mem_copy(&cfg_params->csr11rConfig, &pParam->csr11rConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002448 sizeof(tCsr11rConfigParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002449 pParam->isFastTransitionEnabled = cfg_params->isFastTransitionEnabled;
2450 pParam->RoamRssiDiff = cfg_params->RoamRssiDiff;
2451 pParam->nRoamPrefer5GHz = cfg_params->nRoamPrefer5GHz;
2452 pParam->nRoamIntraBand = cfg_params->nRoamIntraBand;
2453 pParam->isWESModeEnabled = cfg_params->isWESModeEnabled;
2454 pParam->nProbes = cfg_params->nProbes;
2455 pParam->nRoamScanHomeAwayTime = cfg_params->nRoamScanHomeAwayTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456 pParam->isRoamOffloadScanEnabled = cfg_params->isRoamOffloadScanEnabled;
2457 pParam->bFastRoamInConIniFeatureEnabled =
2458 cfg_params->bFastRoamInConIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 pParam->isFastRoamIniFeatureEnabled =
2460 cfg_params->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461#ifdef FEATURE_WLAN_ESE
2462 pParam->isEseIniFeatureEnabled = cfg_params->isEseIniFeatureEnabled;
2463#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302464 qdf_mem_copy(&pParam->neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002465 &cfg_params->neighborRoamConfig,
2466 sizeof(tCsrNeighborRoamConfigParams));
2467 sms_log(pMac, LOG1,
2468 FL("Num of Channels in CFG Channel List: %d"),
2469 cfg_params->neighborRoamConfig.
2470 neighborScanChanList.numChannels);
2471 for (i = 0; i < cfg_params->neighborRoamConfig.
2472 neighborScanChanList.numChannels; i++) {
2473 sms_log(pMac, LOG1, "%d ",
2474 cfg_params->neighborRoamConfig.
2475 neighborScanChanList.channelList[i]);
2476 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477
2478#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
2479 pParam->cc_switch_mode = cfg_params->cc_switch_mode;
2480#endif
2481 pParam->enableTxLdpc = cfg_params->txLdpcEnable;
2482 pParam->isAmsduSupportInAMPDU = cfg_params->isAmsduSupportInAMPDU;
2483 pParam->nSelect5GHzMargin = cfg_params->nSelect5GHzMargin;
2484 pParam->isCoalesingInIBSSAllowed = cfg_params->isCoalesingInIBSSAllowed;
2485 pParam->allowDFSChannelRoam = cfg_params->allowDFSChannelRoam;
2486 pParam->nInitialDwellTime = cfg_params->nInitialDwellTime;
2487 pParam->initial_scan_no_dfs_chnl = cfg_params->initial_scan_no_dfs_chnl;
2488#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2489 pParam->isRoamOffloadEnabled = cfg_params->isRoamOffloadEnabled;
2490#endif
2491 pParam->enable_dot11p = pMac->enable_dot11p;
2492 csr_set_channels(pMac, pParam);
2493 pParam->obssEnabled = cfg_params->obssEnabled;
Gupta, Kapilc68ad462016-02-01 19:17:23 +05302494 pParam->roam_dense_rssi_thresh_offset =
2495 cfg_params->roam_params.dense_rssi_thresh_offset;
2496 pParam->roam_dense_min_aps =
2497 cfg_params->roam_params.dense_min_aps_cnt;
2498 pParam->roam_dense_traffic_thresh =
2499 cfg_params->roam_params.traffic_threshold;
2500
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501 pParam->conc_custom_rule1 = cfg_params->conc_custom_rule1;
2502 pParam->conc_custom_rule2 = cfg_params->conc_custom_rule2;
2503 pParam->is_sta_connection_in_5gz_enabled =
2504 cfg_params->is_sta_connection_in_5gz_enabled;
2505 pParam->sendDeauthBeforeCon =
2506 cfg_params->sendDeauthBeforeCon;
2507 pParam->max_scan_count = pMac->scan.max_scan_count;
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08002508 pParam->first_scan_bucket_threshold =
2509 pMac->first_scan_bucket_threshold;
Krunal Soni1878d3a2016-01-14 13:00:44 -08002510#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
2511 pParam->sap_channel_avoidance = pMac->sap.sap_channel_avoidance;
2512#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
2513 pParam->max_intf_count = pMac->sme.max_intf_count;
2514 pParam->enableSelfRecovery = pMac->sme.enableSelfRecovery;
2515 pParam->pnoOffload = pMac->pnoOffload;
2516 pParam->f_prefer_non_dfs_on_radar =
2517 pMac->f_prefer_non_dfs_on_radar;
2518 pParam->policy_manager_enabled = pMac->policy_manager_enabled;
2519 pParam->fine_time_meas_cap = pMac->fine_time_meas_cap;
2520 pParam->dual_mac_feature_disable =
2521 pMac->dual_mac_feature_disable;
2522 pParam->is_ps_enabled = pMac->sme.ps_global_info.ps_enabled;
2523 pParam->fEnableDebugLog = pMac->fEnableDebugLog;
2524 pParam->enable5gEBT = pMac->enable5gEBT;
2525 pParam->f_sta_miracast_mcc_rest_time_val =
2526 pMac->f_sta_miracast_mcc_rest_time_val;
2527 sme_update_roam_pno_channel_prediction_config(pMac, pParam,
2528 ROAM_CONFIG_TO_SME_CONFIG);
2529 pParam->early_stop_scan_enable =
2530 pMac->roam.configParam.early_stop_scan_enable;
2531 pParam->early_stop_scan_min_threshold =
2532 pMac->roam.configParam.early_stop_scan_min_threshold;
2533 pParam->early_stop_scan_max_threshold =
2534 pMac->roam.configParam.early_stop_scan_max_threshold;
Sandeep Puligillae0875662016-02-12 16:09:21 -08002535 pParam->obss_width_interval =
2536 pMac->roam.configParam.obss_width_interval;
2537 pParam->obss_active_dwelltime =
2538 pMac->roam.configParam.obss_active_dwelltime;
2539 pParam->obss_passive_dwelltime =
2540 pMac->roam.configParam.obss_passive_dwelltime;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002541 pParam->enableHtSmps = pMac->roam.configParam.enableHtSmps;
2542 pParam->htSmps = pMac->roam.configParam.htSmps;
2543 pParam->send_smps_action = pMac->roam.configParam.send_smps_action;
Sandeep Puligillae0875662016-02-12 16:09:21 -08002544
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302545 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002546}
2547
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302548QDF_STATUS csr_set_phy_mode(tHalHandle hHal, uint32_t phyMode, eCsrBand eBand,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549 bool *pfRestartNeeded)
2550{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302551 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002552 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2553 bool fRestartNeeded = false;
2554 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
2555 if (eCSR_BAND_24 == eBand) {
2556 if (CSR_IS_RADIO_A_ONLY(pMac))
2557 goto end;
2558 if (eCSR_DOT11_MODE_11a & phyMode)
2559 goto end;
2560 }
2561 if (eCSR_BAND_5G == eBand) {
2562 if (CSR_IS_RADIO_BG_ONLY(pMac))
2563 goto end;
2564 if ((eCSR_DOT11_MODE_11b & phyMode)
2565 || (eCSR_DOT11_MODE_11b_ONLY & phyMode)
2566 || (eCSR_DOT11_MODE_11g & phyMode)
2567 || (eCSR_DOT11_MODE_11g_ONLY & phyMode))
2568 goto end;
2569 }
2570 if (eCSR_DOT11_MODE_AUTO & phyMode)
2571 newPhyMode = eCSR_DOT11_MODE_AUTO;
2572 else {
2573 /* Check for dual band and higher capability first */
2574 if (eCSR_DOT11_MODE_11n_ONLY & phyMode) {
2575 if (eCSR_DOT11_MODE_11n_ONLY != phyMode)
2576 goto end;
2577 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2578 } else if (eCSR_DOT11_MODE_11g_ONLY & phyMode) {
2579 if (eCSR_DOT11_MODE_11g_ONLY != phyMode)
2580 goto end;
2581 if (eCSR_BAND_5G == eBand)
2582 goto end;
2583 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2584 eBand = eCSR_BAND_24;
2585 } else if (eCSR_DOT11_MODE_11b_ONLY & phyMode) {
2586 if (eCSR_DOT11_MODE_11b_ONLY != phyMode)
2587 goto end;
2588 if (eCSR_BAND_5G == eBand)
2589 goto end;
2590 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2591 eBand = eCSR_BAND_24;
2592 } else if (eCSR_DOT11_MODE_11n & phyMode) {
2593 newPhyMode = eCSR_DOT11_MODE_11n;
2594 } else if (eCSR_DOT11_MODE_abg & phyMode) {
2595 newPhyMode = eCSR_DOT11_MODE_abg;
2596 } else if (eCSR_DOT11_MODE_11a & phyMode) {
2597 if ((eCSR_DOT11_MODE_11g & phyMode)
2598 || (eCSR_DOT11_MODE_11b & phyMode)) {
2599 if (eCSR_BAND_ALL == eBand)
2600 newPhyMode = eCSR_DOT11_MODE_abg;
2601 else
2602 goto end;
2603 } else {
2604 newPhyMode = eCSR_DOT11_MODE_11a;
2605 eBand = eCSR_BAND_5G;
2606 }
2607 } else if (eCSR_DOT11_MODE_11g & phyMode) {
2608 newPhyMode = eCSR_DOT11_MODE_11g;
2609 eBand = eCSR_BAND_24;
2610 } else if (eCSR_DOT11_MODE_11b & phyMode) {
2611 newPhyMode = eCSR_DOT11_MODE_11b;
2612 eBand = eCSR_BAND_24;
2613 } else {
2614 /* We will never be here */
2615 sms_log(pMac, LOGE,
2616 FL("can't recognize phymode 0x%08X"),
2617 phyMode);
2618 newPhyMode = eCSR_DOT11_MODE_AUTO;
2619 }
2620 }
2621 /* Done validating */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302622 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623 /* Now we need to check whether a restart is needed. */
2624 if (eBand != pMac->roam.configParam.eBand) {
2625 fRestartNeeded = true;
2626 goto end;
2627 }
2628 if (newPhyMode != pMac->roam.configParam.phyMode) {
2629 fRestartNeeded = true;
2630 goto end;
2631 }
2632end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302633 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002634 pMac->roam.configParam.eBand = eBand;
2635 pMac->roam.configParam.phyMode = newPhyMode;
2636 if (pfRestartNeeded)
2637 *pfRestartNeeded = fRestartNeeded;
2638 }
2639 return status;
2640}
2641
2642/**
2643 * csr_prune_ch_list() - prunes the channel list to keep only a type of channels
2644 * @ch_lst: existing channel list
2645 * @is_24_GHz: indicates if 2.5 GHz or 5 GHz channels are required
2646 *
2647 * Return: void
2648 */
2649void csr_prune_ch_list(tCsrChannel *ch_lst, bool is_24_GHz)
2650{
2651 uint8_t idx = 0, num_channels = 0;
2652 for ( ; idx < ch_lst->numChannels; idx++) {
2653 if (is_24_GHz) {
2654 if (CDS_IS_CHANNEL_24GHZ(ch_lst->channelList[idx])) {
2655 ch_lst->channelList[num_channels] =
2656 ch_lst->channelList[idx];
2657 num_channels++;
2658 }
2659 } else {
2660 if (CDS_IS_CHANNEL_5GHZ(ch_lst->channelList[idx])) {
2661 ch_lst->channelList[num_channels] =
2662 ch_lst->channelList[idx];
2663 num_channels++;
2664 }
2665 }
2666 }
2667 /*
2668 * Cleanup the rest of channels. Note we only need to clean up the
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302669 * channels if we had to trim the list. Calling qdf_mem_set() with a 0
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 * size is going to throw asserts on the debug builds so let's be a bit
2671 * smarter about that. Zero out the reset of the channels only if we
2672 * need to. The amount of memory to clear is the number of channesl that
2673 * we trimmed (ch_lst->numChannels - num_channels) times the size of a
2674 * channel in the structure.
2675 */
2676 if (ch_lst->numChannels > num_channels) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302677 qdf_mem_set(&ch_lst->channelList[num_channels],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 sizeof(ch_lst->channelList[0]) *
2679 (ch_lst->numChannels - num_channels), 0);
2680 }
2681 ch_lst->numChannels = num_channels;
2682}
2683
2684/**
2685 * csr_prune_channel_list_for_mode() - prunes the channel list
2686 * @mac_ctx: global mac context
2687 * @ch_lst: existing channel list
2688 *
2689 * Prunes the channel list according to band stored in mac_ctx
2690 *
2691 * Return: void
2692 */
2693void csr_prune_channel_list_for_mode(tpAniSirGlobal mac_ctx,
2694 tCsrChannel *ch_lst)
2695{
2696 /* for dual band NICs, don't need to trim the channel list.... */
2697 if (CSR_IS_OPEARTING_DUAL_BAND(mac_ctx))
2698 return;
2699 /*
2700 * 2.4 GHz band operation requires the channel list to be trimmed to
2701 * the 2.4 GHz channels only
2702 */
2703 if (CSR_IS_24_BAND_ONLY(mac_ctx))
2704 csr_prune_ch_list(ch_lst, true);
2705 else if (CSR_IS_5G_BAND_ONLY(mac_ctx))
2706 csr_prune_ch_list(ch_lst, false);
2707}
2708
2709#define INFRA_AP_DEFAULT_CHANNEL 6
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302710QDF_STATUS csr_is_valid_channel(tpAniSirGlobal pMac, uint8_t chnNum)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711{
2712 uint8_t index = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302713 QDF_STATUS status = QDF_STATUS_E_NOSUPPORT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002714
2715 /* regulatory check */
2716 for (index = 0; index < pMac->scan.base_channels.numChannels;
2717 index++) {
2718 if (pMac->scan.base_channels.channelList[index] == chnNum) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302719 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002720 break;
2721 }
2722 }
2723
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302724 if (status == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 /* dfs nol */
2726 for (index = 0;
2727 index <
2728 pMac->sap.SapDfsInfo.numCurrentRegDomainDfsChannels;
2729 index++) {
2730 tSapDfsNolInfo *dfsChan =
2731 &pMac->sap.SapDfsInfo.sapDfsChannelNolList[index];
2732 if ((dfsChan->dfs_channel_number == chnNum)
2733 && (dfsChan->radar_status_flag ==
2734 eSAP_DFS_CHANNEL_UNAVAILABLE)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302735 QDF_TRACE(QDF_MODULE_ID_SME,
2736 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002737 FL("channel %d is in dfs nol"),
2738 chnNum);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302739 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002740 break;
2741 }
2742 }
2743 }
2744
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302745 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302746 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 FL("channel %d is not available"), chnNum);
2748 }
2749
2750 return status;
2751}
2752
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302753QDF_STATUS csr_get_channel_and_power_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302755 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 uint8_t num20MHzChannelsFound = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302757 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758 uint8_t Index = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302760 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 cds_get_channel_list_with_power(pMac->scan.defaultPowerTable,
Amar Singhal7ccdc4f2015-10-30 15:10:05 -07002762 &num20MHzChannelsFound);
2763
2764 if ((QDF_STATUS_SUCCESS != qdf_status) ||
2765 (num20MHzChannelsFound == 0)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002766 sms_log(pMac, LOGE, FL("failed to get channels "));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302767 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 } else {
2769 if (num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN) {
2770 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2771 }
2772 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2773 /* Move the channel list to the global data */
2774 /* structure -- this will be used as the scan list */
2775 for (Index = 0; Index < num20MHzChannelsFound; Index++) {
2776 pMac->scan.base_channels.channelList[Index] =
Amar Singhala297bfa2015-10-15 15:07:29 -07002777 pMac->scan.defaultPowerTable[Index].chan_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002778 }
2779 pMac->scan.base_channels.numChannels =
2780 num20MHzChannelsFound;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781 }
2782 return status;
2783}
2784
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302785QDF_STATUS csr_apply_channel_and_power_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002786{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302787 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002788
2789 csr_prune_channel_list_for_mode(pMac, &pMac->scan.base_channels);
2790 csr_save_channel_power_for_band(pMac, false);
2791 csr_save_channel_power_for_band(pMac, true);
2792 /* Apply the base channel list, power info, and set the Country code... */
2793 csr_apply_channel_power_info_to_fw(pMac,
2794 &pMac->scan.base_channels,
2795 pMac->scan.countryCodeCurrent);
2796
2797 csr_init_operating_classes((tHalHandle) pMac);
2798 return status;
2799}
2800
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302801QDF_STATUS csr_change_config_params(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 tCsrUpdateConfigParam *pUpdateConfigParam)
2803{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302804 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002805 tCsr11dinfo *ps11dinfo = NULL;
2806 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2807 status = csr_init11d_info(pMac, ps11dinfo);
2808 return status;
2809}
2810
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302811static QDF_STATUS csr_init11d_info(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302813 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002814 uint8_t index;
2815 uint32_t count = 0;
2816 tSirMacChanInfo *pChanInfo;
2817 tSirMacChanInfo *pChanInfoStart;
2818 bool applyConfig = true;
2819
2820 pMac->scan.currentCountryRSSI = -128;
2821 if (!ps11dinfo) {
2822 return status;
2823 }
2824 if (ps11dinfo->Channels.numChannels
2825 && (WNI_CFG_VALID_CHANNEL_LIST_LEN >=
2826 ps11dinfo->Channels.numChannels)) {
2827 pMac->scan.base_channels.numChannels =
2828 ps11dinfo->Channels.numChannels;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302829 qdf_mem_copy(pMac->scan.base_channels.channelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 ps11dinfo->Channels.channelList,
2831 ps11dinfo->Channels.numChannels);
2832 } else {
2833 /* No change */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302834 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002835 }
2836 /* legacy maintenance */
2837
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302838 qdf_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839 WNI_CFG_COUNTRY_CODE_LEN);
2840
2841 /* Tush: at csropen get this initialized with default, during csr reset if this */
2842 /* already set with some value no need initilaize with default again */
2843 if (0 == pMac->scan.countryCodeCurrent[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302844 qdf_mem_copy(pMac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2846 }
2847 /* need to add the max power channel list */
2848 pChanInfo =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302849 qdf_mem_malloc(sizeof(tSirMacChanInfo) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850 WNI_CFG_VALID_CHANNEL_LIST_LEN);
2851 if (pChanInfo != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302852 qdf_mem_set(pChanInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853 sizeof(tSirMacChanInfo) *
2854 WNI_CFG_VALID_CHANNEL_LIST_LEN, 0);
2855
2856 pChanInfoStart = pChanInfo;
2857 for (index = 0; index < ps11dinfo->Channels.numChannels;
2858 index++) {
2859 pChanInfo->firstChanNum =
2860 ps11dinfo->ChnPower[index].firstChannel;
2861 pChanInfo->numChannels =
2862 ps11dinfo->ChnPower[index].numChannels;
2863 pChanInfo->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302864 QDF_MIN(ps11dinfo->ChnPower[index].maxtxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002865 pMac->roam.configParam.nTxPowerCap);
2866 pChanInfo++;
2867 count++;
2868 }
2869 if (count) {
2870 csr_save_to_channel_power2_g_5_g(pMac,
2871 count *
2872 sizeof(tSirMacChanInfo),
2873 pChanInfoStart);
2874 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302875 qdf_mem_free(pChanInfoStart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876 }
2877 /* Only apply them to CFG when not in STOP state. Otherwise they will be applied later */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302878 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 for (index = 0; index < CSR_ROAM_SESSION_MAX; index++) {
2880 if ((CSR_IS_SESSION_VALID(pMac, index))
2881 && CSR_IS_ROAM_STOP(pMac, index)) {
2882 applyConfig = false;
2883 }
2884 }
2885
2886 if (true == applyConfig) {
2887 /* Apply the base channel list, power info, and set the Country code... */
2888 csr_apply_channel_power_info_to_fw(pMac,
2889 &pMac->scan.
2890 base_channels,
2891 pMac->scan.
2892 countryCodeCurrent);
2893 }
2894 }
2895 return status;
2896}
2897
2898/* Initialize the Channel + Power List in the local cache and in the CFG */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302899QDF_STATUS csr_init_channel_power_list(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900{
2901 uint8_t index;
2902 uint32_t count = 0;
2903 tSirMacChanInfo *pChanInfo;
2904 tSirMacChanInfo *pChanInfoStart;
2905
2906 if (!ps11dinfo || !pMac) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302907 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002908 }
2909
2910 pChanInfo =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302911 qdf_mem_malloc(sizeof(tSirMacChanInfo) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002912 WNI_CFG_VALID_CHANNEL_LIST_LEN);
2913 if (pChanInfo != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302914 qdf_mem_set(pChanInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002915 sizeof(tSirMacChanInfo) *
2916 WNI_CFG_VALID_CHANNEL_LIST_LEN, 0);
2917 pChanInfoStart = pChanInfo;
2918
2919 for (index = 0; index < ps11dinfo->Channels.numChannels;
2920 index++) {
2921 pChanInfo->firstChanNum =
2922 ps11dinfo->ChnPower[index].firstChannel;
2923 pChanInfo->numChannels =
2924 ps11dinfo->ChnPower[index].numChannels;
2925 pChanInfo->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302926 QDF_MIN(ps11dinfo->ChnPower[index].maxtxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927 pMac->roam.configParam.nTxPowerCap);
2928 pChanInfo++;
2929 count++;
2930 }
2931 if (count) {
2932 csr_save_to_channel_power2_g_5_g(pMac,
2933 count *
2934 sizeof(tSirMacChanInfo),
2935 pChanInfoStart);
2936 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302937 qdf_mem_free(pChanInfoStart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938 }
2939
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302940 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002941}
2942
Abhishek Singhd86d9832015-12-30 17:18:13 +05302943/**
2944 * csr_roam_remove_duplicate_cmd_from_list()- Remove duplicate roam cmd from
2945 * list
2946 *
2947 * @mac_ctx: pointer to global mac
2948 * @session_id: session id for the cmd
2949 * @list: pending list from which cmd needs to be removed
2950 * @command: cmd to be removed, can be NULL
2951 * @roam_reason: cmd with reason to be removed
2952 *
2953 * Remove duplicate command from the pending list.
2954 *
2955 * Return: void
2956 */
2957static void csr_roam_remove_duplicate_cmd_from_list(tpAniSirGlobal mac_ctx,
2958 uint32_t session_id, tDblLinkList *list,
2959 tSmeCmd *command, eCsrRoamReason roam_reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960{
Abhishek Singhd86d9832015-12-30 17:18:13 +05302961 tListElem *entry, *next_entry;
2962 tSmeCmd *dup_cmd;
2963 tDblLinkList local_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002964
Abhishek Singhd86d9832015-12-30 17:18:13 +05302965 qdf_mem_zero(&local_list, sizeof(tDblLinkList));
2966 if (!QDF_IS_STATUS_SUCCESS(csr_ll_open(mac_ctx->hHdd, &local_list))) {
2967 sms_log(mac_ctx, LOGE, FL(" failed to open list"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 return;
2969 }
Abhishek Singhd86d9832015-12-30 17:18:13 +05302970 csr_ll_lock(list);
2971 entry = csr_ll_peek_head(list, LL_ACCESS_NOLOCK);
2972 while (entry) {
2973 next_entry = csr_ll_next(list, entry, LL_ACCESS_NOLOCK);
2974 dup_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
2975 /*
2976 * Remove the previous command if..
2977 * - the new roam command is for the same RoamReason...
2978 * - the new roam command is a NewProfileList.
2979 * - the new roam command is a Forced Dissoc
2980 * - the new roam command is from an 802.11 OID
2981 * (OID_SSID or OID_BSSID).
2982 */
2983 if ((command && (command->sessionId == dup_cmd->sessionId) &&
2984 ((command->command == dup_cmd->command) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002985 /*
2986 * This peermac check is requried for Softap/GO
Abhishek Singhd86d9832015-12-30 17:18:13 +05302987 * scenarios. for STA scenario below OR check will
2988 * suffice as command will always be NULL for
2989 * STA scenarios
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990 */
Abhishek Singhd86d9832015-12-30 17:18:13 +05302991 (!qdf_mem_cmp(dup_cmd->u.roamCmd.peerMac,
2992 command->u.roamCmd.peerMac,
2993 sizeof(QDF_MAC_ADDR_SIZE))) &&
2994 ((command->u.roamCmd.roamReason ==
2995 dup_cmd->u.roamCmd.roamReason) ||
2996 (eCsrForcedDisassoc ==
2997 command->u.roamCmd.roamReason) ||
2998 (eCsrHddIssued ==
2999 command->u.roamCmd.roamReason)))) ||
3000 /* OR if pCommand is NULL */
3001 ((session_id == dup_cmd->sessionId) &&
3002 (eSmeCommandRoam == dup_cmd->command) &&
3003 ((eCsrForcedDisassoc == roam_reason) ||
3004 (eCsrHddIssued == roam_reason)))) {
3005 sms_log(mac_ctx, LOGW, FL("RoamReason = %d"),
3006 dup_cmd->u.roamCmd.roamReason);
3007 /* Remove the roam command from the pending list */
3008 if (csr_ll_remove_entry(list, entry, LL_ACCESS_NOLOCK))
3009 csr_ll_insert_tail(&local_list, entry,
3010 LL_ACCESS_NOLOCK);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003011 }
Abhishek Singhd86d9832015-12-30 17:18:13 +05303012 entry = next_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013 }
Abhishek Singhd86d9832015-12-30 17:18:13 +05303014 csr_ll_unlock(list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015
Abhishek Singhd86d9832015-12-30 17:18:13 +05303016 while ((entry = csr_ll_remove_head(&local_list, LL_ACCESS_NOLOCK))) {
3017 dup_cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 /* Tell caller that the command is cancelled */
Abhishek Singhd86d9832015-12-30 17:18:13 +05303019 csr_roam_call_callback(mac_ctx, dup_cmd->sessionId, NULL,
3020 dup_cmd->u.roamCmd.roamId,
3021 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
3022 csr_release_command_roam(mac_ctx, dup_cmd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003023 }
Abhishek Singhd86d9832015-12-30 17:18:13 +05303024 csr_ll_close(&local_list);
3025}
3026
3027/**
3028 * csr_roam_remove_duplicate_command()- Remove duplicate roam cmd
3029 * from pending lists.
3030 *
3031 * @mac_ctx: pointer to global mac
3032 * @session_id: session id for the cmd
3033 * @command: cmd to be removed, can be null
3034 * @roam_reason: cmd with reason to be removed
3035 *
3036 * Remove duplicate command from the sme and roam pending list.
3037 *
3038 * Return: void
3039 */
3040void csr_roam_remove_duplicate_command(tpAniSirGlobal mac_ctx,
3041 uint32_t session_id, tSmeCmd *command,
3042 eCsrRoamReason roam_reason)
3043{
3044 /* Always lock active list before locking pending lists */
3045 csr_ll_lock(&mac_ctx->sme.smeCmdActiveList);
3046 csr_roam_remove_duplicate_cmd_from_list(mac_ctx,
3047 session_id, &mac_ctx->sme.smeCmdPendingList,
3048 command, roam_reason);
3049 csr_roam_remove_duplicate_cmd_from_list(mac_ctx,
3050 session_id, &mac_ctx->roam.roamCmdPendingList,
3051 command, roam_reason);
3052 csr_ll_unlock(&mac_ctx->sme.smeCmdActiveList);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053}
3054
3055/**
3056 * csr_roam_populate_channels() - Helper function to populate channels
3057 * @beacon_ies: pointer to beacon ie
3058 * @roam_info: Roaming related information
3059 * @chan1: center freq 1
3060 * @chan2: center freq2
3061 *
3062 * This function will issue populate chan1 and chan2 based on beacon ie
3063 *
3064 * Return: none.
3065 */
3066static void csr_roam_populate_channels(tDot11fBeaconIEs *beacon_ies,
3067 tCsrRoamInfo *roam_info,
3068 uint8_t *chan1, uint8_t *chan2)
3069{
3070 ePhyChanBondState phy_state;
3071 if (beacon_ies->VHTOperation.present) {
3072 *chan1 = beacon_ies->VHTOperation.chanCenterFreqSeg1;
3073 *chan2 = beacon_ies->VHTOperation.chanCenterFreqSeg2;
3074 roam_info->chan_info.info = MODE_11AC_VHT80;
3075 } else if (beacon_ies->HTInfo.present) {
3076 if (beacon_ies->HTInfo.recommendedTxWidthSet ==
3077 eHT_CHANNEL_WIDTH_40MHZ) {
3078 phy_state = beacon_ies->HTInfo.secondaryChannelOffset;
3079 if (phy_state == PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
3080 *chan1 = beacon_ies->HTInfo.primaryChannel +
3081 CSR_CB_CENTER_CHANNEL_OFFSET;
3082 else if (phy_state == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
3083 *chan1 = beacon_ies->HTInfo.primaryChannel -
3084 CSR_CB_CENTER_CHANNEL_OFFSET;
3085 else
3086 *chan1 = beacon_ies->HTInfo.primaryChannel;
3087
3088 roam_info->chan_info.info = MODE_11NA_HT40;
3089 } else {
3090 *chan1 = beacon_ies->HTInfo.primaryChannel;
3091 roam_info->chan_info.info = MODE_11NA_HT20;
3092 }
3093 *chan2 = 0;
3094 } else {
3095 *chan1 = 0;
3096 *chan2 = 0;
3097 roam_info->chan_info.info = MODE_11A;
3098 }
3099}
3100
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303101QDF_STATUS csr_roam_call_callback(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102 tCsrRoamInfo *pRoamInfo, uint32_t roamId,
3103 eRoamCmdStatus u1, eCsrRoamResult u2)
3104{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303105 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
3107 uint32_t rssi = 0;
3108 WLAN_HOST_DIAG_EVENT_DEF(connectionStatus,
3109 host_event_wlan_status_payload_type);
3110#endif
3111 tCsrRoamSession *pSession;
3112 tDot11fBeaconIEs *beacon_ies = NULL;
3113 uint8_t chan1, chan2;
3114
3115 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
3116 sms_log(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303117 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303118 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 }
3120 pSession = CSR_GET_SESSION(pMac, sessionId);
3121
3122 if (false == pSession->sessionActive) {
3123 sms_log(pMac, LOG1, "%s Session is not Active", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303124 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003125 }
3126
3127 sms_log(pMac, LOG4, "Received RoamCmdStatus %d with Roam Result %d", u1,
3128 u2);
3129
3130 if (eCSR_ROAM_ASSOCIATION_COMPLETION == u1 &&
3131 eCSR_ROAM_RESULT_ASSOCIATED == u2 && pRoamInfo) {
3132 sms_log(pMac, LOGW,
3133 FL("Assoc complete result=%d status=%d reason=%d"),
3134 u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303135 beacon_ies = qdf_mem_malloc(sizeof(tDot11fBeaconIEs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 if ((NULL != beacon_ies) && (NULL != pRoamInfo->pBssDesc)) {
3137 status = csr_parse_bss_description_ies(
3138 (tHalHandle) pMac, pRoamInfo->pBssDesc,
3139 beacon_ies);
3140 csr_roam_populate_channels(beacon_ies, pRoamInfo,
3141 &chan1, &chan2);
3142 if (0 != chan1)
3143 pRoamInfo->chan_info.band_center_freq1 =
3144 cds_chan_to_freq(chan1);
3145 else
3146 pRoamInfo->chan_info.band_center_freq1 = 0;
3147 if (0 != chan2)
3148 pRoamInfo->chan_info.band_center_freq2 =
3149 cds_chan_to_freq(chan2);
3150 else
3151 pRoamInfo->chan_info.band_center_freq2 = 0;
3152 } else {
3153 pRoamInfo->chan_info.band_center_freq1 = 0;
3154 pRoamInfo->chan_info.band_center_freq2 = 0;
3155 pRoamInfo->chan_info.info = 0;
3156 }
3157 pRoamInfo->chan_info.chan_id =
3158 pRoamInfo->u.pConnectedProfile->operationChannel;
3159 pRoamInfo->chan_info.mhz =
3160 cds_chan_to_freq(pRoamInfo->chan_info.chan_id);
3161 pRoamInfo->chan_info.reg_info_1 =
3162 (csr_get_cfg_max_tx_power(pMac,
3163 pRoamInfo->chan_info.chan_id) << 16);
3164 pRoamInfo->chan_info.reg_info_2 =
3165 (csr_get_cfg_max_tx_power(pMac,
3166 pRoamInfo->chan_info.chan_id) << 8);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303167 qdf_mem_free(beacon_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168 } else if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED)
3169 && (pSession->bRefAssocStartCnt)) {
3170 /*
3171 * Decrement bRefAssocStartCnt for FT reassoc failure.
3172 * Reason: For FT reassoc failures, we first call
3173 * csr_roam_call_callback before notifying a failed roam
3174 * completion through csr_roam_complete. The latter in
3175 * turn calls csr_roam_process_results which tries to
3176 * once again call csr_roam_call_callback if bRefAssocStartCnt
3177 * is non-zero. Since this is redundant for FT reassoc
3178 * failure, decrement bRefAssocStartCnt.
3179 */
3180 pSession->bRefAssocStartCnt--;
3181 } else if (u1 == eCSR_ROAM_SET_CHANNEL_RSP && u2 ==
3182 eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS)
3183 pSession->connectedProfile.operationChannel =
3184 pRoamInfo->channelChangeRespEvent->newChannelNumber;
3185
3186 if (NULL != pSession->callback) {
3187 if (pRoamInfo) {
3188 pRoamInfo->sessionId = (uint8_t) sessionId;
3189 /*
3190 * the reasonCode will be passed to supplicant by
3191 * cfg80211_disconnected. Based on the document,
3192 * the reason code passed to supplicant needs to set
3193 * to 0 if unknow. eSIR_BEACON_MISSED reason code is not
3194 * recognizable so that we set to 0 instead.
3195 */
3196 pRoamInfo->reasonCode =
3197 (pRoamInfo->reasonCode == eSIR_BEACON_MISSED) ?
3198 0 : pRoamInfo->reasonCode;
3199 }
3200 status = pSession->callback(pSession->pContext, pRoamInfo,
3201 roamId, u1, u2);
3202 }
3203 /*
3204 * EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
3205 * eCSR_ROAM_LOSTLINK,
3206 * eCSR_ROAM_DISASSOCIATED,
3207 */
3208#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303209 qdf_mem_set(&connectionStatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210 sizeof(host_event_wlan_status_payload_type), 0);
3211
3212 if ((eCSR_ROAM_ASSOCIATION_COMPLETION == u1)
3213 && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo) {
3214 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
3215 connectionStatus.bssType =
3216 pRoamInfo->u.pConnectedProfile->BSSType;
3217
3218 if (NULL != pRoamInfo->pBssDesc) {
3219 connectionStatus.rssi =
3220 pRoamInfo->pBssDesc->rssi * (-1);
3221 connectionStatus.channel =
3222 pRoamInfo->pBssDesc->channelId;
3223 }
3224 if (cfg_set_int(pMac, WNI_CFG_CURRENT_RSSI,
3225 connectionStatus.rssi) == eSIR_FAILURE)
3226 sms_log(pMac, LOGE,
3227 FL("Can't pass WNI_CFG_CURRENT_RSSI to cfg"));
3228
3229 connectionStatus.qosCapability =
3230 pRoamInfo->u.pConnectedProfile->qosConnection;
3231 connectionStatus.authType =
3232 (uint8_t) diag_auth_type_from_csr_type(
3233 pRoamInfo->u.pConnectedProfile->AuthType);
3234 connectionStatus.encryptionType =
3235 (uint8_t) diag_enc_type_from_csr_type(
3236 pRoamInfo->u.pConnectedProfile->EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303237 qdf_mem_copy(connectionStatus.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003238 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
3239
3240 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303241 qdf_mem_copy(&pMac->sme.eventPayload, &connectionStatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242 sizeof(host_event_wlan_status_payload_type));
3243 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
3244 EVENT_WLAN_STATUS);
3245 }
3246 if ((eCSR_ROAM_MIC_ERROR_IND == u1)
3247 || (eCSR_ROAM_RESULT_MIC_FAILURE == u2)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303248 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 sizeof(host_event_wlan_status_payload_type));
3250 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
3251 WNI_CFG_CURRENT_RSSI, &rssi)))
3252 connectionStatus.rssi = rssi;
3253
3254 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
3255 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
3256 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
3257 EVENT_WLAN_STATUS);
3258 }
3259 if (eCSR_ROAM_RESULT_FORCED == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303260 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 sizeof(host_event_wlan_status_payload_type));
3262 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
3263 WNI_CFG_CURRENT_RSSI, &rssi)))
3264 connectionStatus.rssi = rssi;
3265
3266 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
3267 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
3268 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
3269 EVENT_WLAN_STATUS);
3270 }
3271 if (eCSR_ROAM_RESULT_DISASSOC_IND == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303272 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 sizeof(host_event_wlan_status_payload_type));
3274 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
3275 WNI_CFG_CURRENT_RSSI, &rssi)))
3276 connectionStatus.rssi = rssi;
3277
3278 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
3279 connectionStatus.reason = eCSR_REASON_DISASSOC;
3280 if (pRoamInfo)
3281 connectionStatus.reasonDisconnect =
3282 pRoamInfo->reasonCode;
3283
3284 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
3285 EVENT_WLAN_STATUS);
3286 }
3287 if (eCSR_ROAM_RESULT_DEAUTH_IND == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303288 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 sizeof(host_event_wlan_status_payload_type));
3290 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
3291 WNI_CFG_CURRENT_RSSI, &rssi)))
3292 connectionStatus.rssi = rssi;
3293
3294 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
3295 connectionStatus.reason = eCSR_REASON_DEAUTH;
3296 if (pRoamInfo)
3297 connectionStatus.reasonDisconnect =
3298 pRoamInfo->reasonCode;
3299 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
3300 EVENT_WLAN_STATUS);
3301 }
3302#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
3303 return status;
3304}
3305
3306/* Returns whether handoff is currently in progress or not */
3307bool csr_roam_is_handoff_in_progress(tpAniSirGlobal pMac, uint8_t sessionId)
3308{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 return csr_neighbor_roam_is_handoff_in_progress(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003310}
3311
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303312QDF_STATUS csr_roam_issue_disassociate(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313 eCsrRoamSubState NewSubstate,
3314 bool fMICFailure)
3315{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303316 QDF_STATUS status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303317 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 uint16_t reasonCode;
3319 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
3320
3321 if (!pSession) {
3322 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303323 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 }
3325
3326 if (fMICFailure) {
3327 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
3328 } else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF) {
3329 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
3330 } else if (eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT == NewSubstate) {
3331 reasonCode = eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
3332 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303333 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 FL
3335 ("set to reason code eSIR_MAC_DISASSOC_LEAVING_BSS_REASON"
3336 " and set back NewSubstate"));
3337 } else {
3338 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
3339 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003340 if ((csr_roam_is_handoff_in_progress(pMac, sessionId)) &&
3341 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)) {
3342 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
3343 &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303344 qdf_copy_macaddr(&bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.
3346 bssid);
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -08003347 } else if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303348 qdf_mem_copy(&bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303349 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350 }
3351
3352 sms_log(pMac, LOG2,
3353 FL("CSR Attempting to Disassociate Bssid=" MAC_ADDRESS_STR
3354 " subState = %s reason=%d"), MAC_ADDR_ARRAY(bssId.bytes),
3355 mac_trace_getcsr_roam_sub_state(NewSubstate), reasonCode);
3356
3357 csr_roam_substate_change(pMac, NewSubstate, sessionId);
3358
3359 status = csr_send_mb_disassoc_req_msg(pMac, sessionId, bssId.bytes,
3360 reasonCode);
3361
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303362 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003363 csr_roam_link_down(pMac, sessionId);
3364#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3365 /* no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO */
3366 if (eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate) {
3367 /* notify QoS module that disassoc happening */
3368 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
3369 SME_QOS_CSR_DISCONNECT_REQ, NULL);
3370 }
3371#endif
3372 } else {
3373 sms_log(pMac, LOGW,
3374 FL("csr_send_mb_disassoc_req_msg failed with status %d"),
3375 status);
3376 }
3377
3378 return status;
3379}
3380
3381/* ---------------------------------------------------------------------------
3382 \fn csr_roam_issue_disassociate_sta_cmd
3383 \brief csr function that HDD calls to disassociate a associated station
3384 \param sessionId - session Id for Soft AP
3385 \param pPeerMacAddr - MAC of associated station to delete
3386 \param reason - reason code, be one of the tSirMacReasonCodes
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303387 \return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003388 ---------------------------------------------------------------------------*/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303389QDF_STATUS csr_roam_issue_disassociate_sta_cmd(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003390 uint32_t sessionId,
3391 const uint8_t *pPeerMacAddr,
3392 uint32_t reason)
3393{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303394 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395 tSmeCmd *pCommand;
3396
3397 do {
3398 pCommand = csr_get_command_buffer(pMac);
3399 if (!pCommand) {
3400 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303401 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 break;
3403 }
3404 pCommand->command = eSmeCommandRoam;
3405 pCommand->sessionId = (uint8_t) sessionId;
3406 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303407 qdf_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408 pCommand->u.roamCmd.reason = (tSirMacReasonCodes) reason;
3409 status = csr_queue_sme_command(pMac, pCommand, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303410 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 sms_log(pMac, LOGE,
3412 FL(" fail to send message status = %d"), status);
3413 csr_release_command_roam(pMac, pCommand);
3414 }
3415 } while (0);
3416
3417 return status;
3418}
3419
3420/**
3421 * csr_roam_issue_deauthSta() - delete a associated station
3422 * @sessionId: Session Id for Soft AP
3423 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3424 *
3425 * CSR function that HDD calls to delete a associated station
3426 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303427 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303429QDF_STATUS csr_roam_issue_deauth_sta_cmd(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 uint32_t sessionId,
3431 struct tagCsrDelStaParams *pDelStaParams)
3432{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303433 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 tSmeCmd *pCommand;
3435
3436 do {
3437 pCommand = csr_get_command_buffer(pMac);
3438 if (!pCommand) {
3439 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303440 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003441 break;
3442 }
3443 pCommand->command = eSmeCommandRoam;
3444 pCommand->sessionId = (uint8_t) sessionId;
3445 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303446 qdf_mem_copy(pCommand->u.roamCmd.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003447 pDelStaParams->peerMacAddr.bytes,
3448 sizeof(tSirMacAddr));
3449 pCommand->u.roamCmd.reason =
3450 (tSirMacReasonCodes)pDelStaParams->reason_code;
3451 status = csr_queue_sme_command(pMac, pCommand, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303452 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453 sms_log(pMac, LOGE,
3454 FL(" fail to send message status = %d"), status);
3455 csr_release_command_roam(pMac, pCommand);
3456 }
3457 } while (0);
3458
3459 return status;
3460}
3461
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303462static QDF_STATUS
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003463csr_send_mb_tkip_counter_measures_req_msg(tpAniSirGlobal pMac,
3464 uint32_t sessionId, bool bEnable,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303465 struct qdf_mac_addr *bssId)
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003466{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303467 QDF_STATUS status = QDF_STATUS_SUCCESS;
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003468 tSirSmeTkipCntrMeasReq *pMsg;
3469 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303470 pMsg = qdf_mem_malloc(sizeof(tSirSmeTkipCntrMeasReq));
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003471 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303472 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003473 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303474 status = QDF_STATUS_SUCCESS;
3475 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003476 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303477 qdf_mem_set(pMsg, sizeof(tSirSmeTkipCntrMeasReq), 0);
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003478 pMsg->messageType = eWNI_SME_TKIP_CNTR_MEAS_REQ;
3479 pMsg->length = sizeof(tSirSmeTkipCntrMeasReq);
3480 pMsg->sessionId = sessionId;
3481 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303482 qdf_copy_macaddr(&pMsg->bssId, bssId);
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003483 pMsg->bEnable = bEnable;
3484 status = cds_send_mb_message_to_mac(pMsg);
3485 } while (0);
3486 return status;
3487}
3488
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303489QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490csr_roam_issue_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t sessionId,
3491 bool bEnable)
3492{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303493 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303494 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
3496 if (!pSession) {
3497 sms_log(pMac, LOGE,
3498 "csr_roam_issue_tkip_counter_measures:CSR Session not found");
3499 return status;
3500 }
3501 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303502 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303503 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 } else {
3505 sms_log(pMac, LOGE,
3506 "csr_roam_issue_tkip_counter_measures:Connected BSS Description in CSR Session not found");
3507 return status;
3508 }
3509 sms_log(pMac, LOG2,
3510 "CSR issuing tkip counter measures for Bssid = " MAC_ADDRESS_STR
3511 ", Enable = %d", MAC_ADDR_ARRAY(bssId.bytes), bEnable);
3512 status =
3513 csr_send_mb_tkip_counter_measures_req_msg(pMac, sessionId,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003514 bEnable, &bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 return status;
3516}
3517
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303518QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003519csr_roam_get_associated_stas(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303520 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521 void *pfnSapEventCallback, uint8_t *pAssocStasBuf)
3522{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303523 QDF_STATUS status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303524 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
3526 if (!pSession) {
3527 sms_log(pMac, LOGE,
3528 "csr_roam_get_associated_stas:CSR Session not found");
3529 return status;
3530 }
3531 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303532 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303533 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003534 } else {
3535 sms_log(pMac, LOGE,
3536 "csr_roam_get_associated_stas:Connected BSS Description in CSR Session not found");
3537 return status;
3538 }
3539 sms_log(pMac, LOG2,
3540 "CSR getting associated stations for Bssid = " MAC_ADDRESS_STR,
3541 MAC_ADDR_ARRAY(bssId.bytes));
3542 status =
3543 csr_send_mb_get_associated_stas_req_msg(pMac, sessionId, modId,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003544 bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003545 pUsrContext,
3546 pfnSapEventCallback,
3547 pAssocStasBuf);
3548 return status;
3549}
3550
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303551QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552csr_roam_get_wps_session_overlap(tpAniSirGlobal pMac, uint32_t sessionId,
3553 void *pUsrContext, void *pfnSapEventCallback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303554 struct qdf_mac_addr pRemoveMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003555{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303556 QDF_STATUS status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303557 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
3559
3560 if (!pSession) {
3561 sms_log(pMac, LOGE,
3562 "csr_roam_get_wps_session_overlap:CSR Session not found");
3563 return status;
3564 }
3565 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303566 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303567 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568 } else {
3569 sms_log(pMac, LOGE,
3570 "csr_roam_get_wps_session_overlap:Connected BSS Description in CSR Session not found");
3571 return status;
3572 }
3573 sms_log(pMac, LOG2,
3574 "CSR getting WPS Session Overlap for Bssid = " MAC_ADDRESS_STR,
3575 MAC_ADDR_ARRAY(bssId.bytes));
3576
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003577 status = csr_send_mb_get_wpspbc_sessions(pMac, sessionId, bssId,
3578 pUsrContext, pfnSapEventCallback, pRemoveMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579
3580 return status;
3581}
3582
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303583QDF_STATUS csr_roam_issue_deauth(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584 eCsrRoamSubState NewSubstate)
3585{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303586 QDF_STATUS status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303587 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
3589
3590 if (!pSession) {
3591 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303592 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593 }
3594
3595 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303596 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303597 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 }
3599 sms_log(pMac, LOG2, "CSR Attempting to Deauth Bssid= " MAC_ADDRESS_STR,
3600 MAC_ADDR_ARRAY(bssId.bytes));
3601 csr_roam_substate_change(pMac, NewSubstate, sessionId);
3602
3603 status =
3604 csr_send_mb_deauth_req_msg(pMac, sessionId, bssId.bytes,
3605 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303606 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607 csr_roam_link_down(pMac, sessionId);
3608 else {
3609 sms_log(pMac, LOGE,
3610 FL
3611 ("csr_send_mb_deauth_req_msg failed with status %d Session ID: %d"
3612 MAC_ADDRESS_STR), status, sessionId,
3613 MAC_ADDR_ARRAY(bssId.bytes));
3614 }
3615
3616 return status;
3617}
3618
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303619QDF_STATUS csr_roam_save_connected_bss_desc(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003620 tSirBssDescription *pBssDesc)
3621{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303622 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
3624 uint32_t size;
3625
3626 if (!pSession) {
3627 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303628 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 }
3630 /* If no BSS description was found in this connection (happens with start IBSS), then */
3631 /* nix the BSS description that we keep around for the connected BSS) and get out... */
3632 if (NULL == pBssDesc) {
3633 csr_free_connect_bss_desc(pMac, sessionId);
3634 } else {
3635 size = pBssDesc->length + sizeof(pBssDesc->length);
3636 if (NULL != pSession->pConnectBssDesc) {
3637 if (((pSession->pConnectBssDesc->length) +
3638 sizeof(pSession->pConnectBssDesc->length)) <
3639 size) {
3640 /* not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside */
3641 csr_free_connect_bss_desc(pMac, sessionId);
3642 }
3643 }
3644 if (NULL == pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303645 pSession->pConnectBssDesc = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003646 }
3647 if (NULL == pSession->pConnectBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303648 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649 else
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303650 qdf_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 }
3652 return status;
3653}
3654
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303655QDF_STATUS csr_roam_prepare_bss_config(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003656 tCsrRoamProfile *pProfile,
3657 tSirBssDescription *pBssDesc,
3658 tBssConfigParam *pBssConfig,
3659 tDot11fBeaconIEs *pIes)
3660{
3661 eCsrCfgDot11Mode cfgDot11Mode;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303662 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003663 if (pIes == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303664 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003665
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303666 qdf_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003667 sizeof(tSirMacCapabilityInfo));
3668 /* get qos */
3669 pBssConfig->qosType = csr_get_qo_s_from_bss_desc(pMac, pBssDesc, pIes);
3670 /* get SSID */
3671 if (pIes->SSID.present) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303672 qdf_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 pIes->SSID.num_ssid);
3674 pBssConfig->SSID.length = pIes->SSID.num_ssid;
3675 } else
3676 pBssConfig->SSID.length = 0;
3677 if (csr_is_nullssid(pBssConfig->SSID.ssId, pBssConfig->SSID.length)) {
3678 sms_log(pMac, LOGW, FL("BSS desc SSID is a wild card"));
3679 /* Return failed if profile doesn't have an SSID either. */
3680 if (pProfile->SSIDs.numOfSSIDs == 0) {
3681 sms_log(pMac, LOGW,
3682 FL("BSS desc and profile doesn't have SSID"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303683 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684 }
3685 }
3686 if (CDS_IS_CHANNEL_5GHZ(pBssDesc->channelId))
3687 pBssConfig->eBand = eCSR_BAND_5G;
3688 else
3689 pBssConfig->eBand = eCSR_BAND_24;
3690 /* phymode */
3691 if (csr_is_phy_mode_match(pMac, pProfile->phyMode, pBssDesc,
3692 pProfile, &cfgDot11Mode, pIes)) {
3693 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3694 } else {
3695 sms_log(pMac, LOGW, "Can not find match phy mode");
3696 /* force it */
3697 if (eCSR_BAND_24 == pBssConfig->eBand)
3698 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3699 else
3700 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3701 }
3702 /* Qos */
3703 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3704 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos)) {
3705 /*
3706 * Joining BSS is not 11n capable and WMM is disabled on client.
3707 * Disable QoS and WMM
3708 */
3709 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3710 }
3711
3712 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N)
3713 || (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC))
3714 && ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP)
3715 || (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF)
3716 || (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF))) {
3717 /* Joining BSS is 11n capable and WMM is disabled on AP. */
3718 /* Assume all HT AP's are QOS AP's and enable WMM */
3719 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3720 }
3721 /* auth type */
3722 switch (pProfile->negotiatedAuthType) {
3723 default:
3724 case eCSR_AUTH_TYPE_WPA:
3725 case eCSR_AUTH_TYPE_WPA_PSK:
3726 case eCSR_AUTH_TYPE_WPA_NONE:
3727 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3728 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3729 break;
3730 case eCSR_AUTH_TYPE_SHARED_KEY:
3731 pBssConfig->authType = eSIR_SHARED_KEY;
3732 break;
3733 case eCSR_AUTH_TYPE_AUTOSWITCH:
3734 pBssConfig->authType = eSIR_AUTO_SWITCH;
3735 break;
3736 }
3737 /* short slot time */
3738 if (eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode)
3739 pBssConfig->uShortSlotTime =
3740 pMac->roam.configParam.shortSlotTime;
3741 else
3742 pBssConfig->uShortSlotTime = 0;
3743
3744 if (pBssConfig->BssCap.ibss)
3745 /* We don't support 11h on IBSS */
3746 pBssConfig->f11hSupport = false;
3747 else
3748 pBssConfig->f11hSupport =
3749 pMac->roam.configParam.Is11hSupportEnabled;
3750 /* power constraint */
3751 pBssConfig->uPowerLimit =
3752 csr_get11h_power_constraint(pMac, &pIes->PowerConstraints);
3753 /* heartbeat */
3754 if (CSR_IS_11A_BSS(pBssDesc))
3755 pBssConfig->uHeartBeatThresh =
3756 pMac->roam.configParam.HeartbeatThresh50;
3757 else
3758 pBssConfig->uHeartBeatThresh =
3759 pMac->roam.configParam.HeartbeatThresh24;
3760
3761 /*
3762 * Join timeout: if we find a BeaconInterval in the BssDescription,
3763 * then set the Join Timeout to be 10 x the BeaconInterval.
3764 */
3765 if (pBssDesc->beaconInterval)
3766 /* Make sure it is bigger than the minimal */
3767 pBssConfig->uJoinTimeOut =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303768 QDF_MAX(10 * pBssDesc->beaconInterval,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003769 CSR_JOIN_FAILURE_TIMEOUT_MIN);
3770 else
3771 pBssConfig->uJoinTimeOut =
3772 CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3773 /* validate CB */
3774 pBssConfig->cbMode = csr_get_cb_mode_from_ies(pMac, pBssDesc->channelId,
3775 pIes);
3776
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303777 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778}
3779
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303780static QDF_STATUS csr_roam_prepare_bss_config_from_profile(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781 tCsrRoamProfile *pProfile,
3782 tBssConfigParam *
3783 pBssConfig,
3784 tSirBssDescription *
3785 pBssDesc)
3786{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303787 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788 uint8_t operationChannel = 0;
3789 uint8_t qAPisEnabled = false;
3790 /* SSID */
3791 pBssConfig->SSID.length = 0;
3792 if (pProfile->SSIDs.numOfSSIDs) {
3793 /* only use the first one */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303794 qdf_mem_copy(&pBssConfig->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795 &pProfile->SSIDs.SSIDList[0].SSID,
3796 sizeof(tSirMacSSid));
3797 } else {
3798 /* SSID must present */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303799 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800 }
3801 /* Settomg up the capabilities */
3802 if (csr_is_bss_type_ibss(pProfile->BSSType)) {
3803 pBssConfig->BssCap.ibss = 1;
3804 } else {
3805 pBssConfig->BssCap.ess = 1;
3806 }
3807 if (eCSR_ENCRYPT_TYPE_NONE !=
3808 pProfile->EncryptionType.encryptionType[0]) {
3809 pBssConfig->BssCap.privacy = 1;
3810 }
3811 pBssConfig->eBand = pMac->roam.configParam.eBand;
3812 /* phymode */
3813 if (pProfile->ChannelInfo.ChannelList) {
3814 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3815 }
3816 pBssConfig->uCfgDot11Mode =
3817 csr_roam_get_phy_mode_band_for_bss(pMac, pProfile, operationChannel,
3818 &pBssConfig->eBand);
3819 /* QOS */
3820 /* Is this correct to always set to this // *** */
3821 if (pBssConfig->BssCap.ess == 1) {
3822 /*For Softap case enable WMM */
3823 if (CSR_IS_INFRA_AP(pProfile)
3824 && (eCsrRoamWmmNoQos !=
3825 pMac->roam.configParam.WMMSupportMode)) {
3826 qAPisEnabled = true;
3827 } else
3828 if (csr_roam_get_qos_info_from_bss(pMac, pBssDesc) ==
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303829 QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003830 qAPisEnabled = true;
3831 } else {
3832 qAPisEnabled = false;
3833 }
3834 } else {
3835 qAPisEnabled = true;
3836 }
3837 if ((eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode &&
3838 qAPisEnabled) ||
3839 ((eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode &&
3840 qAPisEnabled))) {
3841 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3842 } else {
3843 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3844 }
3845
3846 /* auth type */
3847 /* Take the preferred Auth type. */
3848 switch (pProfile->AuthType.authType[0]) {
3849 default:
3850 case eCSR_AUTH_TYPE_WPA:
3851 case eCSR_AUTH_TYPE_WPA_PSK:
3852 case eCSR_AUTH_TYPE_WPA_NONE:
3853 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3854 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3855 break;
3856 case eCSR_AUTH_TYPE_SHARED_KEY:
3857 pBssConfig->authType = eSIR_SHARED_KEY;
3858 break;
3859 case eCSR_AUTH_TYPE_AUTOSWITCH:
3860 pBssConfig->authType = eSIR_AUTO_SWITCH;
3861 break;
3862 }
3863 /* short slot time */
3864 if (WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode) {
3865 pBssConfig->uShortSlotTime =
3866 pMac->roam.configParam.shortSlotTime;
3867 } else {
3868 pBssConfig->uShortSlotTime = 0;
3869 }
3870 /* power constraint. We don't support 11h on IBSS */
3871 pBssConfig->f11hSupport = false;
3872 pBssConfig->uPowerLimit = 0;
3873 /* heartbeat */
3874 if (eCSR_BAND_5G == pBssConfig->eBand) {
3875 pBssConfig->uHeartBeatThresh =
3876 pMac->roam.configParam.HeartbeatThresh50;
3877 } else {
3878 pBssConfig->uHeartBeatThresh =
3879 pMac->roam.configParam.HeartbeatThresh24;
3880 }
3881 /* Join timeout */
3882 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3883
3884 return status;
3885}
3886
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303887static QDF_STATUS csr_roam_get_qos_info_from_bss(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888 tSirBssDescription *pBssDesc)
3889{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303890 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003891 tDot11fBeaconIEs *pIes = NULL;
3892
3893 do {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303894 if (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895 csr_get_parsed_bss_description_ies(
3896 pMac, pBssDesc, &pIes))) {
3897 /* err msg */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303898 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003899 "csr_roam_get_qos_info_from_bss() failed");
3900 break;
3901 }
3902 /* check if the AP is QAP & it supports APSD */
3903 if (CSR_IS_QOS_BSS(pIes)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303904 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003905 }
3906 } while (0);
3907
3908 if (NULL != pIes) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303909 qdf_mem_free(pIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003910 }
3911
3912 return status;
3913}
3914
3915void csr_set_cfg_privacy(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3916 bool fPrivacy)
3917{
3918 /*
3919 * the only difference between this function and
3920 * the csr_set_cfg_privacyFromProfile() is the setting of the privacy
3921 * CFG based on the advertised privacy setting from the AP for WPA
3922 * associations. See note below in this function...
3923 */
3924 uint32_t PrivacyEnabled = 0, RsnEnabled = 0, WepDefaultKeyId = 0;
3925 uint32_t WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3926 uint32_t Key0Length = 0, Key1Length = 0, Key2Length = 0, Key3Length = 0;
3927
3928 /* Reserve for the biggest key */
3929 uint8_t Key0[WNI_CFG_WEP_DEFAULT_KEY_1_LEN];
3930 uint8_t Key1[WNI_CFG_WEP_DEFAULT_KEY_2_LEN];
3931 uint8_t Key2[WNI_CFG_WEP_DEFAULT_KEY_3_LEN];
3932 uint8_t Key3[WNI_CFG_WEP_DEFAULT_KEY_4_LEN];
3933
3934 switch (pProfile->negotiatedUCEncryptionType) {
3935 case eCSR_ENCRYPT_TYPE_NONE:
3936 /* for NO encryption, turn off Privacy and Rsn. */
3937 PrivacyEnabled = 0;
3938 RsnEnabled = 0;
3939 /* clear out the WEP keys that may be hanging around. */
3940 Key0Length = 0;
3941 Key1Length = 0;
3942 Key2Length = 0;
3943 Key3Length = 0;
3944 break;
3945
3946 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3947 case eCSR_ENCRYPT_TYPE_WEP40:
3948
3949 /* Privacy is ON. NO RSN for Wep40 static key. */
3950 PrivacyEnabled = 1;
3951 RsnEnabled = 0;
3952 /* Set the Wep default key ID. */
3953 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3954 /* Wep key size if 5 bytes (40 bits). */
3955 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3956 /*
3957 * set encryption keys in the CFG database or
3958 * clear those that are not present in this profile.
3959 */
3960 if (pProfile->Keys.KeyLength[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303961 qdf_mem_copy(Key0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003962 pProfile->Keys.KeyMaterial[0],
3963 WNI_CFG_WEP_KEY_LENGTH_5);
3964 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3965 } else {
3966 Key0Length = 0;
3967 }
3968
3969 if (pProfile->Keys.KeyLength[1]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303970 qdf_mem_copy(Key1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003971 pProfile->Keys.KeyMaterial[1],
3972 WNI_CFG_WEP_KEY_LENGTH_5);
3973 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
3974 } else {
3975 Key1Length = 0;
3976 }
3977
3978 if (pProfile->Keys.KeyLength[2]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303979 qdf_mem_copy(Key2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003980 pProfile->Keys.KeyMaterial[2],
3981 WNI_CFG_WEP_KEY_LENGTH_5);
3982 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3983 } else {
3984 Key2Length = 0;
3985 }
3986
3987 if (pProfile->Keys.KeyLength[3]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303988 qdf_mem_copy(Key3,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003989 pProfile->Keys.KeyMaterial[3],
3990 WNI_CFG_WEP_KEY_LENGTH_5);
3991 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3992 } else {
3993 Key3Length = 0;
3994 }
3995 break;
3996
3997 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3998 case eCSR_ENCRYPT_TYPE_WEP104:
3999
4000 /* Privacy is ON. NO RSN for Wep40 static key. */
4001 PrivacyEnabled = 1;
4002 RsnEnabled = 0;
4003 /* Set the Wep default key ID. */
4004 WepDefaultKeyId = pProfile->Keys.defaultIndex;
4005 /* Wep key size if 13 bytes (104 bits). */
4006 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
4007 /*
4008 * set encryption keys in the CFG database or clear
4009 * those that are not present in this profile.
4010 */
4011 if (pProfile->Keys.KeyLength[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304012 qdf_mem_copy(Key0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004013 pProfile->Keys.KeyMaterial[0],
4014 WNI_CFG_WEP_KEY_LENGTH_13);
4015 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
4016 } else {
4017 Key0Length = 0;
4018 }
4019
4020 if (pProfile->Keys.KeyLength[1]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304021 qdf_mem_copy(Key1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004022 pProfile->Keys.KeyMaterial[1],
4023 WNI_CFG_WEP_KEY_LENGTH_13);
4024 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
4025 } else {
4026 Key1Length = 0;
4027 }
4028
4029 if (pProfile->Keys.KeyLength[2]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304030 qdf_mem_copy(Key2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004031 pProfile->Keys.KeyMaterial[2],
4032 WNI_CFG_WEP_KEY_LENGTH_13);
4033 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
4034 } else {
4035 Key2Length = 0;
4036 }
4037
4038 if (pProfile->Keys.KeyLength[3]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304039 qdf_mem_copy(Key3,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004040 pProfile->Keys.KeyMaterial[3],
4041 WNI_CFG_WEP_KEY_LENGTH_13);
4042 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
4043 } else {
4044 Key3Length = 0;
4045 }
4046 break;
4047
4048 case eCSR_ENCRYPT_TYPE_TKIP:
4049 case eCSR_ENCRYPT_TYPE_AES:
4050#ifdef FEATURE_WLAN_WAPI
4051 case eCSR_ENCRYPT_TYPE_WPI:
4052#endif /* FEATURE_WLAN_WAPI */
4053 /*
4054 * this is the only difference between this function and
4055 * the csr_set_cfg_privacyFromProfile().
4056 * (setting of the privacy CFG based on the advertised
4057 * privacy setting from AP for WPA/WAPI associations).
4058 */
4059 PrivacyEnabled = (0 != fPrivacy);
4060 /* turn on RSN enabled for WPA associations */
4061 RsnEnabled = 1;
4062 /* clear static WEP keys that may be hanging around. */
4063 Key0Length = 0;
4064 Key1Length = 0;
4065 Key2Length = 0;
4066 Key3Length = 0;
4067 break;
4068 default:
4069 PrivacyEnabled = 0;
4070 RsnEnabled = 0;
4071 break;
4072 }
4073
4074 cfg_set_int(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled);
4075 cfg_set_int(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled);
4076 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length);
4077 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length);
4078 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length);
4079 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length);
4080 cfg_set_int(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength);
4081 cfg_set_int(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId);
4082}
4083
4084static void csr_set_cfg_ssid(tpAniSirGlobal pMac, tSirMacSSid *pSSID)
4085{
4086 uint32_t len = 0;
4087 if (pSSID->length <= WNI_CFG_SSID_LEN) {
4088 len = pSSID->length;
4089 }
4090 cfg_set_str(pMac, WNI_CFG_SSID, (uint8_t *) pSSID->ssId, len);
4091}
4092
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304093QDF_STATUS csr_set_qos_to_cfg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094 eCsrMediaAccessType qosType)
4095{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304096 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004097 uint32_t QoSEnabled;
4098 uint32_t WmeEnabled;
4099 /* set the CFG enable/disable variables based on the qosType being configured... */
4100 switch (qosType) {
4101 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
4102 QoSEnabled = false;
4103 WmeEnabled = true;
4104 break;
4105 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
4106 QoSEnabled = false;
4107 WmeEnabled = true;
4108 break;
4109 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
4110 QoSEnabled = false;
4111 WmeEnabled = true;
4112 break;
4113 case eCSR_MEDIUM_ACCESS_11e_eDCF:
4114 QoSEnabled = true;
4115 WmeEnabled = false;
4116 break;
4117 case eCSR_MEDIUM_ACCESS_11e_HCF:
4118 QoSEnabled = true;
4119 WmeEnabled = false;
4120 break;
4121 default:
4122 case eCSR_MEDIUM_ACCESS_DCF:
4123 QoSEnabled = false;
4124 WmeEnabled = false;
4125 break;
4126 }
4127 /* save the WMM setting for later use */
4128 pMac->roam.roamSession[sessionId].fWMMConnection = (bool) WmeEnabled;
4129 pMac->roam.roamSession[sessionId].fQOSConnection = (bool) QoSEnabled;
4130 return status;
4131}
4132
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304133static QDF_STATUS csr_get_rate_set(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134 tCsrRoamProfile *pProfile, eCsrPhyMode phyMode,
4135 tSirBssDescription *pBssDesc,
4136 tDot11fBeaconIEs *pIes,
4137 tSirMacRateSet *pOpRateSet,
4138 tSirMacRateSet *pExRateSet)
4139{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304140 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004141 int i;
4142 eCsrCfgDot11Mode cfgDot11Mode;
4143 uint8_t *pDstRate;
4144 uint16_t rateBitmap = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304145 qdf_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
4146 qdf_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304147 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148
4149 if (NULL == pIes) {
4150 sms_log(pMac, LOGE, FL("failed to parse BssDesc"));
4151 return status;
4152 }
4153
4154 csr_is_phy_mode_match(pMac, phyMode, pBssDesc, pProfile,
4155 &cfgDot11Mode, pIes);
4156 /*
4157 * Originally, we thought that for 11a networks, the 11a rates
4158 * are always in the Operational Rate set & for 11b and 11g
4159 * networks, the 11b rates appear in the Operational Rate set.
4160 * Consequently, in either case, we would blindly put the rates
4161 * we support into our Operational Rate set.
4162 * (including the basic rates, which we've already verified are
4163 * supported earlier in the roaming decision).
4164 * However, it turns out that this is not always the case.
4165 * Some AP's (e.g. D-Link DI-784) ram 11g rates into the
4166 * Operational Rate set too. Now, we're a little more careful.
4167 */
4168 pDstRate = pOpRateSet->rate;
4169 if (pIes->SuppRates.present) {
4170 for (i = 0; i < pIes->SuppRates.num_rates; i++) {
4171 if (csr_rates_is_dot11_rate_supported(pMac,
4172 pIes->SuppRates.rates[i]) &&
4173 !csr_check_rate_bitmap(
4174 pIes->SuppRates.rates[i],
4175 rateBitmap)) {
4176 csr_add_rate_bitmap(pIes->SuppRates.
4177 rates[i], &rateBitmap);
4178 *pDstRate++ = pIes->SuppRates.rates[i];
4179 pOpRateSet->numRates++;
4180 }
4181 }
4182 }
Abhishek Singh10112382015-12-03 16:06:59 +05304183 /*
4184 * If there are Extended Rates in the beacon, we will reflect the
4185 * extended rates that we support in our Extended Operational Rate
4186 * set.
4187 */
4188 if (pIes->ExtSuppRates.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004189 pDstRate = pExRateSet->rate;
4190 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++) {
4191 if (csr_rates_is_dot11_rate_supported(pMac,
4192 pIes->ExtSuppRates.rates[i]) &&
4193 !csr_check_rate_bitmap(
4194 pIes->ExtSuppRates.rates[i],
4195 rateBitmap)) {
4196 *pDstRate++ = pIes->ExtSuppRates.rates[i];
4197 pExRateSet->numRates++;
4198 }
4199 }
4200 }
4201 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304202 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203 return status;
4204}
4205
4206static void csr_set_cfg_rate_set(tpAniSirGlobal pMac, eCsrPhyMode phyMode,
4207 tCsrRoamProfile *pProfile,
4208 tSirBssDescription *pBssDesc,
4209 tDot11fBeaconIEs *pIes)
4210{
4211 int i;
4212 uint8_t *pDstRate;
4213 eCsrCfgDot11Mode cfgDot11Mode;
4214 uint8_t OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; /* leave enough room for the max number of rates */
4215 uint32_t OperationalRatesLength = 0;
4216 uint8_t ExtendedOperationalRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; /* leave enough room for the max number of rates */
4217 uint32_t ExtendedOperationalRatesLength = 0;
4218 uint8_t MCSRateIdxSet[SIZE_OF_SUPPORTED_MCS_SET];
4219 uint32_t MCSRateLength = 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304220 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004221 if (NULL != pIes) {
4222 csr_is_phy_mode_match(pMac, phyMode, pBssDesc, pProfile,
4223 &cfgDot11Mode, pIes);
4224 /* Originally, we thought that for 11a networks, the 11a rates are always */
4225 /* in the Operational Rate set & for 11b and 11g networks, the 11b rates */
4226 /* appear in the Operational Rate set. Consequently, in either case, we */
4227 /* would blindly put the rates we support into our Operational Rate set */
4228 /* (including the basic rates, which we have already verified are */
4229 /* supported earlier in the roaming decision). */
4230 /* However, it turns out that this is not always the case. Some AP's */
4231 /* (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set, */
4232 /* too. Now, we're a little more careful: */
4233 pDstRate = OperationalRates;
4234 if (pIes->SuppRates.present) {
4235 for (i = 0; i < pIes->SuppRates.num_rates; i++) {
4236 if (csr_rates_is_dot11_rate_supported
4237 (pMac, pIes->SuppRates.rates[i])
4238 && (OperationalRatesLength <
4239 CSR_DOT11_SUPPORTED_RATES_MAX)) {
4240 *pDstRate++ = pIes->SuppRates.rates[i];
4241 OperationalRatesLength++;
4242 }
4243 }
4244 }
4245 if (eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
4246 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
4247 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) {
4248 /* If there are Extended Rates in the beacon, we will reflect those */
4249 /* extended rates that we support in out Extended Operational Rate */
4250 /* set: */
4251 pDstRate = ExtendedOperationalRates;
4252 if (pIes->ExtSuppRates.present) {
4253 for (i = 0; i < pIes->ExtSuppRates.num_rates;
4254 i++) {
4255 if (csr_rates_is_dot11_rate_supported
4256 (pMac, pIes->ExtSuppRates.rates[i])
4257 && (ExtendedOperationalRatesLength <
4258 CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX)) {
4259 *pDstRate++ =
4260 pIes->ExtSuppRates.rates[i];
4261 ExtendedOperationalRatesLength++;
4262 }
4263 }
4264 }
4265 }
4266 /* Enable proprietary MAC features if peer node is Airgo node and STA */
4267 /* user wants to use them */
4268 /* For ANI network companions, we need to populate the proprietary rate */
4269 /* set with any proprietary rates we found in the beacon, only if user */
4270 /* allows them... */
4271 /* No proprietary modes... */
4272 /* Get MCS Rate */
4273 pDstRate = MCSRateIdxSet;
4274 if (pIes->HTCaps.present) {
4275 for (i = 0; i < VALID_MAX_MCS_INDEX; i++) {
4276 if ((unsigned int)pIes->HTCaps.
4277 supportedMCSSet[0] & (1 << i)) {
4278 MCSRateLength++;
4279 *pDstRate++ = i;
4280 }
4281 }
4282 }
4283 /* Set the operational rate set CFG variables... */
4284 cfg_set_str(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
4285 OperationalRates, OperationalRatesLength);
4286 cfg_set_str(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
4287 ExtendedOperationalRates,
4288 ExtendedOperationalRatesLength);
4289 cfg_set_str(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
4290 MCSRateLength);
4291 } /* Parsing BSSDesc */
4292 else {
4293 sms_log(pMac, LOGE, FL("failed to parse BssDesc"));
4294 }
4295}
4296
4297static void csr_set_cfg_rate_set_from_profile(tpAniSirGlobal pMac,
4298 tCsrRoamProfile *pProfile)
4299{
4300 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
4301 {8,
4302 {SIR_MAC_RATE_6,
4303 SIR_MAC_RATE_9,
4304 SIR_MAC_RATE_12,
4305 SIR_MAC_RATE_18,
4306 SIR_MAC_RATE_24,
4307 SIR_MAC_RATE_36,
4308 SIR_MAC_RATE_48,
4309 SIR_MAC_RATE_54} } };
4310 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
4311 {4,
4312 {SIR_MAC_RATE_1,
4313 SIR_MAC_RATE_2,
4314 SIR_MAC_RATE_5_5,
4315 SIR_MAC_RATE_11} } };
4316
4317 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
4318 {SIR_MAC_RATE_72,
4319 SIR_MAC_RATE_96,
4320 SIR_MAC_RATE_108} };
4321 eCsrCfgDot11Mode cfgDot11Mode;
4322 eCsrBand eBand;
4323 /* leave enough room for the max number of rates */
4324 uint8_t OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
4325 uint32_t OperationalRatesLength = 0;
4326 /* leave enough room for the max number of rates */
4327 uint8_t ExtendedOperationalRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
4328 uint32_t ExtendedOperationalRatesLength = 0;
4329 /* leave enough room for the max number of proprietary rates */
4330 uint8_t ProprietaryOperationalRates[4];
4331 uint32_t ProprietaryOperationalRatesLength = 0;
4332 uint32_t PropRatesEnable = 0;
4333 uint8_t operationChannel = 0;
4334 if (pProfile->ChannelInfo.ChannelList) {
4335 operationChannel = pProfile->ChannelInfo.ChannelList[0];
4336 }
4337 cfgDot11Mode =
4338 csr_roam_get_phy_mode_band_for_bss(pMac, pProfile, operationChannel,
4339 &eBand);
4340 /* For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g */
4341 /* networks, the 11b rates appear in the Operational Rate set. In either case, */
4342 /* we can blindly put the rates we support into our Operational Rate set */
4343 /* (including the basic rates, which we have already verified are supported */
4344 /* earlier in the roaming decision). */
4345 if (eCSR_BAND_5G == eBand) {
4346 /* 11a rates into the Operational Rate Set. */
4347 OperationalRatesLength =
4348 DefaultSupportedRates11a.supportedRateSet.numRates *
4349 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304350 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004351 DefaultSupportedRates11a.supportedRateSet.rate,
4352 OperationalRatesLength);
4353
4354 /* Nothing in the Extended rate set. */
4355 ExtendedOperationalRatesLength = 0;
4356 /* populate proprietary rates if user allows them */
4357 if (pMac->roam.configParam.ProprietaryRatesEnabled) {
4358 ProprietaryOperationalRatesLength =
4359 DefaultSupportedPropRates.numPropRates *
4360 sizeof(*DefaultSupportedPropRates.propRate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304361 qdf_mem_copy(ProprietaryOperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004362 DefaultSupportedPropRates.propRate,
4363 ProprietaryOperationalRatesLength);
4364 } else {
4365 /* No proprietary modes */
4366 ProprietaryOperationalRatesLength = 0;
4367 }
4368 } else if (eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode) {
4369 /* 11b rates into the Operational Rate Set. */
4370 OperationalRatesLength =
4371 DefaultSupportedRates11b.supportedRateSet.numRates *
4372 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304373 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374 DefaultSupportedRates11b.supportedRateSet.rate,
4375 OperationalRatesLength);
4376 /* Nothing in the Extended rate set. */
4377 ExtendedOperationalRatesLength = 0;
4378 /* No proprietary modes */
4379 ProprietaryOperationalRatesLength = 0;
4380 } else {
4381 /* 11G */
4382
4383 /* 11b rates into the Operational Rate Set. */
4384 OperationalRatesLength =
4385 DefaultSupportedRates11b.supportedRateSet.numRates *
4386 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304387 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004388 DefaultSupportedRates11b.supportedRateSet.rate,
4389 OperationalRatesLength);
4390
4391 /* 11a rates go in the Extended rate set. */
4392 ExtendedOperationalRatesLength =
4393 DefaultSupportedRates11a.supportedRateSet.numRates *
4394 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304395 qdf_mem_copy(ExtendedOperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004396 DefaultSupportedRates11a.supportedRateSet.rate,
4397 ExtendedOperationalRatesLength);
4398
4399 /* populate proprietary rates if user allows them */
4400 if (pMac->roam.configParam.ProprietaryRatesEnabled) {
4401 ProprietaryOperationalRatesLength =
4402 DefaultSupportedPropRates.numPropRates *
4403 sizeof(*DefaultSupportedPropRates.propRate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304404 qdf_mem_copy(ProprietaryOperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004405 DefaultSupportedPropRates.propRate,
4406 ProprietaryOperationalRatesLength);
4407 } else {
4408 /* No proprietary modes */
4409 ProprietaryOperationalRatesLength = 0;
4410 }
4411 }
4412 /* set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them */
4413 if (ProprietaryOperationalRatesLength
4414 && pMac->roam.configParam.ProprietaryRatesEnabled) {
4415 PropRatesEnable = 1;
4416 } else {
4417 PropRatesEnable = 0;
4418 }
4419
4420 /* Set the operational rate set CFG variables... */
4421 cfg_set_str(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
4422 OperationalRatesLength);
4423 cfg_set_str(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
4424 ExtendedOperationalRates, ExtendedOperationalRatesLength);
4425 cfg_set_str(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
4426 ProprietaryOperationalRates,
4427 ProprietaryOperationalRatesLength);
4428}
4429
4430void csr_roam_ccm_cfg_set_callback(tpAniSirGlobal pMac, int32_t result)
4431{
4432 tListElem *pEntry =
4433 csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
4434 uint32_t sessionId;
4435 tSmeCmd *pCommand = NULL;
4436#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4437 tCsrRoamSession *pSession = NULL;
4438#endif
4439 if (NULL == pEntry) {
4440 sms_log(pMac, LOGW, "CFG_CNF with active list empty");
4441 return;
4442 }
4443 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
4444 sessionId = pCommand->sessionId;
4445#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4446 pSession = &pMac->roam.roamSession[sessionId];
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08004447 if (pSession->roam_synch_in_progress) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304448 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449 "LFR3:csr_roam_cfg_set_callback");
4450 }
4451#endif
4452
4453 if (CSR_IS_ROAM_JOINING(pMac, sessionId)
4454 && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId)) {
4455 csr_roaming_state_config_cnf_processor(pMac, (uint32_t) result);
4456 }
4457}
4458
4459/* This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE */
4460uint32_t csr_roam_get_phy_mode_from_dot11_mode(eCsrCfgDot11Mode dot11Mode,
4461 eCsrBand band)
4462{
4463 if (eCSR_CFG_DOT11_MODE_11B == dot11Mode) {
4464 return WNI_CFG_PHY_MODE_11B;
4465 } else {
4466 if (eCSR_BAND_24 == band)
4467 return WNI_CFG_PHY_MODE_11G;
4468 }
4469 return WNI_CFG_PHY_MODE_11A;
4470}
4471
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004472ePhyChanBondState csr_get_htcb_state_from_vhtcb_state(ePhyChanBondState aniCBMode)
4473{
4474 switch (aniCBMode) {
4475 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
4476 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
4477 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
4478 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4479 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
4480 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
4481 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
4482 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4483 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
4484 default:
4485 return PHY_SINGLE_CHANNEL_CENTERED;
4486 }
4487}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004488
4489/* pIes may be NULL */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304490QDF_STATUS csr_roam_set_bss_config_cfg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 tCsrRoamProfile *pProfile,
4492 tSirBssDescription *pBssDesc,
4493 tBssConfigParam *pBssConfig,
4494 tDot11fBeaconIEs *pIes, bool resetCountry)
4495{
4496 tSirRetStatus status;
4497 uint32_t cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4498 uint8_t channel = 0;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08004499 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
4500
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501 /* Make sure we have the domain info for the BSS we try to connect to. */
4502 /* Do we need to worry about sequence for OSs that are not Windows?? */
4503 if (pBssDesc) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05304504 if ((QDF_SAP_MODE !=
Peng Xuf5d60c82015-10-02 17:17:03 -07004505 csr_get_session_persona(pMac, sessionId)) &&
4506 csr_learn_11dcountry_information(
4507 pMac, pBssDesc, pIes, true)) {
4508 csr_apply_country_information(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509 }
4510 if ((csr_is11d_supported(pMac)) && pIes) {
4511 if (!pIes->Country.present) {
4512 csr_apply_channel_power_info_wrapper(pMac);
4513 } else {
4514 /* Let's also update the below to make sure we don't update CC while */
4515 /* connected to an AP which is advertising some CC */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304516 qdf_mem_copy(pMac->scan.currentCountryBssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004517 pBssDesc->bssId,
4518 sizeof(tSirMacAddr));
4519 }
4520 }
4521 }
4522 /* Qos */
4523 csr_set_qos_to_cfg(pMac, sessionId, pBssConfig->qosType);
4524 /* SSID */
4525 csr_set_cfg_ssid(pMac, &pBssConfig->SSID);
4526
4527 /* Auth type */
4528 cfg_set_int(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType);
4529 /* encryption type */
4530 csr_set_cfg_privacy(pMac, pProfile, (bool) pBssConfig->BssCap.privacy);
4531 /* short slot time */
4532 cfg_set_int(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED,
4533 pBssConfig->uShortSlotTime);
4534 /* 11d */
4535 cfg_set_int(pMac, WNI_CFG_11D_ENABLED,
4536 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport :
4537 pProfile->ieee80211d));
4538 cfg_set_int(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT,
4539 pBssConfig->uPowerLimit);
4540 /* CB */
4541
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07004542 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_IBSS(pProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543 channel = pProfile->operationChannel;
4544 } else {
4545 if (pBssDesc) {
4546 channel = pBssDesc->channelId;
4547 }
4548 }
4549 if (0 != channel) {
4550 if (CDS_IS_CHANNEL_24GHZ(channel)) { /* for now if we are on 2.4 Ghz, CB will be always disabled */
4551 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4552 } else {
4553 cfgCb = pBssConfig->cbMode;
4554 }
4555 }
4556 /* Rate */
4557 /* Fixed Rate */
4558 if (pBssDesc) {
4559 csr_set_cfg_rate_set(pMac, (eCsrPhyMode) pProfile->phyMode,
4560 pProfile, pBssDesc, pIes);
4561 } else {
4562 csr_set_cfg_rate_set_from_profile(pMac, pProfile);
4563 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08004564 status = cfg_set_int(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT,
4565 pBssConfig->uJoinTimeOut);
4566 /* Any roaming related changes should be above this line */
4567 if (pSession && pSession->roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304568 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569 /* Make this the last CFG to set. The callback will trigger a join_req */
4570 /* Join time out */
4571 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId);
4572
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573 csr_roam_ccm_cfg_set_callback(pMac, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304574 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004575}
4576
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304577QDF_STATUS csr_roam_stop_network(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578 tCsrRoamProfile *pProfile,
4579 tSirBssDescription *pBssDesc,
4580 tDot11fBeaconIEs *pIes)
4581{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304582 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583 tBssConfigParam *pBssConfig;
4584 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
4585
4586 if (!pSession) {
4587 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304588 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589 }
4590
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304591 pBssConfig = qdf_mem_malloc(sizeof(tBssConfigParam));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 if (NULL == pBssConfig)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304593 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304595 qdf_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004596 status = csr_roam_prepare_bss_config(pMac, pProfile, pBssDesc,
4597 pBssConfig, pIes);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304598 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004599 eCsrRoamSubState substate;
4600 substate = eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING;
4601 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
4602 /* This will allow to pass cbMode during join req */
4603 pSession->bssParams.cbMode = pBssConfig->cbMode;
4604 /* For IBSS, we need to prepare some more information */
4605 if (csr_is_bss_type_ibss(pProfile->BSSType) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606 CSR_IS_INFRA_AP(pProfile))
4607 csr_roam_prepare_bss_params(pMac, sessionId, pProfile,
4608 pBssDesc, pBssConfig, pIes);
4609
4610 /*
4611 * If we are in an IBSS, then stop the IBSS...
4612 * Not worry about WDS connection for now
4613 */
4614 if (csr_is_conn_state_ibss(pMac, sessionId)) {
4615 status = csr_roam_issue_stop_bss(pMac, sessionId,
4616 substate);
4617 } else if (csr_is_conn_state_infra(pMac, sessionId)) {
4618 /*
4619 * the new Bss is an Ibss OR we are roaming from
4620 * Infra to Infra across SSIDs
4621 * (roaming to a new SSID)...
4622 * Not worry about WDS connection for now
4623 */
4624 if (pBssDesc && (csr_is_ibss_bss_desc(pBssDesc) ||
4625 !csr_is_ssid_equal(pMac,
4626 pSession->pConnectBssDesc,
4627 pBssDesc, pIes)))
4628 status = csr_roam_issue_disassociate(pMac,
4629 sessionId, substate, false);
4630 else if (pBssDesc)
4631 /*
4632 * In an infra & going to an infra network with
4633 * the same SSID. This calls for a reassoc seq.
4634 * So issue the CFG sets for this new AP. Set
4635 * parameters for this Bss.
4636 */
4637 status = csr_roam_set_bss_config_cfg(pMac,
4638 sessionId, pProfile, pBssDesc,
4639 pBssConfig, pIes, false);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07004640 } else if (pBssDesc ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641 CSR_IS_INFRA_AP(pProfile)) {
4642 /*
4643 * Neither in IBSS nor in Infra. We can go ahead and set
4644 * the cfg for tne new network... nothing to stop.
4645 */
4646 bool is11rRoamingFlag = false;
4647 is11rRoamingFlag = csr_roam_is11r_assoc(pMac,
4648 sessionId);
4649 /* Set parameters for this Bss. */
4650 status = csr_roam_set_bss_config_cfg(pMac, sessionId,
4651 pProfile, pBssDesc, pBssConfig, pIes,
4652 is11rRoamingFlag);
4653 }
4654 } /* Success getting BSS config info */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304655 qdf_mem_free(pBssConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656 return status;
4657}
4658
4659/**
4660 * csr_roam_state_for_same_profile() - Determine roam state for same profile
4661 * @mac_ctx: pointer to mac context
4662 * @profile: Roam profile
4663 * @session: Roam session
4664 * @session_id: session id
4665 * @ies_local: local ies
4666 * @bss_descr: bss description
4667 *
4668 * This function will determine the roam state for same profile
4669 *
4670 * Return: Roaming state.
4671 */
4672static eCsrJoinState csr_roam_state_for_same_profile(tpAniSirGlobal mac_ctx,
4673 tCsrRoamProfile *profile, tCsrRoamSession *session,
4674 uint32_t session_id, tDot11fBeaconIEs *ies_local,
4675 tSirBssDescription *bss_descr)
4676{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304677 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678 tBssConfigParam bssConfig;
4679 if (csr_roam_is_same_profile_keys(mac_ctx, &session->connectedProfile,
4680 profile))
4681 return eCsrReassocToSelfNoCapChange;
4682 /* The key changes */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304683 qdf_mem_set(&bssConfig, sizeof(bssConfig), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 status = csr_roam_prepare_bss_config(mac_ctx, profile, bss_descr,
4685 &bssConfig, ies_local);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304686 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004687 session->bssParams.uCfgDot11Mode =
4688 bssConfig.uCfgDot11Mode;
4689 session->bssParams.cbMode =
4690 bssConfig.cbMode;
4691 /* reapply the cfg including keys so reassoc happens. */
4692 status = csr_roam_set_bss_config_cfg(mac_ctx, session_id,
4693 profile, bss_descr, &bssConfig,
4694 ies_local, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304695 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004696 return eCsrContinueRoaming;
4697 }
4698
4699 return eCsrStopRoaming;
4700
4701}
4702
4703eCsrJoinState csr_roam_join(tpAniSirGlobal pMac, uint32_t sessionId,
4704 tCsrScanResultInfo *pScanResult,
4705 tCsrRoamProfile *pProfile)
4706{
4707 eCsrJoinState eRoamState = eCsrContinueRoaming;
4708 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4709 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *) (pScanResult->pvIes);
4710 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
4711
4712 if (!pSession) {
4713 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
4714 return eCsrStopRoaming;
4715 }
4716
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717 if (!pIesLocal &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304718 !QDF_IS_STATUS_SUCCESS(csr_get_parsed_bss_description_ies(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004719 pBssDesc, &pIesLocal))) {
4720 sms_log(pMac, LOGE, FL("fail to parse IEs"));
4721 return eCsrStopRoaming;
4722 }
4723 if (csr_is_infra_bss_desc(pBssDesc)) {
4724 /*
4725 * If we are connected in infra mode and the join bss descr is
4726 * for the same BssID, then we are attempting to join the AP we
4727 * are already connected with. In that case, see if the Bss or
4728 * sta capabilities have changed and handle the changes
4729 * without disturbing the current association
4730 */
4731
4732 if (csr_is_conn_state_connected_infra(pMac, sessionId) &&
4733 csr_is_bss_id_equal(pMac,
4734 pBssDesc, pSession->pConnectBssDesc) &&
4735 csr_is_ssid_equal(pMac, pSession->pConnectBssDesc,
4736 pBssDesc, pIesLocal)) {
4737 /*
4738 * Check to see if the Auth type has changed in the
4739 * profile. If so, we don't want to reassociate with
4740 * authenticating first. To force this, stop the
4741 * current association (Disassociate) and then re 'Join'
4742 * the AP, wihch will force an Authentication (with the
4743 * new Auth type) followed by a new Association.
4744 */
4745 if (csr_is_same_profile(pMac,
4746 &pSession->connectedProfile, pProfile)) {
4747 sms_log(pMac, LOGW,
4748 FL("detect same profile"));
4749 eRoamState =
4750 csr_roam_state_for_same_profile(pMac,
4751 pProfile, pSession, sessionId,
4752 pIesLocal, pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304753 } else if (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 csr_roam_issue_disassociate(pMac,
4755 sessionId,
4756 eCSR_ROAM_SUBSTATE_DISASSOC_REQ,
4757 false))) {
4758 sms_log(pMac, LOGE,
4759 FL("fail disassoc session %d"),
4760 sessionId);
4761 eRoamState = eCsrStopRoaming;
4762 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304763 } else if (!QDF_IS_STATUS_SUCCESS(csr_roam_stop_network(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764 sessionId, pProfile, pBssDesc, pIesLocal))) {
4765 /* we used to pre-auth here with open auth
4766 * networks but that wasn't working so well.
4767 * stop the existing network before attempting
4768 * to join the new network... */
4769 eRoamState = eCsrStopRoaming;
4770 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304771 } else if (!QDF_IS_STATUS_SUCCESS(csr_roam_stop_network(pMac, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004772 pProfile, pBssDesc,
4773 pIesLocal))) {
4774 eRoamState = eCsrStopRoaming;
4775 }
4776
4777 if (pIesLocal && !pScanResult->pvIes)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304778 qdf_mem_free(pIesLocal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004779 return eRoamState;
4780}
4781
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304782QDF_STATUS csr_roam_should_roam(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004783 tSirBssDescription *pBssDesc, uint32_t roamId)
4784{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304785 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004786 tCsrRoamInfo roamInfo;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304787 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004788 roamInfo.pBssDesc = pBssDesc;
4789 status =
4790 csr_roam_call_callback(pMac, sessionId, &roamInfo, roamId,
4791 eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4792 return status;
4793}
4794
4795/* In case no matching BSS is found, use whatever default we can find */
4796static void csr_roam_assign_default_param(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4797{
4798 /* Need to get all negotiated types in place first */
4799 /* auth type */
4800 /* Take the preferred Auth type. */
4801 switch (pCommand->u.roamCmd.roamProfile.AuthType.authType[0]) {
4802 default:
4803 case eCSR_AUTH_TYPE_WPA:
4804 case eCSR_AUTH_TYPE_WPA_PSK:
4805 case eCSR_AUTH_TYPE_WPA_NONE:
4806 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4807 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
4808 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4809 break;
4810
4811 case eCSR_AUTH_TYPE_SHARED_KEY:
4812 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
4813 eCSR_AUTH_TYPE_SHARED_KEY;
4814 break;
4815
4816 case eCSR_AUTH_TYPE_AUTOSWITCH:
4817 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
4818 eCSR_AUTH_TYPE_AUTOSWITCH;
4819 break;
4820 }
4821 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4822 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4823 /* In this case, the multicast encryption needs to follow the uncast ones. */
4824 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4825 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4826}
4827
4828static void csr_set_abort_roaming_command(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4829{
4830 switch (pCommand->u.roamCmd.roamReason) {
4831 case eCsrLostLink1:
4832 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4833 break;
4834 case eCsrLostLink2:
4835 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4836 break;
4837 case eCsrLostLink3:
4838 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4839 break;
4840 default:
4841 sms_log(pMac, LOGE,
4842 FL(" aborting roaming reason %d not recognized"),
4843 pCommand->u.roamCmd.roamReason);
4844 break;
4845 }
4846}
4847
4848/**
4849 * csr_roam_select_bss() - Handle join scenario based on profile
4850 * @mac_ctx: Global MAC Context
4851 * @roam_bss_entry: The next BSS to join
4852 * @csr_result_info: Result of join
4853 * @csr_scan_result: Global scan result
4854 * @session_id: SME Session ID
4855 * @roam_id: Roaming ID
4856 * @roam_state: Current roaming state
4857 * @bss_list: BSS List
4858 *
4859 * Return: true if the entire BSS list is done, false otherwise.
4860 */
4861static bool csr_roam_select_bss(tpAniSirGlobal mac_ctx,
4862 tListElem *roam_bss_entry, tCsrScanResultInfo **csr_result_info,
4863 tCsrScanResult **csr_scan_result, uint32_t session_id,
4864 uint32_t roam_id, eCsrJoinState *roam_state,
4865 tScanResultList *bss_list)
4866{
4867 uint8_t conc_channel = 0;
4868 bool status = false;
4869 tCsrScanResult *scan_result = NULL;
4870 tCsrScanResultInfo *result = NULL;
4871
4872 while (roam_bss_entry) {
4873 scan_result = GET_BASE_ADDR(roam_bss_entry, tCsrScanResult,
4874 Link);
4875 /*
4876 * If concurrency enabled take the
4877 * concurrent connected channel first.
4878 * Valid multichannel concurrent
4879 * sessions exempted
4880 */
4881 result = &scan_result->Result;
4882 if (cds_concurrent_open_sessions_running() &&
4883 !csr_is_valid_mc_concurrent_session(mac_ctx,
4884 session_id, &result->BssDescriptor)) {
4885 conc_channel = csr_get_concurrent_operation_channel(
4886 mac_ctx);
4887 sms_log(mac_ctx, LOG1, FL("csr Conc Channel = %d"),
4888 conc_channel);
4889 if ((conc_channel) && (conc_channel ==
4890 result->BssDescriptor.channelId)) {
4891 /*
4892 * make this 0 because we do not want the below
4893 * check to pass as we don't want to connect on
4894 * other channel
4895 */
4896 sms_log(mac_ctx, LOG1, FL("Conc chnl match=%d"),
4897 conc_channel);
4898 conc_channel = 0;
4899 }
4900 }
4901
4902 /* Ok to roam this */
4903 if (!conc_channel &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304904 QDF_IS_STATUS_SUCCESS(csr_roam_should_roam(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004905 session_id, &result->BssDescriptor, roam_id))) {
4906 status = false;
4907 break;
4908 } else {
4909 *roam_state = eCsrStopRoamingDueToConcurrency;
4910 status = true;
4911 }
4912 roam_bss_entry = csr_ll_next(&bss_list->List, roam_bss_entry,
4913 LL_ACCESS_LOCK);
4914 }
4915 *csr_result_info = result;
4916 *csr_scan_result = scan_result;
4917 return status;
4918}
4919
4920/**
4921 * csr_roam_join_handle_profile() - Handle join scenario based on profile
4922 * @mac_ctx: Global MAC Context
4923 * @session_id: SME Session ID
4924 * @cmd: Command
4925 * @roam_info_ptr: Pointed to the roaming info for join
4926 * @roam_state: Current roaming state
4927 * @result: Result of join
4928 * @scan_result: Global scan result
4929 *
4930 * Return: None
4931 */
4932static void csr_roam_join_handle_profile(tpAniSirGlobal mac_ctx,
4933 uint32_t session_id, tSmeCmd *cmd, tCsrRoamInfo *roam_info_ptr,
4934 eCsrJoinState *roam_state, tCsrScanResultInfo *result,
4935 tCsrScanResult *scan_result)
4936{
4937#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4938 uint8_t acm_mask = 0;
4939#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304940 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
4942 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
4943 tDot11fBeaconIEs *ies_local = NULL;
4944 /*
4945 * We have something to roam, tell HDD when it is infra.
4946 * For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004947 */
4948 if (CSR_IS_INFRASTRUCTURE(profile)) {
4949 if (roam_info_ptr && session->bRefAssocStartCnt) {
4950 session->bRefAssocStartCnt--;
4951 roam_info_ptr->pProfile = profile;
4952 /*
4953 * Complete the last assoc attempt as a
4954 * new one is about to be tried
4955 */
4956 csr_roam_call_callback(mac_ctx, session_id,
4957 roam_info_ptr, cmd->u.roamCmd.roamId,
4958 eCSR_ROAM_ASSOCIATION_COMPLETION,
4959 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4960 }
4961 /* If roaming has stopped, don't continue the roaming command */
4962 if (!CSR_IS_ROAMING(session) && CSR_IS_ROAMING_COMMAND(cmd)) {
4963 /* No need to complete roaming as it already complete */
4964 sms_log(mac_ctx, LOGW,
4965 FL(
4966 "Roam cmd(reason %d)aborted as roam complete"),
4967 cmd->u.roamCmd.roamReason);
4968 *roam_state = eCsrStopRoaming;
4969 csr_set_abort_roaming_command(mac_ctx, cmd);
4970 return;
4971 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304972 qdf_mem_set(roam_info_ptr, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004973 if (!scan_result)
4974 cmd->u.roamCmd.roamProfile.uapsd_mask = 0;
4975 else
4976 ies_local = scan_result->Result.pvIes;
4977
4978 if (scan_result && !ies_local &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304979 (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004980 csr_get_parsed_bss_description_ies(
4981 mac_ctx,
4982 &result->BssDescriptor,
4983 &ies_local)))) {
4984 sms_log(mac_ctx, LOGE, FL(" cannot parse IEs"));
4985 *roam_state = eCsrStopRoaming;
4986 return;
4987 }
4988 roam_info_ptr->pBssDesc = &result->BssDescriptor;
4989 cmd->u.roamCmd.pLastRoamBss = roam_info_ptr->pBssDesc;
4990 /* dont put uapsd_mask if BSS doesn't support uAPSD */
4991 if (scan_result && cmd->u.roamCmd.roamProfile.uapsd_mask
4992 && CSR_IS_QOS_BSS(ies_local)
4993 && CSR_IS_UAPSD_BSS(ies_local)) {
4994#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4995 acm_mask = sme_qos_get_acm_mask(mac_ctx,
4996 &result->BssDescriptor, ies_local);
4997#endif /* WLAN_MDM_CODE_REDUCTION_OPT */
4998 } else {
4999 cmd->u.roamCmd.roamProfile.uapsd_mask = 0;
5000 }
5001 if (ies_local && !result->pvIes)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305002 qdf_mem_free(ies_local);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005003 roam_info_ptr->pProfile = profile;
5004 session->bRefAssocStartCnt++;
5005 csr_roam_call_callback(mac_ctx, session_id, roam_info_ptr,
5006 cmd->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_START,
5007 eCSR_ROAM_RESULT_NONE);
5008 }
5009 if (NULL != cmd->u.roamCmd.pRoamBssEntry) {
5010 /*
5011 * We have BSS
5012 * Need to assign these value because
5013 * they are used in csr_is_same_profile
5014 */
5015 scan_result = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
5016 tCsrScanResult, Link);
5017 /*
5018 * The OSEN IE doesn't provide the cipher suite.Therefore set
5019 * to constant value of AES
5020 */
5021 if (cmd->u.roamCmd.roamProfile.bOSENAssociation) {
5022 cmd->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
5023 eCSR_ENCRYPT_TYPE_AES;
5024 cmd->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
5025 eCSR_ENCRYPT_TYPE_AES;
5026 } else {
5027 /* Negotiated while building scan result. */
5028 cmd->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
5029 scan_result->ucEncryptionType;
5030 cmd->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
5031 scan_result->mcEncryptionType;
5032 }
5033 cmd->u.roamCmd.roamProfile.negotiatedAuthType =
5034 scan_result->authType;
5035 if (CSR_IS_START_IBSS(&cmd->u.roamCmd.roamProfile)) {
5036 if (csr_is_same_profile(mac_ctx,
5037 &session->connectedProfile, profile)) {
5038 *roam_state = eCsrStartIbssSameIbss;
5039 return;
5040 }
5041 }
5042 if (cmd->u.roamCmd.fReassocToSelfNoCapChange) {
5043 /* trying to connect to the one already connected */
5044 cmd->u.roamCmd.fReassocToSelfNoCapChange = false;
5045 *roam_state = eCsrReassocToSelfNoCapChange;
5046 return;
5047 }
5048 /* Attempt to Join this Bss... */
5049 *roam_state = csr_roam_join(mac_ctx, session_id,
5050 &scan_result->Result, profile);
5051 return;
5052 }
5053
5054 /* For an IBSS profile, then we need to start the IBSS. */
5055 if (CSR_IS_START_IBSS(profile)) {
5056 bool same_ibss = false;
5057 /* Attempt to start this IBSS... */
5058 csr_roam_assign_default_param(mac_ctx, cmd);
5059 status = csr_roam_start_ibss(mac_ctx, session_id,
5060 profile, &same_ibss);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305061 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005062 if (same_ibss)
5063 *roam_state = eCsrStartIbssSameIbss;
5064 else
5065 *roam_state = eCsrContinueRoaming;
5066 } else {
5067 /* it somehow fail need to stop */
5068 *roam_state = eCsrStopRoaming;
5069 }
5070 return;
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07005071 } else if (CSR_IS_INFRA_AP(profile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005072 /* Attempt to start this WDS... */
5073 csr_roam_assign_default_param(mac_ctx, cmd);
5074 /* For AP WDS, we dont have any BSSDescription */
5075 status = csr_roam_start_wds(mac_ctx, session_id, profile, NULL);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305076 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077 *roam_state = eCsrContinueRoaming;
5078 else
5079 *roam_state = eCsrStopRoaming;
5080 } else {
5081 /* Nothing we can do */
5082 sms_log(mac_ctx, LOGW, FL("cannot continue without BSS list"));
5083 *roam_state = eCsrStopRoaming;
5084 return;
5085 }
5086
5087}
5088/**
5089 * csr_roam_join_next_bss() - Pick the next BSS for join
5090 * @mac_ctx: Global MAC Context
5091 * @cmd: Command
5092 * @use_same_bss: Use Same BSS to Join
5093 *
5094 * Return: The Join State
5095 */
5096static eCsrJoinState csr_roam_join_next_bss(tpAniSirGlobal mac_ctx,
5097 tSmeCmd *cmd, bool use_same_bss)
5098{
5099 tCsrScanResult *scan_result = NULL;
5100 eCsrJoinState roam_state = eCsrStopRoaming;
5101 tScanResultList *bss_list =
5102 (tScanResultList *) cmd->u.roamCmd.hBSSList;
5103 bool done = false;
5104 tCsrRoamInfo roam_info, *roam_info_ptr = NULL;
5105 uint32_t session_id = cmd->sessionId;
5106 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
5107 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
5108 tCsrRoamJoinStatus *join_status;
5109 tCsrScanResultInfo *result = NULL;
5110
5111 if (!session) {
5112 sms_log(mac_ctx, LOGE, FL("session %d not found"), session_id);
5113 return eCsrStopRoaming;
5114 }
5115
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305116 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
5117 qdf_mem_copy(&roam_info.bssid, &session->joinFailStatusCode.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005118 sizeof(tSirMacAddr));
5119 /*
5120 * When handling AP's capability change, continue to associate
5121 * to same BSS and make sure pRoamBssEntry is not Null.
5122 */
5123 if ((NULL != bss_list) &&
5124 ((false == use_same_bss) ||
5125 (cmd->u.roamCmd.pRoamBssEntry == NULL))) {
5126 if (cmd->u.roamCmd.pRoamBssEntry == NULL) {
5127 /* Try the first BSS */
5128 cmd->u.roamCmd.pLastRoamBss = NULL;
5129 cmd->u.roamCmd.pRoamBssEntry =
5130 csr_ll_peek_head(&bss_list->List,
5131 LL_ACCESS_LOCK);
5132 } else {
5133 cmd->u.roamCmd.pRoamBssEntry =
5134 csr_ll_next(&bss_list->List,
5135 cmd->u.roamCmd.pRoamBssEntry,
5136 LL_ACCESS_LOCK);
5137 /*
5138 * Done with all the BSSs.
5139 * In this case, will tell HDD the
5140 * completion
5141 */
5142 if (NULL == cmd->u.roamCmd.pRoamBssEntry)
5143 goto end;
5144 /*
5145 * We need to indicate to HDD that we
5146 * are done with this one.
5147 */
5148 roam_info.pBssDesc = cmd->u.roamCmd.pLastRoamBss;
5149 join_status = &session->joinFailStatusCode;
5150 roam_info.statusCode = join_status->statusCode;
5151 roam_info.reasonCode = join_status->reasonCode;
5152 roam_info_ptr = &roam_info;
5153 }
5154 done = csr_roam_select_bss(mac_ctx,
5155 cmd->u.roamCmd.pRoamBssEntry, &result,
5156 &scan_result, session_id, cmd->u.roamCmd.roamId,
5157 &roam_state, bss_list);
5158 if (done)
5159 goto end;
5160 }
5161 if (!roam_info_ptr)
5162 roam_info_ptr = &roam_info;
5163 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
5164 csr_roam_join_handle_profile(mac_ctx, session_id, cmd, roam_info_ptr,
5165 &roam_state, result, scan_result);
5166end:
5167 if ((eCsrStopRoaming == roam_state) && CSR_IS_INFRASTRUCTURE(profile) &&
5168 (session->bRefAssocStartCnt > 0)) {
5169 /*
5170 * Need to indicate association_completion if association_start
5171 * has been done
5172 */
5173 session->bRefAssocStartCnt--;
5174 /*
5175 * Complete the last assoc attempte as a
5176 * new one is about to be tried
5177 */
5178 roam_info_ptr = &roam_info;
5179 roam_info_ptr->pProfile = profile;
5180 csr_roam_call_callback(mac_ctx, session_id,
5181 roam_info_ptr, cmd->u.roamCmd.roamId,
5182 eCSR_ROAM_ASSOCIATION_COMPLETION,
5183 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
5184 }
5185
5186 return roam_state;
5187}
5188
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305189static QDF_STATUS csr_roam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005190{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305191 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005192 eCsrJoinState RoamState;
5193 eCsrRoamSubState substate;
5194 uint32_t sessionId = pCommand->sessionId;
5195
5196 /* Attept to join a Bss... */
5197 RoamState = csr_roam_join_next_bss(pMac, pCommand, false);
5198
5199 /* if nothing to join.. */
5200 if ((eCsrStopRoaming == RoamState) ||
5201 (eCsrStopRoamingDueToConcurrency == RoamState)) {
5202 bool fComplete = false;
5203 /* and if connected in Infrastructure mode... */
5204 if (csr_is_conn_state_infra(pMac, sessionId)) {
5205 /* ... then we need to issue a disassociation */
5206 substate = eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN;
5207 status = csr_roam_issue_disassociate(pMac, sessionId,
5208 substate, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305209 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005210 sms_log(pMac, LOGW,
5211 FL("fail issuing disassoc status = %d"),
5212 status);
5213 /*
5214 * roam command is completed by caller in the
5215 * failed case
5216 */
5217 fComplete = true;
5218 }
5219 } else if (csr_is_conn_state_ibss(pMac, sessionId)) {
5220 status = csr_roam_issue_stop_bss(pMac, sessionId,
5221 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305222 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005223 sms_log(pMac, LOGW,
5224 FL("fail issuing stop bss status = %d"),
5225 status);
5226 /*
5227 * roam command is completed by caller in the
5228 * failed case
5229 */
5230 fComplete = true;
5231 }
5232 } else if (csr_is_conn_state_connected_infra_ap(pMac,
5233 sessionId)) {
5234 substate = eCSR_ROAM_SUBSTATE_STOP_BSS_REQ;
5235 status = csr_roam_issue_stop_bss(pMac, sessionId,
5236 substate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305237 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005238 sms_log(pMac, LOGW,
5239 FL("fail issuing stop bss status = %d"),
5240 status);
5241 /*
5242 * roam command is completed by caller in the
5243 * failed case
5244 */
5245 fComplete = true;
5246 }
5247 } else {
5248 fComplete = true;
5249 }
5250
5251 if (fComplete) {
5252 /* otherwise, we can complete the Roam command here. */
5253 if (eCsrStopRoamingDueToConcurrency == RoamState)
5254 csr_roam_complete(pMac,
5255 eCsrJoinFailureDueToConcurrency, NULL);
5256 else
5257 csr_roam_complete(pMac,
5258 eCsrNothingToJoin, NULL);
5259 }
5260 } else if (eCsrReassocToSelfNoCapChange == RoamState) {
5261 csr_roam_complete(pMac, eCsrSilentlyStopRoamingSaveState,
5262 NULL);
5263 } else if (eCsrStartIbssSameIbss == RoamState) {
5264 csr_roam_complete(pMac, eCsrSilentlyStopRoaming, NULL);
5265 }
5266
5267 return status;
5268}
5269
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305270QDF_STATUS csr_process_ft_reassoc_roam_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005271 tSmeCmd *pCommand)
5272{
5273 uint32_t sessionId;
5274 tCsrRoamSession *pSession;
5275 tCsrScanResult *pScanResult = NULL;
5276 tSirBssDescription *pBssDesc = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305277 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005278 sessionId = pCommand->sessionId;
5279 pSession = CSR_GET_SESSION(pMac, sessionId);
5280
5281 if (!pSession) {
5282 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305283 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005284 }
5285
5286 if (CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming) {
5287 /* the roaming is cancelled. Simply complete the command */
5288 sms_log(pMac, LOG1, FL("Roam command canceled"));
5289 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305290 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005291 }
5292 if (pCommand->u.roamCmd.pRoamBssEntry) {
5293 pScanResult =
5294 GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry,
5295 tCsrScanResult, Link);
5296 pBssDesc = &pScanResult->Result.BssDescriptor;
5297 } else {
5298 /* the roaming is cancelled. Simply complete the command */
5299 sms_log(pMac, LOG1, FL("Roam command canceled"));
5300 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305301 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005302 }
5303 status = csr_roam_issue_reassociate(pMac, sessionId, pBssDesc,
5304 (tDot11fBeaconIEs *) (pScanResult->
5305 Result.pvIes),
5306 &pCommand->u.roamCmd.roamProfile);
5307 return status;
5308}
5309
5310/**
5311 * csr_roam_trigger_reassociate() - Helper function to trigger reassociate
5312 * @mac_ctx: pointer to mac context
5313 * @cmd: sme command
5314 * @roam_info: Roaming infor structure
5315 * @session_ptr: session pointer
5316 * @session_id: session id
5317 *
5318 * This function will trigger reassociate.
5319 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305320 * Return: QDF_STATUS for success or failure.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005321 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305322static QDF_STATUS csr_roam_trigger_reassociate(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005323 tSmeCmd *cmd, tCsrRoamInfo *roam_info,
5324 tCsrRoamSession *session_ptr, uint32_t session_id)
5325{
5326 tDot11fBeaconIEs *pIes = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305327 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005328
5329 if (session_ptr->pConnectBssDesc) {
5330 status = csr_get_parsed_bss_description_ies(mac_ctx,
5331 session_ptr->pConnectBssDesc, &pIes);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305332 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333 sms_log(mac_ctx, LOGE, FL("fail to parse IEs"));
5334 } else {
5335 roam_info->reasonCode =
5336 eCsrRoamReasonStaCapabilityChanged;
5337 csr_roam_call_callback(mac_ctx, session_ptr->sessionId,
5338 roam_info, 0, eCSR_ROAM_ROAMING_START,
5339 eCSR_ROAM_RESULT_NONE);
5340 session_ptr->roamingReason = eCsrReassocRoaming;
5341 roam_info->pBssDesc = session_ptr->pConnectBssDesc;
5342 roam_info->pProfile = &cmd->u.roamCmd.roamProfile;
5343 session_ptr->bRefAssocStartCnt++;
5344 csr_roam_call_callback(mac_ctx, session_id, roam_info,
5345 cmd->u.roamCmd.roamId,
5346 eCSR_ROAM_ASSOCIATION_START,
5347 eCSR_ROAM_RESULT_NONE);
5348
5349 sms_log(mac_ctx, LOG1,
5350 FL("calling csr_roam_issue_reassociate"));
5351 status = csr_roam_issue_reassociate(mac_ctx, session_id,
5352 session_ptr->pConnectBssDesc, pIes,
5353 &cmd->u.roamCmd.roamProfile);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305354 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005355 sms_log(mac_ctx, LOGE, FL("failed status %d"),
5356 status);
5357 csr_release_command_roam(mac_ctx, cmd);
5358 }
5359
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305360 qdf_mem_free(pIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005361 pIes = NULL;
5362 }
5363 } else {
5364 sms_log(mac_ctx, LOGE, FL
5365 ("reassoc to same AP failed as connected BSS is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305366 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005367 }
5368 return status;
5369}
5370
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305371QDF_STATUS csr_roam_process_command(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005372{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305373 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005374 tCsrRoamInfo roamInfo;
5375 uint32_t sessionId = pCommand->sessionId;
5376 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
5377
5378 if (!pSession) {
5379 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305380 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005381 }
5382 sms_log(pMac, LOG1, FL("Roam Reason : %d, sessionId: %d"),
5383 pCommand->u.roamCmd.roamReason, sessionId);
5384
5385 switch (pCommand->u.roamCmd.roamReason) {
5386 case eCsrForcedDisassoc:
5387 if (eCSR_ROAMING_STATE_IDLE == pMac->roam.curState[sessionId]) {
5388 sms_log(pMac, LOGE,
5389 FL("Ignore eCsrForcedDisassoc cmd on roam state"
5390 " %d"), eCSR_ROAMING_STATE_IDLE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305391 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005392 }
5393
5394 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
5395 true, false);
5396 csr_free_roam_profile(pMac, sessionId);
5397 break;
5398 case eCsrSmeIssuedDisassocForHandoff:
5399 /* Not to free pMac->roam.pCurRoamProfile (via
5400 * csr_free_roam_profile) because its needed after disconnect */
5401 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
5402 true, false);
5403
5404 break;
5405 case eCsrForcedDisassocMICFailure:
5406 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
5407 true, true);
5408 csr_free_roam_profile(pMac, sessionId);
5409 break;
5410 case eCsrForcedDeauth:
5411 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
5412 false, false);
5413 csr_free_roam_profile(pMac, sessionId);
5414 break;
5415 case eCsrHddIssuedReassocToSameAP:
5416 case eCsrSmeIssuedReassocToSameAP:
5417 status = csr_roam_trigger_reassociate(pMac, pCommand, &roamInfo,
5418 pSession, sessionId);
5419 break;
5420 case eCsrCapsChange:
5421 sms_log(pMac, LOGE, FL("received eCsrCapsChange "));
5422 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
5423 sessionId);
5424 status = csr_roam_issue_disassociate(pMac, sessionId,
5425 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
5426 false);
5427 break;
5428 case eCsrSmeIssuedFTReassoc:
5429 sms_log(pMac, LOG1, FL("received FT Reassoc Req "));
5430 status = csr_process_ft_reassoc_roam_command(pMac, pCommand);
5431 break;
5432
5433 case eCsrStopBss:
5434 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
5435 sessionId);
5436 status = csr_roam_issue_stop_bss(pMac, sessionId,
5437 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
5438 break;
5439
5440 case eCsrForcedDisassocSta:
5441 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
5442 sessionId);
5443 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ,
5444 sessionId);
5445 status = csr_send_mb_disassoc_req_msg(pMac, sessionId,
5446 pCommand->u.roamCmd.peerMac,
5447 pCommand->u.roamCmd.reason);
5448 break;
5449
5450 case eCsrForcedDeauthSta:
5451 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
5452 sessionId);
5453 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ,
5454 sessionId);
5455 status = csr_send_mb_deauth_req_msg(pMac, sessionId,
5456 pCommand->u.roamCmd.peerMac,
5457 pCommand->u.roamCmd.reason);
5458 break;
5459
5460 case eCsrPerformPreauth:
5461 sms_log(pMac, LOG1, FL("Attempting FT PreAuth Req"));
5462 status = csr_roam_issue_ft_preauth_req(pMac, sessionId,
5463 pCommand->u.roamCmd.pLastRoamBss);
5464 break;
5465 default:
5466 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
5467 sessionId);
5468
5469 if (pCommand->u.roamCmd.fUpdateCurRoamProfile) {
5470 /* Remember the roaming profile */
5471 csr_free_roam_profile(pMac, sessionId);
5472 pSession->pCurRoamProfile =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305473 qdf_mem_malloc(sizeof(tCsrRoamProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005474 if (NULL != pSession->pCurRoamProfile) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305475 qdf_mem_set(pSession->pCurRoamProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005476 sizeof(tCsrRoamProfile), 0);
5477 csr_roam_copy_profile(pMac,
5478 pSession->pCurRoamProfile,
5479 &pCommand->u.roamCmd.roamProfile);
5480 }
5481 }
5482 /*
5483 * At this point original uapsd_mask is saved in
5484 * pCurRoamProfile. uapsd_mask in the pCommand may change from
5485 * this point on. Attempt to roam with the new scan results
5486 * (if we need to..)
5487 */
5488 status = csr_roam(pMac, pCommand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305489 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005490 sms_log(pMac, LOGW,
5491 FL("csr_roam() failed with status = 0x%08X"),
5492 status);
5493 break;
5494 }
5495 return status;
5496}
5497
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005498void csr_reinit_roam_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5499{
5500 if (pCommand->u.roamCmd.fReleaseBssList) {
5501 csr_scan_result_purge(pMac, pCommand->u.roamCmd.hBSSList);
5502 pCommand->u.roamCmd.fReleaseBssList = false;
5503 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5504 }
5505 if (pCommand->u.roamCmd.fReleaseProfile) {
5506 csr_release_profile(pMac, &pCommand->u.roamCmd.roamProfile);
5507 pCommand->u.roamCmd.fReleaseProfile = false;
5508 }
5509 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5510 /* Because u.roamCmd is union and share with scanCmd and StatusChange */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305511 qdf_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005512}
5513
5514void csr_reinit_wm_status_change_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5515{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305516 qdf_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517 0);
5518}
5519
5520void csr_roam_complete(tpAniSirGlobal pMac, eCsrRoamCompleteResult Result,
5521 void *Context)
5522{
5523 tListElem *pEntry;
5524 tSmeCmd *pCommand;
5525 bool fReleaseCommand = true;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305526 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005527 "%s: Roam Completion ...", __func__);
5528 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
5529 if (pEntry) {
5530 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
5531 /* If the head of the queue is Active and it is a ROAM command, remove */
5532 /* and put this on the Free queue. */
5533 if (eSmeCommandRoam == pCommand->command) {
5534 /* we need to process the result first before removing it from active list because state changes */
5535 /* still happening insides roamQProcessRoamResults so no other roam command should be issued */
5536 fReleaseCommand =
5537 csr_roam_process_results(pMac, pCommand, Result,
5538 Context);
5539 if (fReleaseCommand) {
5540 if (csr_ll_remove_entry
5541 (&pMac->sme.smeCmdActiveList, pEntry,
5542 LL_ACCESS_LOCK)) {
5543 csr_release_command_roam(pMac, pCommand);
5544 } else {
5545 sms_log(pMac, LOGE,
5546 " **********csr_roam_complete fail to release command reason %d",
5547 pCommand->u.roamCmd.roamReason);
5548 }
5549 } else {
5550 sms_log(pMac, LOGE,
5551 " **********csr_roam_complete fail to release command reason %d",
5552 pCommand->u.roamCmd.roamReason);
5553 }
5554 } else {
5555 sms_log(pMac, LOGW,
5556 "CSR: Roam Completion called but ROAM command is not ACTIVE ...");
5557 }
5558 } else {
5559 sms_log(pMac, LOGW,
5560 "CSR: Roam Completion called but NO commands are ACTIVE ...");
5561 }
5562 if (fReleaseCommand) {
5563 sme_process_pending_queue(pMac);
5564 }
5565}
5566
5567void csr_reset_pmkid_candidate_list(tpAniSirGlobal pMac, uint32_t sessionId)
5568{
5569 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
5570 if (!pSession) {
5571 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
5572 return;
5573 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305574 qdf_mem_set(&(pSession->PmkidCandidateInfo[0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
5576 pSession->NumPmkidCandidate = 0;
5577}
5578
5579#ifdef FEATURE_WLAN_WAPI
5580void csr_reset_bkid_candidate_list(tpAniSirGlobal pMac, uint32_t sessionId)
5581{
5582 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
5583 if (!pSession) {
5584 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
5585 return;
5586 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305587 qdf_mem_set(&(pSession->BkidCandidateInfo[0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
5589 pSession->NumBkidCandidate = 0;
5590}
5591#endif /* FEATURE_WLAN_WAPI */
5592extern uint8_t csr_wpa_oui[][CSR_WPA_OUI_SIZE];
5593
5594/**
5595 * csr_roam_save_params() - Helper function to save params
5596 * @mac_ctx: pointer to mac context
5597 * @session_ptr: Session pointer
5598 * @auth_type: auth type
5599 * @ie_ptr: pointer to ie
5600 * @ie_local: pointr to local ie
5601 *
5602 * This function will save params to session
5603 *
5604 * Return: none.
5605 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305606static QDF_STATUS csr_roam_save_params(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005607 tCsrRoamSession *session_ptr,
5608 eCsrAuthType auth_type,
5609 tDot11fBeaconIEs *ie_ptr,
5610 tDot11fBeaconIEs *ie_local)
5611{
5612 uint32_t nIeLen;
5613 uint8_t *pIeBuf;
5614
5615 if ((eCSR_AUTH_TYPE_RSN == auth_type) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005616 (eCSR_AUTH_TYPE_FT_RSN == auth_type) ||
5617 (eCSR_AUTH_TYPE_FT_RSN_PSK == auth_type) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005618#if defined WLAN_FEATURE_11W
5619 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == auth_type) ||
5620 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == auth_type) ||
5621#endif
5622 (eCSR_AUTH_TYPE_RSN_PSK == auth_type)) {
5623 if (ie_local->RSN.present) {
5624 tDot11fIERSN *rsnie = &ie_local->RSN;
5625 /*
5626 * Calculate the actual length
5627 * version + gp_cipher_suite + pwise_cipher_suite_count
5628 * + akm_suite_count + reserved + pwise_cipher_suites
5629 */
5630 nIeLen = 8 + 2 + 2
5631 + (rsnie->pwise_cipher_suite_count * 4)
5632 + (rsnie->akm_suite_count * 4);
5633 if (rsnie->pmkid_count)
5634 /* pmkid */
5635 nIeLen += 2 + rsnie->pmkid_count * 4;
5636
5637 /* nIeLen doesn't count EID and length fields */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305638 session_ptr->pWpaRsnRspIE = qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005639 if (NULL == session_ptr->pWpaRsnRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305640 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005641
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305642 qdf_mem_set(session_ptr->pWpaRsnRspIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005643 nIeLen + 2, 0);
5644 session_ptr->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5645 session_ptr->pWpaRsnRspIE[1] = (uint8_t) nIeLen;
5646 /* copy upto akm_suites */
5647 pIeBuf = session_ptr->pWpaRsnRspIE + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305648 qdf_mem_copy(pIeBuf, &rsnie->version,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005649 sizeof(rsnie->version));
5650 pIeBuf += sizeof(rsnie->version);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305651 qdf_mem_copy(pIeBuf, &rsnie->gp_cipher_suite,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005652 sizeof(rsnie->gp_cipher_suite));
5653 pIeBuf += sizeof(rsnie->gp_cipher_suite);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305654 qdf_mem_copy(pIeBuf, &rsnie->pwise_cipher_suite_count,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005655 sizeof(rsnie->pwise_cipher_suite_count));
5656 pIeBuf += sizeof(rsnie->pwise_cipher_suite_count);
5657 if (rsnie->pwise_cipher_suite_count) {
5658 /* copy pwise_cipher_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305659 qdf_mem_copy(pIeBuf, rsnie->pwise_cipher_suites,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005660 rsnie->pwise_cipher_suite_count * 4);
5661 pIeBuf += rsnie->pwise_cipher_suite_count * 4;
5662 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305663 qdf_mem_copy(pIeBuf, &rsnie->akm_suite_count, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005664 pIeBuf += 2;
5665 if (rsnie->akm_suite_count) {
5666 /* copy akm_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305667 qdf_mem_copy(pIeBuf, rsnie->akm_suites,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005668 rsnie->akm_suite_count * 4);
5669 pIeBuf += rsnie->akm_suite_count * 4;
5670 }
5671 /* copy the rest */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305672 qdf_mem_copy(pIeBuf, rsnie->akm_suites +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005673 rsnie->akm_suite_count * 4,
5674 2 + rsnie->pmkid_count * 4);
5675 session_ptr->nWpaRsnRspIeLength = nIeLen + 2;
5676 }
5677 } else if ((eCSR_AUTH_TYPE_WPA == auth_type) ||
5678 (eCSR_AUTH_TYPE_WPA_PSK == auth_type)) {
5679 if (ie_local->WPA.present) {
5680 tDot11fIEWPA *wpaie = &ie_local->WPA;
5681 /* Calculate the actual length wpaie */
5682 nIeLen = 12 + 2 /* auth_suite_count */
5683 + wpaie->unicast_cipher_count * 4
5684 + wpaie->auth_suite_count * 4;
5685
5686 /* The WPA capabilities follows the Auth Suite
5687 * (two octects)-- this field is optional, and
5688 * we always "send" zero, so just remove it. This is
5689 * consistent with our assumptions in the frames
5690 * compiler; nIeLen doesn't count EID & length fields */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305691 session_ptr->pWpaRsnRspIE = qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692 if (NULL == session_ptr->pWpaRsnRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305693 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005694 session_ptr->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5695 session_ptr->pWpaRsnRspIE[1] = (uint8_t) nIeLen;
5696 pIeBuf = session_ptr->pWpaRsnRspIE + 2;
5697 /* Copy WPA OUI */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305698 qdf_mem_copy(pIeBuf, &csr_wpa_oui[1], 4);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005699 pIeBuf += 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305700 qdf_mem_copy(pIeBuf, &wpaie->version,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005701 8 + wpaie->unicast_cipher_count * 4);
5702 pIeBuf += 8 + wpaie->unicast_cipher_count * 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305703 qdf_mem_copy(pIeBuf, &wpaie->auth_suite_count,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005704 2 + wpaie->auth_suite_count * 4);
5705 pIeBuf += wpaie->auth_suite_count * 4;
5706 session_ptr->nWpaRsnRspIeLength = nIeLen + 2;
5707 }
5708 }
5709#ifdef FEATURE_WLAN_WAPI
5710 else if ((eCSR_AUTH_TYPE_WAPI_WAI_PSK == auth_type) ||
5711 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ==
5712 auth_type)) {
5713 if (ie_local->WAPI.present) {
5714 tDot11fIEWAPI *wapi_ie = &ie_local->WAPI;
5715 /* Calculate the actual length of wapi ie*/
5716 nIeLen = 4 + 2 /* pwise_cipher_suite_count */
5717 + wapi_ie->akm_suite_count * 4
5718 + wapi_ie->unicast_cipher_suite_count * 4
5719 + 6; /* gp_cipher_suite + preauth + reserved */
5720
5721 if (wapi_ie->bkid_count)
5722 nIeLen += 2 + wapi_ie->bkid_count * 4;
5723
5724 /* nIeLen doesn't count EID and length fields */
5725 session_ptr->pWapiRspIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305726 qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005727 if (NULL == session_ptr->pWapiRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305728 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005729 session_ptr->pWapiRspIE[0] = DOT11F_EID_WAPI;
5730 session_ptr->pWapiRspIE[1] = (uint8_t) nIeLen;
5731 pIeBuf = session_ptr->pWapiRspIE + 2;
5732 /* copy upto akm_suite_count */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305733 qdf_mem_copy(pIeBuf, &wapi_ie->version, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005734 pIeBuf += 4;
5735 if (wapi_ie->akm_suite_count) {
5736 /* copy akm_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305737 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005738 wapi_ie->akm_suites,
5739 wapi_ie->akm_suite_count * 4);
5740 pIeBuf += wapi_ie->akm_suite_count * 4;
5741 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305742 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005743 &wapi_ie->unicast_cipher_suite_count, 2);
5744 pIeBuf += 2;
5745 if (wapi_ie->unicast_cipher_suite_count) {
5746 uint16_t suite_size =
5747 wapi_ie->unicast_cipher_suite_count * 4;
5748 /* copy pwise_cipher_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305749 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005750 wapi_ie->unicast_cipher_suites,
5751 suite_size);
5752 pIeBuf += suite_size;
5753 }
5754 /* gp_cipher_suite */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305755 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005756 wapi_ie->multicast_cipher_suite, 4);
5757 pIeBuf += 4;
5758 /* preauth + reserved */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305759 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005760 wapi_ie->multicast_cipher_suite + 4, 2);
5761 pIeBuf += 2;
5762 if (wapi_ie->bkid_count) {
5763 /* bkid_count */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305764 qdf_mem_copy(pIeBuf, &wapi_ie->bkid_count, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005765 pIeBuf += 2;
5766 /* copy akm_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305767 qdf_mem_copy(pIeBuf, wapi_ie->bkid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768 wapi_ie->bkid_count * 4);
5769 pIeBuf += wapi_ie->bkid_count * 4;
5770 }
5771 session_ptr->nWapiRspIeLength = nIeLen + 2;
5772 }
5773 }
5774#endif /* FEATURE_WLAN_WAPI */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305775 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005776}
5777
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305778static QDF_STATUS csr_roam_save_security_rsp_ie(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005779 uint32_t sessionId,
5780 eCsrAuthType authType,
5781 tSirBssDescription *pSirBssDesc,
5782 tDot11fBeaconIEs *pIes)
5783{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305784 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005785 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
5786 tDot11fBeaconIEs *pIesLocal = pIes;
5787
5788 if (!pSession) {
5789 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305790 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005791 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005792
5793 if ((eCSR_AUTH_TYPE_WPA == authType) ||
5794 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
5795 (eCSR_AUTH_TYPE_RSN == authType) ||
5796 (eCSR_AUTH_TYPE_RSN_PSK == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005797 || (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5798 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005799#ifdef FEATURE_WLAN_WAPI
5800 || (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5801 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
5802#endif /* FEATURE_WLAN_WAPI */
5803#ifdef WLAN_FEATURE_11W
5804 || (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
5805 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
5806#endif /* FEATURE_WLAN_WAPI */
5807 ) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305808 if (!pIesLocal && !QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005809 (csr_get_parsed_bss_description_ies(pMac,
5810 pSirBssDesc, &pIesLocal)))
5811 sms_log(pMac, LOGE, FL(" cannot parse IEs"));
5812 if (pIesLocal) {
5813 status = csr_roam_save_params(pMac, pSession, authType,
5814 pIes, pIesLocal);
5815 if (!pIes)
5816 /* locally allocated */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305817 qdf_mem_free(pIesLocal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005818 }
5819 }
5820 return status;
5821}
5822
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005823/* Returns whether the current association is a 11r assoc or not */
5824bool csr_roam_is11r_assoc(tpAniSirGlobal pMac, uint8_t sessionId)
5825{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005826 return csr_neighbor_roam_is11r_assoc(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005827}
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -08005828
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005829/* Returns whether "Legacy Fast Roaming" is currently enabled...or not */
5830bool csr_roam_is_fast_roam_enabled(tpAniSirGlobal pMac, uint32_t sessionId)
5831{
5832 tCsrRoamSession *pSession = NULL;
5833
5834 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
5835 pSession = CSR_GET_SESSION(pMac, sessionId);
5836 if (NULL != pSession->pCurRoamProfile) {
5837 if (pSession->pCurRoamProfile->csrPersona !=
Anurag Chouhan6d760662016-02-20 16:05:43 +05305838 QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005839 return false;
5840 }
5841 }
5842 }
5843 if (true == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac)) {
5844 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
5845 } else {
5846 return pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
5847 (!csr_is_concurrent_session_running(pMac));
5848 }
5849}
5850
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005851#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5852eCsrPhyMode csr_roamdot11mode_to_phymode(uint8_t dot11mode)
5853{
5854 eCsrPhyMode phymode = eCSR_DOT11_MODE_abg;
5855
5856 switch (dot11mode) {
5857 case WNI_CFG_DOT11_MODE_ALL:
5858 phymode = eCSR_DOT11_MODE_abg;
5859 break;
5860 case WNI_CFG_DOT11_MODE_11A:
5861 phymode = eCSR_DOT11_MODE_11a;
5862 break;
5863 case WNI_CFG_DOT11_MODE_11B:
5864 phymode = eCSR_DOT11_MODE_11b;
5865 break;
5866 case WNI_CFG_DOT11_MODE_11G:
5867 phymode = eCSR_DOT11_MODE_11g;
5868 break;
5869 case WNI_CFG_DOT11_MODE_11N:
5870 phymode = eCSR_DOT11_MODE_11n;
5871 break;
5872 case WNI_CFG_DOT11_MODE_11G_ONLY:
5873 phymode = eCSR_DOT11_MODE_11g_ONLY;
5874 break;
5875 case WNI_CFG_DOT11_MODE_11N_ONLY:
5876 phymode = eCSR_DOT11_MODE_11n_ONLY;
5877 break;
5878 case WNI_CFG_DOT11_MODE_11AC:
5879 phymode = eCSR_DOT11_MODE_11ac;
5880 break;
5881 case WNI_CFG_DOT11_MODE_11AC_ONLY:
5882 phymode = eCSR_DOT11_MODE_11ac_ONLY;
5883 break;
5884 default:
5885 break;
5886 }
5887
5888 return phymode;
5889}
5890#endif
5891
5892#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005893void csr_roam_synch_clean_up (tpAniSirGlobal mac, uint8_t session_id)
5894{
5895 cds_msg_t msg;
5896 struct roam_offload_synch_fail *roam_offload_failed = NULL;
5897 tCsrRoamSession *session = &mac->roam.roamSession[session_id];
5898
5899 /* Clean up the roam synch in progress for LFR3 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305900 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005901 "%s: Roam Synch Failed, Clean Up", __func__);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08005902 session->roam_synch_in_progress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005903
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305904 roam_offload_failed = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005905 sizeof(struct roam_offload_synch_fail));
5906 if (NULL == roam_offload_failed) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305907 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005908 "%s: unable to allocate memory for roam synch fail" ,
5909 __func__);
5910 return;
5911 }
5912
5913 roam_offload_failed->session_id = session_id;
5914 msg.type = WMA_ROAM_OFFLOAD_SYNCH_FAIL;
5915 msg.reserved = 0;
5916 msg.bodyptr = roam_offload_failed;
Anurag Chouhan6d760662016-02-20 16:05:43 +05305917 if (!QDF_IS_STATUS_SUCCESS(cds_mq_post_message(QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005918 &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305919 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005920 "%s: Unable to post WMA_ROAM_OFFLOAD_SYNCH_FAIL to WMA",
5921 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305922 qdf_mem_free(roam_offload_failed);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005923 }
5924}
5925#endif
5926
5927#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5928/**
5929 * csr_roam_copy_ht_profile() - Copy from src to dst
5930 * @dst_profile: Destination HT profile
5931 * @src_profile: Source HT profile
5932 *
5933 * Copy the HT profile from the given source to destination
5934 *
5935 * Return: None
5936 */
5937static void csr_roam_copy_ht_profile(tCsrRoamHTProfile *dst_profile,
5938 tSirSmeHTProfile *src_profile)
5939{
5940 dst_profile->phymode =
5941 csr_roamdot11mode_to_phymode(src_profile->dot11mode);
5942 dst_profile->htCapability = src_profile->htCapability;
5943 dst_profile->htSupportedChannelWidthSet =
5944 src_profile->htSupportedChannelWidthSet;
5945 dst_profile->htRecommendedTxWidthSet =
5946 src_profile->htRecommendedTxWidthSet;
5947 dst_profile->htSecondaryChannelOffset =
5948 src_profile->htSecondaryChannelOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005949 dst_profile->vhtCapability = src_profile->vhtCapability;
5950 dst_profile->vhtTxChannelWidthSet = src_profile->vhtTxChannelWidthSet;
5951 dst_profile->apCenterChan = src_profile->apCenterChan;
5952 dst_profile->apChanWidth = src_profile->apChanWidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005953}
5954#endif
5955
5956/**
5957 * csr_roam_process_results_default() - Process the result for start bss
5958 * @mac_ctx: Global MAC Context
5959 * @cmd: Command to be processed
5960 * @context: Additional data in context of the cmd
5961 *
5962 * Return: None
5963 */
5964static void csr_roam_process_results_default(tpAniSirGlobal mac_ctx,
5965 tSmeCmd *cmd, void *context, eCsrRoamCompleteResult res)
5966{
5967 uint32_t session_id = cmd->sessionId;
5968 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
5969 tCsrRoamInfo roam_info;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305970 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005971
5972 sms_log(mac_ctx, LOGW, FL("receives no association indication"));
5973 sms_log(mac_ctx, LOG1, FL("Assoc ref count %d"),
5974 session->bRefAssocStartCnt);
5975 if (CSR_IS_INFRASTRUCTURE(&session->connectedProfile)
5976 || CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ(mac_ctx, session_id)) {
5977 /*
5978 * do not free for the other profiles as we need
5979 * to send down stop BSS later
5980 */
5981 csr_free_connect_bss_desc(mac_ctx, session_id);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08005982 csr_roam_free_connect_profile(&session->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005983 csr_roam_free_connected_info(mac_ctx, &session->connectedInfo);
5984 csr_set_default_dot11_mode(mac_ctx);
5985 }
5986
5987 switch (cmd->u.roamCmd.roamReason) {
5988 /*
5989 * If this transition is because of an 802.11 OID, then we
5990 * transition back to INIT state so we sit waiting for more
5991 * OIDs to be issued and we don't start the IDLE timer.
5992 */
5993 case eCsrSmeIssuedFTReassoc:
5994 case eCsrSmeIssuedAssocToSimilarAP:
5995 case eCsrHddIssued:
5996 case eCsrSmeIssuedDisassocForHandoff:
5997 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
5998 session_id);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305999 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006000 roam_info.pBssDesc = cmd->u.roamCmd.pLastRoamBss;
6001 roam_info.pProfile = &cmd->u.roamCmd.roamProfile;
6002 roam_info.statusCode = session->joinFailStatusCode.statusCode;
6003 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306004 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006005 &session->joinFailStatusCode.bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306006 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006008 /*
6009 * If Join fails while Handoff is in progress, indicate
6010 * disassociated event to supplicant to reconnect
6011 */
6012 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)) {
6013 csr_neighbor_roam_indicate_connect(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306014 (uint8_t)session_id, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006016 if (session->bRefAssocStartCnt > 0) {
6017 session->bRefAssocStartCnt--;
6018 if (eCsrJoinFailureDueToConcurrency == res)
6019 csr_roam_call_callback(mac_ctx, session_id,
6020 &roam_info, cmd->u.roamCmd.roamId,
6021 eCSR_ROAM_ASSOCIATION_COMPLETION,
6022 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
6023 else
6024 csr_roam_call_callback(mac_ctx, session_id,
6025 &roam_info, cmd->u.roamCmd.roamId,
6026 eCSR_ROAM_ASSOCIATION_COMPLETION,
6027 eCSR_ROAM_RESULT_FAILURE);
6028 } else {
6029 /*
6030 * bRefAssocStartCnt is not incremented when
6031 * eRoamState == eCsrStopRoamingDueToConcurrency
6032 * in csr_roam_join_next_bss API. so handle this in
6033 * else case by sending assoc failure
6034 */
6035 csr_roam_call_callback(mac_ctx, session_id,
6036 &roam_info, cmd->u.scanCmd.roamId,
6037 eCSR_ROAM_ASSOCIATION_FAILURE,
6038 eCSR_ROAM_RESULT_FAILURE);
6039 }
6040 sms_log(mac_ctx, LOG1, FL("roam(reason %d) failed"),
6041 cmd->u.roamCmd.roamReason);
6042#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6043 sme_qos_update_hand_off((uint8_t) session_id, false);
6044 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
6045 SME_QOS_CSR_DISCONNECT_IND, NULL);
6046#endif
6047 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
6048 eCSR_ROAM_RESULT_FAILURE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006049 break;
6050 case eCsrHddIssuedReassocToSameAP:
6051 case eCsrSmeIssuedReassocToSameAP:
6052 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
6053 session_id);
6054
6055 csr_roam_call_callback(mac_ctx, session_id, NULL,
6056 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
6057 eCSR_ROAM_RESULT_FORCED);
6058#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6059 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
6060 SME_QOS_CSR_DISCONNECT_IND, NULL);
6061#endif
6062 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
6063 eCSR_ROAM_RESULT_FAILURE, false);
6064 break;
6065 case eCsrForcedDisassoc:
6066 case eCsrForcedDeauth:
6067 case eCsrSmeIssuedIbssJoinFailure:
6068 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
6069 session_id);
6070
6071 if (eCsrSmeIssuedIbssJoinFailure == cmd->u.roamCmd.roamReason)
6072 /* notify HDD that IBSS join failed */
6073 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
6074 eCSR_ROAM_IBSS_IND,
6075 eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6076 else
6077 csr_roam_call_callback(mac_ctx, session_id, NULL,
6078 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
6079 eCSR_ROAM_RESULT_FORCED);
6080#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6081 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
6082 SME_QOS_CSR_DISCONNECT_IND,
6083 NULL);
6084#endif
6085 csr_roam_link_down(mac_ctx, session_id);
6086
6087 if (mac_ctx->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS) {
6088 sms_log(mac_ctx, LOGW,
6089 FL("FW still in connected state"));
6090 break;
6091 }
6092 break;
6093 case eCsrForcedIbssLeave:
6094 csr_roam_call_callback(mac_ctx, session_id, NULL,
6095 cmd->u.roamCmd.roamId, eCSR_ROAM_IBSS_LEAVE,
6096 eCSR_ROAM_RESULT_IBSS_STOP);
Krunal Soni2c68f232015-10-26 20:52:51 -07006097 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006098 break;
6099 case eCsrForcedDisassocMICFailure:
6100 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
6101 session_id);
6102
6103 csr_roam_call_callback(mac_ctx, session_id, NULL,
6104 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
6105 eCSR_ROAM_RESULT_MIC_FAILURE);
6106#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6107 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
6108 SME_QOS_CSR_DISCONNECT_REQ, NULL);
6109#endif
6110 break;
6111 case eCsrStopBss:
6112 csr_roam_call_callback(mac_ctx, session_id, NULL,
6113 cmd->u.roamCmd.roamId, eCSR_ROAM_INFRA_IND,
6114 eCSR_ROAM_RESULT_INFRA_STOPPED);
6115 break;
6116 case eCsrForcedDisassocSta:
6117 case eCsrForcedDeauthSta:
6118 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
6119 session_id);
6120 session = CSR_GET_SESSION(mac_ctx, session_id);
6121 if (CSR_IS_SESSION_VALID(mac_ctx, session_id) &&
6122 CSR_IS_INFRA_AP(&session->connectedProfile)) {
6123 roam_info.u.pConnectedProfile =
6124 &session->connectedProfile;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306125 qdf_mem_copy(roam_info.peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006126 cmd->u.roamCmd.peerMac,
6127 sizeof(tSirMacAddr));
6128 roam_info.reasonCode = eCSR_ROAM_RESULT_FORCED;
6129 roam_info.statusCode = eSIR_SME_SUCCESS;
6130 status = csr_roam_call_callback(mac_ctx, session_id,
6131 &roam_info, cmd->u.roamCmd.roamId,
6132 eCSR_ROAM_LOSTLINK,
6133 eCSR_ROAM_RESULT_FORCED);
6134 }
6135 break;
6136 case eCsrLostLink1:
6137 /* if lost link roam1 failed, then issue lost link Scan2 ... */
6138 csr_scan_request_lost_link2(mac_ctx, session_id);
6139 break;
6140 case eCsrLostLink2:
6141 /* if lost link roam2 failed, then issue lost link scan3 ... */
6142 csr_scan_request_lost_link3(mac_ctx, session_id);
6143 break;
6144 case eCsrLostLink3:
6145 default:
6146 csr_roam_state_change(mac_ctx,
6147 eCSR_ROAMING_STATE_IDLE, session_id);
6148
6149 /* We are done with one round of lostlink roaming here */
6150 csr_scan_handle_failed_lostlink3(mac_ctx, session_id);
6151 break;
6152 }
6153}
6154
6155/**
6156 * csr_roam_process_start_bss_success() - Process the result for start bss
6157 * @mac_ctx: Global MAC Context
6158 * @cmd: Command to be processed
6159 * @context: Additional data in context of the cmd
6160 *
6161 * Return: None
6162 */
6163static void csr_roam_process_start_bss_success(tpAniSirGlobal mac_ctx,
6164 tSmeCmd *cmd, void *context)
6165{
6166 uint32_t session_id = cmd->sessionId;
6167 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
6168 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
6169 tSirBssDescription *bss_desc = NULL;
6170 tCsrRoamInfo roam_info;
6171 tSirSmeStartBssRsp *start_bss_rsp = NULL;
6172 tCsrScanResult *scan_res = NULL;
6173 eRoamCmdStatus roam_status;
6174 eCsrRoamResult roam_result;
6175 tDot11fBeaconIEs *ies_ptr = NULL;
6176 tSirMacAddr bcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306177 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006178 host_log_ibss_pkt_type *ibss_log;
6179 uint32_t bi;
6180#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6181 tSirSmeHTProfile *src_profile = NULL;
6182 tCsrRoamHTProfile *dst_profile = NULL;
6183#endif
6184
6185 /*
6186 * on the StartBss Response, LIM is returning the Bss Description that
6187 * we are beaconing. Add this Bss Description to our scan results and
6188 * chain the Profile to this Bss Description. On a Start BSS, there was
6189 * no detected Bss description (no partner) so we issued the Start Bss
6190 * to start the Ibss without any Bss description. Lim was kind enough
6191 * to return the Bss Description that we start beaconing for the newly
6192 * started Ibss.
6193 */
6194 sms_log(mac_ctx, LOG2, FL("receives start BSS ok indication"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306195 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006196 start_bss_rsp = (tSirSmeStartBssRsp *) context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306197 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006198 if (CSR_IS_IBSS(profile))
6199 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
6200 else if (CSR_IS_INFRA_AP(profile))
6201 session->connectState =
6202 eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
6203 else
6204 session->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006205 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006206 session_id);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006207 bss_desc = &start_bss_rsp->bssDescription;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306208 if (!QDF_IS_STATUS_SUCCESS
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006209 (csr_get_parsed_bss_description_ies(mac_ctx, bss_desc,
6210 &ies_ptr))) {
6211 sms_log(mac_ctx, LOGW, FL("cannot parse IBSS IEs"));
6212 roam_info.pBssDesc = bss_desc;
6213 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
6214 cmd->u.roamCmd.roamId, eCSR_ROAM_IBSS_IND,
6215 eCSR_ROAM_RESULT_IBSS_START_FAILED);
6216 return;
6217 }
6218 if (!CSR_IS_INFRA_AP(profile)) {
6219 scan_res =
6220 csr_scan_append_bss_description(mac_ctx,
6221 bss_desc, ies_ptr, false,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006222 session_id);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006223 }
6224 csr_roam_save_connected_bss_desc(mac_ctx, session_id, bss_desc);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08006225 csr_roam_free_connect_profile(&session->connectedProfile);
6226 csr_roam_free_connected_info(mac_ctx, &session->connectedInfo);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006227 if (bss_desc) {
6228 csr_roam_save_connected_infomation(mac_ctx, session_id,
6229 profile, bss_desc, ies_ptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306230 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306231 sizeof(struct qdf_mac_addr));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006232 }
6233 /* We are done with the IEs so free it */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306234 qdf_mem_free(ies_ptr);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006235#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6236 WLAN_HOST_DIAG_LOG_ALLOC(ibss_log,
6237 host_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6238 if (ibss_log) {
6239 if (CSR_INVALID_SCANRESULT_HANDLE ==
6240 cmd->u.roamCmd.hBSSList) {
6241 /*
6242 * We start the IBSS (didn't find any
6243 * matched IBSS out there)
6244 */
6245 ibss_log->eventId =
6246 WLAN_IBSS_EVENT_START_IBSS_RSP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006247 } else {
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006248 ibss_log->eventId =
6249 WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
6250 }
6251 if (bss_desc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306252 qdf_mem_copy(ibss_log->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306253 bss_desc->bssId, QDF_MAC_ADDR_SIZE);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006254 ibss_log->operatingChannel =
6255 bss_desc->channelId;
6256 }
6257 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(
6258 mac_ctx,
6259 WNI_CFG_BEACON_INTERVAL,
6260 &bi)))
6261 /* U8 is not enough for BI */
6262 ibss_log->beaconInterval = (uint8_t) bi;
6263 WLAN_HOST_DIAG_LOG_REPORT(ibss_log);
6264 }
6265#endif
6266 /*
6267 * Only set context for non-WDS_STA. We don't even need it for
6268 * WDS_AP. But since the encryption.
6269 * is WPA2-PSK so it won't matter.
6270 */
6271 if (CSR_IS_ENC_TYPE_STATIC(profile->negotiatedUCEncryptionType)
6272 && session->pCurRoamProfile
6273 && !CSR_IS_INFRA_AP(session->pCurRoamProfile)) {
6274 /*
6275 * Issue the set Context request to LIM to establish
6276 * the Broadcast STA context for the Ibss. In Rome IBSS
6277 * case, dummy key installation will break proper BSS
6278 * key installation, so skip it.
6279 */
6280 if (!CSR_IS_IBSS(session->pCurRoamProfile)) {
6281 /* NO keys. these key parameters don't matter */
6282 csr_roam_issue_set_context_req(mac_ctx,
6283 session_id,
6284 profile->negotiatedMCEncryptionType,
6285 bss_desc, &bcast_mac, false,
6286 false, eSIR_TX_RX, 0, 0, NULL, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006287 }
6288 }
6289 /*
6290 * Only tell upper layer is we start the BSS because Vista doesn't like
6291 * multiple connection indications. If we don't start the BSS ourself,
6292 * handler of eSIR_SME_JOINED_NEW_BSS will trigger the connection start
6293 * indication in Vista
6294 */
6295 if (!CSR_IS_JOIN_TO_IBSS(profile)) {
6296 roam_status = eCSR_ROAM_IBSS_IND;
6297 roam_result = eCSR_ROAM_RESULT_IBSS_STARTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006298 if (CSR_IS_INFRA_AP(profile)) {
6299 roam_status = eCSR_ROAM_INFRA_IND;
6300 roam_result = eCSR_ROAM_RESULT_INFRA_STARTED;
6301 }
6302 /*
6303 * Only tell upper layer is we start the BSS because Vista
6304 * doesn't like multiple connection indications. If we don't
6305 * start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS
6306 * will trigger the connection start indication in Vista
6307 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306308 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006309 roam_info.statusCode = session->joinFailStatusCode.statusCode;
6310 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
6311 /* We start the IBSS (didn't find any matched IBSS out there) */
6312 roam_info.pBssDesc = bss_desc;
6313 roam_info.staId = (uint8_t) start_bss_rsp->staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306314 qdf_mem_copy(roam_info.bssid.bytes, bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306315 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006316 if (!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
6317 (csr_is_concurrent_session_running(mac_ctx))) {
6318 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
6319 }
6320#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6321 dst_profile = &session->connectedProfile.HTProfile;
6322 src_profile = &start_bss_rsp->HTProfile;
6323 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306324 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006325 csr_roam_copy_ht_profile(dst_profile, src_profile);
6326#endif
6327 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
6328 cmd->u.roamCmd.roamId,
6329 roam_status, roam_result);
6330 }
6331
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006332}
6333
6334/**
6335 * csr_roam_process_join_res() - Process the Join results
6336 * @mac_ctx: Global MAC Context
6337 * @result: Result after the command was processed
6338 * @cmd: Command to be processed
6339 * @context: Additional data in context of the cmd
6340 *
6341 * Process the join results which are obtained in a succesful join
6342 *
6343 * Return: None
6344 */
6345static void csr_roam_process_join_res(tpAniSirGlobal mac_ctx,
6346 eCsrRoamCompleteResult res, tSmeCmd *cmd, void *context)
6347{
6348 tSirMacAddr bcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
6349 sme_QosAssocInfo assoc_info;
6350 uint32_t key_timeout_interval = 0;
6351 uint8_t acm_mask = 0; /* HDD needs ACM mask in assoc rsp callback */
6352 uint32_t session_id = cmd->sessionId;
6353 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
6354 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
6355 tSirBssDescription *bss_desc = NULL;
6356 tCsrScanResult *scan_res = NULL;
6357 sme_qos_csr_event_indType ind_qos;
6358 csr_roam_offload_synch_params *roam_offload_params = NULL;
6359#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6360 tSirSmeHTProfile *src_profile = NULL;
6361 tCsrRoamHTProfile *dst_profile = NULL;
6362#endif
6363 tCsrRoamConnectedProfile *conn_profile = NULL;
6364 tDot11fBeaconIEs *ies_ptr = NULL;
6365 tCsrRoamInfo roam_info;
6366 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
6367 tSirSmeJoinRsp *join_rsp = (tSirSmeJoinRsp *) context;
6368 uint32_t len;
6369
6370 roam_offload_params = &session->roamOffloadSynchParams;
6371 conn_profile = &session->connectedProfile;
6372 if (eCsrReassocSuccess == res)
6373 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
6374 else
6375 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
6376 sms_log(mac_ctx, LOGW, FL("receives association indication"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306377 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006378 /* always free the memory here */
6379 if (session->pWpaRsnRspIE) {
6380 session->nWpaRsnRspIeLength = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306381 qdf_mem_free(session->pWpaRsnRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006382 session->pWpaRsnRspIE = NULL;
6383 }
6384#ifdef FEATURE_WLAN_WAPI
6385 if (session->pWapiRspIE) {
6386 session->nWapiRspIeLength = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306387 qdf_mem_free(session->pWapiRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006388 session->pWapiRspIE = NULL;
6389 }
6390#endif /* FEATURE_WLAN_WAPI */
6391#ifdef FEATURE_WLAN_BTAMP_UT_RF
6392 session->maxRetryCount = 0;
6393 csr_roam_stop_join_retry_timer(mac_ctx, session_id);
6394#endif
6395 /*
6396 * Reset remain_in_power_active_till_dhcp as
6397 * it might have been set by last failed secured connection.
6398 * It should be set only for secured connection.
6399 */
6400 ps_global_info->remain_in_power_active_till_dhcp = false;
6401 if (CSR_IS_INFRASTRUCTURE(profile))
6402 session->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
6403 else
6404 session->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
6405 /*
6406 * Use the last connected bssdesc for reassoc-ing to the same AP.
6407 * NOTE: What to do when reassoc to a different AP???
6408 */
6409 if ((eCsrHddIssuedReassocToSameAP == cmd->u.roamCmd.roamReason)
6410 || (eCsrSmeIssuedReassocToSameAP ==
6411 cmd->u.roamCmd.roamReason)) {
6412 bss_desc = session->pConnectBssDesc;
6413 if (bss_desc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306414 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306415 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006416 } else {
6417 if (cmd->u.roamCmd.pRoamBssEntry) {
6418 scan_res = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
6419 tCsrScanResult, Link);
6420 if (scan_res != NULL) {
6421 bss_desc = &scan_res->Result.BssDescriptor;
6422 ies_ptr = (tDot11fBeaconIEs *)
6423 (scan_res->Result.pvIes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306424 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306425 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006426 }
6427 }
6428 }
6429 if (bss_desc) {
6430 roam_info.staId = STA_INVALID_IDX;
6431 csr_roam_save_connected_infomation(mac_ctx, session_id,
6432 profile, bss_desc, ies_ptr);
6433 /* Save WPA/RSN IE */
6434 csr_roam_save_security_rsp_ie(mac_ctx, session_id,
6435 profile->negotiatedAuthType, bss_desc, ies_ptr);
6436#ifdef FEATURE_WLAN_ESE
6437 roam_info.isESEAssoc = conn_profile->isESEAssoc;
6438#endif
6439
6440 /*
6441 * csr_roam_state_change also affects sub-state.
6442 * Hence, csr_roam_state_change happens first and then
6443 * substate change.
6444 * Moving even save profile above so that below
6445 * mentioned conditon is also met.
6446 * JEZ100225: Moved to after saving the profile.
6447 * Fix needed in main/latest
6448 */
6449 csr_roam_state_change(mac_ctx,
6450 eCSR_ROAMING_STATE_JOINED, session_id);
6451
6452 /*
6453 * Make sure the Set Context is issued before link
6454 * indication to NDIS. After link indication is
6455 * made to NDIS, frames could start flowing.
6456 * If we have not set context with LIM, the frames
6457 * will be dropped for the security context may not
6458 * be set properly.
6459 *
6460 * this was causing issues in the 2c_wlan_wep WHQL test
6461 * when the SetContext was issued after the link
6462 * indication. (Link Indication happens in the
6463 * profFSMSetConnectedInfra call).
6464 *
6465 * this reordering was done on titan_prod_usb branch
6466 * and is being replicated here.
6467 */
6468
6469 if (CSR_IS_ENC_TYPE_STATIC
6470 (profile->negotiatedUCEncryptionType) &&
6471 !profile->bWPSAssociation) {
6472 /*
6473 * Issue the set Context request to LIM to establish
6474 * the Unicast STA context
6475 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306476 if (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006477 csr_roam_issue_set_context_req(mac_ctx,
6478 session_id,
6479 profile->negotiatedUCEncryptionType,
6480 bss_desc, &(bss_desc->bssId),
6481 false, true,
6482 eSIR_TX_RX, 0, 0, NULL, 0))) {
6483 /* NO keys. these key parameters don't matter */
6484 sms_log(mac_ctx, LOGE,
6485 FL("Set context for unicast fail"));
6486 csr_roam_substate_change(mac_ctx,
6487 eCSR_ROAM_SUBSTATE_NONE, session_id);
6488 }
6489 /*
6490 * Issue the set Context request to LIM
6491 * to establish the Broadcast STA context
6492 * NO keys. these key parameters don't matter
6493 */
6494 csr_roam_issue_set_context_req(mac_ctx, session_id,
6495 profile->negotiatedMCEncryptionType,
6496 bss_desc, &bcast_mac, false, false,
6497 eSIR_TX_RX, 0, 0, NULL, 0);
6498 } else {
6499#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08006500 if (session->roam_synch_in_progress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006501 && (roam_offload_params->authStatus
6502 == CSR_ROAM_AUTH_STATUS_AUTHENTICATED)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306503 QDF_TRACE(QDF_MODULE_ID_SME,
6504 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006505 FL("LFR3:Don't start waitforkey timer"));
6506 csr_roam_substate_change(mac_ctx,
6507 eCSR_ROAM_SUBSTATE_NONE, session_id);
6508 } else {
6509#endif
6510 /* Need to wait for supplicant authtication */
6511 roam_info.fAuthRequired = true;
6512 /*
6513 * Set the substate to WaitForKey in case
6514 * authentiation is needed
6515 */
6516 csr_roam_substate_change(mac_ctx,
6517 eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY,
6518 session_id);
6519
6520 /*
6521 * Set remain_in_power_active_till_dhcp to make
6522 * sure we wait for until keys are set before
6523 * going into BMPS.
6524 */
6525 ps_global_info->remain_in_power_active_till_dhcp
6526 = true;
6527
6528 if (profile->bWPSAssociation)
6529 key_timeout_interval =
6530 CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
6531 else
6532 key_timeout_interval =
6533 CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
6534
6535 /* Save session_id in case of timeout */
6536 mac_ctx->roam.WaitForKeyTimerInfo.sessionId =
6537 (uint8_t) session_id;
6538 /*
6539 * This time should be long enough for the rest
6540 * of the process plus setting key
6541 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306542 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006543 (csr_roam_start_wait_for_key_timer(
6544 mac_ctx, key_timeout_interval))
6545 ) {
6546 /* Reset state so nothing is blocked. */
6547 sms_log(mac_ctx, LOGE, FL
6548 ("Failed preauth timer start"));
6549 csr_roam_substate_change(mac_ctx,
6550 eCSR_ROAM_SUBSTATE_NONE,
6551 session_id);
6552 }
6553#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6554 }
6555#endif
6556 }
6557
6558 assoc_info.pBssDesc = bss_desc; /* could be NULL */
6559 assoc_info.pProfile = profile;
6560 if (context) {
6561#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08006562 if (session->roam_synch_in_progress)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306563 QDF_TRACE(QDF_MODULE_ID_SME,
6564 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006565 FL("LFR3:Clear Connected info"));
6566#endif
6567 csr_roam_free_connected_info(mac_ctx,
6568 &session->connectedInfo);
6569 len = join_rsp->assocReqLength +
6570 join_rsp->assocRspLength +
6571 join_rsp->beaconLength;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006572 len += join_rsp->parsedRicRspLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006573#ifdef FEATURE_WLAN_ESE
6574 len += join_rsp->tspecIeLen;
6575#endif
6576 if (len) {
6577 session->connectedInfo.pbFrames =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306578 qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006579 if (session->connectedInfo.pbFrames !=
6580 NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306581 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006582 session->connectedInfo.pbFrames,
6583 join_rsp->frames, len);
6584 session->connectedInfo.nAssocReqLength =
6585 join_rsp->assocReqLength;
6586 session->connectedInfo.nAssocRspLength =
6587 join_rsp->assocRspLength;
6588 session->connectedInfo.nBeaconLength =
6589 join_rsp->beaconLength;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006590 session->connectedInfo.nRICRspLength =
6591 join_rsp->parsedRicRspLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006592#ifdef FEATURE_WLAN_ESE
6593 session->connectedInfo.nTspecIeLength =
6594 join_rsp->tspecIeLen;
6595#endif
6596 roam_info.nAssocReqLength =
6597 join_rsp->assocReqLength;
6598 roam_info.nAssocRspLength =
6599 join_rsp->assocRspLength;
6600 roam_info.nBeaconLength =
6601 join_rsp->beaconLength;
6602 roam_info.pbFrames =
6603 session->connectedInfo.pbFrames;
6604 }
6605 }
6606 if (cmd->u.roamCmd.fReassoc)
6607 roam_info.fReassocReq =
6608 roam_info.fReassocRsp = true;
6609 conn_profile->vht_channel_width =
6610 join_rsp->vht_channel_width;
6611 session->connectedInfo.staId =
6612 (uint8_t) join_rsp->staId;
6613 roam_info.staId = (uint8_t) join_rsp->staId;
6614 roam_info.ucastSig = (uint8_t) join_rsp->ucastSig;
6615 roam_info.bcastSig = (uint8_t) join_rsp->bcastSig;
6616 roam_info.timingMeasCap = join_rsp->timingMeasCap;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05306617 roam_info.chan_info.nss = join_rsp->nss;
6618 roam_info.chan_info.rate_flags =
6619 join_rsp->max_rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006620#ifdef FEATURE_WLAN_TDLS
6621 roam_info.tdls_prohibited = join_rsp->tdls_prohibited;
6622 roam_info.tdls_chan_swit_prohibited =
6623 join_rsp->tdls_chan_swit_prohibited;
6624 sms_log(mac_ctx, LOG1,
6625 FL("tdls:prohibit: %d, chan_swit_prohibit: %d"),
6626 roam_info.tdls_prohibited,
6627 roam_info.tdls_chan_swit_prohibited);
6628#endif
6629#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6630 src_profile = &join_rsp->HTProfile;
6631 dst_profile = &conn_profile->HTProfile;
6632 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306633 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006634 csr_roam_copy_ht_profile(dst_profile,
6635 src_profile);
6636#endif
6637 } else {
6638 if (cmd->u.roamCmd.fReassoc) {
6639 roam_info.fReassocReq =
6640 roam_info.fReassocRsp = true;
6641 roam_info.nAssocReqLength =
6642 session->connectedInfo.nAssocReqLength;
6643 roam_info.nAssocRspLength =
6644 session->connectedInfo.nAssocRspLength;
6645 roam_info.nBeaconLength =
6646 session->connectedInfo.nBeaconLength;
6647 roam_info.pbFrames =
6648 session->connectedInfo.pbFrames;
6649 }
6650 }
6651
6652 /*
6653 * Update the staId from the previous connected profile info
6654 * as the reassociation is triggred at SME/HDD
6655 */
6656
6657 if ((eCsrHddIssuedReassocToSameAP ==
6658 cmd->u.roamCmd.roamReason) ||
6659 (eCsrSmeIssuedReassocToSameAP ==
6660 cmd->u.roamCmd.roamReason))
6661 roam_info.staId = session->connectedInfo.staId;
6662
6663#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6664 /*
6665 * Indicate SME-QOS with reassoc success event,
6666 * only after copying the frames
6667 */
6668 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id, ind_qos,
6669 &assoc_info);
6670#endif
6671 roam_info.pBssDesc = bss_desc;
6672 roam_info.statusCode =
6673 session->joinFailStatusCode.statusCode;
6674 roam_info.reasonCode =
6675 session->joinFailStatusCode.reasonCode;
6676#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6677 acm_mask = sme_qos_get_acm_mask(mac_ctx, bss_desc, NULL);
6678#endif
6679 conn_profile->acm_mask = acm_mask;
6680 /*
6681 * start UAPSD if uapsd_mask is not 0 because HDD will
6682 * configure for trigger frame It may be better to let QoS do
6683 * this????
6684 */
6685 if (conn_profile->modifyProfileFields.uapsd_mask) {
6686 sms_log(mac_ctx, LOGE,
6687 " uapsd_mask (0x%X) set, request UAPSD now",
6688 conn_profile->modifyProfileFields.uapsd_mask);
6689 sme_ps_start_uapsd(mac_ctx, session_id,
6690 NULL, NULL);
6691 }
6692 conn_profile->dot11Mode = session->bssParams.uCfgDot11Mode;
6693 roam_info.u.pConnectedProfile = conn_profile;
6694
6695 if (session->bRefAssocStartCnt > 0) {
6696 session->bRefAssocStartCnt--;
6697 if (!IS_FEATURE_SUPPORTED_BY_FW
6698 (SLM_SESSIONIZATION) &&
6699 (csr_is_concurrent_session_running(mac_ctx))) {
6700 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
6701 }
6702#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08006703 if (session->roam_synch_in_progress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006704 roam_info.roamSynchInProgress = 1;
6705 roam_info.synchAuthStatus =
6706 roam_offload_params->authStatus;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306707 qdf_mem_copy(roam_info.kck,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006708 roam_offload_params->kck,
6709 SIR_KCK_KEY_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306710 qdf_mem_copy(roam_info.kek,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006711 roam_offload_params->kek,
6712 SIR_KEK_KEY_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306713 qdf_mem_copy(roam_info.replay_ctr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006714 roam_offload_params->replay_ctr,
6715 SIR_REPLAY_CTR_LEN);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306716 QDF_TRACE(QDF_MODULE_ID_SME,
6717 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006718 FL
6719 ("LFR3: Copy KCK, KEK and Replay Ctr"));
6720 }
Ravi Joshi277ae9b2015-11-13 11:30:43 -08006721
6722 roam_info.subnet_change_status =
6723 CSR_GET_SUBNET_STATUS(roam_offload_params->roamReason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006724#endif
6725 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
6726 cmd->u.roamCmd.roamId,
6727 eCSR_ROAM_ASSOCIATION_COMPLETION,
6728 eCSR_ROAM_RESULT_ASSOCIATED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006729 }
6730
6731 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
6732 eCSR_ROAM_RESULT_NONE, true);
6733 csr_reset_pmkid_candidate_list(mac_ctx, session_id);
6734#ifdef FEATURE_WLAN_WAPI
6735 csr_reset_bkid_candidate_list(mac_ctx, session_id);
6736#endif
6737 } else {
6738 sms_log(mac_ctx, LOGW,
6739 "Roam command doesn't have a BSS desc");
6740 }
6741 /* Not to signal link up because keys are yet to be set.
6742 * The linkup function will overwrite the sub-state that
6743 * we need to keep at this point.
6744 */
6745 if (!CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id)) {
6746#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08006747 if (session->roam_synch_in_progress) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306748 QDF_TRACE(QDF_MODULE_ID_SME,
6749 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006750 FL
6751 ("NO CSR_IS_WAIT_FOR_KEY -> csr_roam_link_up"));
6752 }
6753#endif
6754 csr_roam_link_up(mac_ctx, conn_profile->bssid);
6755 }
6756}
6757
6758/**
6759 * csr_roam_process_results() - Process the Roam Results
6760 * @mac_ctx: Global MAC Context
6761 * @cmd: Command that has been processed
6762 * @res: Results available after processing the command
6763 * @context: Context
6764 *
6765 * Process the available results and make an appropriate decision
6766 *
6767 * Return: true if the command can be released, else not.
6768 */
6769static bool csr_roam_process_results(tpAniSirGlobal mac_ctx, tSmeCmd *cmd,
6770 eCsrRoamCompleteResult res, void *context)
6771{
6772 bool release_cmd = true;
6773 tSirBssDescription *bss_desc = NULL;
6774 tCsrRoamInfo roam_info;
6775 uint32_t session_id = cmd->sessionId;
6776 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
6777 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
6778 eRoamCmdStatus roam_status;
6779 eCsrRoamResult roam_result;
6780 host_log_ibss_pkt_type *ibss_log;
6781
6782 if (!session) {
6783 sms_log(mac_ctx, LOGE, FL("session %d not found "), session_id);
6784 return false;
6785 }
6786 sms_log(mac_ctx, LOG1, FL("Processing ROAM results..."));
6787 switch (res) {
6788 case eCsrJoinSuccess:
6789 case eCsrReassocSuccess:
6790 csr_roam_process_join_res(mac_ctx, res, cmd, context);
6791 break;
6792 case eCsrStartBssSuccess:
6793 csr_roam_process_start_bss_success(mac_ctx, cmd, context);
6794 break;
6795 case eCsrStartBssFailure:
6796#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6797 WLAN_HOST_DIAG_LOG_ALLOC(ibss_log,
6798 host_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6799 if (ibss_log) {
6800 ibss_log->status = WLAN_IBSS_STATUS_FAILURE;
6801 WLAN_HOST_DIAG_LOG_REPORT(ibss_log);
6802 }
6803#endif
6804 roam_status = eCSR_ROAM_IBSS_IND;
6805 roam_result = eCSR_ROAM_RESULT_IBSS_STARTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006806 if (CSR_IS_INFRA_AP(profile)) {
6807 roam_status = eCSR_ROAM_INFRA_IND;
6808 roam_result = eCSR_ROAM_RESULT_INFRA_START_FAILED;
6809 }
6810 if (context) {
6811 bss_desc = (tSirBssDescription *) context;
6812 } else {
6813 bss_desc = NULL;
6814 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306815 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006816 roam_info.pBssDesc = bss_desc;
6817 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
6818 cmd->u.roamCmd.roamId, roam_status,
6819 roam_result);
6820 csr_set_default_dot11_mode(mac_ctx);
6821 break;
6822 case eCsrSilentlyStopRoaming:
6823 /*
6824 * We are here because we try to start the same IBSS.
6825 * No message to PE. return the roaming state to Joined.
6826 */
6827 sms_log(mac_ctx, LOGW, FL("receives silently stop roam ind"));
6828 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
6829 session_id);
6830 csr_roam_substate_change(mac_ctx, eCSR_ROAM_SUBSTATE_NONE,
6831 session_id);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306832 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006833 roam_info.pBssDesc = session->pConnectBssDesc;
6834 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306835 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006836 &roam_info.pBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306837 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006838 /*
6839 * Since there is no change in the current state, simply pass
6840 * back no result otherwise HDD may be mistakenly mark to
6841 * disconnected state.
6842 */
6843 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
6844 cmd->u.roamCmd.roamId,
6845 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE);
6846 break;
6847 case eCsrSilentlyStopRoamingSaveState:
6848 /* We are here because we try to connect to the same AP */
6849 /* No message to PE */
6850 sms_log(mac_ctx, LOGW,
6851 FL("receives silently stop roaming indication"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306852 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006853
6854 /* to aviod resetting the substate to NONE */
6855 mac_ctx->roam.curState[session_id] = eCSR_ROAMING_STATE_JOINED;
6856 /*
6857 * No need to change substate to wai_for_key because there
6858 * is no state change
6859 */
6860 roam_info.pBssDesc = session->pConnectBssDesc;
6861 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306862 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006863 &roam_info.pBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306864 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006865 roam_info.statusCode = session->joinFailStatusCode.statusCode;
6866 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
6867 roam_info.nBeaconLength = session->connectedInfo.nBeaconLength;
6868 roam_info.nAssocReqLength =
6869 session->connectedInfo.nAssocReqLength;
6870 roam_info.nAssocRspLength =
6871 session->connectedInfo.nAssocRspLength;
6872 roam_info.pbFrames = session->connectedInfo.pbFrames;
6873 roam_info.staId = session->connectedInfo.staId;
6874 roam_info.u.pConnectedProfile = &session->connectedProfile;
Abhishek Singhacfdc922015-12-30 17:31:21 +05306875 if (0 == roam_info.staId)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306876 QDF_ASSERT(0);
Abhishek Singhacfdc922015-12-30 17:31:21 +05306877
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006878 session->bRefAssocStartCnt--;
6879 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
6880 cmd->u.roamCmd.roamId,
6881 eCSR_ROAM_ASSOCIATION_COMPLETION,
6882 eCSR_ROAM_RESULT_ASSOCIATED);
6883 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
6884 eCSR_ROAM_RESULT_ASSOCIATED, true);
6885 break;
6886 case eCsrReassocFailure:
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006887 /*
6888 * Currently Reassoc failure is handled through eCsrJoinFailure
6889 * Need to revisit for eCsrReassocFailure handling
6890 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006891#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6892 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
6893 SME_QOS_CSR_REASSOC_FAILURE, NULL);
6894#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006895 break;
6896 case eCsrJoinFailure:
6897 case eCsrNothingToJoin:
6898 case eCsrJoinFailureDueToConcurrency:
6899 default:
6900 csr_roam_process_results_default(mac_ctx, cmd, context, res);
6901 break;
6902 }
6903 return release_cmd;
6904}
6905
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306906QDF_STATUS csr_roam_copy_profile(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006907 tCsrRoamProfile *pDstProfile,
6908 tCsrRoamProfile *pSrcProfile)
6909{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306910 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006911 uint32_t size = 0;
6912
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306913 qdf_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006914 if (pSrcProfile->BSSIDs.numOfBSSIDs) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05306915 size = sizeof(struct qdf_mac_addr) * pSrcProfile->BSSIDs.numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306916 pDstProfile->BSSIDs.bssid = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006917 if (NULL == pDstProfile->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306918 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006919 goto end;
6920 }
6921 pDstProfile->BSSIDs.numOfBSSIDs =
6922 pSrcProfile->BSSIDs.numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306923 qdf_mem_copy(pDstProfile->BSSIDs.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006924 pSrcProfile->BSSIDs.bssid, size);
6925 }
6926 if (pSrcProfile->SSIDs.numOfSSIDs) {
6927 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306928 pDstProfile->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006929 if (NULL == pDstProfile->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306930 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006931 goto end;
6932 }
6933 pDstProfile->SSIDs.numOfSSIDs =
6934 pSrcProfile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306935 qdf_mem_copy(pDstProfile->SSIDs.SSIDList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006936 pSrcProfile->SSIDs.SSIDList, size);
6937 }
6938 if (pSrcProfile->nWPAReqIELength) {
6939 pDstProfile->pWPAReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306940 qdf_mem_malloc(pSrcProfile->nWPAReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006941 if (NULL == pDstProfile->pWPAReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306942 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006943 goto end;
6944 }
6945 pDstProfile->nWPAReqIELength =
6946 pSrcProfile->nWPAReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306947 qdf_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006948 pSrcProfile->nWPAReqIELength);
6949 }
6950 if (pSrcProfile->nRSNReqIELength) {
6951 pDstProfile->pRSNReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306952 qdf_mem_malloc(pSrcProfile->nRSNReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006953 if (NULL == pDstProfile->pRSNReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306954 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006955 goto end;
6956 }
6957 pDstProfile->nRSNReqIELength =
6958 pSrcProfile->nRSNReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306959 qdf_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006960 pSrcProfile->nRSNReqIELength);
6961 }
6962#ifdef FEATURE_WLAN_WAPI
6963 if (pSrcProfile->nWAPIReqIELength) {
6964 pDstProfile->pWAPIReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306965 qdf_mem_malloc(pSrcProfile->nWAPIReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006966 if (NULL == pDstProfile->pWAPIReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306967 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006968 goto end;
6969 }
6970 pDstProfile->nWAPIReqIELength =
6971 pSrcProfile->nWAPIReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306972 qdf_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006973 pSrcProfile->nWAPIReqIELength);
6974 }
6975#endif /* FEATURE_WLAN_WAPI */
6976 if (pSrcProfile->nAddIEScanLength) {
6977 pDstProfile->pAddIEScan =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306978 qdf_mem_malloc(pSrcProfile->nAddIEScanLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006979 if (NULL == pDstProfile->pAddIEScan) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306980 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006981 goto end;
6982 }
6983 pDstProfile->nAddIEScanLength =
6984 pSrcProfile->nAddIEScanLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306985 qdf_mem_copy(pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006986 pSrcProfile->nAddIEScanLength);
6987 }
6988 if (pSrcProfile->nAddIEAssocLength) {
6989 pDstProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306990 qdf_mem_malloc(pSrcProfile->nAddIEAssocLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006991 if (NULL == pDstProfile->pAddIEAssoc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306992 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006993 goto end;
6994 }
6995 pDstProfile->nAddIEAssocLength =
6996 pSrcProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306997 qdf_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006998 pSrcProfile->nAddIEAssocLength);
6999 }
7000 if (pSrcProfile->ChannelInfo.ChannelList) {
7001 pDstProfile->ChannelInfo.ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307002 qdf_mem_malloc(pSrcProfile->ChannelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007003 numOfChannels);
7004 if (NULL == pDstProfile->ChannelInfo.ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307005 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007006 goto end;
7007 }
7008 pDstProfile->ChannelInfo.numOfChannels =
7009 pSrcProfile->ChannelInfo.numOfChannels;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307010 qdf_mem_copy(pDstProfile->ChannelInfo.ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007011 pSrcProfile->ChannelInfo.ChannelList,
7012 pSrcProfile->ChannelInfo.numOfChannels);
7013 }
7014 pDstProfile->AuthType = pSrcProfile->AuthType;
7015 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
7016 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
7017 pDstProfile->negotiatedUCEncryptionType =
7018 pSrcProfile->negotiatedUCEncryptionType;
7019 pDstProfile->negotiatedMCEncryptionType =
7020 pSrcProfile->negotiatedMCEncryptionType;
7021 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
7022#ifdef WLAN_FEATURE_11W
7023 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
7024 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
7025 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
7026#endif
7027 pDstProfile->BSSType = pSrcProfile->BSSType;
7028 pDstProfile->phyMode = pSrcProfile->phyMode;
7029 pDstProfile->csrPersona = pSrcProfile->csrPersona;
7030
7031#ifdef FEATURE_WLAN_WAPI
7032 if (csr_is_profile_wapi(pSrcProfile))
7033 if (pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
7034 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
7035#endif /* FEATURE_WLAN_WAPI */
7036 pDstProfile->CBMode = pSrcProfile->CBMode;
7037 pDstProfile->ch_params.ch_width = pSrcProfile->ch_params.ch_width;
7038 pDstProfile->ch_params.center_freq_seg0 =
7039 pSrcProfile->ch_params.center_freq_seg0;
7040 pDstProfile->ch_params.center_freq_seg1 =
7041 pSrcProfile->ch_params.center_freq_seg1;
7042 pDstProfile->ch_params.sec_ch_offset =
7043 pSrcProfile->ch_params.sec_ch_offset;
7044 /*Save the WPS info */
7045 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
7046 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
7047 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
7048 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
7049 pDstProfile->privacy = pSrcProfile->privacy;
7050 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
7051 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
7052 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
7053 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
7054 pDstProfile->SSIDs.SSIDList[0].ssidHidden =
7055 pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
7056 pDstProfile->protEnabled = pSrcProfile->protEnabled;
7057 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
7058 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
7059 pDstProfile->wps_state = pSrcProfile->wps_state;
7060 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
7061 pDstProfile->sap_dot11mc = pSrcProfile->sap_dot11mc;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307062 qdf_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007063 sizeof(pDstProfile->Keys));
7064#ifdef WLAN_FEATURE_11W
7065 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
7066 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
7067 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
7068#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007069 if (pSrcProfile->MDID.mdiePresent) {
7070 pDstProfile->MDID.mdiePresent = 1;
7071 pDstProfile->MDID.mobilityDomain =
7072 pSrcProfile->MDID.mobilityDomain;
7073 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307074 qdf_mem_copy(&pDstProfile->addIeParams, &pSrcProfile->addIeParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007075 sizeof(tSirAddIeParams));
7076end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307077 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007078 csr_release_profile(pMac, pDstProfile);
7079 pDstProfile = NULL;
7080 }
7081
7082 return status;
7083}
7084
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307085QDF_STATUS csr_roam_copy_connected_profile(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007086 uint32_t sessionId, tCsrRoamProfile *pDstProfile)
7087{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307088 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007089 tCsrRoamConnectedProfile *pSrcProfile =
7090 &pMac->roam.roamSession[sessionId].connectedProfile;
7091
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307092 qdf_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007093
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307094 pDstProfile->BSSIDs.bssid = qdf_mem_malloc(sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007095 if (NULL == pDstProfile->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307096 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007097 sms_log(pMac, LOGE,
7098 FL("failed to allocate memory for BSSID "
7099 MAC_ADDRESS_STR),
7100 MAC_ADDR_ARRAY(pSrcProfile->bssid.bytes));
7101 goto end;
7102 }
7103 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Anurag Chouhanc5548422016-02-24 18:33:27 +05307104 qdf_copy_macaddr(pDstProfile->BSSIDs.bssid, &pSrcProfile->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007105
7106 if (pSrcProfile->SSID.ssId) {
7107 pDstProfile->SSIDs.SSIDList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307108 qdf_mem_malloc(sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007109 if (NULL == pDstProfile->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307110 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007111 sms_log(pMac, LOGE,
7112 FL("failed to allocate memory for SSID "
7113 MAC_ADDRESS_STR),
7114 MAC_ADDR_ARRAY(pSrcProfile->bssid.bytes));
7115 goto end;
7116 }
7117 pDstProfile->SSIDs.numOfSSIDs = 1;
7118 pDstProfile->SSIDs.SSIDList[0].handoffPermitted =
7119 pSrcProfile->handoffPermitted;
7120 pDstProfile->SSIDs.SSIDList[0].ssidHidden =
7121 pSrcProfile->ssidHidden;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307122 qdf_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007123 &pSrcProfile->SSID, sizeof(tSirMacSSid));
7124 }
7125 if (pSrcProfile->nAddIEAssocLength) {
7126 pDstProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307127 qdf_mem_malloc(pSrcProfile->nAddIEAssocLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007128 if (NULL == pDstProfile->pAddIEAssoc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307129 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007130 sms_log(pMac, LOGE,
7131 FL("failed to allocate mem for additional ie"));
7132 goto end;
7133 }
7134 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307135 qdf_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007136 pSrcProfile->nAddIEAssocLength);
7137 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307138 pDstProfile->ChannelInfo.ChannelList = qdf_mem_malloc(1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007139 if (NULL == pDstProfile->ChannelInfo.ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307140 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007141 goto end;
7142 }
7143 pDstProfile->ChannelInfo.numOfChannels = 1;
7144 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
7145 pDstProfile->AuthType.numEntries = 1;
7146 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
7147 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
7148 pDstProfile->EncryptionType.numEntries = 1;
7149 pDstProfile->EncryptionType.encryptionType[0] =
7150 pSrcProfile->EncryptionType;
7151 pDstProfile->negotiatedUCEncryptionType =
7152 pSrcProfile->EncryptionType;
7153 pDstProfile->mcEncryptionType.numEntries = 1;
7154 pDstProfile->mcEncryptionType.encryptionType[0] =
7155 pSrcProfile->mcEncryptionType;
7156 pDstProfile->negotiatedMCEncryptionType =
7157 pSrcProfile->mcEncryptionType;
7158 pDstProfile->BSSType = pSrcProfile->BSSType;
7159 pDstProfile->CBMode = pSrcProfile->CBMode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307160 qdf_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007161 sizeof(pDstProfile->Keys));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007162 if (pSrcProfile->MDID.mdiePresent) {
7163 pDstProfile->MDID.mdiePresent = 1;
7164 pDstProfile->MDID.mobilityDomain =
7165 pSrcProfile->MDID.mobilityDomain;
7166 }
Krunal Sonib2f13042015-11-02 18:41:08 -08007167#ifdef WLAN_FEATURE_11W
7168 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
7169 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
7170 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
7171#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007172
7173end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307174 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007175 csr_release_profile(pMac, pDstProfile);
7176 pDstProfile = NULL;
7177 }
7178
7179 return status;
7180}
7181
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307182QDF_STATUS csr_roam_issue_connect(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007183 tCsrRoamProfile *pProfile,
7184 tScanResultHandle hBSSList,
7185 eCsrRoamReason reason, uint32_t roamId,
7186 bool fImediate, bool fClearScan)
7187{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307188 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007189 tSmeCmd *pCommand;
7190
7191 pCommand = csr_get_command_buffer(pMac);
7192 if (NULL == pCommand) {
7193 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307194 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007195 } else {
7196 if (fClearScan) {
7197 csr_scan_abort_mac_scan_not_for_connect(pMac, sessionId);
7198 }
7199 pCommand->u.roamCmd.fReleaseProfile = false;
7200 if (NULL == pProfile) {
7201 /* We can roam now */
7202 /* Since pProfile is NULL, we need to build our own profile, set everything to default */
7203 /* We can only support open and no encryption */
7204 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
7205 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] =
7206 eCSR_AUTH_TYPE_OPEN_SYSTEM;
7207 pCommand->u.roamCmd.roamProfile.EncryptionType.
7208 numEntries = 1;
7209 pCommand->u.roamCmd.roamProfile.EncryptionType.
7210 encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
7211 pCommand->u.roamCmd.roamProfile.csrPersona =
Anurag Chouhan6d760662016-02-20 16:05:43 +05307212 QDF_STA_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007213 } else {
7214 /* make a copy of the profile */
7215 status =
7216 csr_roam_copy_profile(pMac,
7217 &pCommand->u.roamCmd.roamProfile,
7218 pProfile);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307219 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007220 pCommand->u.roamCmd.fReleaseProfile = true;
7221 }
7222 }
7223
7224 pCommand->command = eSmeCommandRoam;
7225 pCommand->sessionId = (uint8_t) sessionId;
7226 pCommand->u.roamCmd.hBSSList = hBSSList;
7227 pCommand->u.roamCmd.roamId = roamId;
7228 pCommand->u.roamCmd.roamReason = reason;
7229 /* We need to free the BssList when the command is done */
7230 pCommand->u.roamCmd.fReleaseBssList = true;
7231 pCommand->u.roamCmd.fUpdateCurRoamProfile = true;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307232 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007233 FL("CSR PERSONA=%d"),
7234 pCommand->u.roamCmd.roamProfile.csrPersona);
7235 status = csr_queue_sme_command(pMac, pCommand, fImediate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307236 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007237 sms_log(pMac, LOGE,
7238 FL(" fail to send message status = %d"), status);
7239 csr_release_command_roam(pMac, pCommand);
7240 }
7241 }
7242
7243 return status;
7244}
7245
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307246QDF_STATUS csr_roam_issue_reassoc(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007247 tCsrRoamProfile *pProfile,
7248 tCsrRoamModifyProfileFields *pMmodProfileFields,
7249 eCsrRoamReason reason, uint32_t roamId,
7250 bool fImediate)
7251{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307252 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007253 tSmeCmd *pCommand;
7254
7255 pCommand = csr_get_command_buffer(pMac);
7256 if (NULL == pCommand) {
7257 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307258 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007259 } else {
7260 csr_scan_abort_mac_scan_not_for_connect(pMac, sessionId);
7261 if (pProfile) {
7262 /* This is likely trying to reassoc to different profile */
7263 pCommand->u.roamCmd.fReleaseProfile = false;
7264 /* make a copy of the profile */
7265 status =
7266 csr_roam_copy_profile(pMac,
7267 &pCommand->u.roamCmd.roamProfile,
7268 pProfile);
7269 pCommand->u.roamCmd.fUpdateCurRoamProfile = true;
7270 } else {
7271 status =
7272 csr_roam_copy_connected_profile(pMac, sessionId,
7273 &pCommand->u.roamCmd.
7274 roamProfile);
7275 /* how to update WPA/WPA2 info in roamProfile?? */
7276 pCommand->u.roamCmd.roamProfile.uapsd_mask =
7277 pMmodProfileFields->uapsd_mask;
7278 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307279 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007280 pCommand->u.roamCmd.fReleaseProfile = true;
7281 }
7282 pCommand->command = eSmeCommandRoam;
7283 pCommand->sessionId = (uint8_t) sessionId;
7284 pCommand->u.roamCmd.roamId = roamId;
7285 pCommand->u.roamCmd.roamReason = reason;
7286 /* We need to free the BssList when the command is done */
7287 /* For reassoc there is no BSS list, so the bool set to false */
7288 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
7289 pCommand->u.roamCmd.fReleaseBssList = false;
7290 pCommand->u.roamCmd.fReassoc = true;
7291 csr_roam_remove_duplicate_command(pMac, sessionId, pCommand,
7292 reason);
7293 status = csr_queue_sme_command(pMac, pCommand, fImediate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307294 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007295 sms_log(pMac, LOGE,
7296 FL(" fail to send message status = %d"), status);
7297 csr_roam_completion(pMac, sessionId, NULL, pCommand,
7298 eCSR_ROAM_RESULT_FAILURE, false);
7299 csr_release_command_roam(pMac, pCommand);
7300 }
7301 }
7302 return status;
7303}
7304
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307305QDF_STATUS csr_dequeue_roam_command(tpAniSirGlobal pMac, eCsrRoamReason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007306{
7307 tListElem *pEntry;
7308 tSmeCmd *pCommand;
7309 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7310 if (pEntry) {
7311 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7312 if ((eSmeCommandRoam == pCommand->command) &&
7313 (eCsrPerformPreauth == reason)) {
7314 sms_log(pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
7315 pCommand->command,
7316 pCommand->u.roamCmd.roamReason);
7317 if (csr_ll_remove_entry
7318 (&pMac->sme.smeCmdActiveList, pEntry,
7319 LL_ACCESS_LOCK)) {
7320 csr_release_command_preauth(pMac, pCommand);
7321 }
7322 } else if ((eSmeCommandRoam == pCommand->command) &&
7323 (eCsrSmeIssuedFTReassoc == reason)) {
7324 sms_log(pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
7325 pCommand->command,
7326 pCommand->u.roamCmd.roamReason);
7327 if (csr_ll_remove_entry
7328 (&pMac->sme.smeCmdActiveList, pEntry,
7329 LL_ACCESS_LOCK)) {
7330 csr_release_command_roam(pMac, pCommand);
7331 }
7332 } else {
7333 sms_log(pMac, LOGE, FL("Command = %d, Reason = %d "),
7334 pCommand->command,
7335 pCommand->u.roamCmd.roamReason);
7336 }
7337 } else {
7338 sms_log(pMac, LOGE,
7339 FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
7340 }
7341 sme_process_pending_queue(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307342 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007343}
7344
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307345QDF_STATUS csr_roam_connect(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007346 tCsrRoamProfile *pProfile,
7347 uint32_t *pRoamId)
7348{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307349 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007350 tScanResultHandle hBSSList;
7351 tCsrScanResultFilter *pScanFilter;
7352 uint32_t roamId = 0;
7353 bool fCallCallback = false;
7354 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
7355 tSirBssDescription first_ap_profile;
7356
7357 if (NULL == pSession) {
7358 sms_log(pMac, LOGE,
7359 FL("session does not exist for given sessionId:%d"),
7360 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307361 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007362 }
7363
7364 if (NULL == pProfile) {
7365 sms_log(pMac, LOGP, FL("No profile specified"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307366 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007367 }
7368 /* Initialize the count before proceeding with the Join requests */
7369 pSession->join_bssid_count = 0;
7370 sms_log(pMac, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05307371 FL("called BSSType = %s (%d) authtype = %d encryType = %d"),
7372 lim_bss_type_to_string(pProfile->BSSType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007373 pProfile->BSSType, pProfile->AuthType.authType[0],
7374 pProfile->EncryptionType.encryptionType[0]);
7375 csr_roam_cancel_roaming(pMac, sessionId);
7376 csr_scan_remove_fresh_scan_command(pMac, sessionId);
7377 /* Only abort the scan if its not used for other roam/connect purpose */
7378 csr_scan_abort_mac_scan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
7379 csr_roam_remove_duplicate_command(pMac, sessionId, NULL, eCsrHddIssued);
7380 /* Check whether ssid changes */
7381 if (csr_is_conn_state_connected(pMac, sessionId) &&
7382 pProfile->SSIDs.numOfSSIDs && !csr_is_ssid_in_list(pMac,
7383 &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7384 csr_roam_issue_disassociate_cmd(pMac, sessionId,
7385 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Abhishek Singhacfdc922015-12-30 17:31:21 +05307386 /*
7387 * If roamSession.connectState is disconnecting that mean
7388 * disconnect was received with scan for ssid in progress
7389 * and dropped. This state will ensure that connect will
7390 * not be issued from scan for ssid completion. Thus
7391 * if this fresh connect also issue scan for ssid the connect
7392 * command will be dropped assuming disconnect is in progress.
7393 * Thus reset connectState here
7394 */
7395 if (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING ==
7396 pMac->roam.roamSession[sessionId].connectState)
7397 pMac->roam.roamSession[sessionId].connectState =
7398 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007399#ifdef FEATURE_WLAN_BTAMP_UT_RF
7400 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
7401#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307402 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007403 if (NULL == pScanFilter) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307404 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007405 goto end;
7406 }
7407
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307408 qdf_mem_set(pScanFilter, sizeof(tCsrScanResultFilter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007409 0);
7410 /* Try to connect to any BSS */
7411 if (NULL == pProfile) {
7412 /* No encryption */
7413 pScanFilter->EncryptionType.numEntries = 1;
7414 pScanFilter->EncryptionType.encryptionType[0] =
7415 eCSR_ENCRYPT_TYPE_NONE;
7416 } else {
7417 /* Here is the profile we need to connect to */
7418 status = csr_roam_prepare_filter_from_profile(pMac,
7419 pProfile, pScanFilter);
7420 }
7421 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7422 if (pRoamId)
7423 *pRoamId = roamId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307424 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307425 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007426 goto end;
7427 }
7428
7429 /*Save the WPS info */
7430 if (NULL != pProfile) {
7431 pScanFilter->bWPSAssociation =
7432 pProfile->bWPSAssociation;
7433 pScanFilter->bOSENAssociation =
7434 pProfile->bOSENAssociation;
7435 } else {
7436 pScanFilter->bWPSAssociation = 0;
7437 pScanFilter->bOSENAssociation = 0;
7438 }
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007439 if (pProfile && CSR_IS_INFRA_AP(pProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007440 /* This can be started right away */
7441 status = csr_roam_issue_connect(pMac, sessionId, pProfile, NULL,
7442 eCsrHddIssued, roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307443 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007444 sms_log(pMac, LOGE,
7445 FL("CSR failed to issue start BSS cmd with status = 0x%08X"),
7446 status);
7447 fCallCallback = true;
7448 } else {
7449 sms_log(pMac, LOG1,
7450 FL("Connect request to proceed for sap mode"));
7451 }
7452
7453 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307454 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007455 goto end;
7456 }
7457 status = csr_scan_get_result(pMac, pScanFilter, &hBSSList);
7458 sms_log(pMac, LOG1,
7459 FL("******* csr_scan_get_result Status ****** %d"), status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307460 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007461 /* check if set hw mode needs to be done */
7462 if ((pMac->policy_manager_enabled) &&
Anurag Chouhan6d760662016-02-20 16:05:43 +05307463 ((pScanFilter->csrPersona == QDF_STA_MODE) ||
7464 (pScanFilter->csrPersona == QDF_P2P_CLIENT_MODE))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007465 csr_get_bssdescr_from_scan_handle(hBSSList,
7466 &first_ap_profile);
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05307467 status = cds_handle_conc_multiport(sessionId,
7468 first_ap_profile.channelId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307469 if ((QDF_IS_STATUS_SUCCESS(status)) &&
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05307470 (!csr_wait_for_connection_update(pMac, true))) {
7471 sms_log(pMac, LOG1,
7472 FL("conn update error"));
7473 csr_scan_result_purge(pMac, hBSSList);
7474 fCallCallback = true;
7475 goto error;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307476 } else if (status == QDF_STATUS_E_FAILURE) {
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05307477 sms_log(pMac, LOG1, FL("conn update error"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007478 csr_scan_result_purge(pMac, hBSSList);
7479 fCallCallback = true;
7480 goto error;
7481 }
7482 }
7483
7484 status = csr_roam_issue_connect(pMac, sessionId, pProfile,
7485 hBSSList, eCsrHddIssued, roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307486 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007487 sms_log(pMac, LOGE,
7488 FL("CSR failed to issue connect cmd with status = 0x%08X"),
7489 status);
7490 csr_scan_result_purge(pMac, hBSSList);
7491 fCallCallback = true;
7492 }
7493 } else if (NULL != pProfile) {
7494 /* Check whether it is for start ibss */
7495 if (CSR_IS_START_IBSS(pProfile)) {
7496 status = csr_roam_issue_connect(pMac, sessionId,
7497 pProfile, NULL, eCsrHddIssued,
7498 roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307499 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007500 sms_log(pMac, LOGE,
7501 FL("CSR failed to issue startIBSS cmd with status = 0x%08X"),
7502 status);
7503 fCallCallback = true;
7504 }
7505 } else {
7506 /* scan for this SSID */
7507 status = csr_scan_for_ssid(pMac, sessionId, pProfile,
7508 roamId, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307509 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007510 sms_log(pMac, LOGE,
7511 FL("CSR failed to issue SSID scan cmd with status = 0x%08X"),
7512 status);
7513 fCallCallback = true;
7514 } else {
7515 sms_log(pMac, LOG1,
7516 FL("SSID scan requested"));
7517 }
7518 }
7519 } else {
7520 fCallCallback = true;
7521 }
7522
7523error:
7524 if (NULL != pProfile)
7525 /*
7526 * we need to free memory for filter
7527 * if profile exists
7528 */
7529 csr_free_scan_filter(pMac, pScanFilter);
7530
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307531 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007532end:
7533 /* tell the caller if we fail to trigger a join request */
7534 if (fCallCallback) {
7535 csr_roam_call_callback(pMac, sessionId, NULL, roamId,
7536 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7537 }
7538 return status;
7539}
7540
7541/**
7542 * csr_roam_reassoc() - process reassoc command
7543 * @mac_ctx: mac global context
7544 * @session_id: session id
7545 * @profile: roam profile
7546 * @mod_fields: AC info being modified in reassoc
7547 * @roam_id: roam id to be populated
7548 *
7549 * Return: status of operation
7550 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307551QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007552csr_roam_reassoc(tpAniSirGlobal mac_ctx, uint32_t session_id,
7553 tCsrRoamProfile *profile,
7554 tCsrRoamModifyProfileFields mod_fields,
7555 uint32_t *roam_id)
7556{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307557 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007558 bool fCallCallback = true;
7559 uint32_t roamId = 0;
7560
7561 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
7562 if (NULL == profile) {
7563 sms_log(mac_ctx, LOGP, FL("No profile specified"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307564 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007565 }
7566 sms_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05307567 FL("called BSSType = %s (%d) authtype = %d encryType = %d"),
7568 lim_bss_type_to_string(profile->BSSType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007569 profile->BSSType, profile->AuthType.authType[0],
7570 profile->EncryptionType.encryptionType[0]);
7571 csr_roam_cancel_roaming(mac_ctx, session_id);
7572 csr_scan_remove_fresh_scan_command(mac_ctx, session_id);
7573 csr_scan_abort_mac_scan_not_for_connect(mac_ctx, session_id);
7574 csr_roam_remove_duplicate_command(mac_ctx, session_id, NULL,
7575 eCsrHddIssuedReassocToSameAP);
7576 if (csr_is_conn_state_connected(mac_ctx, session_id)) {
7577 if (profile) {
7578 if (profile->SSIDs.numOfSSIDs &&
7579 csr_is_ssid_in_list(mac_ctx,
7580 &session->connectedProfile.SSID,
7581 &profile->SSIDs)) {
7582 fCallCallback = false;
7583 } else {
7584 /*
7585 * Connected SSID did not match with what is
7586 * asked in profile
7587 */
7588 sms_log(mac_ctx, LOG1, FL("SSID mismatch"));
7589 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307590 } else if (qdf_mem_cmp(&mod_fields,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007591 &session->connectedProfile.modifyProfileFields,
7592 sizeof(tCsrRoamModifyProfileFields))) {
7593 fCallCallback = false;
7594 } else {
7595 sms_log(mac_ctx, LOG1,
7596 /*
7597 * Either the profile is NULL or none of the
7598 * fields in tCsrRoamModifyProfileFields got
7599 * modified
7600 */
7601 FL("Profile NULL or nothing to modify."));
7602 }
7603 } else {
7604 sms_log(mac_ctx, LOG1, FL("Not connected! No need to reassoc"));
7605 }
7606 if (!fCallCallback) {
7607 roamId = GET_NEXT_ROAM_ID(&mac_ctx->roam);
7608 if (roam_id)
7609 *roam_id = roamId;
7610 status = csr_roam_issue_reassoc(mac_ctx, session_id, profile,
7611 &mod_fields, eCsrHddIssuedReassocToSameAP,
7612 roamId, false);
7613 } else {
7614 status = csr_roam_call_callback(mac_ctx, session_id, NULL,
7615 roamId, eCSR_ROAM_FAILED,
7616 eCSR_ROAM_RESULT_FAILURE);
7617 }
7618 return status;
7619}
7620
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307621QDF_STATUS csr_roam_join_last_profile(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007622{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307623 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007624 tScanResultHandle hBSSList = NULL;
7625 tCsrScanResultFilter *pScanFilter = NULL;
7626 uint32_t roamId;
7627 tCsrRoamProfile *pProfile = NULL;
7628 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
7629
7630 if (!pSession) {
7631 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307632 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007633 }
7634
7635 if (pSession->pCurRoamProfile) {
7636 csr_scan_abort_mac_scan_not_for_connect(pMac, sessionId);
7637 /* We have to make a copy of pCurRoamProfile because it
7638 * will be free inside csr_roam_issue_connect */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307639 pProfile = qdf_mem_malloc(sizeof(tCsrRoamProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007640 if (NULL == pProfile) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307641 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007642 goto end;
7643 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307644 qdf_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007645 status = csr_roam_copy_profile(pMac, pProfile,
7646 pSession->pCurRoamProfile);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307647 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007648 goto end;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307649 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007650 if (NULL == pScanFilter) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307651 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007652 goto end;
7653 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307654 qdf_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007655 status = csr_roam_prepare_filter_from_profile(pMac, pProfile,
7656 pScanFilter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307657 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007658 goto end;
7659 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7660 status = csr_scan_get_result(pMac, pScanFilter, &hBSSList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307661 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007662 /* we want to put the last connected BSS to the
7663 * very beginning, if possible */
7664 csr_move_bss_to_head_from_bssid(pMac,
7665 &pSession->connectedProfile.bssid, hBSSList);
7666 status = csr_roam_issue_connect(pMac, sessionId,
7667 pProfile, hBSSList, eCsrHddIssued,
7668 roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307669 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007670 csr_scan_result_purge(pMac, hBSSList);
7671 goto end;
7672 }
7673 } else {
7674 /* scan for this SSID only incase AP suppresses SSID */
7675 status = csr_scan_for_ssid(pMac, sessionId, pProfile,
7676 roamId, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307677 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007678 goto end;
7679 }
7680 } /* We have a profile */
7681 else {
7682 sms_log(pMac, LOGW, FL("cannot find a roaming profile"));
7683 goto end;
7684 }
7685end:
7686 if (pScanFilter) {
7687 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307688 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007689 }
7690 if (NULL != pProfile) {
7691 csr_release_profile(pMac, pProfile);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307692 qdf_mem_free(pProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007693 }
7694 return status;
7695}
7696
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307697QDF_STATUS csr_roam_reconnect(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007698{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307699 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007700 if (csr_is_conn_state_connected(pMac, sessionId)) {
7701 status =
7702 csr_roam_issue_disassociate_cmd(pMac, sessionId,
7703 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307704 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007705 status = csr_roam_join_last_profile(pMac, sessionId);
7706 }
7707 }
7708 return status;
7709}
7710
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307711QDF_STATUS csr_roam_connect_to_last_profile(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007712{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307713 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007714 sms_log(pMac, LOGW, FL("is called"));
7715 csr_roam_cancel_roaming(pMac, sessionId);
7716 csr_roam_remove_duplicate_command(pMac, sessionId, NULL, eCsrHddIssued);
7717 if (csr_is_conn_state_disconnected(pMac, sessionId)) {
7718 status = csr_roam_join_last_profile(pMac, sessionId);
7719 }
7720 return status;
7721}
7722
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307723QDF_STATUS csr_roam_process_disassoc_deauth(tpAniSirGlobal pMac, tSmeCmd *pCommand,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007724 bool fDisassoc, bool fMICFailure)
7725{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307726 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007727 bool fComplete = false;
7728 eCsrRoamSubState NewSubstate;
7729 uint32_t sessionId = pCommand->sessionId;
7730
7731 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
7732 sms_log(pMac, LOG1,
7733 FL(" Stop Wait for key timer and change substate to"
7734 " eCSR_ROAM_SUBSTATE_NONE"));
7735 csr_roam_stop_wait_for_key_timer(pMac);
7736 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7737 }
7738 /* change state to 'Roaming'... */
7739 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
7740
7741 if (csr_is_conn_state_ibss(pMac, sessionId)) {
7742 /* If we are in an IBSS, then stop the IBSS... */
7743 status =
7744 csr_roam_issue_stop_bss(pMac, sessionId,
7745 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307746 fComplete = (!QDF_IS_STATUS_SUCCESS(status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007747 } else if (csr_is_conn_state_infra(pMac, sessionId)) {
7748 /*
7749 * in Infrastructure, we need to disassociate from the
7750 * Infrastructure network...
7751 */
7752 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7753 if (eCsrSmeIssuedDisassocForHandoff ==
7754 pCommand->u.roamCmd.roamReason) {
7755 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7756 } else
7757 if ((eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason)
7758 && (eSIR_MAC_DISASSOC_LEAVING_BSS_REASON ==
7759 pCommand->u.roamCmd.reason)) {
7760 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307761 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007762 FL
7763 ("set to substate eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT"));
7764 }
Abhishek Singhe0680852015-12-16 14:28:48 +05307765 if (eCsrSmeIssuedDisassocForHandoff !=
7766 pCommand->u.roamCmd.roamReason) {
7767 /*
7768 * If we are in neighbor preauth done state then
7769 * on receiving disassoc or deauth we dont roam
7770 * instead we just disassoc from current ap and
7771 * then go to disconnected state.
7772 * This happens for ESE and 11r FT connections ONLY.
7773 */
Abhishek Singhe0680852015-12-16 14:28:48 +05307774 if (csr_roam_is11r_assoc(pMac, sessionId) &&
7775 (csr_neighbor_roam_state_preauth_done(pMac,
7776 sessionId))) {
7777 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
7778 pMac, sessionId);
7779 }
Abhishek Singhe0680852015-12-16 14:28:48 +05307780#ifdef FEATURE_WLAN_ESE
7781 if (csr_roam_is_ese_assoc(pMac, sessionId) &&
7782 (csr_neighbor_roam_state_preauth_done(pMac,
7783 sessionId))) {
7784 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
7785 pMac, sessionId);
7786 }
7787#endif
Abhishek Singhe0680852015-12-16 14:28:48 +05307788 if (csr_roam_is_fast_roam_enabled(pMac, sessionId) &&
7789 (csr_neighbor_roam_state_preauth_done(pMac,
7790 sessionId))) {
7791 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
7792 pMac, sessionId);
7793 }
Abhishek Singhe0680852015-12-16 14:28:48 +05307794 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007795 if (fDisassoc) {
7796 status =
7797 csr_roam_issue_disassociate(pMac, sessionId,
7798 NewSubstate, fMICFailure);
7799 } else {
7800 status =
7801 csr_roam_issue_deauth(pMac, sessionId,
7802 eCSR_ROAM_SUBSTATE_DEAUTH_REQ);
7803 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307804 fComplete = (!QDF_IS_STATUS_SUCCESS(status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007805 } else {
7806 /* we got a dis-assoc request while not connected to any peer */
7807 /* just complete the command */
7808 fComplete = true;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307809 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007810 }
7811 if (fComplete) {
7812 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
7813 }
7814
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307815 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007816 if (csr_is_conn_state_infra(pMac, sessionId)) {
7817 /* Set the state to disconnect here */
7818 pMac->roam.roamSession[sessionId].connectState =
7819 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7820 }
7821 } else {
7822 sms_log(pMac, LOGW, FL(" failed with status %d"), status);
7823 }
7824 return status;
7825}
7826
7827/**
7828 * csr_prepare_disconnect_command() - function to prepare disconnect command
7829 * @mac: pointer to global mac structure
7830 * @session_id: sme session index
7831 * @sme_cmd: pointer to sme command being prepared
7832 *
7833 * Function to prepare internal sme disconnect command
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307834 * Return: QDF_STATUS_SUCCESS on success else QDF_STATUS_E_RESOURCES on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007835 */
7836
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307837QDF_STATUS csr_prepare_disconnect_command(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007838 uint32_t session_id, tSmeCmd **sme_cmd)
7839{
7840 tSmeCmd *command;
7841
7842 command = csr_get_command_buffer(mac);
7843 if (!command) {
7844 sms_log(mac, LOGE, FL("fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307845 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007846 }
7847
7848 command->command = eSmeCommandRoam;
7849 command->sessionId = (uint8_t)session_id;
7850 command->u.roamCmd.roamReason = eCsrForcedDisassoc;
7851
7852 *sme_cmd = command;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307853 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007854}
7855
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307856QDF_STATUS csr_roam_issue_disassociate_cmd(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007857 eCsrRoamDisconnectReason reason)
7858{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307859 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007860 tSmeCmd *pCommand;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007861 do {
7862 pCommand = csr_get_command_buffer(pMac);
7863 if (!pCommand) {
7864 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307865 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007866 break;
7867 }
7868 /* Change the substate in case it is wait-for-key */
7869 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
7870 csr_roam_stop_wait_for_key_timer(pMac);
7871 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
7872 sessionId);
7873 }
7874 pCommand->command = eSmeCommandRoam;
7875 pCommand->sessionId = (uint8_t) sessionId;
7876 sms_log(pMac, LOG1,
7877 FL("Disassociate reason: %d, sessionId: %d"),
7878 reason, sessionId);
7879 switch (reason) {
7880 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7881 pCommand->u.roamCmd.roamReason =
7882 eCsrForcedDisassocMICFailure;
7883 break;
7884 case eCSR_DISCONNECT_REASON_DEAUTH:
7885 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7886 break;
7887 case eCSR_DISCONNECT_REASON_HANDOFF:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007888 pCommand->u.roamCmd.roamReason =
7889 eCsrSmeIssuedDisassocForHandoff;
7890 break;
7891 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7892 case eCSR_DISCONNECT_REASON_DISASSOC:
7893 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7894 break;
7895 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7896 pCommand->u.roamCmd.roamReason =
7897 eCsrSmeIssuedIbssJoinFailure;
7898 break;
7899 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7900 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7901 break;
7902 case eCSR_DISCONNECT_REASON_STA_HAS_LEFT:
7903 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7904 pCommand->u.roamCmd.reason =
7905 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307906 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007907 FL
7908 ("SME convert to internal reason code eCsrStaHasLeft"));
7909 break;
7910 default:
7911 break;
7912 }
Abhishek Singhb7b2a3b2015-12-03 16:09:38 +05307913 status = csr_queue_sme_command(pMac, pCommand, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307914 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007915 sms_log(pMac, LOGE,
7916 FL(" fail to send message status = %d"), status);
7917 csr_release_command_roam(pMac, pCommand);
7918 }
7919 } while (0);
7920 return status;
7921}
7922
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307923QDF_STATUS csr_roam_issue_stop_bss_cmd(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007924 bool fHighPriority)
7925{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307926 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007927 tSmeCmd *pCommand;
7928 pCommand = csr_get_command_buffer(pMac);
7929 if (NULL != pCommand) {
7930 /* Change the substate in case it is wait-for-key */
7931 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
7932 csr_roam_stop_wait_for_key_timer(pMac);
7933 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
7934 sessionId);
7935 }
7936 pCommand->command = eSmeCommandRoam;
7937 pCommand->sessionId = (uint8_t) sessionId;
7938 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7939 status = csr_queue_sme_command(pMac, pCommand, fHighPriority);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307940 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007941 sms_log(pMac, LOGE,
7942 FL(" fail to send message status = %d"), status);
7943 csr_release_command_roam(pMac, pCommand);
7944 }
7945 } else {
7946 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307947 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007948 }
7949 return status;
7950}
7951
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307952QDF_STATUS csr_roam_disconnect_internal(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007953 eCsrRoamDisconnectReason reason)
7954{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307955 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007956 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
7957
7958 if (!pSession) {
7959 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307960 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007961 }
7962#ifdef FEATURE_WLAN_BTAMP_UT_RF
7963 /* Stop the retry */
7964 pSession->maxRetryCount = 0;
7965 csr_roam_stop_join_retry_timer(pMac, sessionId);
7966#endif
7967 /* Not to call cancel roaming here */
7968 /* Only issue disconnect when necessary */
7969 if (csr_is_conn_state_connected(pMac, sessionId)
7970 || csr_is_bss_type_ibss(pSession->connectedProfile.BSSType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007971 || csr_is_roam_command_waiting_for_session(pMac, sessionId)) {
7972 sms_log(pMac, LOG2, FL("called"));
7973 status = csr_roam_issue_disassociate_cmd(pMac, sessionId,
7974 reason);
7975 } else {
kaliu154d7892015-12-30 17:27:58 +05307976 pMac->roam.roamSession[sessionId].connectState =
7977 eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007978 csr_scan_abort_scan_for_ssid(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307979 status = QDF_STATUS_CMD_NOT_QUEUED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007980 sms_log(pMac, LOG1,
7981 FL
7982 (" Disconnect cmd not queued, Roam command is not present"
7983 " return with status %d"), status);
7984 }
7985 return status;
7986}
7987
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307988QDF_STATUS csr_roam_disconnect(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007989 eCsrRoamDisconnectReason reason)
7990{
7991 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
7992
7993 if (!pSession) {
7994 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307995 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007996 }
7997
7998 csr_roam_cancel_roaming(pMac, sessionId);
7999 csr_roam_remove_duplicate_command(pMac, sessionId, NULL,
8000 eCsrForcedDisassoc);
8001
8002 return csr_roam_disconnect_internal(pMac, sessionId, reason);
8003}
8004
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308005QDF_STATUS csr_roam_save_connected_infomation(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008006 uint32_t sessionId,
8007 tCsrRoamProfile *pProfile,
8008 tSirBssDescription *pSirBssDesc,
8009 tDot11fBeaconIEs *pIes)
8010{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308011 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008012 tDot11fBeaconIEs *pIesTemp = pIes;
8013 uint8_t index;
8014 tCsrRoamSession *pSession = NULL;
8015 tCsrRoamConnectedProfile *pConnectProfile = NULL;
8016
8017 pSession = CSR_GET_SESSION(pMac, sessionId);
8018 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308019 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008020 FL("session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308021 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008022 }
8023 pConnectProfile = &pSession->connectedProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008024 if (pConnectProfile->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308025 qdf_mem_free(pConnectProfile->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008026 pConnectProfile->pAddIEAssoc = NULL;
8027 }
Varun Reddy Yeturud5216002016-02-03 17:09:09 -08008028 /*
8029 * In case of LFR2.0, the connected profile is copied into a temporary
8030 * profile and cleared and then is copied back. This is not needed for
8031 * LFR3.0, since the profile is not cleared.
8032 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008033 if (!pSession->roam_synch_in_progress) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308034 qdf_mem_set(&pSession->connectedProfile,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008035 sizeof(tCsrRoamConnectedProfile), 0);
8036 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
8037 pConnectProfile->AuthInfo = pProfile->AuthType;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008038 pConnectProfile->EncryptionType =
8039 pProfile->negotiatedUCEncryptionType;
8040 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
8041 pConnectProfile->mcEncryptionType =
8042 pProfile->negotiatedMCEncryptionType;
8043 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
8044 pConnectProfile->BSSType = pProfile->BSSType;
8045 pConnectProfile->modifyProfileFields.uapsd_mask =
8046 pProfile->uapsd_mask;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308047 qdf_mem_copy(&pConnectProfile->Keys, &pProfile->Keys,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008048 sizeof(tCsrKeys));
8049 if (pProfile->nAddIEAssocLength) {
8050 pConnectProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308051 qdf_mem_malloc(pProfile->nAddIEAssocLength);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008052 if (NULL == pConnectProfile->pAddIEAssoc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308053 status = QDF_STATUS_E_NOMEM;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008054 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308055 status = QDF_STATUS_SUCCESS;
8056 if (!QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008057 sms_log(pMac, LOGE,
8058 FL("Failed to allocate memory for IE"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308059 return QDF_STATUS_E_FAILURE;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008060 }
8061 pConnectProfile->nAddIEAssocLength =
8062 pProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308063 qdf_mem_copy(pConnectProfile->pAddIEAssoc,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008064 pProfile->pAddIEAssoc,
8065 pProfile->nAddIEAssocLength);
8066 }
8067#ifdef WLAN_FEATURE_11W
8068 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
8069 pConnectProfile->MFPRequired = pProfile->MFPRequired;
8070 pConnectProfile->MFPCapable = pProfile->MFPCapable;
8071#endif
8072 }
Varun Reddy Yeturud5216002016-02-03 17:09:09 -08008073 if (pIes)
8074 pConnectProfile->CBMode = csr_get_cb_mode_from_ies(pMac,
8075 pSirBssDesc->channelId, pIes);
8076 else
8077 sms_log(pMac, LOGE, FL("IE unavailable to derive CB mode"));
8078
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08008079 /* Save bssid */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008080 pConnectProfile->operationChannel = pSirBssDesc->channelId;
8081 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
8082 if (!pConnectProfile->beaconInterval) {
8083 sms_log(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
8084 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008085 csr_get_bss_id_bss_desc(pMac, pSirBssDesc, &pConnectProfile->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008086 if (pSirBssDesc->mdiePresent) {
8087 pConnectProfile->MDID.mdiePresent = 1;
8088 pConnectProfile->MDID.mobilityDomain =
8089 (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
8090 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008091 if (NULL == pIesTemp) {
8092 status =
8093 csr_get_parsed_bss_description_ies(pMac, pSirBssDesc,
8094 &pIesTemp);
8095 }
8096#ifdef FEATURE_WLAN_ESE
8097 if ((csr_is_profile_ese(pProfile) ||
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308098 (QDF_IS_STATUS_SUCCESS(status) && (pIesTemp->ESEVersion.present)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008099 && (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)))
8100 && (pMac->roam.configParam.isEseIniFeatureEnabled)) {
8101 pConnectProfile->isESEAssoc = 1;
8102 }
8103#endif
8104 /* save ssid */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308105 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008106 if (pIesTemp->SSID.present) {
8107 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308108 qdf_mem_copy(pConnectProfile->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008109 pIesTemp->SSID.ssid,
8110 pIesTemp->SSID.num_ssid);
8111 }
8112 /* Save the bss desc */
8113 status =
8114 csr_roam_save_connected_bss_desc(pMac, sessionId, pSirBssDesc);
8115
8116 if (CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present) {
8117 /* Some HT AP's dont send WMM IE so in that case we assume all HT Ap's are Qos Enabled AP's */
8118 pConnectProfile->qap = true;
8119 } else {
8120 pConnectProfile->qap = false;
8121 }
8122
8123 if (pIesTemp->ExtCap.present) {
8124 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
8125 pIesTemp->ExtCap.bytes;
8126 pConnectProfile->proxyARPService = p_ext_cap->
8127 proxy_arp_service;
8128 }
8129
8130 if (NULL == pIes) {
8131 /* Free memory if it allocated locally */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308132 qdf_mem_free(pIesTemp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008133 }
8134 }
8135 /* Save Qos connection */
8136 pConnectProfile->qosConnection =
8137 pMac->roam.roamSession[sessionId].fWMMConnection;
8138
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308139 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008140 csr_free_connect_bss_desc(pMac, sessionId);
8141 }
8142 for (index = 0; index < pProfile->SSIDs.numOfSSIDs; index++) {
8143 if ((pProfile->SSIDs.SSIDList[index].SSID.length ==
8144 pConnectProfile->SSID.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308145 && (!qdf_mem_cmp(pProfile->SSIDs.SSIDList[index].SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008146 ssId, pConnectProfile->SSID.ssId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308147 pConnectProfile->SSID.length))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008148 pConnectProfile->handoffPermitted =
8149 pProfile->SSIDs.SSIDList[index].handoffPermitted;
8150 break;
8151 }
8152 pConnectProfile->handoffPermitted = false;
8153 }
8154
8155 return status;
8156}
8157
8158
Abhishek Singhb1d73ab2015-12-03 16:14:00 +05308159bool is_disconnect_pending(tpAniSirGlobal pmac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008160 uint8_t sessionid)
8161{
8162 tListElem *entry = NULL;
8163 tListElem *next_entry = NULL;
8164 tSmeCmd *command = NULL;
8165 bool disconnect_cmd_exist = false;
8166
8167 csr_ll_lock(&pmac->sme.smeCmdPendingList);
8168 entry = csr_ll_peek_head(&pmac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
8169 while (entry) {
8170 next_entry = csr_ll_next(&pmac->sme.smeCmdPendingList,
8171 entry, LL_ACCESS_NOLOCK);
8172
8173 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
8174 if (command && CSR_IS_DISCONNECT_COMMAND(command) &&
8175 command->sessionId == sessionid){
8176 disconnect_cmd_exist = true;
8177 break;
8178 }
8179 entry = next_entry;
8180 }
8181 csr_ll_unlock(&pmac->sme.smeCmdPendingList);
8182 return disconnect_cmd_exist;
8183}
8184
8185static void csr_roam_join_rsp_processor(tpAniSirGlobal pMac,
8186 tSirSmeJoinRsp *pSmeJoinRsp)
8187{
8188 tListElem *pEntry = NULL;
8189 tSmeCmd *pCommand = NULL;
8190 tCsrRoamSession *session_ptr;
8191
8192 if (pSmeJoinRsp) {
8193 session_ptr = CSR_GET_SESSION(pMac, pSmeJoinRsp->sessionId);
8194 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308195 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008196 FL("Sme Join Response is NULL"));
8197 return;
8198 }
8199 if (!session_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308200 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008201 FL("session %d not found"), pSmeJoinRsp->sessionId);
8202 return;
8203 }
8204 /* The head of the active list is the request we sent */
8205 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8206 if (pEntry) {
8207 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8208 }
8209 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode) {
8210 if (pCommand
8211 && eCsrSmeIssuedAssocToSimilarAP ==
8212 pCommand->u.roamCmd.roamReason) {
8213#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8214 sme_qos_csr_event_ind(pMac, pSmeJoinRsp->sessionId,
8215 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8216#endif
8217 }
Archana Ramachandran20d2e232016-02-11 16:58:40 -08008218
8219 session_ptr->supported_nss_1x1 =
8220 pSmeJoinRsp->supported_nss_1x1;
8221 sms_log(pMac, LOG1,
8222 FL("SME session supported nss: %d"),
8223 session_ptr->supported_nss_1x1);
8224
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008225 /* *
8226 * The join bssid count can be reset as soon as
8227 * we are done with the join requests and returning
8228 * the response to upper layers
8229 * */
8230 session_ptr->join_bssid_count = 0;
8231 csr_roam_complete(pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp);
8232 } else {
8233 uint32_t roamId = 0;
8234 bool is_dis_pending;
8235
8236 /* The head of the active list is the request we sent */
8237 /* Try to get back the same profile and roam again */
8238 if (pCommand) {
8239 roamId = pCommand->u.roamCmd.roamId;
8240 }
8241 session_ptr->joinFailStatusCode.statusCode =
8242 pSmeJoinRsp->statusCode;
8243 session_ptr->joinFailStatusCode.reasonCode =
8244 pSmeJoinRsp->protStatusCode;
8245 sms_log(pMac, LOGW,
8246 "SmeJoinReq failed with statusCode= 0x%08X [%d]",
8247 pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008248 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
8249 if (csr_roam_is_handoff_in_progress(pMac, pSmeJoinRsp->sessionId)) {
8250 csr_roam_call_callback(pMac, pSmeJoinRsp->sessionId, NULL,
8251 roamId, eCSR_ROAM_DISASSOCIATED,
8252 eCSR_ROAM_RESULT_FORCED);
8253 /* Should indicate neighbor roam algorithm about the connect failure here */
8254 csr_neighbor_roam_indicate_connect(pMac,
8255 pSmeJoinRsp->sessionId,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308256 QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008257 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008258 /*
8259 * if userspace has issued disconnection,
8260 * driver should not continue connecting
8261 */
8262 is_dis_pending = is_disconnect_pending(pMac, session_ptr->sessionId);
8263 if (pCommand && (session_ptr->join_bssid_count <
8264 CSR_MAX_BSSID_COUNT) && !is_dis_pending) {
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07008265 csr_roam(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008266 } else {
8267 /* ****************************************************
8268 * When the upper layers issue a connect command, there
8269 * is a roam command with reason eCsrHddIssued that
8270 * gets enqueued and an associated timer for the SME
8271 * command timeout is started which is currently 120
8272 * seconds. This command would be dequeued only upon
8273 * succesfull connections. In case of join failures, if
8274 * there are too many BSS in the cache, and if we fail
8275 * Join requests with all of them, there is a chance of
8276 * timing out the above timer.
8277 * ***************************************************/
8278 if (session_ptr->join_bssid_count >=
8279 CSR_MAX_BSSID_COUNT)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308280 QDF_TRACE(QDF_MODULE_ID_SME,
8281 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008282 FL("Excessive Join Req Failures"));
8283
8284 if (is_dis_pending)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308285 QDF_TRACE(QDF_MODULE_ID_SME,
8286 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008287 FL("disconnect is pending, complete roam"));
8288
8289 session_ptr->join_bssid_count = 0;
8290 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
8291 }
8292 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
8293}
8294
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308295QDF_STATUS csr_roam_issue_join(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008296 tSirBssDescription *pSirBssDesc,
8297 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile,
8298 uint32_t roamId)
8299{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308300 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008301 sms_log(pMac, LOG1, "Attempting to Join Bssid= " MAC_ADDRESS_STR,
8302 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
8303
8304 /* Set the roaming substate to 'join attempt'... */
8305 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
8306 /* attempt to Join this BSS... */
8307 status =
8308 csr_send_join_req_msg(pMac, sessionId, pSirBssDesc, pProfile, pIes,
8309 eWNI_SME_JOIN_REQ);
8310 return status;
8311}
8312
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008313void csr_roam_reissue_roam_command(tpAniSirGlobal pMac)
8314{
8315 tListElem *pEntry;
8316 tSmeCmd *pCommand;
8317 tCsrRoamInfo roamInfo;
8318 uint32_t sessionId;
8319 tCsrRoamSession *pSession;
8320
8321 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8322 if (NULL == pEntry) {
8323 sms_log(pMac, LOGE,
8324 FL("Disassoc rsp can't continue, no active CMD"));
8325 return;
8326 }
8327 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8328 if (eSmeCommandRoam != pCommand->command) {
8329 sms_log(pMac, LOGW, FL("Active cmd, is not a roaming CMD"));
8330 return;
8331 }
8332 sessionId = pCommand->sessionId;
8333 pSession = CSR_GET_SESSION(pMac, sessionId);
8334
8335 if (!pSession) {
8336 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
8337 return;
8338 }
8339
8340 if (!pCommand->u.roamCmd.fStopWds) {
8341 if (pSession->bRefAssocStartCnt > 0) {
8342 /*
8343 * bRefAssocStartCnt was incremented in
8344 * csr_roam_join_next_bss when the roam command issued
8345 * previously. As part of reissuing the roam command
8346 * again csr_roam_join_next_bss is going increment
8347 * RefAssocStartCnt. So make sure to decrement the
8348 * bRefAssocStartCnt
8349 */
8350 pSession->bRefAssocStartCnt--;
8351 }
8352 if (eCsrStopRoaming == csr_roam_join_next_bss(pMac, pCommand,
8353 true)) {
8354 sms_log(pMac, LOGW,
8355 FL("Failed to reissue join command"));
8356 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
8357 }
8358 return;
8359 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308360 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008361 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
8362 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
8363 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07008364 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
8365 csr_roam_call_callback(pMac, sessionId, &roamInfo,
8366 pCommand->u.roamCmd.roamId,
8367 eCSR_ROAM_INFRA_IND,
8368 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008369
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308370 if (!QDF_IS_STATUS_SUCCESS(csr_roam_issue_stop_bss(pMac, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008371 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ))) {
8372 sms_log(pMac, LOGE,
8373 FL("Failed to reissue stop_bss command for WDS"));
8374 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
8375 }
8376}
8377
8378bool csr_is_roam_command_waiting_for_session(tpAniSirGlobal pMac, uint32_t sessionId)
8379{
8380 bool fRet = false;
8381 tListElem *pEntry;
8382 tSmeCmd *pCommand = NULL;
8383 /* alwasy lock active list before locking pending list */
8384 csr_ll_lock(&pMac->sme.smeCmdActiveList);
8385 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8386 if (pEntry) {
8387 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8388 if ((eSmeCommandRoam == pCommand->command)
8389 && (sessionId == pCommand->sessionId)) {
8390 fRet = true;
8391 }
8392 }
8393 if (false == fRet) {
8394 csr_ll_lock(&pMac->sme.smeCmdPendingList);
8395 pEntry =
8396 csr_ll_peek_head(&pMac->sme.smeCmdPendingList,
8397 LL_ACCESS_NOLOCK);
8398 while (pEntry) {
8399 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8400 if ((eSmeCommandRoam == pCommand->command)
8401 && (sessionId == pCommand->sessionId)) {
8402 fRet = true;
8403 break;
8404 }
8405 pEntry =
8406 csr_ll_next(&pMac->sme.smeCmdPendingList, pEntry,
8407 LL_ACCESS_NOLOCK);
8408 }
8409 csr_ll_unlock(&pMac->sme.smeCmdPendingList);
8410 }
8411 if (false == fRet) {
8412 csr_ll_lock(&pMac->roam.roamCmdPendingList);
8413 pEntry =
8414 csr_ll_peek_head(&pMac->roam.roamCmdPendingList,
8415 LL_ACCESS_NOLOCK);
8416 while (pEntry) {
8417 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8418 if ((eSmeCommandRoam == pCommand->command)
8419 && (sessionId == pCommand->sessionId)) {
8420 fRet = true;
8421 break;
8422 }
8423 pEntry =
8424 csr_ll_next(&pMac->roam.roamCmdPendingList, pEntry,
8425 LL_ACCESS_NOLOCK);
8426 }
8427 csr_ll_unlock(&pMac->roam.roamCmdPendingList);
8428 }
8429 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
8430 return fRet;
8431}
8432
8433bool csr_is_roam_command_waiting(tpAniSirGlobal pMac)
8434{
8435 bool fRet = false;
8436 uint32_t i;
8437 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
8438 fRet = csr_is_roam_command_waiting_for_session(pMac, i);
8439 if (CSR_IS_SESSION_VALID(pMac, i)
8440 && (fRet)) {
8441 break;
8442 }
8443 }
8444 return fRet;
8445}
8446
8447bool csr_is_command_waiting(tpAniSirGlobal pMac)
8448{
8449 bool fRet = false;
8450 /* alwasy lock active list before locking pending list */
8451 csr_ll_lock(&pMac->sme.smeCmdActiveList);
8452 fRet = csr_ll_is_list_empty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8453 if (false == fRet) {
8454 fRet =
8455 csr_ll_is_list_empty(&pMac->sme.smeCmdPendingList,
8456 LL_ACCESS_LOCK);
8457 }
8458 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
8459 return fRet;
8460}
8461
8462bool csr_is_scan_for_roam_command_active(tpAniSirGlobal pMac)
8463{
8464 bool fRet = false;
8465 tListElem *pEntry;
8466 tCsrCmd *pCommand;
8467 /* alwasy lock active list before locking pending list */
8468 csr_ll_lock(&pMac->sme.smeCmdActiveList);
8469 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8470 if (pEntry) {
8471 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
8472 if ((eCsrRoamCommandScan == pCommand->command) &&
8473 ((eCsrScanForSsid == pCommand->u.scanCmd.reason) ||
8474 (eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason))) {
8475 fRet = true;
8476 }
8477 }
8478 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
8479 return fRet;
8480}
8481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008482static void
8483csr_roaming_state_config_cnf_processor(tpAniSirGlobal mac_ctx,
8484 uint32_t result)
8485{
8486 tListElem *entry = csr_ll_peek_head(&mac_ctx->sme.smeCmdActiveList,
8487 LL_ACCESS_LOCK);
8488 tCsrScanResult *scan_result = NULL;
8489 tSirBssDescription *bss_desc = NULL;
8490 tSmeCmd *cmd = NULL;
8491 uint32_t session_id;
8492 tCsrRoamSession *session;
8493 tDot11fBeaconIEs *local_ies = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308494 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008495
8496 if (NULL == entry) {
8497 sms_log(mac_ctx, LOGE, FL("CFG_CNF with active list empty"));
8498 return;
8499 }
8500 cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
8501 session_id = cmd->sessionId;
8502 session = CSR_GET_SESSION(mac_ctx, session_id);
8503
8504 if (!session) {
8505 sms_log(mac_ctx, LOGE, FL("session %d not found"), session_id);
8506 return;
8507 }
8508
8509 if (CSR_IS_ROAMING(session) && session->fCancelRoaming) {
8510 /* the roaming is cancelled. Simply complete the command */
8511 sms_log(mac_ctx, LOGW, FL("Roam command canceled"));
8512 csr_roam_complete(mac_ctx, eCsrNothingToJoin, NULL);
8513 return;
8514 }
8515
8516 /* If the roaming has stopped, not to continue the roaming command */
8517 if (!CSR_IS_ROAMING(session) && CSR_IS_ROAMING_COMMAND(cmd)) {
8518 /* No need to complete roaming here as it already completes */
8519 sms_log(mac_ctx, LOGW,
8520 FL("Roam cmd (reason %d) aborted(roaming completed)"),
8521 cmd->u.roamCmd.roamReason);
8522 csr_set_abort_roaming_command(mac_ctx, cmd);
8523 csr_roam_complete(mac_ctx, eCsrNothingToJoin, NULL);
8524 return;
8525 }
8526
8527 if (!IS_SIR_STATUS_SUCCESS(result)) {
8528 /*
8529 * In the event the configuration failed, for infra let the roam
8530 * processor attempt to join something else...
8531 */
8532 if (cmd->u.roamCmd.pRoamBssEntry
8533 && CSR_IS_INFRASTRUCTURE(&cmd->u.roamCmd.roamProfile)) {
8534 csr_roam(mac_ctx, cmd);
8535 } else {
8536 /* We need to complete the command */
8537 if (csr_is_bss_type_ibss
8538 (cmd->u.roamCmd.roamProfile.BSSType)) {
8539 csr_roam_complete(mac_ctx, eCsrStartBssFailure,
8540 NULL);
8541 } else {
8542 csr_roam_complete(mac_ctx, eCsrNothingToJoin,
8543 NULL);
8544 }
8545 }
8546 return;
8547 }
8548
8549 /* we have active entry */
8550 sms_log(mac_ctx, LOG2, "Cfg sequence complete");
8551 /*
8552 * Successfully set the configuration parameters for the new Bss.
8553 * Attempt to join the roaming Bss
8554 */
8555 if (cmd->u.roamCmd.pRoamBssEntry) {
8556 scan_result = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
8557 tCsrScanResult,
8558 Link);
8559 bss_desc = &scan_result->Result.BssDescriptor;
8560 }
8561 if (csr_is_bss_type_ibss(cmd->u.roamCmd.roamProfile.BSSType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008562 || CSR_IS_INFRA_AP(&cmd->u.roamCmd.roamProfile)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308563 if (!QDF_IS_STATUS_SUCCESS(csr_roam_issue_start_bss(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008564 session_id, &session->bssParams,
8565 &cmd->u.roamCmd.roamProfile,
8566 bss_desc,
8567 cmd->u.roamCmd.roamId))) {
8568 sms_log(mac_ctx, LOGE, FL("CSR start BSS failed"));
8569 /* We need to complete the command */
8570 csr_roam_complete(mac_ctx, eCsrStartBssFailure, NULL);
8571 }
8572 return;
8573 }
8574
8575 if (!cmd->u.roamCmd.pRoamBssEntry) {
8576 sms_log(mac_ctx, LOGE, FL("pRoamBssEntry is NULL"));
8577 /* We need to complete the command */
8578 csr_roam_complete(mac_ctx, eCsrJoinFailure, NULL);
8579 return;
8580 }
8581
8582 if (NULL == scan_result) {
8583 /* If we are roaming TO an Infrastructure BSS... */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308584 QDF_ASSERT(scan_result != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008585 return;
8586 }
8587
8588 if (!csr_is_infra_bss_desc(bss_desc)) {
8589 sms_log(mac_ctx, LOGW,
8590 FL("found BSSType mismatching the one in BSS descp"));
8591 return;
8592 }
8593
8594 local_ies = (tDot11fBeaconIEs *) scan_result->Result.pvIes;
8595 if (!local_ies) {
8596 status = csr_get_parsed_bss_description_ies(mac_ctx, bss_desc,
8597 &local_ies);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308598 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008599 return;
8600 }
8601
8602 if (csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
8603 if (csr_is_ssid_equal(mac_ctx, session->pConnectBssDesc,
8604 bss_desc, local_ies)) {
8605 cmd->u.roamCmd.fReassoc = true;
8606 csr_roam_issue_reassociate(mac_ctx, session_id,
8607 bss_desc, local_ies,
8608 &cmd->u.roamCmd.roamProfile);
8609 } else {
8610 /*
8611 * otherwise, we have to issue a new Join request to LIM
8612 * because we disassociated from the previously
8613 * associated AP.
8614 */
8615 status = csr_roam_issue_join(mac_ctx, session_id,
8616 bss_desc, local_ies,
8617 &cmd->u.roamCmd.roamProfile,
8618 cmd->u.roamCmd.roamId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308619 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008620 /* try something else */
8621 csr_roam(mac_ctx, cmd);
8622 }
8623 }
8624 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308625 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008626 /*
8627 * We need to come with other way to figure out that this is
8628 * because of HO in BMP The below API will be only available for
8629 * Android as it uses a different HO algorithm. Reassoc request
8630 * will be used only for ESE and 11r handoff whereas other
8631 * legacy roaming should use join request
8632 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008633 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
8634 && csr_roam_is11r_assoc(mac_ctx, session_id)) {
8635 status = csr_roam_issue_reassociate(mac_ctx,
8636 session_id, bss_desc,
8637 (tDot11fBeaconIEs *)
8638 (scan_result->Result.pvIes),
8639 &cmd->u.roamCmd.roamProfile);
8640 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008641#ifdef FEATURE_WLAN_ESE
8642 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
8643 && csr_roam_is_ese_assoc(mac_ctx, session_id)) {
8644 /* Now serialize the reassoc command. */
8645 status = csr_roam_issue_reassociate_cmd(mac_ctx,
8646 session_id);
8647 } else
8648#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008649 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
8650 && csr_roam_is_fast_roam_enabled(mac_ctx, session_id)) {
8651 /* Now serialize the reassoc command. */
8652 status = csr_roam_issue_reassociate_cmd(mac_ctx,
8653 session_id);
Deepak Dhamdhereecce9742015-11-08 01:16:43 -08008654 } else {
8655 /*
8656 * else we are not connected and attempting to Join.
8657 * Issue the Join request.
8658 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008659 status = csr_roam_issue_join(mac_ctx, session_id,
8660 bss_desc,
8661 (tDot11fBeaconIEs *)
8662 (scan_result->Result.pvIes),
8663 &cmd->u.roamCmd.roamProfile,
8664 cmd->u.roamCmd.roamId);
8665 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308666 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008667 /* try something else */
8668 csr_roam(mac_ctx, cmd);
8669 }
8670 }
8671 if (!scan_result->Result.pvIes) {
8672 /* Locally allocated */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308673 qdf_mem_free(local_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008674 }
8675}
8676
8677static void csr_roam_roaming_state_reassoc_rsp_processor(tpAniSirGlobal pMac,
8678 tpSirSmeJoinRsp pSmeJoinRsp)
8679{
8680 eCsrRoamCompleteResult result;
8681 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
8682 &pMac->roam.neighborRoamInfo[pSmeJoinRsp->sessionId];
8683 tCsrRoamInfo roamInfo;
8684 uint32_t roamId = 0;
8685
8686 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308687 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008688 FL("CSR SmeReassocReq Successful"));
8689 result = eCsrReassocSuccess;
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -08008690 /*
8691 * Since the neighbor roam algorithm uses reassoc req for
8692 * handoff instead of join, we need the response contents while
8693 * processing the result in csr_roam_process_results()
8694 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008695 if (csr_roam_is_handoff_in_progress(pMac, pSmeJoinRsp->sessionId)) {
8696 /* Need to dig more on indicating events to SME QoS module */
8697 sme_qos_csr_event_ind(pMac, pSmeJoinRsp->sessionId,
8698 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8699 csr_roam_complete(pMac, result, pSmeJoinRsp);
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -08008700 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008701 csr_roam_complete(pMac, result, NULL);
8702 }
8703 }
8704 /* Should we handle this similar to handling the join failure? Is it ok
8705 * to call csr_roam_complete() with state as CsrJoinFailure */
8706 else {
8707 sms_log(pMac, LOGW,
8708 "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]",
8709 pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode);
8710 result = eCsrReassocFailure;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008711 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE ==
8712 pSmeJoinRsp->statusCode)
8713 || (eSIR_SME_FT_REASSOC_FAILURE ==
8714 pSmeJoinRsp->statusCode)
8715 || (eSIR_SME_INVALID_PARAMETERS ==
8716 pSmeJoinRsp->statusCode)) {
8717 /* Inform HDD to turn off FT flag in HDD */
8718 if (pNeighborRoamInfo) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308719 qdf_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008720 csr_roam_call_callback(pMac,
8721 pSmeJoinRsp->sessionId,
8722 &roamInfo, roamId,
8723 eCSR_ROAM_FT_REASSOC_FAILED,
8724 eSIR_SME_SUCCESS);
8725 /*
8726 * Since the above callback sends a disconnect
8727 * to HDD, we should clean-up our state
8728 * machine as well to be in sync with the upper
8729 * layers. There is no need to send a disassoc
8730 * since: 1) we will never reassoc to the current
8731 * AP in LFR, and 2) there is no need to issue a
8732 * disassoc to the AP with which we were trying
8733 * to reassoc.
8734 */
8735 csr_roam_complete(pMac, eCsrJoinFailure, NULL);
8736 return;
8737 }
8738 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008739 /* In the event that the Reassociation fails, then we need to Disassociate the current association and keep */
8740 /* roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a */
8741 /* 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc. */
8742 /* The disassoc rsp message will remove the command from active list */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308743 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008744 (csr_roam_issue_disassociate
8745 (pMac, pSmeJoinRsp->sessionId,
8746 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, false))) {
8747 csr_roam_complete(pMac, eCsrJoinFailure, NULL);
8748 }
8749 }
8750}
8751
8752static void csr_roam_roaming_state_stop_bss_rsp_processor(tpAniSirGlobal pMac,
8753 tSirSmeRsp *pSmeRsp)
8754{
8755#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8756 {
8757 host_log_ibss_pkt_type *pIbssLog;
8758 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
8759 LOG_WLAN_IBSS_C);
8760 if (pIbssLog) {
8761 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8762 if (eSIR_SME_SUCCESS != pSmeRsp->statusCode) {
8763 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8764 }
8765 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
8766 }
8767 }
8768#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
8769 pMac->roam.roamSession[pSmeRsp->sessionId].connectState =
8770 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8771 if (CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ(pMac, pSmeRsp->sessionId)) {
8772 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
8773 } else
8774 if (CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE
8775 (pMac, pSmeRsp->sessionId)) {
8776 csr_roam_reissue_roam_command(pMac);
8777 }
8778}
8779
8780/**
8781 * csr_dequeue_command() - removes a command from active cmd list
8782 * @pMac: mac global context
8783 *
8784 * Return: void
8785 */
8786static void
8787csr_dequeue_command(tpAniSirGlobal mac_ctx)
8788{
8789 bool fRemoveCmd;
8790 tSmeCmd *cmd = NULL;
8791 tListElem *entry = csr_ll_peek_head(&mac_ctx->sme.smeCmdActiveList,
8792 LL_ACCESS_LOCK);
8793 if (!entry) {
8794 sms_log(mac_ctx, LOGE, FL("NO commands are active"));
8795 return;
8796 }
8797
8798 cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
8799 /*
8800 * If the head of the queue is Active and it is a given cmd type, remove
8801 * and put this on the Free queue.
8802 */
8803 if (eSmeCommandRoam != cmd->command) {
8804 sms_log(mac_ctx, LOGE, FL("Roam command not active"));
8805 return;
8806 }
8807 /*
8808 * we need to process the result first before removing it from active
8809 * list because state changes still happening insides
8810 * roamQProcessRoamResults so no other roam command should be issued.
8811 */
8812 fRemoveCmd = csr_ll_remove_entry(&mac_ctx->sme.smeCmdActiveList, entry,
8813 LL_ACCESS_LOCK);
8814 if (cmd->u.roamCmd.fReleaseProfile) {
8815 csr_release_profile(mac_ctx, &cmd->u.roamCmd.roamProfile);
8816 cmd->u.roamCmd.fReleaseProfile = false;
8817 }
8818 if (fRemoveCmd)
8819 csr_release_command_roam(mac_ctx, cmd);
8820 else
8821 sms_log(mac_ctx, LOGE, FL("fail to remove cmd reason %d"),
8822 cmd->u.roamCmd.roamReason);
8823}
8824
8825/**
8826 * csr_post_roam_failure() - post roam failure back to csr and issues a disassoc
8827 * @pMac: mac global context
8828 * @session_id: session id
8829 * @roam_info: roam info struct
8830 * @scan_filter: scan filter to free
8831 * @cur_roam_profile: current csr roam profile
8832 *
8833 * Return: void
8834 */
8835static void
8836csr_post_roam_failure(tpAniSirGlobal mac_ctx,
8837 uint32_t session_id,
8838 tCsrRoamInfo *roam_info,
8839 tCsrScanResultFilter *scan_filter,
8840 tCsrRoamProfile *cur_roam_profile)
8841{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308842 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008843
8844 if (scan_filter) {
8845 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308846 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008847 }
8848 if (cur_roam_profile)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308849 qdf_mem_free(cur_roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008850
8851#ifdef WLAN_FEATURE_ROAM_OFFLOAD
8852 csr_roam_synch_clean_up(mac_ctx, session_id);
8853#endif
8854 /* Inform the upper layers that the reassoc failed */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308855 qdf_mem_zero(roam_info, sizeof(tCsrRoamInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008856 csr_roam_call_callback(mac_ctx, session_id, roam_info, 0,
8857 eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8858 /*
8859 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT
8860 * session. Upon success, we would re-enter this routine after receiving
8861 * the disassoc response and will fall into the reassoc fail sub-state.
8862 * And, eventually call csr_roam_complete which would remove the roam
8863 * command from SME active queue.
8864 */
8865 status = csr_roam_issue_disassociate(mac_ctx, session_id,
8866 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308867 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008868 sms_log(mac_ctx, LOGE,
8869 FL("csr_roam_issue_disassociate failed, status %d"),
8870 status);
8871 csr_roam_complete(mac_ctx, eCsrJoinFailure, NULL);
8872 }
8873}
8874
8875/**
8876 * csr_check_profile_in_scan_cache() - finds if roam profile is present in scan
8877 * cache or not
8878 * @pMac: mac global context
8879 * @scan_filter: out param, scan filter
8880 * @neighbor_roam_info: roam info struct
8881 * @hBSSList: scan result
8882 *
8883 * Return: true if found else false.
8884 */
8885static bool
8886csr_check_profile_in_scan_cache(tpAniSirGlobal mac_ctx,
8887 tCsrScanResultFilter **scan_filter,
8888 tpCsrNeighborRoamControlInfo neighbor_roam_info,
8889 tScanResultHandle *hBSSList)
8890{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308891 QDF_STATUS status;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308892 *scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008893 if (NULL == *scan_filter) {
8894 sms_log(mac_ctx, LOGE, FL("alloc for ScanFilter failed."));
8895 return false;
8896 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308897 qdf_mem_set(*scan_filter, sizeof(tCsrScanResultFilter), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008898 (*scan_filter)->scan_filter_for_roam = 1;
8899 status = csr_roam_prepare_filter_from_profile(mac_ctx,
8900 &neighbor_roam_info->csrNeighborRoamProfile,
8901 *scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308902 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008903 sms_log(mac_ctx, LOGE,
8904 FL("failed to prepare scan filter, status %d"),
8905 status);
8906 return false;
8907 }
8908 status = csr_scan_get_result(mac_ctx, *scan_filter, hBSSList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308909 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008910 sms_log(mac_ctx, LOGE,
8911 FL("csr_scan_get_result failed, status %d"),
8912 status);
8913 return false;
8914 }
8915 return true;
8916}
8917
8918void csr_roam_roaming_state_disassoc_rsp_processor(tpAniSirGlobal pMac,
8919 tSirSmeDisassocRsp *pSmeRsp)
8920{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008921 tScanResultHandle hBSSList;
8922 tCsrRoamInfo roamInfo;
8923 tCsrScanResultFilter *pScanFilter = NULL;
8924 uint32_t roamId = 0;
8925 tCsrRoamProfile *pCurRoamProfile = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308926 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008927 uint32_t sessionId;
8928 tCsrRoamSession *pSession;
8929 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8930 tSirSmeDisassocRsp SmeDisassocRsp;
8931
8932 csr_ser_des_unpack_diassoc_rsp((uint8_t *) pSmeRsp, &SmeDisassocRsp);
8933 sessionId = SmeDisassocRsp.sessionId;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308934 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, FL("sessionId %d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008935 sessionId);
8936
8937 if (csr_is_conn_state_infra(pMac, sessionId)) {
8938 pMac->roam.roamSession[sessionId].connectState =
8939 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8940 }
8941
8942 pSession = CSR_GET_SESSION(pMac, sessionId);
8943 if (!pSession) {
8944 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
8945 return;
8946 }
8947
8948 if (CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN(pMac, sessionId)) {
8949 sms_log(pMac, LOG2, "***eCsrNothingToJoin***");
8950 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
8951 } else if (CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED(pMac, sessionId) ||
8952 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ(pMac, sessionId)) {
8953 if (eSIR_SME_SUCCESS == SmeDisassocRsp.statusCode) {
8954 sms_log(pMac, LOG2,
8955 FL("CSR force disassociated successful"));
8956 /*
8957 * A callback to HDD will be issued from
8958 * csr_roam_complete so no need to do anything here
8959 */
8960 }
8961 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
8962 } else if (CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308963 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008964 FL("CSR SmeDisassocReq due to HO on session %d"),
8965 sessionId);
8966 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008967 /*
8968 * First ensure if the roam profile is in the scan cache.
8969 * If not, post a reassoc failure and disconnect.
8970 */
8971 if (!csr_check_profile_in_scan_cache(pMac, &pScanFilter,
8972 pNeighborRoamInfo, &hBSSList))
8973 goto POST_ROAM_FAILURE;
8974
8975 /*
8976 * After ensuring that the roam profile is in the scan result
8977 * list, dequeue the command from the active list.
8978 */
8979 csr_dequeue_command(pMac);
8980
8981 /* notify HDD about handoff and provide the BSSID too */
8982 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8983
Anurag Chouhanc5548422016-02-24 18:33:27 +05308984 qdf_copy_macaddr(&roamInfo.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008985 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid);
8986
8987 csr_roam_call_callback(pMac, sessionId, &roamInfo, 0,
8988 eCSR_ROAM_ROAMING_START,
8989 eCSR_ROAM_RESULT_NONE);
8990
8991 /*
8992 * Copy the connected profile to apply the same for this
8993 * connection as well
8994 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308995 pCurRoamProfile = qdf_mem_malloc(sizeof(tCsrRoamProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008996 if (pCurRoamProfile != NULL) {
8997 /*
8998 * notify sub-modules like QoS etc. that handoff
8999 * happening
9000 */
9001 sme_qos_csr_event_ind(pMac, sessionId,
9002 SME_QOS_CSR_HANDOFF_ASSOC_REQ,
9003 NULL);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309004 qdf_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009005 0);
9006 csr_roam_copy_profile(pMac, pCurRoamProfile,
9007 pSession->pCurRoamProfile);
9008 /* make sure to put it at the head of the cmd queue */
9009 status = csr_roam_issue_connect(pMac, sessionId,
9010 pCurRoamProfile, hBSSList,
9011 eCsrSmeIssuedAssocToSimilarAP,
9012 roamId, true, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309013 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009014 sms_log(pMac, LOGE,
9015 FL("issue_connect failed. status %d"),
9016 status);
9017
9018 csr_release_profile(pMac, pCurRoamProfile);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309019 qdf_mem_free(pCurRoamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009020 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309021 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009022 return;
9023 }
9024
9025POST_ROAM_FAILURE:
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -08009026 csr_post_roam_failure(pMac, sessionId, &roamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009027 pScanFilter, pCurRoamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009028 } /* else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) ) */
9029 else if (CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL(pMac, sessionId)) {
9030 /* Disassoc due to Reassoc failure falls into this codepath */
9031 csr_roam_complete(pMac, eCsrJoinFailure, NULL);
9032 } else {
9033 if (eSIR_SME_SUCCESS == SmeDisassocRsp.statusCode) {
9034 /*
9035 * Successfully disassociated from the 'old' Bss.
9036 * We get Disassociate response in three conditions.
9037 * 1) The case where we are disasociating from an Infra
9038 * Bss to start an IBSS.
9039 * 2) When we are disassociating from an Infra Bss to
9040 * join an IBSS or a new infra network.
9041 * 3) Where we are doing an Infra to Infra roam between
9042 * networks with different SSIDs.
9043 * In all cases, we set the new Bss configuration here
9044 * and attempt to join
9045 */
9046 sms_log(pMac, LOG2,
9047 FL("Disassociated successfully"));
9048 } else {
9049 sms_log(pMac, LOGE,
9050 FL("DisassocReq failed, statusCode= 0x%08X"),
9051 SmeDisassocRsp.statusCode);
9052 }
9053 /* We are not done yet. Get the data and continue roaming */
9054 csr_roam_reissue_roam_command(pMac);
9055 }
9056}
9057
9058static void csr_roam_roaming_state_deauth_rsp_processor(tpAniSirGlobal pMac,
9059 tSirSmeDeauthRsp *pSmeRsp)
9060{
9061 tSirResultCodes statusCode;
9062 /* No one is sending eWNI_SME_DEAUTH_REQ to PE. */
9063 sms_log(pMac, LOGW, FL("is no-op"));
9064 statusCode = csr_get_de_auth_rsp_status_code(pSmeRsp);
9065 pMac->roam.deauthRspStatus = statusCode;
9066 if (CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ(pMac, pSmeRsp->sessionId)) {
9067 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
9068 } else {
9069 if (eSIR_SME_SUCCESS == statusCode) {
9070 /* Successfully deauth from the 'old' Bss... */
9071 /* */
9072 sms_log(pMac, LOG2,
9073 "CSR SmeDeauthReq disassociated Successfully");
9074 } else {
9075 sms_log(pMac, LOGW,
9076 "SmeDeauthReq failed with statusCode= 0x%08X",
9077 statusCode);
9078 }
9079 /* We are not done yet. Get the data and continue roaming */
9080 csr_roam_reissue_roam_command(pMac);
9081 }
9082}
9083
9084static void csr_roam_roaming_state_start_bss_rsp_processor(tpAniSirGlobal pMac,
9085 tSirSmeStartBssRsp *
9086 pSmeStartBssRsp)
9087{
9088 eCsrRoamCompleteResult result;
9089
9090 if (eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode) {
9091 sms_log(pMac, LOGW, "SmeStartBssReq Successful");
9092 result = eCsrStartBssSuccess;
9093 } else {
9094 sms_log(pMac, LOGW,
9095 "SmeStartBssReq failed with statusCode= 0x%08X",
9096 pSmeStartBssRsp->statusCode);
9097 /* Let csr_roam_complete decide what to do */
9098 result = eCsrStartBssFailure;
9099 }
9100 csr_roam_complete(pMac, result, pSmeStartBssRsp);
9101}
9102
9103/**
9104 * csr_roaming_state_msg_processor() - process roaming messages
9105 * @pMac: mac global context
9106 * @pMsgBuf: message buffer
9107 *
9108 * We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of
9109 * strucutres. It depends on how the message is constructed. If the message is
9110 * sent by lim_send_sme_rsp, the pMsgBuf is only a generic response and can only
9111 * be used as pointer to tSirSmeRsp. For the messages where sender allocates
9112 * memory for specific structures, then it can be cast accordingly.
9113 *
9114 * Return: status of operation
9115 */
9116void csr_roaming_state_msg_processor(tpAniSirGlobal pMac, void *pMsgBuf)
9117{
9118 tSirSmeRsp *pSmeRsp;
9119 tSmeIbssPeerInd *pIbssPeerInd;
9120 tCsrRoamInfo roamInfo;
9121 pSmeRsp = (tSirSmeRsp *) pMsgBuf;
9122 sms_log(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
9123 pSmeRsp->messageType, pSmeRsp->messageType,
9124 mac_trace_getcsr_roam_sub_state(
9125 pMac->roam.curSubState[pSmeRsp->sessionId]));
9126 pSmeRsp->messageType = pSmeRsp->messageType;
9127 pSmeRsp->length = pSmeRsp->length;
9128 pSmeRsp->statusCode = pSmeRsp->statusCode;
9129
9130 switch (pSmeRsp->messageType) {
9131
9132 case eWNI_SME_JOIN_RSP:
9133 /* in Roaming state, process the Join response message... */
9134 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
9135 /* We sent a JOIN_REQ */
9136 csr_roam_join_rsp_processor(pMac,
9137 (tSirSmeJoinRsp *) pSmeRsp);
9138 break;
9139 case eWNI_SME_REASSOC_RSP:
9140 /* or the Reassociation response message... */
9141 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ(pMac, pSmeRsp->sessionId))
9142 csr_roam_roaming_state_reassoc_rsp_processor(pMac,
9143 (tpSirSmeJoinRsp) pSmeRsp);
9144 break;
9145 case eWNI_SME_STOP_BSS_RSP:
9146 /* or the Stop Bss response message... */
9147 csr_roam_roaming_state_stop_bss_rsp_processor(pMac, pSmeRsp);
9148 break;
9149 case eWNI_SME_DISASSOC_RSP:
9150 /* or the Disassociate response message... */
9151 if (CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ(pMac, pSmeRsp->sessionId)
9152 || CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN(pMac,
9153 pSmeRsp->sessionId)
9154 || CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL(pMac,
9155 pSmeRsp->sessionId)
9156 || CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED(pMac,
9157 pSmeRsp->sessionId)
9158 || CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE(pMac,
9159 pSmeRsp->sessionId)
9160 || CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac,
9161 pSmeRsp->sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309162 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009163 FL("eWNI_SME_DISASSOC_RSP subState = %s"),
9164 mac_trace_getcsr_roam_sub_state(
9165 pMac->roam.curSubState[pSmeRsp->sessionId]));
9166 csr_roam_roaming_state_disassoc_rsp_processor(pMac,
9167 (tSirSmeDisassocRsp *) pSmeRsp);
9168 }
9169 break;
9170 case eWNI_SME_DEAUTH_RSP:
9171 /* or the Deauthentication response message... */
9172 if (CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ(pMac, pSmeRsp->sessionId))
9173 csr_roam_roaming_state_deauth_rsp_processor(pMac,
9174 (tSirSmeDeauthRsp *) pSmeRsp);
9175 break;
9176 case eWNI_SME_START_BSS_RSP:
9177 /* or the Start BSS response message... */
9178 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ(pMac,
9179 pSmeRsp->sessionId))
9180 csr_roam_roaming_state_start_bss_rsp_processor(pMac,
9181 (tSirSmeStartBssRsp *) pSmeRsp);
9182 break;
9183 /* In case CSR issues STOP_BSS, we need to tell HDD about peer departed
9184 * becasue PE is removing them
9185 */
9186 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9187 pIbssPeerInd = (tSmeIbssPeerInd *) pSmeRsp;
9188 sms_log(pMac, LOGE,
9189 FL("Peer departed ntf from LIM in joining state"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309190 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009191 roamInfo.staId = (uint8_t) pIbssPeerInd->staId;
9192 roamInfo.ucastSig = (uint8_t) pIbssPeerInd->ucastSig;
9193 roamInfo.bcastSig = (uint8_t) pIbssPeerInd->bcastSig;
Anurag Chouhanc5548422016-02-24 18:33:27 +05309194 qdf_copy_macaddr(&roamInfo.peerMac, &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009195 csr_roam_call_callback(pMac, pSmeRsp->sessionId, &roamInfo, 0,
9196 eCSR_ROAM_CONNECT_STATUS_UPDATE,
9197 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9198 break;
9199 case eWNI_SME_GET_RSSI_REQ:
9200 {
9201 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq *) pMsgBuf;
9202 if (NULL != pGetRssiReq->rssiCallback)
9203 ((tCsrRssiCallback) pGetRssiReq->rssiCallback)
9204 (pGetRssiReq->lastRSSI, pGetRssiReq->staId,
9205 pGetRssiReq->pDevContext);
9206 else
9207 sms_log(pMac, LOGE,
9208 FL("pGetRssiReq->rssiCallback is NULL"));
9209 }
9210 break;
9211 default:
9212 sms_log(pMac, LOG1,
9213 FL("Unexpected message type = %d[0x%X] received in substate %s"),
9214 pSmeRsp->messageType, pSmeRsp->messageType,
9215 mac_trace_getcsr_roam_sub_state(
9216 pMac->roam.curSubState[pSmeRsp->sessionId]));
9217 /* If we are connected, check the link status change */
9218 if (!csr_is_conn_state_disconnected(pMac, pSmeRsp->sessionId))
9219 csr_roam_check_for_link_status_change(pMac, pSmeRsp);
9220 break;
9221 }
9222}
9223
9224void csr_roam_joined_state_msg_processor(tpAniSirGlobal pMac, void *pMsgBuf)
9225{
9226 tSirSmeRsp *pSirMsg = (tSirSmeRsp *) pMsgBuf;
9227 switch (pSirMsg->messageType) {
9228 case eWNI_SME_GET_STATISTICS_RSP:
9229 sms_log(pMac, LOG2, FL("Stats rsp from PE"));
9230 csr_roam_stats_rsp_processor(pMac, pSirMsg);
9231 break;
9232 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
9233 {
9234 tCsrRoamSession *pSession;
9235 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
9236 tCsrRoamInfo roamInfo;
9237 tCsrRoamInfo *pRoamInfo = NULL;
9238 uint32_t sessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309239 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009240 sms_log(pMac, LOG1,
9241 FL
9242 ("ASSOCIATION confirmation can be given to upper layer "));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309243 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009244 pRoamInfo = &roamInfo;
9245 pUpperLayerAssocCnf =
9246 (tSirSmeAssocIndToUpperLayerCnf *) pMsgBuf;
9247 status =
9248 csr_roam_get_session_id_from_bssid(pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309249 (struct qdf_mac_addr *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009250 pUpperLayerAssocCnf->
9251 bssId, &sessionId);
9252 pSession = CSR_GET_SESSION(pMac, sessionId);
9253
9254 if (!pSession) {
9255 sms_log(pMac, LOGE,
9256 FL(" session %d not found "),
9257 sessionId);
9258 return;
9259 }
9260
9261 pRoamInfo->statusCode = eSIR_SME_SUCCESS; /* send the status code as Success */
9262 pRoamInfo->u.pConnectedProfile =
9263 &pSession->connectedProfile;
9264 pRoamInfo->staId = (uint8_t) pUpperLayerAssocCnf->aid;
9265 pRoamInfo->rsnIELen =
9266 (uint8_t) pUpperLayerAssocCnf->rsnIE.length;
9267 pRoamInfo->prsnIE =
9268 pUpperLayerAssocCnf->rsnIE.rsnIEdata;
9269#ifdef FEATURE_WLAN_WAPI
9270 pRoamInfo->wapiIELen =
9271 (uint8_t) pUpperLayerAssocCnf->wapiIE.length;
9272 pRoamInfo->pwapiIE =
9273 pUpperLayerAssocCnf->wapiIE.wapiIEdata;
9274#endif
9275 pRoamInfo->addIELen =
9276 (uint8_t) pUpperLayerAssocCnf->addIE.length;
9277 pRoamInfo->paddIE =
9278 pUpperLayerAssocCnf->addIE.addIEdata;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309279 qdf_mem_copy(pRoamInfo->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009280 pUpperLayerAssocCnf->peerMacAddr,
9281 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309282 qdf_mem_copy(&pRoamInfo->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009283 pUpperLayerAssocCnf->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309284 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009285 pRoamInfo->wmmEnabledSta =
9286 pUpperLayerAssocCnf->wmmEnabledSta;
9287 pRoamInfo->timingMeasCap =
9288 pUpperLayerAssocCnf->timingMeasCap;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309289 qdf_mem_copy(&pRoamInfo->chan_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009290 &pUpperLayerAssocCnf->chan_info,
9291 sizeof(tSirSmeChanInfo));
9292 if (CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile)) {
9293 pMac->roam.roamSession[sessionId].connectState =
9294 eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
9295 pRoamInfo->fReassocReq =
9296 pUpperLayerAssocCnf->reassocReq;
9297 status =
9298 csr_roam_call_callback(pMac, sessionId,
9299 pRoamInfo, 0,
9300 eCSR_ROAM_INFRA_IND,
9301 eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9302 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009303 }
9304 break;
9305 default:
9306 csr_roam_check_for_link_status_change(pMac, pSirMsg);
9307 break;
9308 }
9309}
9310
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309311QDF_STATUS csr_roam_issue_set_context_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009312 uint32_t sessionId,
9313 eCsrEncryptionType EncryptType,
9314 tSirBssDescription *pBssDescription,
9315 tSirMacAddr *bssId, bool addKey,
9316 bool fUnicast,
9317 tAniKeyDirection aniKeyDirection,
9318 uint8_t keyId, uint16_t keyLength,
9319 uint8_t *pKey, uint8_t paeRole)
9320{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309321 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009322 tAniEdType edType;
9323
9324 if (eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType) {
9325 EncryptType = eCSR_ENCRYPT_TYPE_NONE;
9326 }
9327
9328 edType = csr_translate_encrypt_type_to_ed_type(EncryptType);
9329
9330 /*
9331 * Allow 0 keys to be set for the non-WPA encrypt types. For WPA encrypt
9332 * types, the num keys must be non-zero or LIM will reject the set
9333 * context (assumes the SET_CONTEXT does not occur until the keys are
9334 * distrubuted).
9335 */
9336 if (CSR_IS_ENC_TYPE_STATIC(EncryptType) || addKey) {
9337 tCsrRoamSetKey setKey;
9338 setKey.encType = EncryptType;
9339 setKey.keyDirection = aniKeyDirection;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309340 qdf_mem_copy(&setKey.peerMac, bssId, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009341 /* 0 for supplicant */
9342 setKey.paeRole = paeRole;
9343 /* Key index */
9344 setKey.keyId = keyId;
9345 setKey.keyLength = keyLength;
9346 if (keyLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309347 qdf_mem_copy(setKey.Key, pKey, keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009348 }
9349 status = csr_roam_issue_set_key_command(pMac, sessionId,
9350 &setKey, 0);
9351 }
9352 return status;
9353}
9354
9355/**
9356 * csr_update_key_cmd() - update key info in set key command
9357 * @mac_ctx: mac global context
9358 * @session: roam session
9359 * @set_key: input set key command
9360 * @set_key_cmd: set key command to update
9361 * @enqueue_cmd: indicates if command need to be enqueued to sme
9362 *
9363 * This function will validate the key length, adjust if too long. Tt will
9364 * update bool enqueue_cmd, to false if some error has occured key are local.
9365 *
9366 * Return: status of operation
9367 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309368static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009369csr_update_key_cmd(tpAniSirGlobal mac_ctx, tCsrRoamSession *session,
9370 tCsrRoamSetKey *set_key, tSmeCmd *set_key_cmd,
9371 bool *enqueue_cmd)
9372{
9373 switch (set_key->encType) {
9374 case eCSR_ENCRYPT_TYPE_WEP40:
9375 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9376 /* KeyLength maybe 0 for static WEP */
9377 if (set_key->keyLength) {
9378 if (set_key->keyLength < CSR_WEP40_KEY_LEN) {
9379 sms_log(mac_ctx, LOGW,
9380 FL("Invalid WEP40 keylength [= %d]"),
9381 set_key->keyLength);
9382 *enqueue_cmd = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309383 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009384 }
9385
9386 set_key_cmd->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309387 qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009388 CSR_WEP40_KEY_LEN);
9389 }
9390 *enqueue_cmd = true;
9391 break;
9392 case eCSR_ENCRYPT_TYPE_WEP104:
9393 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9394 /* KeyLength maybe 0 for static WEP */
9395 if (set_key->keyLength) {
9396 if (set_key->keyLength < CSR_WEP104_KEY_LEN) {
9397 sms_log(mac_ctx, LOGW,
9398 FL("Invalid WEP104 keylength [= %d]"),
9399 set_key->keyLength);
9400 *enqueue_cmd = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309401 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009402 }
9403
9404 set_key_cmd->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309405 qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009406 CSR_WEP104_KEY_LEN);
9407 }
9408 *enqueue_cmd = true;
9409 break;
9410 case eCSR_ENCRYPT_TYPE_TKIP:
9411 if (set_key->keyLength < CSR_TKIP_KEY_LEN) {
9412 sms_log(mac_ctx, LOGW,
9413 FL("Invalid TKIP keylength [= %d]"),
9414 set_key->keyLength);
9415 *enqueue_cmd = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309416 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009417 }
9418 set_key_cmd->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309419 qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009420 CSR_TKIP_KEY_LEN);
9421 *enqueue_cmd = true;
9422 break;
9423 case eCSR_ENCRYPT_TYPE_AES:
9424 if (set_key->keyLength < CSR_AES_KEY_LEN) {
9425 sms_log(mac_ctx, LOGW,
9426 FL("Invalid AES/CCMP keylength [= %d]"),
9427 set_key->keyLength);
9428 *enqueue_cmd = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309429 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009430 }
9431 set_key_cmd->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309432 qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009433 CSR_AES_KEY_LEN);
9434 *enqueue_cmd = true;
9435 break;
9436#ifdef FEATURE_WLAN_WAPI
9437 case eCSR_ENCRYPT_TYPE_WPI:
9438 if (set_key->keyLength < CSR_WAPI_KEY_LEN) {
9439 sms_log(mac_ctx, LOGW,
9440 FL("Invalid WAPI keylength [= %d]"),
9441 set_key->keyLength);
9442 *enqueue_cmd = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309443 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009444 }
9445 set_key_cmd->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309446 qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009447 CSR_WAPI_KEY_LEN);
9448 if (session->pCurRoamProfile) {
9449 session->pCurRoamProfile->negotiatedUCEncryptionType =
9450 eCSR_ENCRYPT_TYPE_WPI;
9451 } else {
9452 sms_log(mac_ctx, LOGW,
9453 FL("pCurRoamProfile is NULL."));
9454 *enqueue_cmd = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309455 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009456 }
9457 *enqueue_cmd = true;
9458 break;
9459#endif /* FEATURE_WLAN_WAPI */
9460#ifdef FEATURE_WLAN_ESE
9461 case eCSR_ENCRYPT_TYPE_KRK:
9462 /* no need to enqueue KRK key request, since they are local */
9463 *enqueue_cmd = false;
9464 if (set_key->keyLength < CSR_KRK_KEY_LEN) {
9465 sms_log(mac_ctx, LOGW,
9466 FL("Invalid KRK keylength [= %d]"),
9467 set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309468 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009469 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309470 qdf_mem_copy(session->eseCckmInfo.krk, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009471 CSR_KRK_KEY_LEN);
9472 session->eseCckmInfo.reassoc_req_num = 1;
9473 session->eseCckmInfo.krk_plumbed = true;
9474 break;
9475#ifdef WLAN_FEATURE_ROAM_OFFLOAD
9476 case eCSR_ENCRYPT_TYPE_BTK:
9477 /* no need to enqueue KRK key request, since they are local */
9478 *enqueue_cmd = false;
9479 if (set_key->keyLength < SIR_BTK_KEY_LEN) {
9480 sms_log(mac_ctx, LOGW,
9481 FL("LFR3:Invalid BTK keylength [= %d]"),
9482 set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309483 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009484 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309485 qdf_mem_copy(session->eseCckmInfo.btk, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009486 SIR_BTK_KEY_LEN);
9487 break;
9488#endif
9489#endif /* FEATURE_WLAN_ESE */
9490#ifdef WLAN_FEATURE_11W
9491 /* Check for 11w BIP */
9492 case eCSR_ENCRYPT_TYPE_AES_CMAC:
9493 if (set_key->keyLength < CSR_AES_KEY_LEN) {
9494 sms_log(mac_ctx, LOGW,
9495 FL("Invalid AES/CCMP keylength [= %d]"),
9496 set_key->keyLength);
9497 *enqueue_cmd = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309498 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009499 }
9500 set_key_cmd->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309501 qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009502 CSR_AES_KEY_LEN);
9503 *enqueue_cmd = true;
9504 break;
9505#endif /* WLAN_FEATURE_11W */
9506 default:
9507 /* for open security also we want to enqueue command */
9508 *enqueue_cmd = true;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309509 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009510 } /* end of switch */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309511 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009512}
9513
9514
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309515static QDF_STATUS csr_roam_issue_set_key_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009516 uint32_t sessionId,
9517 tCsrRoamSetKey *pSetKey,
9518 uint32_t roamId)
9519{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309520 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009521 bool enqueue_cmd = true;
9522 tSmeCmd *pCommand = NULL;
9523#if defined(FEATURE_WLAN_ESE) || defined (FEATURE_WLAN_WAPI)
9524 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
9525 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309526 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009527 FL("session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309528 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009529 }
9530#endif /* FEATURE_WLAN_ESE */
9531
9532 pCommand = csr_get_command_buffer(pMac);
9533 if (NULL == pCommand) {
9534 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309535 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009536 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309537 qdf_mem_zero(pCommand, sizeof(tSmeCmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009538 pCommand->command = eSmeCommandSetKey;
9539 pCommand->sessionId = (uint8_t) sessionId;
9540 /*
9541 * following function will validate the key length, Adjust if too long.
9542 * for static WEP the keys are not set thru' SetContextReq
9543 *
9544 * it will update bool enqueue_cmd, to false if some error has occured
9545 * key are local. enqueue sme command only if enqueue_cmd is true
9546 * status is indication of success or failure and will be returned to
9547 * called of current function if command is not enqueued due to key req
9548 * being local
9549 */
9550 status = csr_update_key_cmd(pMac, pSession, pSetKey,
9551 pCommand, &enqueue_cmd);
9552 if (enqueue_cmd) {
9553 pCommand->u.setKeyCmd.roamId = roamId;
9554 pCommand->u.setKeyCmd.encType = pSetKey->encType;
9555 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection;
Anurag Chouhanc5548422016-02-24 18:33:27 +05309556 qdf_copy_macaddr(&pCommand->u.setKeyCmd.peermac,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08009557 &pSetKey->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009558 /* 0 for supplicant */
9559 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole;
9560 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309561 qdf_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009562 CSR_MAX_RSC_LEN);
9563 /*
9564 * Always put set key to the head of the Q because it is the
9565 * only thing to get executed in case of WT_KEY state
9566 */
9567
9568 status = csr_queue_sme_command(pMac, pCommand, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309569 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009570 sms_log(pMac, LOGE,
9571 FL("fail to send message status = %d"), status);
9572 /* update to false so that command can be freed */
9573 enqueue_cmd = false;
9574 }
9575 }
9576
9577 /*
9578 * Free the command if enqueue_cmd == false:
9579 * this means that command was not enqueued because either there has
9580 * been a failure, or it is a "local" operation like the set ESE CCKM
9581 * KRK key.
9582 */
9583 if (false == enqueue_cmd)
9584 csr_release_command_set_key(pMac, pCommand);
9585
9586 return status;
9587}
9588
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309589QDF_STATUS csr_roam_process_set_key_command(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009590{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309591 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009592 uint8_t numKeys = (pCommand->u.setKeyCmd.keyLength) ? 1 : 0;
9593 tAniEdType edType =
9594 csr_translate_encrypt_type_to_ed_type(pCommand->u.setKeyCmd.encType);
9595 bool fUnicast =
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08009596 (pCommand->u.setKeyCmd.peermac.bytes[0] == 0xFF) ? false : true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009597 uint32_t sessionId = pCommand->sessionId;
9598#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9599 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
9600 WLAN_HOST_DIAG_EVENT_DEF(setKeyEvent,
9601 host_event_wlan_security_payload_type);
9602
9603 if (NULL == pSession) {
9604 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309605 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009606 }
9607
9608 if (eSIR_ED_NONE != edType) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309609 qdf_mem_set(&setKeyEvent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009610 sizeof(host_event_wlan_security_payload_type), 0);
Anurag Chouhanc5548422016-02-24 18:33:27 +05309611 if (qdf_is_macaddr_group(&pCommand->u.setKeyCmd.peermac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009612 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
9613 setKeyEvent.encryptionModeMulticast =
9614 (uint8_t) diag_enc_type_from_csr_type(pCommand->u.
9615 setKeyCmd.encType);
9616 setKeyEvent.encryptionModeUnicast =
9617 (uint8_t) diag_enc_type_from_csr_type(pSession->
9618 connectedProfile.
9619 EncryptionType);
9620 } else {
9621 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
9622 setKeyEvent.encryptionModeUnicast =
9623 (uint8_t) diag_enc_type_from_csr_type(pCommand->u.
9624 setKeyCmd.encType);
9625 setKeyEvent.encryptionModeMulticast =
9626 (uint8_t) diag_enc_type_from_csr_type(pSession->
9627 connectedProfile.
9628 mcEncryptionType);
9629 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309630 qdf_mem_copy(setKeyEvent.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009631 pSession->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309632 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009633 if (CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType)) {
9634 uint32_t defKeyId;
9635 /* It has to be static WEP here */
9636 if (IS_SIR_STATUS_SUCCESS
9637 (wlan_cfg_get_int
9638 (pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId))) {
9639 setKeyEvent.keyId = (uint8_t) defKeyId;
9640 }
9641 } else {
9642 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
9643 }
9644 setKeyEvent.authMode =
9645 (uint8_t) diag_auth_type_from_csr_type(pSession->
9646 connectedProfile.
9647 AuthType);
9648 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9649 }
9650#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
9651 if (csr_is_set_key_allowed(pMac, sessionId)) {
9652 status = csr_send_mb_set_context_req_msg(pMac, sessionId,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08009653 pCommand->u.
9654 setKeyCmd.peermac,
9655 numKeys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009656 edType, fUnicast,
9657 pCommand->u.setKeyCmd.
9658 keyDirection,
9659 pCommand->u.setKeyCmd.keyId,
9660 pCommand->u.setKeyCmd.
9661 keyLength,
9662 pCommand->u.setKeyCmd.Key,
9663 pCommand->u.setKeyCmd.
9664 paeRole,
9665 pCommand->u.setKeyCmd.
9666 keyRsc);
9667 } else {
9668 sms_log(pMac, LOGW, FL(" cannot process not connected"));
9669 /* Set this status so the error handling take care of the case. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309670 status = QDF_STATUS_CSR_WRONG_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009671 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309672 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009673 sms_log(pMac, LOGE, FL(" error status %d"), status);
9674 csr_roam_call_callback(pMac, sessionId, NULL,
9675 pCommand->u.setKeyCmd.roamId,
9676 eCSR_ROAM_SET_KEY_COMPLETE,
9677 eCSR_ROAM_RESULT_FAILURE);
9678#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9679 if (eSIR_ED_NONE != edType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05309680 if (qdf_is_macaddr_group(
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08009681 &pCommand->u.setKeyCmd.peermac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009682 setKeyEvent.eventId =
9683 WLAN_SECURITY_EVENT_SET_GTK_RSP;
9684 } else {
9685 setKeyEvent.eventId =
9686 WLAN_SECURITY_EVENT_SET_PTK_RSP;
9687 }
9688 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9689 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent,
9690 EVENT_WLAN_SECURITY);
9691 }
9692#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
9693 }
9694 return status;
9695}
9696
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309697QDF_STATUS csr_roam_set_key(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009698 tCsrRoamSetKey *pSetKey, uint32_t roamId)
9699{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309700 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009701
9702 if (!csr_is_set_key_allowed(pMac, sessionId)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309703 status = QDF_STATUS_CSR_WRONG_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009704 } else {
9705 status =
9706 csr_roam_issue_set_key_command(pMac, sessionId, pSetKey, roamId);
9707 }
9708 return status;
9709}
9710
9711/*
9712 Prepare a filter base on a profile for parsing the scan results.
9713 Upon successful return, caller MUST call csr_free_scan_filter on
9714 pScanFilter when it is done with the filter.
9715 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309716QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009717csr_roam_prepare_filter_from_profile(tpAniSirGlobal mac_ctx,
9718 tCsrRoamProfile *profile,
9719 tCsrScanResultFilter *scan_fltr)
9720{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309721 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009722 uint32_t size = 0;
9723 uint8_t idx = 0;
9724 tCsrChannelInfo *fltr_ch_info = &scan_fltr->ChannelInfo;
9725 tCsrChannelInfo *profile_ch_info = &profile->ChannelInfo;
9726 struct roam_ext_params *roam_params;
9727 uint8_t i;
9728
9729 roam_params = &mac_ctx->roam.configParam.roam_params;
9730
9731 if (profile->BSSIDs.numOfBSSIDs) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05309732 size = sizeof(struct qdf_mac_addr) * profile->BSSIDs.numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309733 scan_fltr->BSSIDs.bssid = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009734 if (NULL == scan_fltr->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309735 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009736 goto free_filter;
9737 }
9738 scan_fltr->BSSIDs.numOfBSSIDs = profile->BSSIDs.numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309739 qdf_mem_copy(scan_fltr->BSSIDs.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009740 profile->BSSIDs.bssid, size);
9741 }
9742
9743 if (profile->SSIDs.numOfSSIDs) {
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07009744 scan_fltr->SSIDs.numOfSSIDs = profile->SSIDs.numOfSSIDs;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309745 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009746 FL("No of Allowed List:%d"),
9747 roam_params->num_ssid_allowed_list);
9748 if (scan_fltr->scan_filter_for_roam
9749 && roam_params->num_ssid_allowed_list) {
9750 scan_fltr->SSIDs.numOfSSIDs =
9751 roam_params->num_ssid_allowed_list;
9752 size = sizeof(tCsrSSIDInfo) *
9753 scan_fltr->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309754 scan_fltr->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009755 if (NULL == scan_fltr->SSIDs.SSIDList)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309756 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009757 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309758 status = QDF_STATUS_SUCCESS;
9759 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009760 goto free_filter;
9761 for (i = 0;
9762 i < roam_params->num_ssid_allowed_list;
9763 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309764 qdf_mem_copy((void *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009765 scan_fltr->SSIDs.SSIDList[i].SSID.ssId,
9766 roam_params->ssid_allowed_list[i].ssId,
9767 roam_params->ssid_allowed_list[i].length);
9768 scan_fltr->SSIDs.SSIDList[i].SSID.length =
9769 roam_params->ssid_allowed_list[i].length;
9770 scan_fltr->SSIDs.SSIDList[i].handoffPermitted =
9771 1;
9772 scan_fltr->SSIDs.SSIDList[i].ssidHidden = 0;
9773 }
9774 } else {
9775 size = sizeof(tCsrSSIDInfo) *
9776 profile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309777 scan_fltr->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009778 if (NULL == scan_fltr->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309779 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009780 goto free_filter;
9781 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309782 qdf_mem_copy(scan_fltr->SSIDs.SSIDList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009783 profile->SSIDs.SSIDList, size);
9784 }
9785 }
9786
9787 if (!profile_ch_info->ChannelList
9788 || (profile_ch_info->ChannelList[0] == 0)) {
9789 fltr_ch_info->numOfChannels = 0;
9790 fltr_ch_info->ChannelList = NULL;
9791 } else if (profile_ch_info->numOfChannels) {
9792 fltr_ch_info->numOfChannels = 0;
9793 fltr_ch_info->ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309794 qdf_mem_malloc(sizeof(*(fltr_ch_info->ChannelList)) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009795 profile_ch_info->numOfChannels);
9796 if (NULL == fltr_ch_info->ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309797 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009798 goto free_filter;
9799 }
9800
9801 for (idx = 0; idx < profile_ch_info->numOfChannels; idx++) {
9802 if (csr_roam_is_channel_valid(mac_ctx,
9803 profile_ch_info->ChannelList[idx])) {
9804 fltr_ch_info->
9805 ChannelList[fltr_ch_info->numOfChannels]
9806 = profile_ch_info->ChannelList[idx];
9807 fltr_ch_info->numOfChannels++;
9808 } else {
9809 sms_log(mac_ctx, LOG1,
9810 FL("Channel (%d) is invalid"),
9811 profile_ch_info->ChannelList[idx]);
9812 }
9813 }
9814 } else {
9815 sms_log(mac_ctx, LOGE, FL("Channel list empty"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309816 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009817 goto free_filter;
9818 }
9819 scan_fltr->uapsd_mask = profile->uapsd_mask;
9820 scan_fltr->authType = profile->AuthType;
9821 scan_fltr->EncryptionType = profile->EncryptionType;
9822 scan_fltr->mcEncryptionType = profile->mcEncryptionType;
9823 scan_fltr->BSSType = profile->BSSType;
9824 scan_fltr->phyMode = profile->phyMode;
9825#ifdef FEATURE_WLAN_WAPI
9826 /*
9827 * check if user asked for WAPI with 11n or auto mode, in that
9828 * case modify the phymode to 11g
9829 */
9830 if (csr_is_profile_wapi(profile)) {
9831 if (scan_fltr->phyMode & eCSR_DOT11_MODE_11n)
9832 scan_fltr->phyMode &= ~eCSR_DOT11_MODE_11n;
9833 if (scan_fltr->phyMode & eCSR_DOT11_MODE_AUTO)
9834 scan_fltr->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9835 if (!scan_fltr->phyMode)
9836 scan_fltr->phyMode = eCSR_DOT11_MODE_11g;
9837 }
9838#endif /* FEATURE_WLAN_WAPI */
9839 /*Save the WPS info */
9840 scan_fltr->bWPSAssociation = profile->bWPSAssociation;
9841 scan_fltr->bOSENAssociation = profile->bOSENAssociation;
9842 if (profile->countryCode[0]) {
9843 /*
9844 * This causes the matching function to use countryCode as one
9845 * of the criteria.
9846 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309847 qdf_mem_copy(scan_fltr->countryCode, profile->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009848 WNI_CFG_COUNTRY_CODE_LEN);
9849 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009850 if (profile->MDID.mdiePresent) {
9851 scan_fltr->MDID.mdiePresent = 1;
9852 scan_fltr->MDID.mobilityDomain = profile->MDID.mobilityDomain;
9853 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009854
9855#ifdef WLAN_FEATURE_11W
9856 /* Management Frame Protection */
9857 scan_fltr->MFPEnabled = profile->MFPEnabled;
9858 scan_fltr->MFPRequired = profile->MFPRequired;
9859 scan_fltr->MFPCapable = profile->MFPCapable;
9860#endif
9861 scan_fltr->csrPersona = profile->csrPersona;
9862
9863free_filter:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309864 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009865 csr_free_scan_filter(mac_ctx, scan_fltr);
9866
9867 return status;
9868}
9869
9870bool csr_roam_issue_wm_status_change(tpAniSirGlobal pMac, uint32_t sessionId,
9871 eCsrRoamWmStatusChangeTypes Type,
9872 tSirSmeRsp *pSmeRsp)
9873{
9874 bool fCommandQueued = false;
9875 tSmeCmd *pCommand;
9876 do {
9877 /* Validate the type is ok... */
9878 if ((eCsrDisassociated != Type)
9879 && (eCsrDeauthenticated != Type))
9880 break;
9881 pCommand = csr_get_command_buffer(pMac);
9882 if (!pCommand) {
9883 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
9884 break;
9885 }
9886 /* Change the substate in case it is waiting for key */
9887 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
9888 csr_roam_stop_wait_for_key_timer(pMac);
9889 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
9890 sessionId);
9891 }
9892 pCommand->command = eSmeCommandWmStatusChange;
9893 pCommand->sessionId = (uint8_t) sessionId;
9894 pCommand->u.wmStatusChangeCmd.Type = Type;
9895 if (eCsrDisassociated == Type) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309896 qdf_mem_copy(&pCommand->u.wmStatusChangeCmd.u.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009897 DisassocIndMsg, pSmeRsp,
9898 sizeof(pCommand->u.wmStatusChangeCmd.u.
9899 DisassocIndMsg));
9900 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309901 qdf_mem_copy(&pCommand->u.wmStatusChangeCmd.u.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009902 DeauthIndMsg, pSmeRsp,
9903 sizeof(pCommand->u.wmStatusChangeCmd.u.
9904 DeauthIndMsg));
9905 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309906 if (QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009907 (csr_queue_sme_command(pMac, pCommand, true))) {
9908 fCommandQueued = true;
9909 } else {
9910 sms_log(pMac, LOGE, FL(" fail to send message "));
9911 csr_release_command_wm_status_change(pMac, pCommand);
9912 }
9913
9914 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9915 csr_set_default_dot11_mode(pMac);
9916 } while (0);
9917 return fCommandQueued;
9918}
9919
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309920static QDF_STATUS csr_send_snr_request(void *pGetRssiReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009921{
9922 void *wma_handle;
9923
Anurag Chouhan6d760662016-02-20 16:05:43 +05309924 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009925 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309926 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009927 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309928 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009929 }
9930
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309931 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009932 wma_send_snr_request(wma_handle, pGetRssiReq)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309933 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009934 "Failed to Trigger wma stats request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309935 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009936 }
9937
9938 /* dont send success, otherwise call back
9939 * will released with out values */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309940 return QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009941}
9942
9943static void csr_update_rssi(tpAniSirGlobal pMac, void *pMsg)
9944{
9945 int8_t rssi = 0;
9946 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq *) pMsg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309947 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009948 if (pGetRssiReq) {
9949 if (NULL != pGetRssiReq->p_cds_context) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309950 qdf_status = csr_send_snr_request(pGetRssiReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009951 } else {
9952 sms_log(pMac, LOGE,
9953 FL("pGetRssiReq->p_cds_context is NULL"));
9954 return;
9955 }
9956
9957 if (NULL != pGetRssiReq->rssiCallback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309958 if (qdf_status != QDF_STATUS_E_BUSY)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009959 ((tCsrRssiCallback) (pGetRssiReq->rssiCallback))
9960 (rssi, pGetRssiReq->staId,
9961 pGetRssiReq->pDevContext);
9962 else
9963 sms_log(pMac, LOG1,
9964 FL
9965 ("rssi request is posted. waiting for reply"));
9966 } else {
9967 sms_log(pMac, LOGE,
9968 FL("pGetRssiReq->rssiCallback is NULL"));
9969 return;
9970 }
9971 } else {
9972 sms_log(pMac, LOGE, FL("pGetRssiReq is NULL"));
9973 }
9974 return;
9975
9976}
9977
9978static void csr_update_snr(tpAniSirGlobal pMac, void *pMsg)
9979{
9980 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq *) pMsg;
9981
9982 if (pGetSnrReq) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309983 if (QDF_STATUS_SUCCESS != wma_get_snr(pGetSnrReq)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009984 sms_log(pMac, LOGE, FL("Error in wma_get_snr"));
9985 return;
9986 }
9987
9988 } else {
9989 sms_log(pMac, LOGE, FL("pGetSnrReq is NULL"));
9990 }
9991 return;
9992}
9993
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309994static QDF_STATUS csr_send_reset_ap_caps_changed(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309995 struct qdf_mac_addr *bssId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009996{
9997 tpSirResetAPCapsChange pMsg;
9998 uint16_t len;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309999 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010000
10001 /* Create the message and send to lim */
10002 len = sizeof(tSirResetAPCapsChange);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010003 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010004 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010005 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010006 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010007 status = QDF_STATUS_SUCCESS;
Srinivas Girigowda40567b92015-09-24 15:17:25 -070010008
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010009 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010010 qdf_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010011 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
10012 pMsg->length = len;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010013 qdf_copy_macaddr(&pMsg->bssId, bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010014 sms_log(pMac, LOG1,
10015 FL("CSR reset caps change for Bssid= " MAC_ADDRESS_STR),
Srinivas Girigowda40567b92015-09-24 15:17:25 -070010016 MAC_ADDR_ARRAY(pMsg->bssId.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010017 status = cds_send_mb_message_to_mac(pMsg);
10018 } else {
Srinivas Girigowda40567b92015-09-24 15:17:25 -070010019 sms_log(pMac, LOGE, FL("Memory allocation failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010020 }
10021 return status;
10022}
10023
10024static void
10025csr_roam_chk_lnk_assoc_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10026{
10027 tCsrRoamSession *session;
10028 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010029 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010030 tCsrRoamInfo *roam_info_ptr = NULL;
10031 tSirSmeAssocInd *pAssocInd;
10032 tCsrRoamInfo roam_info;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010033 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010034
10035 sms_log(mac_ctx, LOG1, FL("Receive WNI_SME_ASSOC_IND from SME"));
10036 pAssocInd = (tSirSmeAssocInd *) msg_ptr;
10037 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010038 (struct qdf_mac_addr *) pAssocInd->bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010039 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010040 sms_log(mac_ctx, LOG1,
10041 FL("Couldn't find session_id for given BSSID"));
10042 return;
10043 }
10044 session = CSR_GET_SESSION(mac_ctx, sessionId);
10045 if (!session) {
10046 sms_log(mac_ctx, LOGE, FL("session %d not found"), sessionId);
10047 return;
10048 }
10049 roam_info_ptr = &roam_info;
10050 /* Required for indicating the frames to upper layer */
10051 roam_info_ptr->assocReqLength = pAssocInd->assocReqLength;
10052 roam_info_ptr->assocReqPtr = pAssocInd->assocReqPtr;
10053 roam_info_ptr->beaconPtr = pAssocInd->beaconPtr;
10054 roam_info_ptr->beaconLength = pAssocInd->beaconLength;
10055 roam_info_ptr->statusCode = eSIR_SME_SUCCESS;
10056 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
10057 roam_info_ptr->staId = (uint8_t) pAssocInd->staId;
10058 roam_info_ptr->rsnIELen = (uint8_t) pAssocInd->rsnIE.length;
10059 roam_info_ptr->prsnIE = pAssocInd->rsnIE.rsnIEdata;
10060#ifdef FEATURE_WLAN_WAPI
10061 roam_info_ptr->wapiIELen = (uint8_t) pAssocInd->wapiIE.length;
10062 roam_info_ptr->pwapiIE = pAssocInd->wapiIE.wapiIEdata;
10063#endif
10064 roam_info_ptr->addIELen = (uint8_t) pAssocInd->addIE.length;
10065 roam_info_ptr->paddIE = pAssocInd->addIE.addIEdata;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010066 qdf_mem_copy(roam_info_ptr->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010067 pAssocInd->peerMacAddr,
10068 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010069 qdf_mem_copy(roam_info_ptr->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010070 pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010071 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010072 roam_info_ptr->wmmEnabledSta = pAssocInd->wmmEnabledSta;
10073 roam_info_ptr->timingMeasCap = pAssocInd->timingMeasCap;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010074 qdf_mem_copy(&roam_info_ptr->chan_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010075 &pAssocInd->chan_info,
10076 sizeof(tSirSmeChanInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010077 if (CSR_IS_INFRA_AP(roam_info_ptr->u.pConnectedProfile)) {
10078 if (session->pCurRoamProfile &&
10079 CSR_IS_ENC_TYPE_STATIC(
10080 session->pCurRoamProfile->negotiatedUCEncryptionType)) {
10081 /* NO keys... these key parameters don't matter. */
10082 csr_roam_issue_set_context_req(mac_ctx, sessionId,
10083 session->pCurRoamProfile->negotiatedUCEncryptionType,
10084 session->pConnectBssDesc,
10085 &(roam_info_ptr->peerMac.bytes),
10086 false, true, eSIR_TX_RX, 0, 0, NULL, 0);
10087 roam_info_ptr->fAuthRequired = false;
10088 } else {
10089 roam_info_ptr->fAuthRequired = true;
10090 }
10091 status = csr_roam_call_callback(mac_ctx, sessionId,
10092 roam_info_ptr, 0, eCSR_ROAM_INFRA_IND,
10093 eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010094 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010095 /* Refused due to Mac filtering */
10096 roam_info_ptr->statusCode = eSIR_SME_ASSOC_REFUSED;
10097 }
10098
10099 /* Send Association completion message to PE */
10100 status = csr_send_assoc_cnf_msg(mac_ctx, pAssocInd, status);
10101 /*
10102 * send a message to CSR itself just to avoid the EAPOL frames going
10103 * OTA before association response
10104 */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070010105 if (CSR_IS_INFRA_AP(roam_info_ptr->u.pConnectedProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010106 && (roam_info_ptr->statusCode != eSIR_SME_ASSOC_REFUSED)) {
10107 roam_info_ptr->fReassocReq = pAssocInd->reassocReq;
10108 status = csr_send_assoc_ind_to_upper_layer_cnf_msg(mac_ctx,
10109 pAssocInd, status, sessionId);
10110 }
10111}
10112
10113static void
10114csr_roam_chk_lnk_disassoc_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10115{
10116 tCsrRoamSession *session;
10117 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010118 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010119 tCsrRoamInfo *roam_info_ptr = NULL;
10120 tSirSmeDisassocInd *pDisassocInd;
10121 tSmeCmd cmd;
10122 tCsrRoamInfo roam_info;
10123
10124 /*
10125 * Check if AP dis-associated us because of MIC failure. If so,
10126 * then we need to take action immediately and not wait till the
10127 * the WmStatusChange requests is pushed and processed
10128 */
10129 pDisassocInd = (tSirSmeDisassocInd *) msg_ptr;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010130 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010131 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010132 &pDisassocInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010133 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010134 sms_log(mac_ctx, LOGE, FL("Session Id not found for BSSID "
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010135 MAC_ADDRESS_STR),
10136 MAC_ADDR_ARRAY(pDisassocInd->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010137 return;
10138 }
10139
10140 sms_log(mac_ctx, LOGE,
10141 FL("DISASSOCIATION Indication from MAC for session %d "),
10142 sessionId);
10143 sms_log(mac_ctx, LOGE,
10144 FL("DISASSOCIATION from peer =" MAC_ADDRESS_STR
10145 " " " reason = %d status = %d "),
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010146 MAC_ADDR_ARRAY(pDisassocInd->peer_macaddr.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010147 pDisassocInd->reasonCode,
10148 pDisassocInd->statusCode);
10149 /*
10150 * If we are in neighbor preauth done state then on receiving
10151 * disassoc or deauth we dont roam instead we just disassoc
10152 * from current ap and then go to disconnected state
10153 * This happens for ESE and 11r FT connections ONLY.
10154 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010155 if (csr_roam_is11r_assoc(mac_ctx, sessionId) &&
10156 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10157 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10158 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010159#ifdef FEATURE_WLAN_ESE
10160 if (csr_roam_is_ese_assoc(mac_ctx, sessionId) &&
10161 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10162 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10163 mac_ctx, sessionId);
10164#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010165 if (csr_roam_is_fast_roam_enabled(mac_ctx, sessionId) &&
10166 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10167 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10168 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010169 session = CSR_GET_SESSION(mac_ctx, sessionId);
10170 if (!session) {
10171 sms_log(mac_ctx, LOGE, FL("session %d not found"), sessionId);
10172 return;
10173 }
10174 if (csr_is_conn_state_infra(mac_ctx, sessionId))
10175 session->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10176#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10177 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
10178 SME_QOS_CSR_DISCONNECT_IND, NULL);
10179#endif
10180 csr_roam_link_down(mac_ctx, sessionId);
10181 csr_roam_issue_wm_status_change(mac_ctx, sessionId,
10182 eCsrDisassociated, msg_ptr);
10183 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
10184 roam_info_ptr = &roam_info;
10185 roam_info_ptr->statusCode = pDisassocInd->statusCode;
10186 roam_info_ptr->reasonCode = pDisassocInd->reasonCode;
10187 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
10188 roam_info_ptr->staId = (uint8_t) pDisassocInd->staId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010189 qdf_copy_macaddr(&roam_info_ptr->peerMac,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010190 &pDisassocInd->peer_macaddr);
Anurag Chouhanc5548422016-02-24 18:33:27 +053010191 qdf_copy_macaddr(&roam_info_ptr->bssid,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010192 &pDisassocInd->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010193 status = csr_roam_call_callback(mac_ctx, sessionId,
10194 roam_info_ptr, 0,
10195 eCSR_ROAM_INFRA_IND,
10196 eCSR_ROAM_RESULT_DISASSOC_IND);
10197 /*
10198 * STA/P2P client got disassociated so remove any pending
10199 * deauth commands in sme pending list
10200 */
10201 cmd.command = eSmeCommandRoam;
10202 cmd.sessionId = (uint8_t) sessionId;
10203 cmd.u.roamCmd.roamReason = eCsrForcedDeauthSta;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010204 qdf_mem_copy(cmd.u.roamCmd.peerMac,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010205 pDisassocInd->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010206 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010207 csr_roam_remove_duplicate_command(mac_ctx, sessionId, &cmd,
10208 eCsrForcedDeauthSta);
10209 }
10210}
10211
10212static void
10213csr_roam_chk_lnk_deauth_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10214{
10215 tCsrRoamSession *session;
10216 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010217 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010218 tCsrRoamInfo *roam_info_ptr = NULL;
10219 tSirSmeDeauthInd *pDeauthInd;
10220 tCsrRoamInfo roam_info;
10221
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010222 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010223 sms_log(mac_ctx, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
10224 pDeauthInd = (tpSirSmeDeauthInd) msg_ptr;
10225 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080010226 &pDeauthInd->bssid,
10227 &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010228 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010229 return;
10230 /* If we are in neighbor preauth done state then on receiving
10231 * disassoc or deauth we dont roam instead we just disassoc
10232 * from current ap and then go to disconnected state
10233 * This happens for ESE and 11r FT connections ONLY.
10234 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010235 if (csr_roam_is11r_assoc(mac_ctx, sessionId) &&
10236 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10237 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10238 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010239#ifdef FEATURE_WLAN_ESE
10240 if (csr_roam_is_ese_assoc(mac_ctx, sessionId) &&
10241 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10242 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10243 mac_ctx, sessionId);
10244#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010245 if (csr_roam_is_fast_roam_enabled(mac_ctx, sessionId) &&
10246 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10247 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10248 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010249 session = CSR_GET_SESSION(mac_ctx, sessionId);
10250 if (!session) {
10251 sms_log(mac_ctx, LOGE, FL("session %d not found"), sessionId);
10252 return;
10253 }
10254
10255 if (csr_is_conn_state_infra(mac_ctx, sessionId))
10256 session->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10257#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10258 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
10259 SME_QOS_CSR_DISCONNECT_IND, NULL);
10260#endif
10261 csr_roam_link_down(mac_ctx, sessionId);
10262 csr_roam_issue_wm_status_change(mac_ctx, sessionId,
10263 eCsrDeauthenticated,
10264 msg_ptr);
10265 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
10266 roam_info_ptr = &roam_info;
10267 roam_info_ptr->statusCode = pDeauthInd->statusCode;
10268 roam_info_ptr->reasonCode = pDeauthInd->reasonCode;
10269 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
10270 roam_info_ptr->staId = (uint8_t) pDeauthInd->staId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010271 qdf_copy_macaddr(&roam_info_ptr->peerMac,
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080010272 &pDeauthInd->peer_macaddr);
Anurag Chouhanc5548422016-02-24 18:33:27 +053010273 qdf_copy_macaddr(&roam_info_ptr->bssid,
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080010274 &pDeauthInd->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010275 status = csr_roam_call_callback(mac_ctx, sessionId,
10276 roam_info_ptr, 0,
10277 eCSR_ROAM_INFRA_IND,
10278 eCSR_ROAM_RESULT_DEAUTH_IND);
10279 }
10280}
10281
10282static void
10283csr_roam_chk_lnk_swt_ch_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10284{
10285 tCsrRoamSession *session;
10286 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010287 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010288 tpSirSmeSwitchChannelInd pSwitchChnInd;
10289
10290 /* in case of STA, the SWITCH_CHANNEL originates from its AP */
10291 sms_log(mac_ctx, LOGW, FL("eWNI_SME_SWITCH_CHL_IND from SME"));
10292 pSwitchChnInd = (tpSirSmeSwitchChannelInd) msg_ptr;
10293 /* Update with the new channel id. The channel id is hidden in the
10294 * statusCode.
10295 */
10296 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda591c5652015-12-30 17:39:50 -080010297 &pSwitchChnInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010298 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010299 session = CSR_GET_SESSION(mac_ctx, sessionId);
10300 if (!session) {
10301 sms_log(mac_ctx, LOGE,
10302 FL("session %d not found"), sessionId);
10303 return;
10304 }
10305 session->connectedProfile.operationChannel =
10306 (uint8_t) pSwitchChnInd->newChannelId;
10307 if (session->pConnectBssDesc) {
10308 session->pConnectBssDesc->channelId =
10309 (uint8_t) pSwitchChnInd->newChannelId;
10310 }
10311 }
10312}
10313
10314static void
10315csr_roam_chk_lnk_deauth_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10316{
10317 tCsrRoamSession *session;
10318 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010319 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010320 tCsrRoamInfo *roam_info_ptr = NULL;
10321 tSirSmeDeauthRsp *pDeauthRsp = (tSirSmeDeauthRsp *) msg_ptr;
10322 tCsrRoamInfo roam_info;
10323
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010324 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010325 sms_log(mac_ctx, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
10326 sessionId = pDeauthRsp->sessionId;
10327 if (!CSR_IS_SESSION_VALID(mac_ctx, sessionId))
10328 return;
10329 session = CSR_GET_SESSION(mac_ctx, sessionId);
10330 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
10331 roam_info_ptr = &roam_info;
10332 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010333 qdf_copy_macaddr(&roam_info_ptr->peerMac,
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -080010334 &pDeauthRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010335 roam_info_ptr->reasonCode = eCSR_ROAM_RESULT_FORCED;
10336 roam_info_ptr->statusCode = pDeauthRsp->statusCode;
10337 status = csr_roam_call_callback(mac_ctx, sessionId,
10338 roam_info_ptr, 0,
10339 eCSR_ROAM_LOSTLINK,
10340 eCSR_ROAM_RESULT_FORCED);
10341 }
10342}
10343
10344static void
10345csr_roam_chk_lnk_disassoc_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10346{
10347 tCsrRoamSession *session;
10348 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010349 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010350 tCsrRoamInfo *roam_info_ptr = NULL;
10351 tCsrRoamInfo roam_info;
10352 /*
10353 * session id is invalid here so cant use it to access the array
10354 * curSubstate as index
10355 */
10356 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *) msg_ptr;
10357
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010358 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010359 sms_log(mac_ctx, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
10360 sessionId = pDisassocRsp->sessionId;
10361 if (!CSR_IS_SESSION_VALID(mac_ctx, sessionId))
10362 return;
10363 session = CSR_GET_SESSION(mac_ctx, sessionId);
10364 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
10365 roam_info_ptr = &roam_info;
10366 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010367 qdf_copy_macaddr(&roam_info_ptr->peerMac,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -080010368 &pDisassocRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010369 roam_info_ptr->reasonCode = eCSR_ROAM_RESULT_FORCED;
10370 roam_info_ptr->statusCode = pDisassocRsp->statusCode;
10371 status = csr_roam_call_callback(mac_ctx, sessionId,
10372 roam_info_ptr, 0,
10373 eCSR_ROAM_LOSTLINK,
10374 eCSR_ROAM_RESULT_FORCED);
10375 }
10376}
10377
10378#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10379static void
10380csr_roam_diag_mic_fail(tpAniSirGlobal mac_ctx, uint32_t sessionId)
10381{
10382 WLAN_HOST_DIAG_EVENT_DEF(secEvent,
10383 host_event_wlan_security_payload_type);
10384 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, sessionId);
10385 if (!session) {
10386 sms_log(mac_ctx, LOGE, FL("session %d not found"), sessionId);
10387 return;
10388 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010389 qdf_mem_set(&secEvent, sizeof(host_event_wlan_security_payload_type),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010390 0);
10391 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
10392 secEvent.encryptionModeMulticast =
10393 (uint8_t) diag_enc_type_from_csr_type(
10394 session->connectedProfile.mcEncryptionType);
10395 secEvent.encryptionModeUnicast =
10396 (uint8_t) diag_enc_type_from_csr_type(
10397 session->connectedProfile.EncryptionType);
10398 secEvent.authMode =
10399 (uint8_t) diag_auth_type_from_csr_type(
10400 session->connectedProfile.AuthType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010401 qdf_mem_copy(secEvent.bssid, session->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010402 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010403 WLAN_HOST_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
10404}
10405#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10406
10407static void
10408csr_roam_chk_lnk_mic_fail_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10409{
10410 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010411 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010412 tCsrRoamInfo *roam_info_ptr = NULL;
10413 tCsrRoamInfo roam_info;
10414 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd) msg_ptr;
10415 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
10416
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010417 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010418 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda37c133b2015-09-24 16:14:15 -070010419 &pMicInd->bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010420 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010421 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010422 roam_info.u.pMICFailureInfo = &pMicInd->info;
10423 roam_info_ptr = &roam_info;
10424 if (pMicInd->info.multicast)
10425 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
10426 else
10427 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
10428 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
10429 eCSR_ROAM_MIC_ERROR_IND, result);
10430 }
10431#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10432 csr_roam_diag_mic_fail(mac_ctx, sessionId);
10433#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10434}
10435
10436static void
10437csr_roam_chk_lnk_pbs_probe_req_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10438{
10439 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010440 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010441 tCsrRoamInfo roam_info;
10442 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd) msg_ptr;
10443
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010444 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010445 sms_log(mac_ctx, LOG1, FL("WPS PBC Probe request Indication from SME"));
10446
10447 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowdad6673be2015-11-24 14:18:13 -080010448 &pProbeReqInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010449 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010450 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010451 roam_info.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
10452 csr_roam_call_callback(mac_ctx, sessionId, &roam_info,
10453 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
10454 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
10455 }
10456}
10457
10458#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10459static void
10460csr_roam_diag_joined_new_bss(tpAniSirGlobal mac_ctx,
10461 tSirSmeNewBssInfo *pNewBss)
10462{
10463 host_log_ibss_pkt_type *pIbssLog;
10464 uint32_t bi;
10465 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
10466 LOG_WLAN_IBSS_C);
10467 if (!pIbssLog)
10468 return;
10469 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
10470 if (pNewBss) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053010471 qdf_copy_macaddr(&pIbssLog->bssid, &pNewBss->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010472 if (pNewBss->ssId.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010473 qdf_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010474 pNewBss->ssId.length);
10475 pIbssLog->operatingChannel = pNewBss->channelNumber;
10476 }
10477 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(mac_ctx,
10478 WNI_CFG_BEACON_INTERVAL,
10479 &bi)))
10480 /* U8 is not enough for beacon interval */
10481 pIbssLog->beaconInterval = (uint8_t) bi;
10482 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
10483}
10484#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10485
10486static void
10487csr_roam_chk_lnk_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
10488 tSirSmeRsp *msg_ptr)
10489{
10490 tCsrRoamSession *session;
10491 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010492 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010493 tCsrRoamInfo *roam_info_ptr = NULL;
10494 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
10495 tCsrRoamInfo roam_info;
10496 tSirSmeApNewCaps *pApNewCaps;
10497 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10498 tSirMacAddr Broadcastaddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
10499 tSirSmeNewBssInfo *pNewBss;
10500 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
10501
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010502 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010503 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *) msg_ptr;
10504 switch (pStatusChangeMsg->statusChangeCode) {
10505 case eSIR_SME_IBSS_ACTIVE:
10506 sessionId = csr_find_ibss_session(mac_ctx);
10507 if (CSR_SESSION_ID_INVALID == sessionId)
10508 break;
10509 session = CSR_GET_SESSION(mac_ctx, sessionId);
10510 if (!session) {
10511 sms_log(mac_ctx, LOGE, FL("session %d not found"),
10512 sessionId);
10513 return;
10514 }
10515 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
10516 if (session->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010517 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010518 session->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010519 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010520 roam_info.u.pConnectedProfile =
10521 &session->connectedProfile;
10522 roam_info_ptr = &roam_info;
10523 } else {
10524 sms_log(mac_ctx, LOGE,
10525 FL("CSR: connected BSS is empty"));
10526 }
10527 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
10528 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10529 break;
10530
10531 case eSIR_SME_IBSS_INACTIVE:
10532 sessionId = csr_find_ibss_session(mac_ctx);
10533 if (CSR_SESSION_ID_INVALID != sessionId) {
10534 session = CSR_GET_SESSION(mac_ctx, sessionId);
10535 if (!session) {
10536 sms_log(mac_ctx, LOGE,
10537 FL("session %d not found"), sessionId);
10538 return;
10539 }
10540 session->connectState =
10541 eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
10542 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
10543 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10544 }
10545 break;
10546
10547 case eSIR_SME_JOINED_NEW_BSS:
10548 /* IBSS coalescing. */
10549 sms_log(mac_ctx, LOGW,
10550 FL("CSR: eSIR_SME_JOINED_NEW_BSS received from PE"));
10551 sessionId = csr_find_ibss_session(mac_ctx);
10552 if (CSR_SESSION_ID_INVALID == sessionId)
10553 break;
10554 session = CSR_GET_SESSION(mac_ctx, sessionId);
10555 if (!session) {
10556 sms_log(mac_ctx, LOGE, FL("session %d not found"),
10557 sessionId);
10558 return;
10559 }
10560 /* update the connection state information */
10561 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
10562#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10563 csr_roam_diag_joined_new_bss(mac_ctx, pNewBss);
10564#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10565 csr_roam_update_connected_profile_from_new_bss(mac_ctx,
10566 sessionId,
10567 pNewBss);
10568
10569 if ((eCSR_ENCRYPT_TYPE_NONE ==
10570 session->connectedProfile.EncryptionType)) {
10571 csr_roam_issue_set_context_req(mac_ctx,
10572 sessionId,
10573 session->connectedProfile.EncryptionType,
10574 session->pConnectBssDesc,
10575 &Broadcastaddr, false, false,
10576 eSIR_TX_RX, 0, 0, NULL, 0);
10577 }
10578 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
10579 roamStatus = eCSR_ROAM_IBSS_IND;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010580 qdf_mem_copy(&roam_info.bssid, &pNewBss->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010581 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010582 roam_info_ptr = &roam_info;
10583 /* This BSSID is the real BSSID, save it */
10584 if (session->pConnectBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010585 qdf_mem_copy(session->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010586 &pNewBss->bssId, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010587 break;
10588
10589 /*
10590 * detection by LIM that the capabilities of the associated
10591 * AP have changed.
10592 */
10593 case eSIR_SME_AP_CAPS_CHANGED:
10594 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
10595 sms_log(mac_ctx, LOGW,
10596 FL("CSR handling eSIR_SME_AP_CAPS_CHANGED"));
10597 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda26ebb192015-09-24 15:12:09 -070010598 &pApNewCaps->bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010599 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010600 break;
10601 if (eCSR_ROAMING_STATE_JOINED ==
10602 mac_ctx->roam.curState[sessionId]
10603 && ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC
10604 == mac_ctx->roam.curSubState[sessionId])
10605 || (eCSR_ROAM_SUBSTATE_NONE ==
10606 mac_ctx->roam.curSubState[sessionId])
10607 || (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC
10608 == mac_ctx->roam.curSubState[sessionId])
10609 || (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC ==
10610 mac_ctx->roam.curSubState[sessionId]))) {
10611 sms_log(mac_ctx, LOGW,
10612 FL("Calling csr_roam_disconnect_internal"));
10613 csr_roam_disconnect_internal(mac_ctx, sessionId,
10614 eCSR_DISCONNECT_REASON_UNSPECIFIED);
10615 } else {
10616 sms_log(mac_ctx, LOGW,
10617 FL("Skipping the new scan as CSR is in state %s and sub-state %s"),
10618 mac_trace_getcsr_roam_state(
10619 mac_ctx->roam.curState[sessionId]),
10620 mac_trace_getcsr_roam_sub_state(
10621 mac_ctx->roam.curSubState[sessionId]));
10622 /* We ignore the caps change event if CSR is not in full
10623 * connected state. Send one event to PE to reset
10624 * limSentCapsChangeNtf Once limSentCapsChangeNtf set
10625 * 0, lim can send sub sequent CAPS change event
10626 * otherwise lim cannot send any CAPS change events to
10627 * SME
10628 */
10629 csr_send_reset_ap_caps_changed(mac_ctx,
10630 &pApNewCaps->bssId);
10631 }
10632 break;
10633
10634 default:
10635 roamStatus = eCSR_ROAM_FAILED;
10636 result = eCSR_ROAM_RESULT_NONE;
10637 break;
10638 } /* end switch on statusChangeCode */
10639 if (eCSR_ROAM_RESULT_NONE != result) {
10640 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
10641 roamStatus, result);
10642 }
10643}
10644
10645static void
10646csr_roam_chk_lnk_ibss_new_peer_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10647{
10648 tCsrRoamSession *session;
10649 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010650 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010651 tCsrRoamInfo *roam_info_ptr = NULL;
10652 tSmeIbssPeerInd *pIbssPeerInd = (tSmeIbssPeerInd *) msg_ptr;
10653 tCsrRoamInfo roam_info;
10654#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10655 host_log_ibss_pkt_type *pIbssLog;
10656 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
10657 LOG_WLAN_IBSS_C);
10658 if (pIbssLog) {
10659 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010660 qdf_copy_macaddr(&pIbssLog->peer_macaddr,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080010661 &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010662 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
10663 }
10664#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10665
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010666 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010667 sessionId = csr_find_ibss_session(mac_ctx);
10668 if (CSR_SESSION_ID_INVALID == sessionId)
10669 return;
10670 session = CSR_GET_SESSION(mac_ctx, sessionId);
10671 if (!session) {
10672 sms_log(mac_ctx, LOGE, FL("session %d not found"), sessionId);
10673 return;
10674 }
10675 /*
10676 * Issue the set Context request to LIM to establish the Unicast STA
10677 * context for the new peer...
10678 */
10679 if (!session->pConnectBssDesc) {
10680 sms_log(mac_ctx, LOGW, FL("CSR: connected BSS is empty"));
10681 goto callback_and_free;
10682 }
Anurag Chouhanc5548422016-02-24 18:33:27 +053010683 qdf_copy_macaddr(&roam_info.peerMac, &pIbssPeerInd->peer_addr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010684 qdf_mem_copy(&roam_info.bssid, session->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010685 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010686 if (pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010687 roam_info.pbFrames = qdf_mem_malloc((pIbssPeerInd->mesgLen -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010688 sizeof(tSmeIbssPeerInd)));
10689 if (NULL == roam_info.pbFrames) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010690 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010691 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010692 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010693 roam_info.nBeaconLength = pIbssPeerInd->mesgLen -
10694 sizeof(tSmeIbssPeerInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010695 qdf_mem_copy(roam_info.pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010696 ((uint8_t *) pIbssPeerInd) +
10697 sizeof(tSmeIbssPeerInd),
10698 roam_info.nBeaconLength);
10699 }
10700 roam_info.staId = (uint8_t) pIbssPeerInd->staId;
10701 roam_info.ucastSig = (uint8_t) pIbssPeerInd->ucastSig;
10702 roam_info.bcastSig = (uint8_t) pIbssPeerInd->bcastSig;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010703 roam_info.pBssDesc = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010704 session->pConnectBssDesc->length);
10705 if (NULL == roam_info.pBssDesc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010706 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010707 if (roam_info.pbFrames)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010708 qdf_mem_free(roam_info.pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010709 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010710 qdf_mem_free(roam_info.pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010711 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010712 status = QDF_STATUS_SUCCESS;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010713 qdf_mem_copy(roam_info.pBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010714 session->pConnectBssDesc,
10715 session->pConnectBssDesc->length);
10716 roam_info_ptr = &roam_info;
10717 }
10718 } else {
10719 roam_info_ptr = &roam_info;
10720 }
10721 if ((eCSR_ENCRYPT_TYPE_NONE ==
10722 session->connectedProfile.EncryptionType)) {
10723 /* NO keys. these key parameters don't matter */
10724 csr_roam_issue_set_context_req(mac_ctx, sessionId,
10725 session->connectedProfile.EncryptionType,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080010726 session->pConnectBssDesc,
10727 &pIbssPeerInd->peer_addr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010728 false, true, eSIR_TX_RX, 0, 0, NULL, 0);
10729 }
10730
10731callback_and_free:
10732 /* send up the sec type for the new peer */
10733 if (roam_info_ptr)
10734 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
10735 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
10736 eCSR_ROAM_CONNECT_STATUS_UPDATE,
10737 eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10738 if (roam_info_ptr) {
10739 if (roam_info.pbFrames)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010740 qdf_mem_free(roam_info.pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010741 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010742 qdf_mem_free(roam_info.pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010743 }
10744}
10745
10746static void
10747csr_roam_chk_lnk_ibss_peer_departed_ind(tpAniSirGlobal mac_ctx,
10748 tSirSmeRsp *msg_ptr)
10749{
10750 uint32_t sessionId = CSR_SESSION_ID_INVALID;
10751 tCsrRoamInfo roam_info;
10752 tSmeIbssPeerInd *pIbssPeerInd;
10753
10754 if (NULL == msg_ptr) {
10755 sms_log(mac_ctx, LOGE, FL("IBSS peer ind. message is NULL"));
10756 return;
10757 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010758 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010759 pIbssPeerInd = (tSmeIbssPeerInd *) msg_ptr;
10760 sessionId = csr_find_ibss_session(mac_ctx);
10761 if (CSR_SESSION_ID_INVALID != sessionId) {
10762#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10763 host_log_ibss_pkt_type *pIbssLog;
10764 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
10765 LOG_WLAN_IBSS_C);
10766 if (pIbssLog) {
10767 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10768 if (pIbssPeerInd) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053010769 qdf_copy_macaddr(&pIbssLog->peer_macaddr,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080010770 &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010771 }
10772 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
10773 }
10774#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10775 sms_log(mac_ctx, LOGW,
10776 FL("CSR: Peer departed notification from LIM"));
10777 roam_info.staId = (uint8_t) pIbssPeerInd->staId;
10778 roam_info.ucastSig = (uint8_t) pIbssPeerInd->ucastSig;
10779 roam_info.bcastSig = (uint8_t) pIbssPeerInd->bcastSig;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010780 qdf_copy_macaddr(&roam_info.peerMac, &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010781 csr_roam_call_callback(mac_ctx, sessionId, &roam_info, 0,
10782 eCSR_ROAM_CONNECT_STATUS_UPDATE,
10783 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10784 }
10785}
10786
10787#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10788static void
10789csr_roam_diag_set_ctx_rsp(tpAniSirGlobal mac_ctx,
10790 tCsrRoamSession *session,
10791 tSirSmeSetContextRsp *pRsp)
10792{
10793 WLAN_HOST_DIAG_EVENT_DEF(setKeyEvent,
10794 host_event_wlan_security_payload_type);
10795 if (eCSR_ENCRYPT_TYPE_NONE ==
10796 session->connectedProfile.EncryptionType)
10797 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010798 qdf_mem_set(&setKeyEvent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010799 sizeof(host_event_wlan_security_payload_type), 0);
Anurag Chouhanc5548422016-02-24 18:33:27 +053010800 if (qdf_is_macaddr_group(&pRsp->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010801 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
10802 else
10803 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
10804 setKeyEvent.encryptionModeMulticast =
10805 (uint8_t) diag_enc_type_from_csr_type(
10806 session->connectedProfile.mcEncryptionType);
10807 setKeyEvent.encryptionModeUnicast =
10808 (uint8_t) diag_enc_type_from_csr_type(
10809 session->connectedProfile.EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010810 qdf_mem_copy(setKeyEvent.bssid, session->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010811 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010812 setKeyEvent.authMode =
10813 (uint8_t) diag_auth_type_from_csr_type(
10814 session->connectedProfile.AuthType);
10815 if (eSIR_SME_SUCCESS != pRsp->statusCode)
10816 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10817 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10818}
10819#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10820
10821static void
10822csr_roam_chk_lnk_set_ctx_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10823{
10824 tCsrRoamSession *session;
10825 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010826 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010827 tCsrRoamInfo *roam_info_ptr = NULL;
10828 tSmeCmd *cmd;
10829 tCsrRoamInfo roam_info;
10830 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10831 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *) msg_ptr;
10832 tListElem *entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010833
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010834 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010835 entry = csr_ll_peek_head(&mac_ctx->sme.smeCmdActiveList,
10836 LL_ACCESS_LOCK);
10837 if (!entry) {
10838 sms_log(mac_ctx, LOGE, FL("CSR: NO commands are ACTIVE ..."));
10839 goto process_pending_n_exit;
10840 }
10841
10842 cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
10843 if (eSmeCommandSetKey != cmd->command) {
10844 sms_log(mac_ctx, LOGE, FL("CSR: setkey cmd is not ACTIVE ..."));
10845 goto process_pending_n_exit;
10846 }
10847 sessionId = cmd->sessionId;
10848 session = CSR_GET_SESSION(mac_ctx, sessionId);
10849 if (!session) {
10850 sms_log(mac_ctx, LOGE, FL("session %d not found"), sessionId);
10851 return;
10852 }
10853#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10854 csr_roam_diag_set_ctx_rsp(mac_ctx, session, pRsp);
10855#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10856 if (CSR_IS_WAIT_FOR_KEY(mac_ctx, sessionId)) {
10857 csr_roam_stop_wait_for_key_timer(mac_ctx);
10858 /* We are done with authentication, whethere succeed or not */
10859 csr_roam_substate_change(mac_ctx, eCSR_ROAM_SUBSTATE_NONE,
10860 sessionId);
10861 /* We do it here because this linkup function is not called
10862 * after association when a key needs to be set.
10863 */
10864 if (csr_is_conn_state_connected_infra(mac_ctx, sessionId))
10865 csr_roam_link_up(mac_ctx,
10866 session->connectedProfile.bssid);
10867 }
10868 if (eSIR_SME_SUCCESS == pRsp->statusCode) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053010869 qdf_copy_macaddr(&roam_info.peerMac, &pRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010870 /* Make sure we install the GTK before indicating to HDD as
10871 * authenticated. This is to prevent broadcast packets go out
10872 * after PTK and before GTK.
10873 */
Anurag Chouhanc5548422016-02-24 18:33:27 +053010874 if (qdf_is_macaddr_broadcast(&pRsp->peer_macaddr)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010875 tpSirSetActiveModeSetBncFilterReq pMsg;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010876 pMsg = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010877 sizeof(tSirSetActiveModeSetBncFilterReq));
10878 pMsg->messageType = eWNI_SME_SET_BCN_FILTER_REQ;
10879 pMsg->length = sizeof(uint8_t);
10880 pMsg->seesionId = sessionId;
10881 status = cds_send_mb_message_to_mac(pMsg);
10882 result = eCSR_ROAM_RESULT_AUTHENTICATED;
10883 } else {
10884 result = eCSR_ROAM_RESULT_NONE;
10885 }
Sandeep Puligillae0875662016-02-12 16:09:21 -080010886 /*
10887 * OBSS SCAN Indication will be sent to Firmware
10888 * to start OBSS Scan
10889 */
10890 if (CSR_IS_CHANNEL_24GHZ(
10891 session->connectedProfile.operationChannel)
10892 && (session->connectState ==
10893 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
10894 && session->pCurRoamProfile
10895 && ((QDF_P2P_CLIENT_MODE ==
10896 session->pCurRoamProfile->csrPersona)
10897 || (QDF_STA_MODE ==
10898 session->pCurRoamProfile->csrPersona))) {
10899 struct sme_obss_ht40_scanind_msg *msg;
10900 msg = qdf_mem_malloc(sizeof(
10901 struct sme_obss_ht40_scanind_msg));
10902 msg->msg_type = eWNI_SME_HT40_OBSS_SCAN_IND;
10903 msg->length = sizeof(struct sme_obss_ht40_scanind_msg);
10904 qdf_copy_macaddr(&msg->mac_addr,
10905 &session->connectedProfile.bssid);
10906 status = cds_send_mb_message_to_mac(msg);
10907 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010908 roam_info_ptr = &roam_info;
10909 } else {
10910 result = eCSR_ROAM_RESULT_FAILURE;
10911 sms_log(mac_ctx, LOGE,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080010912 FL("CSR: setkey command failed(err=%d) PeerMac "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010913 MAC_ADDRESS_STR),
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080010914 pRsp->statusCode,
10915 MAC_ADDR_ARRAY(pRsp->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010916 }
10917 csr_roam_call_callback(mac_ctx, sessionId, &roam_info,
10918 cmd->u.setKeyCmd.roamId,
10919 eCSR_ROAM_SET_KEY_COMPLETE, result);
10920 /* Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10921 * can go ahead and initiate the TSPEC if any are pending
10922 */
10923 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
10924 SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
10925#ifdef FEATURE_WLAN_ESE
10926 /* Send Adjacent AP repot to new AP. */
10927 if (result == eCSR_ROAM_RESULT_AUTHENTICATED
10928 && session->isPrevApInfoValid
10929 && session->connectedProfile.isESEAssoc) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010930 csr_send_ese_adjacent_ap_rep_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010931 session->isPrevApInfoValid = false;
10932 }
10933#endif
10934 if (csr_ll_remove_entry(&mac_ctx->sme.smeCmdActiveList, entry,
10935 LL_ACCESS_LOCK))
10936 csr_release_command_set_key(mac_ctx, cmd);
10937
10938process_pending_n_exit:
10939 sme_process_pending_queue(mac_ctx);
10940}
10941
10942
10943static void
10944csr_roam_chk_lnk_max_assoc_exceeded(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10945{
10946 uint32_t sessionId = CSR_SESSION_ID_INVALID;
10947 tSmeMaxAssocInd *pSmeMaxAssocInd;
10948 tCsrRoamInfo roam_info;
10949
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010950 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010951 pSmeMaxAssocInd = (tSmeMaxAssocInd *) msg_ptr;
10952 sms_log(mac_ctx, LOG1,
10953 FL("max assoc have been reached, new peer cannot be accepted"));
10954 sessionId = pSmeMaxAssocInd->sessionId;
10955 roam_info.sessionId = sessionId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010956 qdf_copy_macaddr(&roam_info.peerMac, &pSmeMaxAssocInd->peer_mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010957 csr_roam_call_callback(mac_ctx, sessionId, &roam_info, 0,
10958 eCSR_ROAM_INFRA_IND,
10959 eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10960}
10961
10962void csr_roam_check_for_link_status_change(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
10963{
10964 if (NULL == pSirMsg) {
10965 sms_log(pMac, LOGE, FL("pSirMsg is NULL"));
10966 return;
10967 }
10968 switch (pSirMsg->messageType) {
10969 case eWNI_SME_ASSOC_IND:
10970 csr_roam_chk_lnk_assoc_ind(pMac, pSirMsg);
10971 break;
10972 case eWNI_SME_DISASSOC_IND:
10973 csr_roam_chk_lnk_disassoc_ind(pMac, pSirMsg);
10974 break;
10975 case eWNI_SME_DEAUTH_IND:
10976 csr_roam_chk_lnk_deauth_ind(pMac, pSirMsg);
10977 break;
10978 case eWNI_SME_SWITCH_CHL_IND:
10979 csr_roam_chk_lnk_swt_ch_ind(pMac, pSirMsg);
10980 break;
10981 case eWNI_SME_DEAUTH_RSP:
10982 csr_roam_chk_lnk_deauth_rsp(pMac, pSirMsg);
10983 break;
10984 case eWNI_SME_DISASSOC_RSP:
10985 csr_roam_chk_lnk_disassoc_rsp(pMac, pSirMsg);
10986 break;
10987 case eWNI_SME_MIC_FAILURE_IND:
10988 csr_roam_chk_lnk_mic_fail_ind(pMac, pSirMsg);
10989 break;
10990 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
10991 csr_roam_chk_lnk_pbs_probe_req_ind(pMac, pSirMsg);
10992 break;
10993 case eWNI_SME_WM_STATUS_CHANGE_NTF:
10994 csr_roam_chk_lnk_wm_status_change_ntf(pMac, pSirMsg);
10995 break;
10996 case eWNI_SME_IBSS_NEW_PEER_IND:
10997 csr_roam_chk_lnk_ibss_new_peer_ind(pMac, pSirMsg);
10998 break;
10999 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
11000 csr_roam_chk_lnk_ibss_peer_departed_ind(pMac, pSirMsg);
11001 break;
11002 case eWNI_SME_SETCONTEXT_RSP:
11003 csr_roam_chk_lnk_set_ctx_rsp(pMac, pSirMsg);
11004 break;
11005 case eWNI_SME_GET_STATISTICS_RSP:
11006 sms_log(pMac, LOG2, FL("Stats rsp from PE"));
11007 csr_roam_stats_rsp_processor(pMac, pSirMsg);
11008 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -080011009#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011010 case eWNI_SME_GET_TSM_STATS_RSP:
11011 sms_log(pMac, LOG2, FL("TSM Stats rsp from PE"));
11012 csr_tsm_stats_rsp_processor(pMac, pSirMsg);
11013 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -080011014#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011015 case eWNI_SME_GET_RSSI_REQ:
11016 sms_log(pMac, LOG2, FL("GetRssiReq from self"));
11017 csr_update_rssi(pMac, pSirMsg);
11018 break;
11019 case eWNI_SME_GET_SNR_REQ:
11020 sms_log(pMac, LOG2, FL("GetSnrReq from self"));
11021 csr_update_snr(pMac, pSirMsg);
11022 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011023 case eWNI_SME_FT_PRE_AUTH_RSP:
11024 csr_roam_ft_pre_auth_rsp_processor(pMac, (tpSirFTPreAuthRsp) pSirMsg);
11025 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011026 case eWNI_SME_MAX_ASSOC_EXCEEDED:
11027 csr_roam_chk_lnk_max_assoc_exceeded(pMac, pSirMsg);
11028 break;
11029 case eWNI_SME_CANDIDATE_FOUND_IND:
11030 sms_log(pMac, LOG2, FL("Candidate found indication from PE"));
11031 csr_neighbor_roam_candidate_found_ind_hdlr(pMac, pSirMsg);
11032 break;
11033 case eWNI_SME_HANDOFF_REQ:
11034 sms_log(pMac, LOG2, FL("Handoff Req from self"));
11035 csr_neighbor_roam_handoff_req_hdlr(pMac, pSirMsg);
11036 break;
11037 default:
11038 break;
11039 } /* end switch on message type */
11040}
11041
11042void csr_call_roaming_completion_callback(tpAniSirGlobal pMac,
11043 tCsrRoamSession *pSession,
11044 tCsrRoamInfo *pRoamInfo, uint32_t roamId,
11045 eCsrRoamResult roamResult)
11046{
11047 if (pSession) {
11048 if (pSession->bRefAssocStartCnt) {
11049 pSession->bRefAssocStartCnt--;
11050
11051 if (0 != pSession->bRefAssocStartCnt) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011052 QDF_ASSERT(pSession->bRefAssocStartCnt == 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011053 return;
11054 }
11055 /* Need to call association_completion because there is an assoc_start pending. */
11056 csr_roam_call_callback(pMac, pSession->sessionId, NULL,
11057 roamId,
11058 eCSR_ROAM_ASSOCIATION_COMPLETION,
11059 eCSR_ROAM_RESULT_FAILURE);
11060 }
11061 csr_roam_call_callback(pMac, pSession->sessionId, pRoamInfo,
11062 roamId, eCSR_ROAM_ROAMING_COMPLETION,
11063 roamResult);
11064 } else {
11065 sms_log(pMac, LOGW, FL(" pSession is NULL"));
11066 }
11067}
11068
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011069QDF_STATUS csr_roam_start_roaming(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011070 eCsrRoamingReason roamingReason)
11071{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011072 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011073 if (CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
11074 (false == pMac->roam.roamSession[sessionId].fCancelRoaming)) {
11075 status = csr_scan_request_lost_link1(pMac, sessionId);
11076 }
11077 return status;
11078}
11079
11080/* return a bool to indicate whether roaming completed or continue. */
11081bool csr_roam_complete_roaming(tpAniSirGlobal pMac, uint32_t sessionId,
11082 bool fForce, eCsrRoamResult roamResult)
11083{
11084 bool fCompleted = true;
11085 uint32_t roamTime =
11086 (uint32_t) (pMac->roam.configParam.nRoamingTime *
Anurag Chouhan6d760662016-02-20 16:05:43 +053011087 QDF_TICKS_PER_SECOND);
Anurag Chouhan210db072016-02-22 18:42:15 +053011088 uint32_t curTime = (uint32_t) qdf_mc_timer_get_system_ticks();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011089 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11090 if (!pSession) {
11091 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
11092 return false;
11093 }
11094 /* Check whether time is up */
11095 if (pSession->fCancelRoaming || fForce ||
11096 ((curTime - pSession->roamingStartTime) > roamTime) ||
11097 eCsrReassocRoaming == pSession->roamingReason ||
11098 eCsrDynamicRoaming == pSession->roamingReason) {
11099 sms_log(pMac, LOGW, FL(" indicates roaming completion"));
11100 if (pSession->fCancelRoaming
11101 && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason)) {
11102 /* roaming is cancelled, tell HDD to indicate disconnect */
11103 /* Because LIM overload deauth_ind for both deauth frame and missed beacon */
11104 /* we need to use this logic to detinguish it. For missed beacon, LIM set reason */
11105 /* to be eSIR_BEACON_MISSED */
11106 if (eSIR_BEACON_MISSED == pSession->roamingStatusCode) {
11107 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11108 } else if (eCsrLostlinkRoamingDisassoc ==
11109 pSession->roamingReason) {
11110 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
11111 } else if (eCsrLostlinkRoamingDeauth ==
11112 pSession->roamingReason) {
11113 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
11114 } else {
11115 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11116 }
11117 }
11118 csr_call_roaming_completion_callback(pMac, pSession, NULL, 0,
11119 roamResult);
11120 pSession->roamingReason = eCsrNotRoaming;
11121 } else {
11122 pSession->roamResult = roamResult;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011123 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011124 (csr_roam_start_roaming_timer
Anurag Chouhan210db072016-02-22 18:42:15 +053011125 (pMac, sessionId, QDF_MC_TIMER_TO_SEC_UNIT))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011126 csr_call_roaming_completion_callback(pMac, pSession, NULL,
11127 0, roamResult);
11128 pSession->roamingReason = eCsrNotRoaming;
11129 } else {
11130 fCompleted = false;
11131 }
11132 }
11133 return fCompleted;
11134}
11135
11136void csr_roam_cancel_roaming(tpAniSirGlobal pMac, uint32_t sessionId)
11137{
11138 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11139
11140 if (!pSession) {
11141 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
11142 return;
11143 }
11144
11145 if (CSR_IS_ROAMING(pSession)) {
11146 sms_log(pMac, LOGW, "Cancel roaming");
11147 pSession->fCancelRoaming = true;
11148 if (CSR_IS_ROAM_JOINING(pMac, sessionId)
11149 && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId)) {
11150 /* No need to do anything in here because the handler takes care of it */
11151 } else {
11152 eCsrRoamResult roamResult =
11153 CSR_IS_LOSTLINK_ROAMING(pSession->
11154 roamingReason) ?
11155 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
11156 /* Roaming is stopped after here */
11157 csr_roam_complete_roaming(pMac, sessionId, true,
11158 roamResult);
11159 /* Since CSR may be in lostlink roaming situation, abort all roaming related activities */
11160 csr_scan_abort_mac_scan(pMac, sessionId,
11161 eCSR_SCAN_ABORT_DEFAULT);
11162 csr_roam_stop_roaming_timer(pMac, sessionId);
11163 }
11164 }
11165}
11166
11167void csr_roam_roaming_timer_handler(void *pv)
11168{
11169 tCsrTimerInfo *pInfo = (tCsrTimerInfo *) pv;
11170 tpAniSirGlobal pMac = pInfo->pMac;
11171 uint32_t sessionId = pInfo->sessionId;
11172 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11173
11174 if (!pSession) {
11175 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
11176 return;
11177 }
11178
11179 if (false == pSession->fCancelRoaming) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011180 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011181 (csr_roam_start_roaming
11182 (pMac, sessionId, pSession->roamingReason))) {
11183 csr_call_roaming_completion_callback(pMac, pSession, NULL,
11184 0,
11185 pSession->roamResult);
11186 pSession->roamingReason = eCsrNotRoaming;
11187 }
11188 }
11189}
11190
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011191QDF_STATUS csr_roam_start_roaming_timer(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011192 uint32_t interval)
11193{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011194 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011195 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11196
11197 if (!pSession) {
11198 sms_log(pMac, LOGE, FL(" session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011199 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011200 }
11201
11202 sms_log(pMac, LOG1, " csrScanStartRoamingTimer");
11203 pSession->roamingTimerInfo.sessionId = (uint8_t) sessionId;
Anurag Chouhan210db072016-02-22 18:42:15 +053011204 status = qdf_mc_timer_start(&pSession->hTimerRoaming,
11205 interval / QDF_MC_TIMER_TO_MS_UNIT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011206
11207 return status;
11208}
11209
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011210QDF_STATUS csr_roam_stop_roaming_timer(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011211{
Anurag Chouhan210db072016-02-22 18:42:15 +053011212 return qdf_mc_timer_stop
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011213 (&pMac->roam.roamSession[sessionId].hTimerRoaming);
11214}
11215
11216void csr_roam_wait_for_key_time_out_handler(void *pv)
11217{
11218 tCsrTimerInfo *pInfo = (tCsrTimerInfo *) pv;
11219 tpAniSirGlobal pMac = pInfo->pMac;
11220 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, pInfo->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011221 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011222
11223 if (pSession == NULL) {
11224 sms_log(pMac, LOGE, "%s: session not found", __func__);
11225 return;
11226 }
11227
11228 sms_log(pMac, LOGW,
11229 FL("WaitForKey timer expired in state=%s sub-state=%s"),
11230 mac_trace_get_neighbour_roam_state(pMac->roam.
11231 neighborRoamInfo[pInfo->sessionId].
11232 neighborRoamState),
11233 mac_trace_getcsr_roam_sub_state(pMac->roam.
11234 curSubState[pInfo->sessionId]));
11235
11236 if (CSR_IS_WAIT_FOR_KEY(pMac, pInfo->sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011237 if (csr_neighbor_roam_is_handoff_in_progress(pMac, pInfo->sessionId)) {
11238 /*
11239 * Enable heartbeat timer when hand-off is in progress
11240 * and Key Wait timer expired.
11241 */
11242 sms_log(pMac, LOG2,
11243 "Enabling HB timer after WaitKey expiry"
11244 " (nHBCount=%d)",
11245 pMac->roam.configParam.HeartbeatThresh24);
11246 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11247 pMac->roam.configParam.HeartbeatThresh24);
11248 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011249 sms_log(pMac, LOGE, " SME pre-auth state timeout. ");
11250
11251 /* Change the substate so command queue is unblocked. */
11252 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId) {
11253 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
11254 pInfo->sessionId);
11255 }
11256
11257 if (csr_is_conn_state_connected_infra(pMac, pInfo->sessionId)) {
11258 csr_roam_link_up(pMac,
11259 pSession->connectedProfile.bssid);
11260 sme_process_pending_queue(pMac);
11261 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011262 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011263 csr_roam_disconnect(pMac, pInfo->sessionId,
11264 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11265 sme_release_global_lock(&pMac->sme);
11266 }
11267 } else {
11268 sms_log(pMac, LOGE, "%s: session not found", __func__);
11269 }
11270 }
11271
11272}
11273
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011274QDF_STATUS csr_roam_start_wait_for_key_timer(tpAniSirGlobal pMac, uint32_t interval)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011275{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011276 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011277 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
11278 &pMac->roam.neighborRoamInfo[pMac->roam.WaitForKeyTimerInfo.
11279 sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011280 if (csr_neighbor_roam_is_handoff_in_progress(pMac,
Deepak Dhamdhereecce9742015-11-08 01:16:43 -080011281 pMac->roam.WaitForKeyTimerInfo.
11282 sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011283 /* Disable heartbeat timer when hand-off is in progress */
11284 sms_log(pMac, LOG2,
11285 FL("disabling HB timer in state=%s sub-state=%s"),
Deepak Dhamdhereecce9742015-11-08 01:16:43 -080011286 mac_trace_get_neighbour_roam_state(
11287 pNeighborRoamInfo->neighborRoamState),
11288 mac_trace_getcsr_roam_sub_state(
11289 pMac->roam.curSubState[pMac->roam.
11290 WaitForKeyTimerInfo.sessionId]));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011291 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0);
11292 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011293 sms_log(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Anurag Chouhan210db072016-02-22 18:42:15 +053011294 status = qdf_mc_timer_start(&pMac->roam.hTimerWaitForKey,
11295 interval / QDF_MC_TIMER_TO_MS_UNIT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011296
11297 return status;
11298}
11299
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011300QDF_STATUS csr_roam_stop_wait_for_key_timer(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011301{
11302 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
11303 &pMac->roam.neighborRoamInfo[pMac->roam.WaitForKeyTimerInfo.
11304 sessionId];
11305
11306 sms_log(pMac, LOG2,
11307 FL("WaitForKey timer stopped in state=%s sub-state=%s"),
11308 mac_trace_get_neighbour_roam_state(pNeighborRoamInfo->
11309 neighborRoamState),
11310 mac_trace_getcsr_roam_sub_state(pMac->roam.
11311 curSubState[pMac->roam.
11312 WaitForKeyTimerInfo.
11313 sessionId]));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011314 if (csr_neighbor_roam_is_handoff_in_progress(pMac,
11315 pMac->roam.WaitForKeyTimerInfo.
11316 sessionId)) {
11317 /*
11318 * Enable heartbeat timer when hand-off is in progress
11319 * and Key Wait timer got stopped for some reason
11320 */
11321 sms_log(pMac, LOG2, "Enabling HB timer after WaitKey stop"
11322 " (nHBCount=%d)",
11323 pMac->roam.configParam.HeartbeatThresh24);
11324 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11325 pMac->roam.configParam.HeartbeatThresh24);
11326 }
Anurag Chouhan210db072016-02-22 18:42:15 +053011327 return qdf_mc_timer_stop(&pMac->roam.hTimerWaitForKey);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011328}
11329
11330void csr_roam_completion(tpAniSirGlobal pMac, uint32_t sessionId,
11331 tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
11332 eCsrRoamResult roamResult, bool fSuccess)
11333{
11334 eRoamCmdStatus roamStatus = csr_get_roam_complete_status(pMac, sessionId);
11335 uint32_t roamId = 0;
11336 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11337
11338 if (!pSession) {
11339 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
11340 return;
11341 }
11342
11343 if (pCommand) {
11344 roamId = pCommand->u.roamCmd.roamId;
11345 if (sessionId != pCommand->sessionId) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011346 QDF_ASSERT(sessionId == pCommand->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011347 return;
11348 }
11349 }
11350 if (eCSR_ROAM_ROAMING_COMPLETION == roamStatus) {
11351 /* if success, force roaming completion */
11352 csr_roam_complete_roaming(pMac, sessionId, fSuccess, roamResult);
11353 } else {
11354 if (pSession->bRefAssocStartCnt != 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011355 QDF_ASSERT(pSession->bRefAssocStartCnt == 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011356 return;
11357 }
11358 sms_log(pMac, LOGW,
11359 FL
11360 (" indicates association completion. roamResult = %d"),
11361 roamResult);
11362 csr_roam_call_callback(pMac, sessionId, pRoamInfo, roamId,
11363 roamStatus, roamResult);
11364 }
11365}
11366
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011367QDF_STATUS csr_roam_lost_link(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011368 uint32_t type, tSirSmeRsp *pSirMsg)
11369{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011370 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011371 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
11372 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
11373 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
11374 tCsrRoamInfo *pRoamInfo = NULL;
11375 tCsrRoamInfo roamInfo;
11376 bool fToRoam;
11377 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11378
11379 if (!pSession) {
11380 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011381 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011382 }
11383 /* Only need to roam for infra station. In this case P2P client will roam as well */
11384 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
11385 pSession->fCancelRoaming = false;
11386 if (eWNI_SME_DISASSOC_IND == type) {
11387 result = eCSR_ROAM_RESULT_DISASSOC_IND;
11388 pDisassocIndMsg = (tSirSmeDisassocInd *) pSirMsg;
11389 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
11390 pSession->joinFailStatusCode.reasonCode =
11391 pDisassocIndMsg->reasonCode;
11392 } else if (eWNI_SME_DEAUTH_IND == type) {
11393 result = eCSR_ROAM_RESULT_DEAUTH_IND;
11394 pDeauthIndMsg = (tSirSmeDeauthInd *) pSirMsg;
11395 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
11396 /* Convert into proper reason code */
11397 if ((pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ||
11398 (pDeauthIndMsg->reasonCode ==
11399 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON))
11400 pSession->joinFailStatusCode.reasonCode = 0;
11401 else
11402 pSession->joinFailStatusCode.reasonCode =
11403 pDeauthIndMsg->reasonCode;
11404 /*
11405 * cfg layer expects 0 as reason code if
11406 * the driver dosent know the reason code
11407 * eSIR_BEACON_MISSED is defined as locally
11408 */
11409 } else {
11410 sms_log(pMac, LOGW, FL("gets an unknown type (%d)"), type);
11411 result = eCSR_ROAM_RESULT_NONE;
11412 pSession->joinFailStatusCode.reasonCode = 1;
11413 }
11414
11415 /* call profile lost link routine here */
11416 if (!CSR_IS_INFRA_AP(&pSession->connectedProfile)) {
11417 csr_roam_call_callback(pMac, sessionId, NULL, 0,
11418 eCSR_ROAM_LOSTLINK_DETECTED, result);
11419 /*Move the state to Idle after disconnection */
11420 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
11421
11422 }
11423
11424 if (eWNI_SME_DISASSOC_IND == type) {
11425 status = csr_send_mb_disassoc_cnf_msg(pMac, pDisassocIndMsg);
11426 } else if (eWNI_SME_DEAUTH_IND == type) {
11427 status = csr_send_mb_deauth_cnf_msg(pMac, pDeauthIndMsg);
11428 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011429 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011430 /* If fail to send confirmation to PE, not to trigger roaming */
11431 fToRoam = false;
11432 }
11433 /* prepare to tell HDD to disconnect */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011434 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011435 roamInfo.statusCode = (tSirResultCodes) pSession->roamingStatusCode;
11436 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
11437 if (eWNI_SME_DISASSOC_IND == type) {
11438 /* staMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053011439 qdf_copy_macaddr(&roamInfo.peerMac,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080011440 &pDisassocIndMsg->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011441 roamInfo.staId = (uint8_t) pDisassocIndMsg->staId;
11442 roamInfo.reasonCode = pDisassocIndMsg->reasonCode;
11443 } else if (eWNI_SME_DEAUTH_IND == type) {
11444 /* staMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053011445 qdf_copy_macaddr(&roamInfo.peerMac,
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080011446 &pDeauthIndMsg->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011447 roamInfo.staId = (uint8_t) pDeauthIndMsg->staId;
11448 roamInfo.reasonCode = pDeauthIndMsg->reasonCode;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -080011449 roamInfo.rxRssi = pDeauthIndMsg->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011450 }
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080011451 sms_log(pMac, LOGW, FL("roamInfo.staId: %d"), roamInfo.staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011452
11453 /* See if we can possibly roam. If so, start the roaming process and notify HDD
11454 that we are roaming. But if we cannot possibly roam, or if we are unable to
11455 currently roam, then notify HDD of the lost link */
11456 if (fToRoam) {
11457 /* Only remove the connected BSS in infrastructure mode */
11458 csr_roam_remove_connected_bss_from_scan_cache(pMac,
11459 &pSession->
11460 connectedProfile);
11461 /* Not to do anying for lostlink with WDS */
11462 status = csr_roam_start_roaming(pMac, sessionId,
11463 (eWNI_SME_DEAUTH_IND == type) ?
11464 eCsrLostlinkRoamingDeauth :
11465 eCsrLostlinkRoamingDisassoc);
11466 if (pMac->roam.configParam.nRoamingTime) {
11467 status = csr_roam_start_roaming(pMac, sessionId,
11468 (eWNI_SME_DEAUTH_IND == type) ?
11469 eCsrLostlinkRoamingDeauth :
11470 eCsrLostlinkRoamingDisassoc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011471 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011472 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011473 /* For IBSS, we need to give some more info to HDD */
11474 if (csr_is_bss_type_ibss
11475 (pSession->connectedProfile.BSSType)) {
11476 roamInfo.u.pConnectedProfile =
11477 &pSession->connectedProfile;
11478 roamInfo.statusCode =
11479 (tSirResultCodes) pSession->
11480 roamingStatusCode;
11481 roamInfo.reasonCode =
11482 pSession->joinFailStatusCode.
11483 reasonCode;
11484 } else {
11485 roamInfo.reasonCode =
11486 eCsrRoamReasonSmeIssuedForLostLink;
11487 }
11488 pRoamInfo = &roamInfo;
11489 pSession->roamingReason =
11490 (eWNI_SME_DEAUTH_IND ==
11491 type) ? eCsrLostlinkRoamingDeauth :
11492 eCsrLostlinkRoamingDisassoc;
11493 pSession->roamingStartTime =
Anurag Chouhan210db072016-02-22 18:42:15 +053011494 (uint32_t) qdf_mc_timer_get_system_ticks();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011495 csr_roam_call_callback(pMac, sessionId, pRoamInfo,
11496 0, eCSR_ROAM_ROAMING_START,
11497 eCSR_ROAM_RESULT_LOSTLINK);
11498 } else {
11499 sms_log(pMac, LOGW,
11500 " %s Fail to start roaming, status = %d",
11501 __func__, status);
11502 fToRoam = false;
11503 }
11504 } else {
11505 /* We are told not to roam, indicate lostlink */
11506 fToRoam = false;
11507 }
11508 }
11509 if (!fToRoam) {
11510 /* Tell HDD about the lost link */
11511 if (!CSR_IS_INFRA_AP(&pSession->connectedProfile)) {
11512 /* Don't call csr_roam_call_callback for GO/SoftAp case as this indication
11513 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
11514 * csr_roam_check_for_link_status_change API.
11515 */
11516 csr_roam_call_callback(pMac, sessionId, &roamInfo, 0,
11517 eCSR_ROAM_LOSTLINK, result);
11518 }
11519
11520 }
11521
11522 return status;
11523}
11524
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011525QDF_STATUS csr_roam_lost_link_afterhandoff_failure(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011526 uint32_t sessionId)
11527{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011528 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011529 tListElem *pEntry = NULL;
11530 tSmeCmd *pCommand = NULL;
11531 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11532
11533 if (!pSession) {
11534 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011535 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011536 }
11537
11538 pSession->fCancelRoaming = false;
11539 /* Only remove the connected BSS in infrastructure mode */
11540 csr_roam_remove_connected_bss_from_scan_cache(pMac,
11541 &pSession->connectedProfile);
11542 if (pMac->roam.configParam.nRoamingTime) {
11543 status = csr_roam_start_roaming(pMac, sessionId,
11544 pSession->roamingReason);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011545 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011546 /*
11547 * before starting the lost link logic release
11548 * the roam command for handoff
11549 */
11550 pEntry =
11551 csr_ll_peek_head(&pMac->sme.smeCmdActiveList,
11552 LL_ACCESS_LOCK);
11553 if (pEntry) {
11554 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11555 }
11556 if (pCommand) {
11557 if ((eSmeCommandRoam == pCommand->command) &&
11558 (eCsrSmeIssuedAssocToSimilarAP ==
11559 pCommand->u.roamCmd.roamReason)) {
11560 if (csr_ll_remove_entry
11561 (&pMac->sme.smeCmdActiveList,
11562 pEntry, LL_ACCESS_LOCK)) {
11563 csr_release_command_roam(pMac,
11564 pCommand);
11565 }
11566 }
11567 }
11568 sms_log(pMac, LOGW, "Lost link roaming started ...");
11569 }
11570 } else {
11571 /* We are told not to roam, indicate lostlink */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011572 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011573 }
11574
11575 return status;
11576}
11577
11578void csr_roam_wm_status_change_complete(tpAniSirGlobal pMac)
11579{
11580 tListElem *pEntry;
11581 tSmeCmd *pCommand;
11582 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
11583 if (pEntry) {
11584 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11585 if (eSmeCommandWmStatusChange == pCommand->command) {
11586 /* Nothing to process in a Lost Link completion.... It just kicks off a */
11587 /* roaming sequence. */
11588 if (csr_ll_remove_entry
11589 (&pMac->sme.smeCmdActiveList, pEntry,
11590 LL_ACCESS_LOCK)) {
11591 csr_release_command_wm_status_change(pMac, pCommand);
11592 } else {
11593 sms_log(pMac, LOGE,
11594 " ******csr_roam_wm_status_change_complete fail to release command");
11595 }
11596
11597 } else {
11598 sms_log(pMac, LOGW,
11599 "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ...");
11600 }
11601 } else {
11602 sms_log(pMac, LOGW,
11603 "CSR: WmStatusChange Completion called but NO commands are ACTIVE ...");
11604 }
11605 sme_process_pending_queue(pMac);
11606}
11607
11608void csr_roam_process_wm_status_change_command(tpAniSirGlobal pMac,
11609 tSmeCmd *pCommand)
11610{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011611 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011612 tSirSmeRsp *pSirSmeMsg;
11613 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, pCommand->sessionId);
11614
11615 if (!pSession) {
11616 sms_log(pMac, LOGE, FL(" session %d not found "),
11617 pCommand->sessionId);
11618 return;
11619 }
11620 sms_log(pMac, LOG1, FL("session:%d, CmdType : %d"),
11621 pCommand->sessionId, pCommand->u.wmStatusChangeCmd.Type);
11622
11623 switch (pCommand->u.wmStatusChangeCmd.Type) {
11624 case eCsrDisassociated:
11625 pSirSmeMsg =
11626 (tSirSmeRsp *) &pCommand->u.wmStatusChangeCmd.u.
11627 DisassocIndMsg;
11628 status =
11629 csr_roam_lost_link(pMac, pCommand->sessionId,
11630 eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11631 break;
11632 case eCsrDeauthenticated:
11633 pSirSmeMsg =
11634 (tSirSmeRsp *) &pCommand->u.wmStatusChangeCmd.u.
11635 DeauthIndMsg;
11636 status =
11637 csr_roam_lost_link(pMac, pCommand->sessionId,
11638 eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11639 break;
11640 default:
11641 sms_log(pMac, LOGW, FL("gets an unknown command %d"),
11642 pCommand->u.wmStatusChangeCmd.Type);
11643 break;
11644 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011645 /* Lost Link just triggers a roaming sequence. We can complte the Lost Link */
11646 /* command here since there is nothing else to do. */
11647 csr_roam_wm_status_change_complete(pMac);
11648}
11649
11650
11651/**
11652 * csr_compute_mode_and_band() - computes dot11mode
11653 * @pMac: mac global context
11654 * @dot11_mode: out param, do11 mode calculated
11655 * @band: out param, band caclculated
11656 * @opr_ch: operating channels
11657 *
11658 * This function finds dot11 mode based on current mode, operating channel and
11659 * fw supported modes.
11660 *
11661 * Return: void
11662 */
11663static void
11664csr_compute_mode_and_band(tpAniSirGlobal mac_ctx,
11665 eCsrCfgDot11Mode *dot11_mode,
11666 eCsrBand *band,
11667 uint8_t opr_ch)
11668{
11669 bool vht_24_ghz = mac_ctx->roam.configParam.enableVhtFor24GHz;
11670 switch (mac_ctx->roam.configParam.uCfgDot11Mode) {
11671 case eCSR_CFG_DOT11_MODE_11A:
11672 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
11673 *band = eCSR_BAND_5G;
11674 break;
11675 case eCSR_CFG_DOT11_MODE_11B:
11676 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
11677 *band = eCSR_BAND_24;
11678 break;
11679 case eCSR_CFG_DOT11_MODE_11G:
11680 *dot11_mode = eCSR_CFG_DOT11_MODE_11G;
11681 *band = eCSR_BAND_24;
11682 break;
11683 case eCSR_CFG_DOT11_MODE_11N:
11684 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
11685 *band = CSR_GET_BAND(opr_ch);
11686 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011687 case eCSR_CFG_DOT11_MODE_11AC:
11688 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
11689 /*
11690 * If the operating channel is in 2.4 GHz band, check
11691 * for INI item to disable VHT operation in 2.4 GHz band
11692 */
11693 if (CDS_IS_CHANNEL_24GHZ(opr_ch) && !vht_24_ghz)
11694 /* Disable 11AC operation */
11695 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
11696 else
11697 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC;
11698 } else {
11699 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
11700 }
11701 *band = CSR_GET_BAND(opr_ch);
11702 break;
11703 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11704 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
11705 /*
11706 * If the operating channel is in 2.4 GHz band, check
11707 * for INI item to disable VHT operation in 2.4 GHz band
11708 */
11709 if (CDS_IS_CHANNEL_24GHZ(opr_ch) && !vht_24_ghz)
11710 /* Disable 11AC operation */
11711 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
11712 else
11713 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11714 } else {
11715 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
11716 }
11717 *band = CSR_GET_BAND(opr_ch);
11718 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011719 case eCSR_CFG_DOT11_MODE_AUTO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011720 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
11721 /*
11722 * If the operating channel is in 2.4 GHz band,
11723 * check for INI item to disable VHT operation
11724 * in 2.4 GHz band
11725 */
11726 if (CDS_IS_CHANNEL_24GHZ(opr_ch)
11727 && !vht_24_ghz)
11728 /* Disable 11AC operation */
11729 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
11730 else
11731 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC;
11732 } else {
11733 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
11734 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011735 *band = CSR_GET_BAND(opr_ch);
11736 break;
11737 default:
11738 /*
11739 * Global dot11 Mode setting is 11a/b/g. use the channel number
11740 * to determine the Mode setting.
11741 */
11742 if (eCSR_OPERATING_CHANNEL_AUTO == opr_ch) {
11743 *band = mac_ctx->roam.configParam.eBand;
11744 if (eCSR_BAND_24 == *band) {
11745 /*
11746 * See reason in else if ( CDS_IS_CHANNEL_24GHZ
11747 * (opr_ch) ) to pick 11B
11748 */
11749 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
11750 } else {
11751 /* prefer 5GHz */
11752 *band = eCSR_BAND_5G;
11753 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
11754 }
11755 } else if (CDS_IS_CHANNEL_24GHZ(opr_ch)) {
11756 /*
11757 * WiFi tests require IBSS networks to start in 11b mode
11758 * without any change to the default parameter settings
11759 * on the adapter. We use ACU to start an IBSS through
11760 * creation of a startIBSS profile. This startIBSS
11761 * profile has Auto MACProtocol and the adapter property
11762 * setting for dot11Mode is also AUTO. So in this case,
11763 * let's start the IBSS network in 11b mode instead of
11764 * 11g mode. So this is for Auto=profile->MacProtocol &&
11765 * Auto=Global. dot11Mode && profile->channel is < 14,
11766 * then start the IBSS in b mode.
11767 *
11768 * Note: we used to have this start as an 11g IBSS for
11769 * best performance. now to specify that the user will
11770 * have to set the do11Mode in the property page to 11g
11771 * to force it.
11772 */
11773 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
11774 *band = eCSR_BAND_24;
11775 } else {
11776 /* else, it's a 5.0GHz channel. Set mode to 11a. */
11777 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
11778 *band = eCSR_BAND_5G;
11779 }
11780 break;
11781 } /* switch */
11782}
11783
11784/**
11785 * csr_roam_get_phy_mode_band_for_bss() - This function returns band and mode
11786 * information.
11787 * @mac_ctx: mac global context
11788 * @profile: bss profile
11789 * @band: out param, band caclculated
11790 * @opr_ch: operating channels
11791 *
11792 * This function finds dot11 mode based on current mode, operating channel and
11793 * fw supported modes. The only tricky part is that if phyMode is set to 11abg,
11794 * this function may return eCSR_CFG_DOT11_MODE_11B instead of
11795 * eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
11796 *
11797 * Return: dot11mode
11798 */
11799static eCsrCfgDot11Mode
11800csr_roam_get_phy_mode_band_for_bss(tpAniSirGlobal mac_ctx,
11801 tCsrRoamProfile *profile,
11802 uint8_t opr_chn,
11803 eCsrBand *p_band)
11804{
11805 eCsrBand band;
11806 eCsrCfgDot11Mode curr_mode = mac_ctx->roam.configParam.uCfgDot11Mode;
11807 eCsrCfgDot11Mode cfg_dot11_mode =
11808 csr_get_cfg_dot11_mode_from_csr_phy_mode(profile,
11809 (eCsrPhyMode) profile->phyMode,
11810 mac_ctx->roam.configParam.ProprietaryRatesEnabled);
11811
11812 /*
11813 * If the global setting for dot11Mode is set to auto/abg, we overwrite
11814 * the setting in the profile.
11815 */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070011816 if ((!CSR_IS_INFRA_AP(profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011817 && ((eCSR_CFG_DOT11_MODE_AUTO == curr_mode)
11818 || (eCSR_CFG_DOT11_MODE_ABG == curr_mode)))
11819 || (eCSR_CFG_DOT11_MODE_AUTO == cfg_dot11_mode)
11820 || (eCSR_CFG_DOT11_MODE_ABG == cfg_dot11_mode)) {
11821 csr_compute_mode_and_band(mac_ctx, &cfg_dot11_mode,
11822 &band, opr_chn);
11823 } /* if( eCSR_CFG_DOT11_MODE_ABG == cfg_dot11_mode ) */
11824 else {
11825 /* dot11 mode is set, lets pick the band */
11826 if (eCSR_OPERATING_CHANNEL_AUTO == opr_chn) {
11827 /* channel is Auto also. */
11828 band = mac_ctx->roam.configParam.eBand;
11829 if (eCSR_BAND_ALL == band) {
11830 /* prefer 5GHz */
11831 band = eCSR_BAND_5G;
11832 }
11833 } else{
11834 band = CSR_GET_BAND(opr_chn);
11835 }
11836 }
11837 if (p_band)
11838 *p_band = band;
11839
11840 if (opr_chn == 14) {
11841 sms_log(mac_ctx, LOGE, FL("Switching to Dot11B mode"));
11842 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11B;
11843 }
11844
11845 /*
11846 * Incase of WEP Security encryption type is coming as part of add key.
11847 * So while STart BSS dont have information
11848 */
11849 if ((!CSR_IS_11n_ALLOWED(profile->EncryptionType.encryptionType[0])
11850 || ((profile->privacy == 1)
11851 && (profile->EncryptionType.encryptionType[0] ==
11852 eCSR_ENCRYPT_TYPE_NONE)))
11853 && ((eCSR_CFG_DOT11_MODE_11N == cfg_dot11_mode) ||
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -080011854 (eCSR_CFG_DOT11_MODE_11AC == cfg_dot11_mode))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011855 /* We cannot do 11n here */
11856 if (CDS_IS_CHANNEL_24GHZ(opr_chn))
11857 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11G;
11858 else
11859 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11A;
11860 }
11861 return cfg_dot11_mode;
11862}
11863
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011864QDF_STATUS csr_roam_issue_stop_bss(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011865 eCsrRoamSubState NewSubstate)
11866{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011867 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011868 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11869
11870 if (!pSession) {
11871 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011872 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011873 }
11874#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11875 {
11876 host_log_ibss_pkt_type *pIbssLog;
11877 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
11878 LOG_WLAN_IBSS_C);
11879 if (pIbssLog) {
11880 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11881 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
11882 }
11883 }
11884#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
11885 /* Set the roaming substate to 'stop Bss request'... */
11886 csr_roam_substate_change(pMac, NewSubstate, sessionId);
11887
11888 /* attempt to stop the Bss (reason code is ignored...) */
11889 status = csr_send_mb_stop_bss_req_msg(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011890 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011891 sms_log(pMac, LOGW,
11892 FL("csr_send_mb_stop_bss_req_msg failed with status %d"),
11893 status);
11894 }
11895 return status;
11896}
11897
11898/* pNumChan is a caller allocated space with the sizeof pChannels */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011899QDF_STATUS csr_get_cfg_valid_channels(tpAniSirGlobal pMac, uint8_t *pChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011900 uint32_t *pNumChan)
11901{
Edhar, Mahesh Kumareb31abd2016-01-21 17:50:47 +053011902 uint8_t num_chan_temp = 0;
11903 int i;
11904
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011905 if (!IS_SIR_STATUS_SUCCESS(wlan_cfg_get_str(pMac,
11906 WNI_CFG_VALID_CHANNEL_LIST,
11907 (uint8_t *) pChannels, pNumChan)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011908 return QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumareb31abd2016-01-21 17:50:47 +053011909
11910 for (i = 0; i < *pNumChan; i++) {
11911 if (!cds_is_dsrc_channel(cds_chan_to_freq(pChannels[i]))) {
11912 pChannels[num_chan_temp] = pChannels[i];
11913 num_chan_temp++;
11914 }
11915 }
11916
11917 *pNumChan = num_chan_temp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011918 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011919}
11920
Amar Singhala297bfa2015-10-15 15:07:29 -070011921int8_t csr_get_cfg_max_tx_power(tpAniSirGlobal pMac, uint8_t channel)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011922{
11923 uint32_t cfgLength = 0;
11924 uint16_t cfgId = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -070011925 int8_t maxTxPwr = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011926 uint8_t *pCountryInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011927 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011928 uint8_t count = 0;
11929 uint8_t firstChannel;
11930 uint8_t maxChannels;
11931
11932 if (CDS_IS_CHANNEL_5GHZ(channel)) {
11933 cfgId = WNI_CFG_MAX_TX_POWER_5;
11934 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11935 } else if (CDS_IS_CHANNEL_24GHZ(channel)) {
11936 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11937 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11938 } else
11939 return maxTxPwr;
11940
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011941 pCountryInfo = qdf_mem_malloc(cfgLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011942 if (NULL == pCountryInfo)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011943 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011944 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011945 status = QDF_STATUS_SUCCESS;
11946 if (status != QDF_STATUS_SUCCESS) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011947 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011948 FL("%s: failed to allocate memory, status = %d"),
11949 __FUNCTION__, status);
11950 goto error;
11951 }
11952 if (wlan_cfg_get_str(pMac, cfgId, (uint8_t *)pCountryInfo,
11953 &cfgLength) != eSIR_SUCCESS) {
11954 goto error;
11955 }
11956 /* Identify the channel and maxtxpower */
11957 while (count <= (cfgLength - (sizeof(tSirMacChanInfo)))) {
11958 firstChannel = pCountryInfo[count++];
11959 maxChannels = pCountryInfo[count++];
11960 maxTxPwr = pCountryInfo[count++];
11961
11962 if ((channel >= firstChannel) &&
11963 (channel < (firstChannel + maxChannels))) {
11964 break;
11965 }
11966 }
11967
11968error:
11969 if (NULL != pCountryInfo)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011970 qdf_mem_free(pCountryInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011971
11972 return maxTxPwr;
11973}
11974
11975bool csr_roam_is_channel_valid(tpAniSirGlobal pMac, uint8_t channel)
11976{
11977 bool fValid = false;
11978 uint32_t idxValidChannels;
11979 uint32_t len = sizeof(pMac->roam.validChannelList);
11980
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011981 if (QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011982 (csr_get_cfg_valid_channels(pMac, pMac->roam.validChannelList, &len))) {
11983 for (idxValidChannels = 0; (idxValidChannels < len);
11984 idxValidChannels++) {
11985 if (channel ==
11986 pMac->roam.validChannelList[idxValidChannels]) {
11987 fValid = true;
11988 break;
11989 }
11990 }
11991 }
11992 pMac->roam.numValidChannels = len;
11993 return fValid;
11994}
11995
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011996/* This function check and validate whether the NIC can do CB (40MHz) */
11997static ePhyChanBondState csr_get_cb_mode_from_ies(tpAniSirGlobal pMac,
11998 uint8_t primaryChn,
11999 tDot11fBeaconIEs *pIes)
12000{
12001 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
12002 uint8_t centerChn;
12003 uint32_t ChannelBondingMode;
12004 if (CDS_IS_CHANNEL_24GHZ(primaryChn)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012005 ChannelBondingMode =
12006 pMac->roam.configParam.channelBondingMode24GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012007 } else {
12008 ChannelBondingMode =
12009 pMac->roam.configParam.channelBondingMode5GHz;
12010 }
12011
12012 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE == ChannelBondingMode)
12013 return PHY_SINGLE_CHANNEL_CENTERED;
12014
12015 /* Figure what the other side's CB mode */
12016 if (!(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ ==
12017 pIes->HTCaps.supportedChannelWidthSet))) {
12018 return PHY_SINGLE_CHANNEL_CENTERED;
12019 }
12020
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053012021 /* In Case WPA2 and TKIP is the only one cipher suite in Pairwise */
12022 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012023 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053012024 "\x00\x0f\xac\x02", 4))
Abhishek Singh1e39fc22015-12-18 11:23:44 +053012025 /* In Case only WPA1 is supported and TKIP is
12026 * the only one cipher suite in Unicast.
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053012027 */
Abhishek Singh1e39fc22015-12-18 11:23:44 +053012028 || (!pIes->RSN.present && (pIes->WPA.present &&
12029 (pIes->WPA.unicast_cipher_count == 1) &&
12030 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
12031 "\x00\x50\xf2\x02", 4)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012032 sms_log(pMac, LOGW,
12033 " No channel bonding in TKIP mode ");
12034 return PHY_SINGLE_CHANNEL_CENTERED;
12035 }
12036
12037 if (!pIes->HTInfo.present)
12038 return PHY_SINGLE_CHANNEL_CENTERED;
12039
12040 /*
12041 * This is called during INFRA STA/CLIENT and should use the merged
12042 * value of supported channel width and recommended tx width as per
12043 * standard
12044 */
12045 sms_log(pMac, LOG1, "scws %u rtws %u sco %u",
12046 pIes->HTCaps.supportedChannelWidthSet,
12047 pIes->HTInfo.recommendedTxWidthSet,
12048 pIes->HTInfo.secondaryChannelOffset);
12049
12050 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
12051 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
12052 else
12053 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12054
12055 switch (eRet) {
12056 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
12057 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
12058 break;
12059 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
12060 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
12061 break;
12062 case PHY_SINGLE_CHANNEL_CENTERED:
12063 default:
12064 centerChn = primaryChn;
12065 break;
12066 }
12067
Amar Singhal7ccdc4f2015-10-30 15:10:05 -070012068 if ((PHY_SINGLE_CHANNEL_CENTERED != eRet) &&
12069 (QDF_STATUS_SUCCESS != sme_check_ch_in_band(pMac,
12070 centerChn - 2, 2))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012071 sms_log(pMac, LOGE,
12072 "Invalid center channel (%d), disable 40MHz mode",
12073 centerChn);
12074 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12075 }
12076 return eRet;
12077}
12078
12079bool csr_is_encryption_in_list(tpAniSirGlobal pMac,
12080 tCsrEncryptionList *pCipherList,
12081 eCsrEncryptionType encryptionType)
12082{
12083 bool fFound = false;
12084 uint32_t idx;
12085 for (idx = 0; idx < pCipherList->numEntries; idx++) {
12086 if (pCipherList->encryptionType[idx] == encryptionType) {
12087 fFound = true;
12088 break;
12089 }
12090 }
12091 return fFound;
12092}
12093
12094bool csr_is_auth_in_list(tpAniSirGlobal pMac, tCsrAuthList *pAuthList,
12095 eCsrAuthType authType)
12096{
12097 bool fFound = false;
12098 uint32_t idx;
12099 for (idx = 0; idx < pAuthList->numEntries; idx++) {
12100 if (pAuthList->authType[idx] == authType) {
12101 fFound = true;
12102 break;
12103 }
12104 }
12105 return fFound;
12106}
12107
12108bool csr_is_same_profile(tpAniSirGlobal pMac,
12109 tCsrRoamConnectedProfile *pProfile1,
12110 tCsrRoamProfile *pProfile2)
12111{
12112 uint32_t i;
12113 bool fCheck = false;
12114 tCsrScanResultFilter *pScanFilter = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012115 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012116
12117 if (!(pProfile1 && pProfile2))
12118 return fCheck;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012119 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012120 if (NULL == pScanFilter)
12121 return fCheck;
12122
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012123 qdf_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012124 status = csr_roam_prepare_filter_from_profile(pMac, pProfile2,
12125 pScanFilter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012126 if (!(QDF_IS_STATUS_SUCCESS(status)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012127 goto free_scan_filter;
12128
12129 for (i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++) {
12130 fCheck = csr_is_ssid_match(pMac,
12131 pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
12132 pScanFilter->SSIDs.SSIDList[i].SSID.length,
12133 pProfile1->SSID.ssId,
12134 pProfile1->SSID.length,
12135 false);
12136 if (fCheck)
12137 break;
12138 }
12139 if (!fCheck)
12140 goto free_scan_filter;
12141
12142 if (!csr_is_auth_in_list(pMac, &pProfile2->AuthType,
12143 pProfile1->AuthType)
12144 || (pProfile2->BSSType != pProfile1->BSSType)
12145 || !csr_is_encryption_in_list(pMac, &pProfile2->EncryptionType,
12146 pProfile1->EncryptionType)) {
12147 fCheck = false;
12148 goto free_scan_filter;
12149 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012150 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent) {
12151 if (pProfile1->MDID.mobilityDomain
12152 != pProfile2->MDID.mobilityDomain) {
12153 fCheck = false;
12154 goto free_scan_filter;
12155 }
12156 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012157 /* Match found */
12158 fCheck = true;
12159free_scan_filter:
12160 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012161 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012162 return fCheck;
12163}
12164
12165bool csr_roam_is_same_profile_keys(tpAniSirGlobal pMac,
12166 tCsrRoamConnectedProfile *pConnProfile,
12167 tCsrRoamProfile *pProfile2)
12168{
12169 bool fCheck = false;
12170 int i;
12171 do {
12172 /* Only check for static WEP */
12173 if (!csr_is_encryption_in_list
12174 (pMac, &pProfile2->EncryptionType,
12175 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY)
12176 && !csr_is_encryption_in_list(pMac,
12177 &pProfile2->EncryptionType,
12178 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
12179 fCheck = true;
12180 break;
12181 }
12182 if (!csr_is_encryption_in_list
12183 (pMac, &pProfile2->EncryptionType,
12184 pConnProfile->EncryptionType))
12185 break;
12186 if (pConnProfile->Keys.defaultIndex !=
12187 pProfile2->Keys.defaultIndex)
12188 break;
12189 for (i = 0; i < CSR_MAX_NUM_KEY; i++) {
12190 if (pConnProfile->Keys.KeyLength[i] !=
12191 pProfile2->Keys.KeyLength[i])
12192 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012193 if (qdf_mem_cmp(&pConnProfile->Keys.KeyMaterial[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012194 &pProfile2->Keys.KeyMaterial[i],
12195 pProfile2->Keys.KeyLength[i])) {
12196 break;
12197 }
12198 }
12199 if (i == CSR_MAX_NUM_KEY) {
12200 fCheck = true;
12201 }
12202 } while (0);
12203 return fCheck;
12204}
12205
12206/* IBSS */
12207
12208uint8_t csr_roam_get_ibss_start_channel_number50(tpAniSirGlobal pMac)
12209{
12210 uint8_t channel = 0;
12211 uint32_t idx;
12212 uint32_t idxValidChannels;
12213 bool fFound = false;
12214 uint32_t len = sizeof(pMac->roam.validChannelList);
12215
12216 if (eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G) {
12217 channel = pMac->roam.configParam.AdHocChannel5G;
12218 if (!csr_roam_is_channel_valid(pMac, channel)) {
12219 channel = 0;
12220 }
12221 }
12222 if (0 == channel
12223 &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012224 QDF_IS_STATUS_SUCCESS(csr_get_cfg_valid_channels
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012225 (pMac,
12226 (uint8_t *) pMac->roam.validChannelList,
12227 &len))) {
12228 for (idx = 0; (idx < CSR_NUM_IBSS_START_CHANNELS_50) && !fFound;
12229 idx++) {
12230 for (idxValidChannels = 0;
12231 (idxValidChannels < len) && !fFound;
12232 idxValidChannels++) {
12233 if (csr_start_ibss_channels50[idx] ==
12234 pMac->roam.
12235 validChannelList[idxValidChannels]) {
12236 fFound = true;
12237 channel = csr_start_ibss_channels50[idx];
12238 }
12239 }
12240 }
12241 /*
12242 * this is rare, but if it does happen,
12243 * we find anyone in 11a bandwidth and
12244 * return the first 11a channel found!
12245 */
12246 if (!fFound) {
12247 for (idxValidChannels = 0; idxValidChannels < len;
12248 idxValidChannels++) {
12249 if (CDS_IS_CHANNEL_5GHZ(pMac->roam.
12250 validChannelList[idxValidChannels])) {
12251 /* the max channel# in 11g is 14 */
12252 if (idxValidChannels <
12253 CSR_NUM_IBSS_START_CHANNELS_50) {
12254 channel =
12255 pMac->roam.validChannelList
12256 [idxValidChannels];
12257 }
12258 break;
12259 }
12260 }
12261 }
12262 } /* if */
12263
12264 return channel;
12265}
12266
12267uint8_t csr_roam_get_ibss_start_channel_number24(tpAniSirGlobal pMac)
12268{
12269 uint8_t channel = 1;
12270 uint32_t idx;
12271 uint32_t idxValidChannels;
12272 bool fFound = false;
12273 uint32_t len = sizeof(pMac->roam.validChannelList);
12274
12275 if (eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24) {
12276 channel = pMac->roam.configParam.AdHocChannel24;
12277 if (!csr_roam_is_channel_valid(pMac, channel)) {
12278 channel = 0;
12279 }
12280 }
12281
12282 if (0 == channel
12283 &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012284 QDF_IS_STATUS_SUCCESS(csr_get_cfg_valid_channels
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012285 (pMac,
12286 (uint8_t *) pMac->roam.validChannelList,
12287 &len))) {
12288 for (idx = 0; (idx < CSR_NUM_IBSS_START_CHANNELS_24) && !fFound;
12289 idx++) {
12290 for (idxValidChannels = 0;
12291 (idxValidChannels < len) && !fFound;
12292 idxValidChannels++) {
12293 if (csr_start_ibss_channels24[idx] ==
12294 pMac->roam.
12295 validChannelList[idxValidChannels]) {
12296 fFound = true;
12297 channel = csr_start_ibss_channels24[idx];
12298 }
12299 }
12300 }
12301 }
12302
12303 return channel;
12304}
12305
12306/**
12307 * csr_populate_basic_rates() - populates OFDM or CCK rates
12308 * @rates: rate struct to populate
12309 * @type: true: ofdm rates, false: cck rates
12310 * @masked: indicates if rates are to be masked with
12311 * CSR_DOT11_BASIC_RATE_MASK
12312 *
12313 * This function will populate OFDM or CCK rates
12314 *
12315 * Return: void
12316 */
12317static void
12318csr_populate_basic_rates(tSirMacRateSet *rate_set, bool type, bool masked)
12319{
12320 uint8_t ofdm_rates[8] = {
12321 SIR_MAC_RATE_6,
12322 SIR_MAC_RATE_9,
12323 SIR_MAC_RATE_12,
12324 SIR_MAC_RATE_18,
12325 SIR_MAC_RATE_24,
12326 SIR_MAC_RATE_36,
12327 SIR_MAC_RATE_48,
12328 SIR_MAC_RATE_54
12329 };
12330 uint8_t cck_rates[4] = {
12331 SIR_MAC_RATE_1,
12332 SIR_MAC_RATE_2,
12333 SIR_MAC_RATE_5_5,
12334 SIR_MAC_RATE_11
12335 };
12336
12337 if (type == true) {
12338 rate_set->numRates = 8;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012339 qdf_mem_copy(rate_set->rate, ofdm_rates, sizeof(ofdm_rates));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012340 if (masked) {
12341 rate_set->rate[0] |= CSR_DOT11_BASIC_RATE_MASK;
12342 rate_set->rate[2] |= CSR_DOT11_BASIC_RATE_MASK;
12343 rate_set->rate[4] |= CSR_DOT11_BASIC_RATE_MASK;
12344 }
12345 } else {
12346 rate_set->numRates = 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012347 qdf_mem_copy(rate_set->rate, cck_rates, sizeof(cck_rates));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012348 if (masked) {
12349 rate_set->rate[0] |= CSR_DOT11_BASIC_RATE_MASK;
12350 rate_set->rate[1] |= CSR_DOT11_BASIC_RATE_MASK;
12351 rate_set->rate[2] |= CSR_DOT11_BASIC_RATE_MASK;
12352 rate_set->rate[3] |= CSR_DOT11_BASIC_RATE_MASK;
12353 }
12354 }
12355}
12356
12357/**
12358 * csr_convert_mode_to_nw_type() - convert mode into network type
12359 * @dot11_mode: dot11_mode
12360 * @band: 2.4 or 5 GHz
12361 *
12362 * Return: tSirNwType
12363 */
12364static tSirNwType
12365csr_convert_mode_to_nw_type(eCsrCfgDot11Mode dot11_mode, eCsrBand band)
12366{
12367 switch (dot11_mode) {
12368 case eCSR_CFG_DOT11_MODE_11G:
12369 return eSIR_11G_NW_TYPE;
12370 case eCSR_CFG_DOT11_MODE_11B:
12371 return eSIR_11B_NW_TYPE;
12372 case eCSR_CFG_DOT11_MODE_11A:
12373 return eSIR_11A_NW_TYPE;
12374 case eCSR_CFG_DOT11_MODE_11N:
12375 default:
12376 /*
12377 * Because LIM only verifies it against 11a, 11b or 11g, set
12378 * only 11g or 11a here
12379 */
12380 if (eCSR_BAND_24 == band)
12381 return eSIR_11G_NW_TYPE;
12382 else
12383 return eSIR_11A_NW_TYPE;
12384 }
12385 return eSIR_DONOT_USE_NW_TYPE;
12386}
12387
12388/**
12389 * csr_roam_get_bss_start_parms() - get bss start param from profile
12390 * @pMac: mac global context
12391 * @pProfile: roam profile
12392 * @pParam: out param, start bss params
12393 *
12394 * This function populates start bss param from roam profile
12395 *
12396 * Return: void
12397 */
12398static void
12399csr_roam_get_bss_start_parms(tpAniSirGlobal pMac,
12400 tCsrRoamProfile *pProfile,
12401 tCsrRoamStartBssParams *pParam)
12402{
12403 eCsrBand band;
12404 uint8_t opr_ch = 0;
12405 tSirNwType nw_type;
12406 uint8_t tmp_opr_ch = 0;
12407 tSirMacRateSet *opr_rates = &pParam->operationalRateSet;
12408 tSirMacRateSet *ext_rates = &pParam->extendedRateSet;
12409
12410 if (pProfile->ChannelInfo.numOfChannels
12411 && pProfile->ChannelInfo.ChannelList) {
12412 tmp_opr_ch = pProfile->ChannelInfo.ChannelList[0];
12413 }
12414
12415 pParam->uCfgDot11Mode = csr_roam_get_phy_mode_band_for_bss(pMac,
12416 pProfile, tmp_opr_ch, &band);
12417
Anurag Chouhan6d760662016-02-20 16:05:43 +053012418 if (((pProfile->csrPersona == QDF_P2P_CLIENT_MODE)
12419 || (pProfile->csrPersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012420 && (pParam->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)) {
12421 /* This should never happen */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012422 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012423 FL("For P2P (persona %d) dot11_mode is 11B"),
12424 pProfile->csrPersona);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012425 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012426 }
12427
12428 nw_type = csr_convert_mode_to_nw_type(pParam->uCfgDot11Mode, band);
12429 ext_rates->numRates = 0;
12430
12431 switch (nw_type) {
12432 default:
12433 sms_log(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"),
12434 nw_type);
12435 case eSIR_11A_NW_TYPE:
12436 csr_populate_basic_rates(opr_rates, true, true);
12437 if (eCSR_OPERATING_CHANNEL_ANY != tmp_opr_ch) {
12438 opr_ch = tmp_opr_ch;
12439 break;
12440 }
12441 opr_ch = csr_roam_get_ibss_start_channel_number50(pMac);
12442 if (0 == opr_ch &&
12443 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
12444 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)) {
12445 /*
12446 * We could not find a 5G channel by auto pick, let's
12447 * try 2.4G channels. We only do this here because
12448 * csr_roam_get_phy_mode_band_for_bss always picks 11a
12449 * for AUTO
12450 */
12451 nw_type = eSIR_11B_NW_TYPE;
12452 opr_ch = csr_roam_get_ibss_start_channel_number24(pMac);
12453 csr_populate_basic_rates(opr_rates, false, true);
12454 }
12455 break;
12456 case eSIR_11B_NW_TYPE:
12457 csr_populate_basic_rates(opr_rates, false, true);
12458 if (eCSR_OPERATING_CHANNEL_ANY == tmp_opr_ch)
12459 opr_ch = csr_roam_get_ibss_start_channel_number24(pMac);
12460 else
12461 opr_ch = tmp_opr_ch;
12462 break;
12463 case eSIR_11G_NW_TYPE:
12464 /* For P2P Client and P2P GO, disable 11b rates */
Anurag Chouhan6d760662016-02-20 16:05:43 +053012465 if ((pProfile->csrPersona == QDF_P2P_CLIENT_MODE)
12466 || (pProfile->csrPersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012467 || (eCSR_CFG_DOT11_MODE_11G_ONLY ==
12468 pParam->uCfgDot11Mode)) {
12469 csr_populate_basic_rates(opr_rates, true, true);
12470 } else {
12471 csr_populate_basic_rates(opr_rates, false, true);
12472 csr_populate_basic_rates(ext_rates, true, false);
12473 }
12474
12475 if (eCSR_OPERATING_CHANNEL_ANY == tmp_opr_ch)
12476 opr_ch = csr_roam_get_ibss_start_channel_number24(pMac);
12477 else
12478 opr_ch = tmp_opr_ch;
12479 break;
12480 }
12481 pParam->operationChn = opr_ch;
12482 pParam->sirNwType = nw_type;
12483 pParam->ch_params.ch_width = pProfile->ch_params.ch_width;
12484 pParam->ch_params.center_freq_seg0 =
12485 pProfile->ch_params.center_freq_seg0;
12486 pParam->ch_params.center_freq_seg1 =
12487 pProfile->ch_params.center_freq_seg1;
12488 pParam->ch_params.sec_ch_offset =
12489 pProfile->ch_params.sec_ch_offset;
12490}
12491
12492static void
12493csr_roam_get_bss_start_parms_from_bss_desc(tpAniSirGlobal pMac,
12494 tSirBssDescription *pBssDesc,
12495 tDot11fBeaconIEs *pIes,
12496 tCsrRoamStartBssParams *pParam)
12497{
12498 if (!pParam) {
12499 sms_log(pMac, LOGE, FL("BSS param's pointer is NULL"));
12500 return;
12501 }
12502
12503 pParam->sirNwType = pBssDesc->nwType;
12504 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12505 pParam->operationChn = pBssDesc->channelId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012506 qdf_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012507
12508 if (!pIes) {
12509 pParam->ssId.length = 0;
12510 pParam->operationalRateSet.numRates = 0;
12511 sms_log(pMac, LOGE, FL("IEs struct pointer is NULL"));
12512 return;
12513 }
12514
12515 if (pIes->SuppRates.present) {
12516 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
12517 if (pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX) {
12518 sms_log(pMac, LOGE,
12519 FL("num_rates: %d > max val, resetting"),
12520 pIes->SuppRates.num_rates);
12521 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
12522 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012523 qdf_mem_copy(pParam->operationalRateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012524 pIes->SuppRates.rates,
12525 sizeof(*pIes->SuppRates.rates) *
12526 pIes->SuppRates.num_rates);
12527 }
12528 if (pIes->ExtSuppRates.present) {
12529 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
12530 if (pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX) {
12531 sms_log(pMac, LOGE,
12532 FL("num_rates: %d > max val, resetting"),
12533 pIes->ExtSuppRates.num_rates);
12534 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
12535 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012536 qdf_mem_copy(pParam->extendedRateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012537 pIes->ExtSuppRates.rates,
12538 sizeof(*pIes->ExtSuppRates.rates) *
12539 pIes->ExtSuppRates.num_rates);
12540 }
12541 if (pIes->SSID.present) {
12542 pParam->ssId.length = pIes->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012543 qdf_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012544 pParam->ssId.length);
12545 }
12546 pParam->cbMode = csr_get_cb_mode_from_ies(pMac, pParam->operationChn,
12547 pIes);
12548}
12549
12550static void csr_roam_determine_max_rate_for_ad_hoc(tpAniSirGlobal pMac,
12551 tSirMacRateSet *pSirRateSet)
12552{
12553 uint8_t MaxRate = 0;
12554 uint32_t i;
12555 uint8_t *pRate;
12556
12557 pRate = pSirRateSet->rate;
12558 for (i = 0; i < pSirRateSet->numRates; i++) {
12559 MaxRate =
12560 CSR_MAX(MaxRate, (pRate[i] & (~CSR_DOT11_BASIC_RATE_MASK)));
12561 }
12562
12563 /* Save the max rate in the connected state information... */
12564
12565 /* modify LastRates variable as well */
12566
12567 return;
12568}
12569
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012570QDF_STATUS csr_roam_issue_start_bss(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012571 tCsrRoamStartBssParams *pParam,
12572 tCsrRoamProfile *pProfile,
12573 tSirBssDescription *pBssDesc, uint32_t roamId)
12574{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012575 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012576 eCsrBand eBand;
12577 /* Set the roaming substate to 'Start BSS attempt'... */
12578 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ,
12579 sessionId);
12580#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12581 /* Need to figure out whether we need to log WDS??? */
12582 if (CSR_IS_IBSS(pProfile)) {
12583 host_log_ibss_pkt_type *pIbssLog;
12584 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
12585 LOG_WLAN_IBSS_C);
12586 if (pIbssLog) {
12587 if (pBssDesc) {
12588 pIbssLog->eventId =
12589 WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012590 qdf_mem_copy(pIbssLog->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012591 pBssDesc->bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012592 } else {
12593 pIbssLog->eventId =
12594 WLAN_IBSS_EVENT_START_IBSS_REQ;
12595 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012596 qdf_mem_copy(pIbssLog->ssid, pParam->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012597 pParam->ssId.length);
12598 if (pProfile->ChannelInfo.numOfChannels == 0) {
12599 pIbssLog->channelSetting = AUTO_PICK;
12600 } else {
12601 pIbssLog->channelSetting = SPECIFIED;
12602 }
12603 pIbssLog->operatingChannel = pParam->operationChn;
12604 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
12605 }
12606 }
12607#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12608 /* Put RSN information in for Starting BSS */
12609 pParam->nRSNIELength = (uint16_t) pProfile->nRSNReqIELength;
12610 pParam->pRSNIE = pProfile->pRSNReqIE;
12611
12612 pParam->privacy = pProfile->privacy;
12613 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
12614 pParam->authType = pProfile->csr80211AuthType;
12615 pParam->beaconInterval = pProfile->beaconInterval;
12616 pParam->dtimPeriod = pProfile->dtimPeriod;
12617 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
12618 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
12619 if (CSR_IS_INFRA_AP(pProfile) && (pParam->operationChn != 0)) {
12620 if (csr_is_valid_channel(pMac, pParam->operationChn) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012621 QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012622 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
12623 }
12624 }
12625 pParam->protEnabled = pProfile->protEnabled;
12626 pParam->obssProtEnabled = pProfile->obssProtEnabled;
12627 pParam->ht_protection = pProfile->cfg_protection;
12628 pParam->wps_state = pProfile->wps_state;
12629
12630 pParam->uCfgDot11Mode =
12631 csr_roam_get_phy_mode_band_for_bss(pMac, pProfile,
12632 pParam->
12633 operationChn,
12634 &eBand);
12635 pParam->bssPersona = pProfile->csrPersona;
12636
12637#ifdef WLAN_FEATURE_11W
12638 pParam->mfpCapable = (0 != pProfile->MFPCapable);
12639 pParam->mfpRequired = (0 != pProfile->MFPRequired);
12640#endif
12641
12642 pParam->addIeParams.probeRespDataLen =
12643 pProfile->addIeParams.probeRespDataLen;
12644 pParam->addIeParams.probeRespData_buff =
12645 pProfile->addIeParams.probeRespData_buff;
12646
12647 pParam->addIeParams.assocRespDataLen =
12648 pProfile->addIeParams.assocRespDataLen;
12649 pParam->addIeParams.assocRespData_buff =
12650 pProfile->addIeParams.assocRespData_buff;
12651
12652 if (CSR_IS_IBSS(pProfile)) {
12653 pParam->addIeParams.probeRespBCNDataLen =
12654 pProfile->nWPAReqIELength;
12655 pParam->addIeParams.probeRespBCNData_buff = pProfile->pWPAReqIE;
12656 } else {
12657 pParam->addIeParams.probeRespBCNDataLen =
12658 pProfile->addIeParams.probeRespBCNDataLen;
12659 pParam->addIeParams.probeRespBCNData_buff =
12660 pProfile->addIeParams.probeRespBCNData_buff;
12661 }
12662 pParam->sap_dot11mc = pProfile->sap_dot11mc;
12663
12664 /* When starting an IBSS, start on the channel from the Profile. */
12665 status =
12666 csr_send_mb_start_bss_req_msg(pMac, sessionId, pProfile->BSSType, pParam,
12667 pBssDesc);
12668 return status;
12669}
12670
12671static void csr_roam_prepare_bss_params(tpAniSirGlobal pMac, uint32_t sessionId,
12672 tCsrRoamProfile *pProfile,
12673 tSirBssDescription *pBssDesc,
12674 tBssConfigParam *pBssConfig,
12675 tDot11fBeaconIEs *pIes)
12676{
12677 uint8_t Channel;
12678 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12679 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
12680
12681 if (!pSession) {
12682 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
12683 return;
12684 }
12685
12686 if (pBssDesc) {
12687 csr_roam_get_bss_start_parms_from_bss_desc(pMac, pBssDesc, pIes,
12688 &pSession->bssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012689 } else {
12690 csr_roam_get_bss_start_parms(pMac, pProfile, &pSession->bssParams);
12691 /* Use the first SSID */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070012692 if (pProfile->SSIDs.numOfSSIDs)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012693 qdf_mem_copy(&pSession->bssParams.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012694 pProfile->SSIDs.SSIDList,
12695 sizeof(tSirMacSSid));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070012696 if (pProfile->BSSIDs.numOfBSSIDs)
12697 /* Use the first BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012698 qdf_mem_copy(&pSession->bssParams.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012699 pProfile->BSSIDs.bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012700 sizeof(struct qdf_mac_addr));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070012701 else
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012702 qdf_mem_set(&pSession->bssParams.bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012703 sizeof(struct qdf_mac_addr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012704 }
12705 Channel = pSession->bssParams.operationChn;
12706 /* Set operating channel in pProfile which will be used */
12707 /* in csr_roam_set_bss_config_cfg() to determine channel bonding */
12708 /* mode and will be configured in CFG later */
12709 pProfile->operationChannel = Channel;
12710
12711 if (Channel == 0) {
12712 sms_log(pMac, LOGE,
12713 " CSR cannot find a channel to start IBSS");
12714 } else {
12715
12716 csr_roam_determine_max_rate_for_ad_hoc(pMac,
12717 &pSession->bssParams.
12718 operationalRateSet);
12719 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS(pProfile)) {
12720 if (CDS_IS_CHANNEL_24GHZ(Channel)) {
12721 cbMode =
12722 pMac->roam.configParam.
12723 channelBondingMode24GHz;
12724 } else {
12725 cbMode =
12726 pMac->roam.configParam.
12727 channelBondingMode5GHz;
12728 }
12729 sms_log(pMac, LOG1, "## cbMode %d", cbMode);
12730 pBssConfig->cbMode = cbMode;
12731 pSession->bssParams.cbMode = cbMode;
12732 }
12733 }
12734}
12735
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012736static QDF_STATUS csr_roam_start_ibss(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012737 tCsrRoamProfile *pProfile,
12738 bool *pfSameIbss)
12739{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012740 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012741 bool fSameIbss = false;
12742
12743 if (csr_is_conn_state_ibss(pMac, sessionId)) {
12744 /* Check if any profile parameter has changed ? If any profile parameter */
12745 /* has changed then stop old BSS and start a new one with new parameters */
12746 if (csr_is_same_profile
12747 (pMac, &pMac->roam.roamSession[sessionId].connectedProfile,
12748 pProfile)) {
12749 fSameIbss = true;
12750 } else {
12751 status =
12752 csr_roam_issue_stop_bss(pMac, sessionId,
12753 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING);
12754 }
12755 } else if (csr_is_conn_state_connected_infra(pMac, sessionId)) {
12756 /* Disassociate from the connected Infrastructure network... */
12757 status =
12758 csr_roam_issue_disassociate(pMac, sessionId,
12759 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
12760 false);
12761 } else {
12762 tBssConfigParam *pBssConfig;
12763
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012764 pBssConfig = qdf_mem_malloc(sizeof(tBssConfigParam));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012765 if (NULL == pBssConfig)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012766 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012767 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012768 status = QDF_STATUS_SUCCESS;
12769 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012770 qdf_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012771 /* there is no Bss description before we start an IBSS so we need to adopt */
12772 /* all Bss configuration parameters from the Profile. */
12773 status =
12774 csr_roam_prepare_bss_config_from_profile(pMac, pProfile,
12775 pBssConfig,
12776 NULL);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012777 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012778 /* save dotMode */
12779 pMac->roam.roamSession[sessionId].bssParams.
12780 uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12781 /* Prepare some more parameters for this IBSS */
12782 csr_roam_prepare_bss_params(pMac, sessionId,
12783 pProfile, NULL,
12784 pBssConfig, NULL);
12785 status =
12786 csr_roam_set_bss_config_cfg(pMac, sessionId,
12787 pProfile, NULL,
12788 pBssConfig, NULL,
12789 false);
12790 }
12791
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012792 qdf_mem_free(pBssConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012793 } /* Allocate memory */
12794 }
12795
12796 if (pfSameIbss) {
12797 *pfSameIbss = fSameIbss;
12798 }
12799 return status;
12800}
12801
12802static void csr_roam_update_connected_profile_from_new_bss(tpAniSirGlobal pMac,
12803 uint32_t sessionId,
12804 tSirSmeNewBssInfo *pNewBss)
12805{
12806 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
12807
12808 if (!pSession) {
12809 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
12810 return;
12811 }
12812
12813 if (pNewBss) {
12814 /* Set the operating channel. */
12815 pSession->connectedProfile.operationChannel =
12816 pNewBss->channelNumber;
12817 /* move the BSSId from the BSS description into the connected state information. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012818 qdf_mem_copy(&pSession->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012819 &(pNewBss->bssId), sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012820 }
12821 return;
12822}
12823
12824#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012825QDF_STATUS csr_roam_set_psk_pmk(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012826 uint8_t *pPSK_PMK, size_t pmk_len)
12827{
12828 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
12829 if (!pSession) {
12830 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012831 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012832 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012833 qdf_mem_copy(pSession->psk_pmk, pPSK_PMK, sizeof(pSession->psk_pmk));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012834 pSession->pmk_len = pmk_len;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012835 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012836}
12837#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
12838
12839#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12840static void
12841csr_roam_diag_set_pmkid(tCsrRoamSession *pSession)
12842{
12843 WLAN_HOST_DIAG_EVENT_DEF(secEvent,
12844 host_event_wlan_security_payload_type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012845 qdf_mem_set(&secEvent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012846 sizeof(host_event_wlan_security_payload_type), 0);
12847 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12848 secEvent.encryptionModeMulticast =
12849 (uint8_t) diag_enc_type_from_csr_type(
12850 pSession->connectedProfile.mcEncryptionType);
12851 secEvent.encryptionModeUnicast =
12852 (uint8_t) diag_enc_type_from_csr_type(
12853 pSession->connectedProfile.EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012854 qdf_mem_copy(secEvent.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012855 pSession->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012856 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012857 secEvent.authMode = (uint8_t) diag_auth_type_from_csr_type(
12858 pSession->connectedProfile.AuthType);
12859 WLAN_HOST_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12860}
12861#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12862
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012863QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012864csr_roam_set_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId,
12865 tPmkidCacheInfo *pPMKIDCache, uint32_t numItems,
12866 bool update_entire_cache)
12867{
12868 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
12869 uint32_t i = 0;
12870 tPmkidCacheInfo *pmksa;
12871
12872 if (!pSession) {
12873 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012874 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012875 }
12876
12877 sms_log(pMac, LOGW, FL("numItems = %d"), numItems);
12878
12879 if (numItems > CSR_MAX_PMKID_ALLOWED)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012880 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012881
12882#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12883 csr_roam_diag_set_pmkid(pSession);
12884#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12885
12886 if (update_entire_cache) {
12887 if (numItems && pPMKIDCache) {
12888 pSession->NumPmkidCache = (uint16_t) numItems;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012889 qdf_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012890 sizeof(tPmkidCacheInfo) * numItems);
12891 pSession->curr_cache_idx = (uint16_t)numItems;
12892 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012893 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012894 }
12895
12896 for (i = 0; i < numItems; i++) {
12897 pmksa = &pPMKIDCache[i];
12898
12899 /* Delete the entry if present */
12900 csr_roam_del_pmkid_from_cache(pMac, sessionId,
12901 pmksa->BSSID.bytes, false);
12902
12903 /* Add entry to the cache */
Anurag Chouhanc5548422016-02-24 18:33:27 +053012904 qdf_copy_macaddr(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012905 &pSession->PmkidCacheInfo[pSession->curr_cache_idx].BSSID,
12906 &pmksa->BSSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012907 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012908 pSession->PmkidCacheInfo[pSession->curr_cache_idx].PMKID,
12909 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12910
12911 /* Increment the CSR local cache index */
12912 if (pSession->curr_cache_idx < (CSR_MAX_PMKID_ALLOWED - 1))
12913 pSession->curr_cache_idx++;
12914 else
12915 pSession->curr_cache_idx = 0;
12916
12917 pSession->NumPmkidCache++;
12918 if (pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12919 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12920 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012921 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012922}
12923
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012924QDF_STATUS csr_roam_del_pmkid_from_cache(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012925 uint32_t sessionId,
12926 const uint8_t *pBSSId,
12927 bool flush_cache)
12928{
12929 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
12930 bool fMatchFound = false;
12931 uint32_t Index;
12932 uint32_t curr_idx;
12933 uint32_t i;
12934
12935 if (!pSession) {
12936 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012937 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012938 }
12939
12940 /* Check if there are no entries to delete */
12941 if (0 == pSession->NumPmkidCache) {
12942 sms_log(pMac, LOG1, FL("No entries to delete/Flush"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012943 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012944 }
12945
12946 if (flush_cache) {
12947 /* Flush the entire cache */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012948 qdf_mem_zero(pSession->PmkidCacheInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012949 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12950 pSession->NumPmkidCache = 0;
12951 pSession->curr_cache_idx = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012952 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012953 }
12954
12955 /* !flush_cache - so look up in the cache */
12956 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012957 if (!qdf_mem_cmp(pSession->PmkidCacheInfo[Index].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012958 pBSSId, QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012959 fMatchFound = 1;
12960
12961 /* Clear this - the matched entry */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012962 qdf_mem_zero(&pSession->PmkidCacheInfo[Index],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012963 sizeof(tPmkidCacheInfo));
12964 break;
12965 }
12966 }
12967
12968 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12969 sms_log(pMac, LOG1, FL("No such PMKSA entry exists"
12970 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pBSSId));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012971 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012972 }
12973
12974 /* Match Found, Readjust the other entries */
12975 curr_idx = pSession->curr_cache_idx;
12976 if (Index < curr_idx) {
12977 for (i = Index; i < (curr_idx - 1); i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012978 qdf_mem_copy(&pSession->PmkidCacheInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012979 &pSession->PmkidCacheInfo[i + 1],
12980 sizeof(tPmkidCacheInfo));
12981 }
12982
12983 pSession->curr_cache_idx--;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012984 qdf_mem_zero(&pSession->PmkidCacheInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012985 [pSession->curr_cache_idx],
12986 sizeof(tPmkidCacheInfo));
12987 } else if (Index > curr_idx) {
12988 for (i = Index; i > (curr_idx); i--) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012989 qdf_mem_copy(&pSession->PmkidCacheInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012990 &pSession->PmkidCacheInfo[i - 1],
12991 sizeof(tPmkidCacheInfo));
12992 }
12993
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012994 qdf_mem_zero(&pSession->PmkidCacheInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012995 [pSession->curr_cache_idx],
12996 sizeof(tPmkidCacheInfo));
12997 }
12998
12999 /* Decrement the count since an entry has been deleted */
13000 pSession->NumPmkidCache--;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013001 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013002}
13003
13004uint32_t csr_roam_get_num_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId)
13005{
13006 return pMac->roam.roamSession[sessionId].NumPmkidCache;
13007}
13008
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013009QDF_STATUS csr_roam_get_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013010 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
13011{
13012 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13013 tPmkidCacheInfo *pmksa;
13014 uint16_t i, j;
13015
13016 if (!pSession) {
13017 sms_log(pMac, LOGE, FL("session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013018 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013019 }
13020
13021 if (!pNum || !pPmkidCache) {
13022 sms_log(pMac, LOGE, FL("Either pNum or pPmkidCache is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013023 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013024 }
13025
13026 if (pSession->NumPmkidCache == 0) {
13027 *pNum = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013028 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013029 }
13030
13031 if (*pNum < pSession->NumPmkidCache) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013032 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013033 }
13034
13035 if (pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED) {
13036 sms_log(pMac, LOGE,
13037 FL(
13038 "NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED"),
13039 pSession->NumPmkidCache);
13040 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
13041 }
13042
13043 for (i = 0, j = 0; ((j < pSession->NumPmkidCache) &&
13044 (i < CSR_MAX_PMKID_ALLOWED)); i++) {
13045 /* Fill the valid entries */
13046 pmksa = &pSession->PmkidCacheInfo[i];
Anurag Chouhanc5548422016-02-24 18:33:27 +053013047 if (!qdf_is_macaddr_zero(&pmksa->BSSID)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013048 qdf_mem_copy(pPmkidCache, pmksa,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013049 sizeof(tPmkidCacheInfo));
13050 pPmkidCache++;
13051 j++;
13052 }
13053 }
13054
13055 *pNum = pSession->NumPmkidCache;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013056 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013057}
13058
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013059QDF_STATUS csr_roam_get_wpa_rsn_req_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013060 uint32_t *pLen, uint8_t *pBuf)
13061{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013062 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013063 uint32_t len;
13064 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13065
13066 if (!pSession) {
13067 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013068 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013069 }
13070
13071 if (pLen) {
13072 len = *pLen;
13073 *pLen = pSession->nWpaRsnReqIeLength;
13074 if (pBuf) {
13075 if (len >= pSession->nWpaRsnReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013076 qdf_mem_copy(pBuf, pSession->pWpaRsnReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013077 pSession->nWpaRsnReqIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013078 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013079 }
13080 }
13081 }
13082 return status;
13083}
13084
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013085QDF_STATUS csr_roam_get_wpa_rsn_rsp_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013086 uint32_t *pLen, uint8_t *pBuf)
13087{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013088 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013089 uint32_t len;
13090 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13091
13092 if (!pSession) {
13093 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013094 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013095 }
13096
13097 if (pLen) {
13098 len = *pLen;
13099 *pLen = pSession->nWpaRsnRspIeLength;
13100 if (pBuf) {
13101 if (len >= pSession->nWpaRsnRspIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013102 qdf_mem_copy(pBuf, pSession->pWpaRsnRspIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013103 pSession->nWpaRsnRspIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013104 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013105 }
13106 }
13107 }
13108 return status;
13109}
13110
13111#ifdef FEATURE_WLAN_WAPI
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013112QDF_STATUS csr_roam_get_wapi_req_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013113 uint32_t *pLen, uint8_t *pBuf)
13114{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013115 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013116 uint32_t len;
13117 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13118
13119 if (!pSession) {
13120 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013121 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013122 }
13123
13124 if (pLen) {
13125 len = *pLen;
13126 *pLen = pSession->nWapiReqIeLength;
13127 if (pBuf) {
13128 if (len >= pSession->nWapiReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013129 qdf_mem_copy(pBuf, pSession->pWapiReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013130 pSession->nWapiReqIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013131 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013132 }
13133 }
13134 }
13135 return status;
13136}
13137
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013138QDF_STATUS csr_roam_get_wapi_rsp_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013139 uint32_t *pLen, uint8_t *pBuf)
13140{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013141 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013142 uint32_t len;
13143 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13144
13145 if (!pSession) {
13146 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013147 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013148 }
13149
13150 if (pLen) {
13151 len = *pLen;
13152 *pLen = pSession->nWapiRspIeLength;
13153 if (pBuf) {
13154 if (len >= pSession->nWapiRspIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013155 qdf_mem_copy(pBuf, pSession->pWapiRspIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013156 pSession->nWapiRspIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013157 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013158 }
13159 }
13160 }
13161 return status;
13162}
13163#endif /* FEATURE_WLAN_WAPI */
13164eRoamCmdStatus csr_get_roam_complete_status(tpAniSirGlobal pMac, uint32_t sessionId)
13165{
13166 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
13167 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13168
13169 if (!pSession) {
13170 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
13171 return retStatus;
13172 }
13173
13174 if (CSR_IS_ROAMING(pSession)) {
13175 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
13176 pSession->fRoaming = false;
13177 }
13178 return retStatus;
13179}
13180
13181/* This function remove the connected BSS from te cached scan result */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013182QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013183csr_roam_remove_connected_bss_from_scan_cache(tpAniSirGlobal pMac,
13184 tCsrRoamConnectedProfile *pConnProfile)
13185{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013186 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013187 tCsrScanResultFilter *pScanFilter = NULL;
13188 tListElem *pEntry;
13189 tCsrScanResult *pResult;
13190 tDot11fBeaconIEs *pIes;
13191 bool fMatch;
13192
Anurag Chouhanc5548422016-02-24 18:33:27 +053013193 if ((qdf_is_macaddr_zero(&pConnProfile->bssid) ||
13194 qdf_is_macaddr_broadcast(&pConnProfile->bssid)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013195 return status;
13196 /*
13197 * Prepare the filter. Only fill in the necessary fields. Not all fields
13198 * are needed
13199 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013200 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013201 if (NULL == pScanFilter)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013202 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013203
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013204 qdf_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
13205 pScanFilter->BSSIDs.bssid = qdf_mem_malloc(sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013206 if (NULL == pScanFilter->BSSIDs.bssid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013207 qdf_mem_free(pScanFilter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013208 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013209 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013210 qdf_mem_copy(pScanFilter->BSSIDs.bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053013211 &pConnProfile->bssid, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013212 pScanFilter->BSSIDs.numOfBSSIDs = 1;
13213 if (!csr_is_nullssid(pConnProfile->SSID.ssId,
13214 pConnProfile->SSID.length)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013215 pScanFilter->SSIDs.SSIDList = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013216 sizeof(tCsrSSIDInfo));
13217 if (NULL == pScanFilter->SSIDs.SSIDList) {
13218 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013219 qdf_mem_free(pScanFilter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013220 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013221 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013222 qdf_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013223 &pConnProfile->SSID, sizeof(tSirMacSSid));
13224 }
13225 pScanFilter->authType.numEntries = 1;
13226 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
13227 pScanFilter->BSSType = pConnProfile->BSSType;
13228 pScanFilter->EncryptionType.numEntries = 1;
13229 pScanFilter->EncryptionType.encryptionType[0] =
13230 pConnProfile->EncryptionType;
13231 pScanFilter->mcEncryptionType.numEntries = 1;
13232 pScanFilter->mcEncryptionType.encryptionType[0] =
13233 pConnProfile->mcEncryptionType;
13234 /* We ignore the channel for now, BSSID should be enough */
13235 pScanFilter->ChannelInfo.numOfChannels = 0;
13236 /* Also ignore the following fields */
13237 pScanFilter->uapsd_mask = 0;
13238 pScanFilter->bWPSAssociation = false;
13239 pScanFilter->bOSENAssociation = false;
13240 pScanFilter->countryCode[0] = 0;
13241 pScanFilter->phyMode = eCSR_DOT11_MODE_AUTO;
Krunal Sonib2f13042015-11-02 18:41:08 -080013242#ifdef WLAN_FEATURE_11W
13243 pScanFilter->MFPEnabled = pConnProfile->MFPEnabled;
13244 pScanFilter->MFPRequired = pConnProfile->MFPRequired;
13245 pScanFilter->MFPCapable = pConnProfile->MFPCapable;
13246#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013247 csr_ll_lock(&pMac->scan.scanResultList);
13248 pEntry = csr_ll_peek_head(&pMac->scan.scanResultList, LL_ACCESS_NOLOCK);
13249 while (pEntry) {
13250 pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
13251 pIes = (tDot11fBeaconIEs *) (pResult->Result.pvIes);
13252 fMatch = csr_match_bss(pMac, &pResult->Result.BssDescriptor,
13253 pScanFilter, NULL, NULL, NULL, &pIes);
13254 /* Release the IEs allocated by csr_match_bss is needed */
13255 if (!pResult->Result.pvIes) {
13256 /*
13257 * need to free the IEs since it is allocated
13258 * by csr_match_bss
13259 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013260 qdf_mem_free(pIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013261 }
13262 if (fMatch) {
13263 /* We found the one */
13264 if (csr_ll_remove_entry(&pMac->scan.scanResultList,
13265 pEntry, LL_ACCESS_NOLOCK))
13266 /* Free the memory */
13267 csr_free_scan_result_entry(pMac, pResult);
13268 break;
13269 }
13270 pEntry = csr_ll_next(&pMac->scan.scanResultList,
13271 pEntry, LL_ACCESS_NOLOCK);
13272 } /* while */
13273 csr_ll_unlock(&pMac->scan.scanResultList);
13274 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013275 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013276 return status;
13277}
13278
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013279static QDF_STATUS csr_roam_start_wds(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013280 tCsrRoamProfile *pProfile,
13281 tSirBssDescription *pBssDesc)
13282{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013283 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013284 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13285 tBssConfigParam bssConfig;
13286
13287 if (!pSession) {
13288 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013289 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013290 }
13291
13292 if (csr_is_conn_state_ibss(pMac, sessionId)) {
13293 status =
13294 csr_roam_issue_stop_bss(pMac, sessionId,
13295 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING);
13296 } else if (csr_is_conn_state_connected_infra(pMac, sessionId)) {
13297 /* Disassociate from the connected Infrastructure network... */
13298 status =
13299 csr_roam_issue_disassociate(pMac, sessionId,
13300 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
13301 false);
13302 } else {
13303 /* We don't expect Bt-AMP HDD not to disconnect the last connection first at this time. */
13304 /* Otherwise we need to add code to handle the */
13305 /* situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then */
13306 /* send stop_bss to PE, before we can continue. */
13307
13308 if (csr_is_conn_state_wds(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013309 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013310 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013311 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013312 qdf_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013313 /* Assume HDD provide bssid in profile */
Anurag Chouhanc5548422016-02-24 18:33:27 +053013314 qdf_copy_macaddr(&pSession->bssParams.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013315 pProfile->BSSIDs.bssid);
13316 /* there is no Bss description before we start an WDS so we need */
13317 /* to adopt all Bss configuration parameters from the Profile. */
13318 status =
13319 csr_roam_prepare_bss_config_from_profile(pMac, pProfile,
13320 &bssConfig, pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013321 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013322 /* Save profile for late use */
13323 csr_free_roam_profile(pMac, sessionId);
13324 pSession->pCurRoamProfile =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013325 qdf_mem_malloc(sizeof(tCsrRoamProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013326 if (pSession->pCurRoamProfile != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013327 qdf_mem_set(pSession->pCurRoamProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013328 sizeof(tCsrRoamProfile), 0);
13329 csr_roam_copy_profile(pMac,
13330 pSession->pCurRoamProfile,
13331 pProfile);
13332 }
13333 /* Prepare some more parameters for this WDS */
13334 csr_roam_prepare_bss_params(pMac, sessionId, pProfile, NULL,
13335 &bssConfig, NULL);
13336 status =
13337 csr_roam_set_bss_config_cfg(pMac, sessionId, pProfile,
13338 NULL, &bssConfig, NULL,
13339 false);
13340 }
13341 }
13342
13343 return status;
13344}
13345
13346/**
13347 * csr_add_supported_5Ghz_channels()- Add valid 5Ghz channels
13348 * in Join req.
13349 * @mac_ctx: pointer to global mac structure
13350 * @csr_join_req: join req sent to lim
13351 *
13352 * This function is called to update valid 5Ghz channels
13353 * in Join req.
13354 *
13355 * Return: void
13356 */
13357static void csr_add_supported_5Ghz_channels(tpAniSirGlobal mac_ctx,
13358 tSirSmeJoinReq *csr_join_req)
13359{
13360 uint16_t i, j;
13361 uint32_t size = 0;
13362
13363 if (!csr_join_req) {
13364 sms_log(mac_ctx, LOGE, FL(" csr_join_reqis NULL"));
13365 return;
13366 }
13367
13368 size = sizeof(mac_ctx->roam.validChannelList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013369 if (QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013370 (csr_get_cfg_valid_channels(mac_ctx,
13371 (uint8_t *) mac_ctx->roam.validChannelList,
13372 &size))) {
13373 for (i = 0, j = 0; i < size; i++) {
13374 /* Only add 5ghz channels.*/
13375 if (CDS_IS_CHANNEL_5GHZ
13376 (mac_ctx->roam.validChannelList[i])) {
13377 csr_join_req->supportedChannels.channelList[j] =
13378 mac_ctx->roam.validChannelList[i];
13379 j++;
13380 }
13381 }
13382 csr_join_req->supportedChannels.numChnl = j;
13383 } else {
13384 sms_log(mac_ctx, LOGE,
13385 FL("can not find any valid channel"));
13386 csr_join_req->supportedChannels.numChnl = 0;
13387 }
13388}
13389
13390/**
13391 * The communication between HDD and LIM is thru mailbox (MB).
13392 * Both sides will access the data structure "tSirSmeJoinReq".
13393 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the
13394 * regular way like tSirSmeJoinReq.assocType, this guideline stops at component
13395 * tSirRSNie;
13396 * any acces to the components after tSirRSNie is forbidden because the space
13397 * from tSirRSNie is squeezed with the component "tSirBssDescription" and since
13398 * the size of actual 'tSirBssDescription' varies, the receiving side should
13399 * keep in mind not to access the components DIRECTLY after tSirRSNie.
13400 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013401QDF_STATUS csr_send_join_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013402 tSirBssDescription *pBssDescription,
13403 tCsrRoamProfile *pProfile,
13404 tDot11fBeaconIEs *pIes, uint16_t messageType)
13405{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013406 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013407 uint8_t acm_mask = 0, uapsd_mask;
13408 uint16_t msgLen, ieLen;
13409 tSirMacRateSet OpRateSet;
13410 tSirMacRateSet ExRateSet;
13411 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13412 uint32_t dwTmp, ucDot11Mode = 0;
13413 /* RSN MAX is bigger than WPA MAX */
13414 uint8_t wpaRsnIE[DOT11F_IE_RSN_MAX_LEN];
13415 uint8_t txBFCsnValue = 0;
13416 tSirSmeJoinReq *csr_join_req;
13417 tSirMacCapabilityInfo *pAP_capabilityInfo;
13418 tAniBool fTmp;
13419 int8_t pwrLimit = 0;
13420 struct ps_global_info *ps_global_info = &pMac->sme.ps_global_info;
13421 struct ps_params *ps_param = &ps_global_info->ps_params[sessionId];
13422 uint8_t ese_config = 0;
13423
13424
13425 if (!pSession) {
13426 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013427 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013428 }
13429 /* To satisfy klockworks */
13430 if (NULL == pBssDescription) {
13431 sms_log(pMac, LOGE, FL(" pBssDescription is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013432 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013433 }
13434
13435 do {
13436 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13437 pSession->joinFailStatusCode.reasonCode = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013438 qdf_mem_copy(&pSession->joinFailStatusCode.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013439 &pBssDescription->bssId, sizeof(tSirMacAddr));
13440 /*
13441 * the tSirSmeJoinReq which includes a single
13442 * bssDescription. it includes a single uint32_t for the
13443 * IE fields, but the length field in the bssDescription
13444 * needs to be interpreted to determine length of IE fields
13445 * So, take the size of the tSirSmeJoinReq, subtract size of
13446 * bssDescription, add the number of bytes indicated by the
13447 * length field of the bssDescription, add the size of length
13448 * field because it not included in the lenghth field.
13449 */
13450 msgLen = sizeof(tSirSmeJoinReq) - sizeof(*pBssDescription) +
13451 pBssDescription->length +
13452 sizeof(pBssDescription->length) +
13453 /*
13454 * add in the size of the WPA IE that
13455 * we may build.
13456 */
13457 sizeof(tCsrWpaIe) + sizeof(tCsrWpaAuthIe) +
13458 sizeof(uint16_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013459 csr_join_req = qdf_mem_malloc(msgLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013460 if (NULL == csr_join_req)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013461 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013462 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013463 status = QDF_STATUS_SUCCESS;
13464 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013465 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013466 qdf_mem_set(csr_join_req, msgLen, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013467 csr_join_req->messageType = messageType;
13468 csr_join_req->length = msgLen;
13469 csr_join_req->sessionId = (uint8_t) sessionId;
13470 csr_join_req->transactionId = 0;
13471 if (pIes->SSID.present && pIes->SSID.num_ssid) {
13472 csr_join_req->ssId.length = pIes->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013473 qdf_mem_copy(&csr_join_req->ssId.ssId, pIes->SSID.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013474 pIes->SSID.num_ssid);
13475 } else
13476 csr_join_req->ssId.length = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013477 qdf_mem_copy(&csr_join_req->selfMacAddr, &pSession->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013478 sizeof(tSirMacAddr));
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -080013479 sms_log(pMac, LOGE,
13480 "Connecting to ssid:%.*s bssid: "
13481 MAC_ADDRESS_STR" rssi: %d channel: %d country_code: %c%c",
13482 pIes->SSID.num_ssid, pIes->SSID.ssid,
13483 MAC_ADDR_ARRAY(pBssDescription->bssId),
13484 pBssDescription->rssi, pBssDescription->channelId,
13485 pMac->scan.countryCodeCurrent[0],
13486 pMac->scan.countryCodeCurrent[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013487 /* bsstype */
13488 dwTmp = csr_translate_bsstype_to_mac_type
13489 (pProfile->BSSType);
13490 /* Override BssType for BTAMP */
13491 if (dwTmp == eSIR_BTAMP_STA_MODE)
13492 dwTmp = eSIR_BTAMP_AP_MODE;
13493 csr_join_req->bsstype = dwTmp;
13494 /* dot11mode */
13495 ucDot11Mode =
13496 csr_translate_to_wni_cfg_dot11_mode(pMac,
13497 pSession->bssParams.
13498 uCfgDot11Mode);
13499 if (pBssDescription->channelId <= 14
13500 && false == pMac->roam.configParam.enableVhtFor24GHz
13501 && WNI_CFG_DOT11_MODE_11AC == ucDot11Mode) {
13502 /* Need to disable VHT operation in 2.4 GHz band */
13503 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
13504 }
13505 csr_join_req->dot11mode = (uint8_t) ucDot11Mode;
13506#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
13507 csr_join_req->cc_switch_mode =
13508 pMac->roam.configParam.cc_switch_mode;
13509#endif
13510 csr_join_req->staPersona = (uint8_t) pProfile->csrPersona;
13511 csr_join_req->cbMode = (uint8_t) pSession->bssParams.cbMode;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013512 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013513 FL("CSR PERSONA=%d CSR CbMode %d"),
13514 pProfile->csrPersona, pSession->bssParams.cbMode);
13515 csr_join_req->uapsdPerAcBitmask = pProfile->uapsd_mask;
13516 status =
13517 csr_get_rate_set(pMac, pProfile,
13518 (eCsrPhyMode) pProfile->phyMode,
13519 pBssDescription, pIes, &OpRateSet,
13520 &ExRateSet);
13521 ps_param->uapsd_per_ac_bit_mask =
13522 pProfile->uapsd_mask;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013523 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013524 /* OperationalRateSet */
13525 if (OpRateSet.numRates) {
13526 csr_join_req->operationalRateSet.numRates =
13527 OpRateSet.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013528 qdf_mem_copy(&csr_join_req->operationalRateSet.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013529 rate, OpRateSet.rate,
13530 OpRateSet.numRates);
13531 } else
13532 csr_join_req->operationalRateSet.numRates = 0;
13533
13534 /* ExtendedRateSet */
13535 if (ExRateSet.numRates) {
13536 csr_join_req->extendedRateSet.numRates =
13537 ExRateSet.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013538 qdf_mem_copy(&csr_join_req->extendedRateSet.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013539 rate, ExRateSet.rate,
13540 ExRateSet.numRates);
13541 } else
13542 csr_join_req->extendedRateSet.numRates = 0;
13543 } else {
13544 csr_join_req->operationalRateSet.numRates = 0;
13545 csr_join_req->extendedRateSet.numRates = 0;
13546 }
13547 /* rsnIE */
13548 if (csr_is_profile_wpa(pProfile)) {
13549 /* Insert the Wpa IE into the join request */
13550 ieLen =
13551 csr_retrieve_wpa_ie(pMac, pProfile,
13552 pBssDescription, pIes,
13553 (tCsrWpaIe *) (wpaRsnIE));
13554 } else if (csr_is_profile_rsn(pProfile)) {
13555 /* Insert the RSN IE into the join request */
13556 ieLen =
13557 csr_retrieve_rsn_ie(pMac, sessionId, pProfile,
13558 pBssDescription, pIes,
13559 (tCsrRSNIe *) (wpaRsnIE));
13560 }
13561#ifdef FEATURE_WLAN_WAPI
13562 else if (csr_is_profile_wapi(pProfile)) {
13563 /* Insert the WAPI IE into the join request */
13564 ieLen =
13565 csr_retrieve_wapi_ie(pMac, sessionId, pProfile,
13566 pBssDescription, pIes,
13567 (tCsrWapiIe *) (wpaRsnIE));
13568 }
13569#endif /* FEATURE_WLAN_WAPI */
13570 else {
13571 ieLen = 0;
13572 }
13573 /* remember the IE for future use */
13574 if (ieLen) {
13575 if (ieLen > DOT11F_IE_RSN_MAX_LEN) {
13576 sms_log(pMac, LOGE,
13577 FL
13578 (" WPA RSN IE length :%d is more than DOT11F_IE_RSN_MAX_LEN, resetting to %d"),
13579 ieLen, DOT11F_IE_RSN_MAX_LEN);
13580 ieLen = DOT11F_IE_RSN_MAX_LEN;
13581 }
13582#ifdef FEATURE_WLAN_WAPI
13583 if (csr_is_profile_wapi(pProfile)) {
13584 /* Check whether we need to allocate more mem */
13585 if (ieLen > pSession->nWapiReqIeLength) {
13586 if (pSession->pWapiReqIE
13587 && pSession->nWapiReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013588 qdf_mem_free(pSession->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013589 pWapiReqIE);
13590 }
13591 pSession->pWapiReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013592 qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013593 if (NULL == pSession->pWapiReqIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013594 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013595 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013596 status = QDF_STATUS_SUCCESS;
13597 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013598 break;
13599 }
13600 pSession->nWapiReqIeLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013601 qdf_mem_copy(pSession->pWapiReqIE, wpaRsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013602 ieLen);
13603 csr_join_req->rsnIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013604 qdf_mem_copy(&csr_join_req->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013605 wpaRsnIE, ieLen);
13606 } else /* should be WPA/WPA2 otherwise */
13607#endif /* FEATURE_WLAN_WAPI */
13608 {
13609 /* Check whether we need to allocate more mem */
13610 if (ieLen > pSession->nWpaRsnReqIeLength) {
13611 if (pSession->pWpaRsnReqIE
13612 && pSession->nWpaRsnReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013613 qdf_mem_free(pSession->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013614 pWpaRsnReqIE);
13615 }
13616 pSession->pWpaRsnReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013617 qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013618 if (NULL == pSession->pWpaRsnReqIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013619 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013620 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013621 status = QDF_STATUS_SUCCESS;
13622 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013623 break;
13624 }
13625 pSession->nWpaRsnReqIeLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013626 qdf_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013627 ieLen);
13628 csr_join_req->rsnIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013629 qdf_mem_copy(&csr_join_req->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013630 wpaRsnIE, ieLen);
13631 }
13632 } else {
13633 /* free whatever old info */
13634 pSession->nWpaRsnReqIeLength = 0;
13635 if (pSession->pWpaRsnReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013636 qdf_mem_free(pSession->pWpaRsnReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013637 pSession->pWpaRsnReqIE = NULL;
13638 }
13639#ifdef FEATURE_WLAN_WAPI
13640 pSession->nWapiReqIeLength = 0;
13641 if (pSession->pWapiReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013642 qdf_mem_free(pSession->pWapiReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013643 pSession->pWapiReqIE = NULL;
13644 }
13645#endif /* FEATURE_WLAN_WAPI */
13646 csr_join_req->rsnIE.length = 0;
13647 }
13648#ifdef FEATURE_WLAN_ESE
13649 if (eWNI_SME_JOIN_REQ == messageType)
13650 csr_join_req->cckmIE.length = 0;
13651 else if (eWNI_SME_REASSOC_REQ == messageType) {
13652 /* cckmIE */
13653 if (csr_is_profile_ese(pProfile)) {
13654 /* Insert the CCKM IE into the join request */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013655 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013656 qdf_mem_copy((void *)(wpaRsnIE),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013657 pSession->suppCckmIeInfo.cckmIe,
13658 ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013659 } else
13660 ieLen = 0;
13661 /*
13662 * If present, copy the IE into the
13663 * eWNI_SME_REASSOC_REQ message buffer
13664 */
13665 if (ieLen) {
13666 /*
13667 * Copy the CCKM IE over from the temp
13668 * buffer (wpaRsnIE)
13669 */
13670 csr_join_req->cckmIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013671 qdf_mem_copy(&csr_join_req->cckmIE.cckmIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013672 wpaRsnIE, ieLen);
13673 } else
13674 csr_join_req->cckmIE.length = 0;
13675 }
13676#endif /* FEATURE_WLAN_ESE */
13677 /* addIEScan */
13678 if (pProfile->nAddIEScanLength && pProfile->pAddIEScan) {
13679 ieLen = pProfile->nAddIEScanLength;
13680 if (ieLen > pSession->nAddIEScanLength) {
13681 if (pSession->pAddIEScan
13682 && pSession->nAddIEScanLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013683 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013684 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013685 pSession->pAddIEScan = qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013686 if (NULL == pSession->pAddIEScan)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013687 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013688 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013689 status = QDF_STATUS_SUCCESS;
13690 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013691 break;
13692 }
13693 pSession->nAddIEScanLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013694 qdf_mem_copy(pSession->pAddIEScan, pProfile->pAddIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013695 ieLen);
13696 csr_join_req->addIEScan.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013697 qdf_mem_copy(&csr_join_req->addIEScan.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013698 pProfile->pAddIEScan, ieLen);
13699 } else {
13700 pSession->nAddIEScanLength = 0;
13701 if (pSession->pAddIEScan) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013702 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013703 pSession->pAddIEScan = NULL;
13704 }
13705 csr_join_req->addIEScan.length = 0;
13706 }
13707 /* addIEAssoc */
13708 if (pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc) {
13709 ieLen = pProfile->nAddIEAssocLength;
13710 if (ieLen > pSession->nAddIEAssocLength) {
13711 if (pSession->pAddIEAssoc
13712 && pSession->nAddIEAssocLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013713 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013714 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013715 pSession->pAddIEAssoc = qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013716 if (NULL == pSession->pAddIEAssoc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013717 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013718 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013719 status = QDF_STATUS_SUCCESS;
13720 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013721 break;
13722 }
13723 pSession->nAddIEAssocLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013724 qdf_mem_copy(pSession->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013725 pProfile->pAddIEAssoc, ieLen);
13726 csr_join_req->addIEAssoc.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013727 qdf_mem_copy(&csr_join_req->addIEAssoc.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013728 pProfile->pAddIEAssoc, ieLen);
13729 } else {
13730 pSession->nAddIEAssocLength = 0;
13731 if (pSession->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013732 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013733 pSession->pAddIEAssoc = NULL;
13734 }
13735 csr_join_req->addIEAssoc.length = 0;
13736 }
13737
13738 if (eWNI_SME_REASSOC_REQ == messageType) {
13739 /* Unmask any AC in reassoc that is ACM-set */
13740 uapsd_mask = (uint8_t) pProfile->uapsd_mask;
13741 if (uapsd_mask && (NULL != pBssDescription)) {
13742 if (CSR_IS_QOS_BSS(pIes)
13743 && CSR_IS_UAPSD_BSS(pIes))
13744#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13745 acm_mask =
13746 sme_qos_get_acm_mask(pMac,
13747 pBssDescription,
13748 pIes);
13749#endif /* WLAN_MDM_CODE_REDUCTION_OPT */
13750 else
13751 uapsd_mask = 0;
13752 }
13753 }
13754
13755 csr_join_req->UCEncryptionType =
13756 csr_translate_encrypt_type_to_ed_type
13757 (pProfile->negotiatedUCEncryptionType);
13758
13759 csr_join_req->MCEncryptionType =
13760 csr_translate_encrypt_type_to_ed_type
13761 (pProfile->negotiatedMCEncryptionType);
13762#ifdef WLAN_FEATURE_11W
13763 if (pProfile->MFPEnabled)
13764 csr_join_req->MgmtEncryptionType = eSIR_ED_AES_128_CMAC;
13765 else
13766 csr_join_req->MgmtEncryptionType = eSIR_ED_NONE;
13767#endif
13768#ifdef FEATURE_WLAN_ESE
13769 ese_config = pMac->roam.configParam.isEseIniFeatureEnabled;
13770#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013771 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
13772 if (csr_is_profile11r(pProfile)
13773#ifdef FEATURE_WLAN_ESE
13774 &&
13775 !((pProfile->negotiatedAuthType ==
13776 eCSR_AUTH_TYPE_OPEN_SYSTEM) && (pIes->ESEVersion.present)
13777 && (ese_config))
13778#endif
13779 )
13780 csr_join_req->is11Rconnection = true;
13781 else
13782 csr_join_req->is11Rconnection = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013783#ifdef FEATURE_WLAN_ESE
13784 if (true == ese_config)
13785 csr_join_req->isESEFeatureIniEnabled = true;
13786 else
13787 csr_join_req->isESEFeatureIniEnabled = false;
13788
13789 /* A profile can not be both ESE and 11R. But an 802.11R AP
13790 * may be advertising support for ESE as well. So if we are
13791 * associating Open or explicitly ESE then we will get ESE.
13792 * If we are associating explictly 11R only then we will get
13793 * 11R.
13794 */
13795 if ((csr_is_profile_ese(pProfile) ||
13796 ((pIes->ESEVersion.present) &&
13797 (pProfile->negotiatedAuthType ==
13798 eCSR_AUTH_TYPE_OPEN_SYSTEM)))
13799 && (ese_config))
13800 csr_join_req->isESEconnection = true;
13801 else
13802 csr_join_req->isESEconnection = false;
13803
13804 if (eWNI_SME_JOIN_REQ == messageType) {
13805 tESETspecInfo eseTspec;
13806 /*
13807 * ESE-Tspec IEs in the ASSOC request is presently not
13808 * supported. so nullify the TSPEC parameters
13809 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013810 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13811 qdf_mem_copy(&csr_join_req->eseTspecInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013812 &eseTspec, sizeof(tESETspecInfo));
13813 } else if (eWNI_SME_REASSOC_REQ == messageType) {
13814 if ((csr_is_profile_ese(pProfile) ||
13815 ((pIes->ESEVersion.present)
13816 && (pProfile->negotiatedAuthType ==
13817 eCSR_AUTH_TYPE_OPEN_SYSTEM))) &&
13818 (ese_config)) {
13819 tESETspecInfo eseTspec;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013820 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013821 0);
13822 eseTspec.numTspecs =
13823 sme_qos_ese_retrieve_tspec_info(pMac,
13824 sessionId,
13825 (tTspecInfo *) &eseTspec.
13826 tspec[0]);
13827 csr_join_req->eseTspecInfo.numTspecs =
13828 eseTspec.numTspecs;
13829 if (eseTspec.numTspecs) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013830 qdf_mem_copy(&csr_join_req->eseTspecInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013831 .tspec[0],
13832 &eseTspec.tspec[0],
13833 (eseTspec.numTspecs *
13834 sizeof(tTspecInfo)));
13835 }
13836 } else {
13837 tESETspecInfo eseTspec;
13838 /**
13839 * ESE-Tspec IEs in the ASSOC request is
13840 * presently not supported. so nullify the TSPEC
13841 * parameters
13842 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013843 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013844 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013845 qdf_mem_copy(&csr_join_req->eseTspecInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013846 &eseTspec,
13847 sizeof(tESETspecInfo));
13848 }
13849 }
13850#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013851 if (ese_config
Deepak Dhamdhereecce9742015-11-08 01:16:43 -080013852 || csr_roam_is_fast_roam_enabled(pMac, sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013853 csr_join_req->isFastTransitionEnabled = true;
13854 } else {
13855 csr_join_req->isFastTransitionEnabled = false;
13856 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013857 if (csr_roam_is_fast_roam_enabled(pMac, sessionId))
13858 csr_join_req->isFastRoamIniFeatureEnabled = true;
13859 else
13860 csr_join_req->isFastRoamIniFeatureEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013861
13862 csr_join_req->txLdpcIniFeatureEnabled =
13863 (uint8_t) pMac->roam.configParam.txLdpcEnable;
13864
13865 if ((csr_is11h_supported(pMac))
13866 && (CDS_IS_CHANNEL_5GHZ(pBssDescription->channelId))
13867 && (pIes->Country.present)
13868 && (!pMac->roam.configParam.
13869 fSupplicantCountryCodeHasPriority)) {
13870 csr_save_to_channel_power2_g_5_g(pMac,
13871 pIes->Country.num_triplets *
13872 sizeof(tSirMacChanInfo),
13873 (tSirMacChanInfo *)
13874 (&pIes->Country.triplets[0]));
13875 csr_apply_power2_current(pMac);
13876 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013877 qdf_mem_copy(&csr_join_req->htConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013878 &pSession->htConfig, sizeof(tSirHTConfig));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013879 csr_join_req->txBFIniFeatureEnabled =
13880 (uint8_t) pMac->roam.configParam.txBFEnable;
13881
13882 if (pMac->roam.configParam.txBFEnable) {
13883 txBFCsnValue =
13884 (uint8_t)pMac->roam.configParam.txBFCsnValue;
13885 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps) &&
13886 pIes->VHTCaps.numSoundingDim)
Anurag Chouhan6d760662016-02-20 16:05:43 +053013887 txBFCsnValue = QDF_MIN(txBFCsnValue,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013888 pIes->VHTCaps.numSoundingDim);
13889 else if (IS_BSS_VHT_CAPABLE(pIes->vendor2_ie.VHTCaps)
13890 && pIes->vendor2_ie.VHTCaps.numSoundingDim)
Anurag Chouhan6d760662016-02-20 16:05:43 +053013891 txBFCsnValue = QDF_MIN(txBFCsnValue,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013892 pIes->vendor2_ie.VHTCaps.numSoundingDim);
13893 }
13894 csr_join_req->txBFCsnValue = txBFCsnValue;
13895
13896 csr_join_req->txMuBformee =
13897 (uint8_t) pMac->roam.configParam.txMuBformee;
13898
13899 csr_join_req->enableVhtpAid =
13900 (uint8_t) pMac->roam.configParam.enableVhtpAid;
13901
13902 csr_join_req->enableVhtGid =
13903 (uint8_t) pMac->roam.configParam.enableVhtGid;
13904
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013905 csr_join_req->enableAmpduPs =
13906 (uint8_t) pMac->roam.configParam.enableAmpduPs;
13907
13908 csr_join_req->enableHtSmps =
13909 (uint8_t) pMac->roam.configParam.enableHtSmps;
13910
13911 csr_join_req->htSmps = (uint8_t) pMac->roam.configParam.htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -080013912 csr_join_req->send_smps_action =
13913 pMac->roam.configParam.send_smps_action;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013914
13915 csr_join_req->isAmsduSupportInAMPDU =
13916 (uint8_t) pMac->roam.configParam.isAmsduSupportInAMPDU;
13917
13918 if (pMac->roam.roamSession[sessionId].fWMMConnection)
13919 csr_join_req->isWMEenabled = true;
13920 else
13921 csr_join_req->isWMEenabled = false;
13922
13923 if (pMac->roam.roamSession[sessionId].fQOSConnection)
13924 csr_join_req->isQosEnabled = true;
13925 else
13926 csr_join_req->isQosEnabled = false;
13927
13928 if (pProfile->bOSENAssociation)
13929 csr_join_req->isOSENConnection = true;
13930 else
13931 csr_join_req->isOSENConnection = false;
13932
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080013933 /* Fill rrm config parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013934 qdf_mem_copy(&csr_join_req->rrm_config,
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080013935 &pMac->rrm.rrmSmeContext.rrmConfig,
13936 sizeof(struct rrm_config_param));
13937
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013938 pAP_capabilityInfo =
13939 (tSirMacCapabilityInfo *)
13940 &pBssDescription->capabilityInfo;
13941 /*
13942 * tell the target AP my 11H capability only if both AP and STA
13943 * support
13944 * 11H and the channel being used is 11a
13945 */
13946 if (csr_is11h_supported(pMac) && pAP_capabilityInfo->spectrumMgt
13947 && eSIR_11A_NW_TYPE == pBssDescription->nwType) {
13948 fTmp = (tAniBool) 1;
13949 } else
13950 fTmp = (tAniBool) 0;
13951
13952 csr_join_req->spectrumMgtIndicator = fTmp;
13953 csr_join_req->powerCap.minTxPower = MIN_TX_PWR_CAP;
13954 /*
13955 * This is required for 11k test VoWiFi Ent: Test 2.
13956 * We need the power capabilities for Assoc Req.
13957 * This macro is provided by the halPhyCfg.h. We pick our
13958 * max and min capability by the halPhy provided macros
13959 */
13960 pwrLimit = csr_get_cfg_max_tx_power(pMac,
13961 pBssDescription->channelId);
13962 if (0 != pwrLimit)
13963 csr_join_req->powerCap.maxTxPower = pwrLimit;
13964 else
13965 csr_join_req->powerCap.maxTxPower = MAX_TX_PWR_CAP;
13966
13967 csr_add_supported_5Ghz_channels(pMac, csr_join_req);
13968
13969 csr_join_req->uapsdPerAcBitmask = (uint8_t)pProfile->uapsd_mask;
13970 /* Move the entire BssDescription into the join request. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013971 qdf_mem_copy(&csr_join_req->bssDescription, pBssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013972 pBssDescription->length +
13973 sizeof(pBssDescription->length));
13974
13975 /*
13976 * conc_custom_rule1:
13977 * If SAP comes up first and STA comes up later then SAP
13978 * need to follow STA's channel in 2.4Ghz. In following if
13979 * condition we are adding sanity check, just to make sure that
13980 * if this rule is enabled then don't allow STA to connect on
13981 * 5gz channel and also by this time SAP's channel should be the
13982 * same as STA's channel.
13983 */
13984 if (pMac->roam.configParam.conc_custom_rule1) {
13985 if ((0 ==
13986 pMac->
13987 roam.configParam.is_sta_connection_in_5gz_enabled)
13988 && CDS_IS_CHANNEL_5GHZ(pBssDescription->
13989 channelId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013990 QDF_TRACE(QDF_MODULE_ID_SME,
13991 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013992 FL("STA-conn on 5G isn't allowed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013993 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013994 break;
13995 }
13996 if (!CDS_IS_CHANNEL_5GHZ(pBssDescription->channelId) &&
13997 (false == csr_is_conn_allow_2g_band(pMac,
13998 pBssDescription->channelId))) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013999 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014000 break;
14001 }
14002 }
14003
14004 /*
14005 * conc_custom_rule2:
14006 * If P2PGO comes up first and STA comes up later then P2PGO
14007 * need to follow STA's channel in 5Ghz. In following if
14008 * condition we are just adding sanity check to make sure that
14009 * by this time P2PGO's channel is same as STA's channel.
14010 */
14011 if (pMac->roam.configParam.conc_custom_rule2) {
14012 if (!CDS_IS_CHANNEL_24GHZ(pBssDescription->channelId) &&
14013 (false == csr_is_conn_allow_5g_band(pMac,
14014 pBssDescription->channelId))) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014015 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014016 break;
14017 }
14018 }
14019 status = cds_send_mb_message_to_mac(csr_join_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014020 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014021 /*
14022 * cds_send_mb_message_to_mac would've released the mem
14023 * allocated by csr_join_req. Let's make it defensive by
14024 * assigning NULL to the pointer.
14025 */
14026 csr_join_req = NULL;
14027 break;
14028 } else {
14029#ifndef WLAN_MDM_CODE_REDUCTION_OPT
14030 if (eWNI_SME_JOIN_REQ == messageType) {
14031 /* Notify QoS module that join happening */
14032 pSession->join_bssid_count++;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053014033 QDF_TRACE(QDF_MODULE_ID_SME,
14034 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014035 "BSSID Count = %d",
14036 pSession->join_bssid_count);
14037 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
14038 SME_QOS_CSR_JOIN_REQ, NULL);
14039 } else if (eWNI_SME_REASSOC_REQ == messageType) {
14040 /* Notify QoS module that reassoc happening */
14041 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
14042 SME_QOS_CSR_REASSOC_REQ,
14043 NULL);
14044 }
14045#endif
14046 }
14047 } while (0);
14048
14049 /* Clean up the memory in case of any failure */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014050 if (!QDF_IS_STATUS_SUCCESS(status) && (NULL != csr_join_req))
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014051 qdf_mem_free(csr_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014052
14053 return status;
14054}
14055
14056/* */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014057QDF_STATUS csr_send_mb_disassoc_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014058 tSirMacAddr bssId, uint16_t reasonCode)
14059{
14060 tSirSmeDisassocReq *pMsg;
14061 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14062
14063 if (!CSR_IS_SESSION_VALID(pMac, sessionId))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014064 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014065
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014066 pMsg = qdf_mem_malloc(sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014067 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014068 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014069
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014070 qdf_mem_set(pMsg, sizeof(tSirSmeDisassocReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014071 pMsg->messageType = eWNI_SME_DISASSOC_REQ;
14072 pMsg->length = sizeof(tSirSmeDisassocReq);
14073 pMsg->sessionId = sessionId;
14074 pMsg->transactionId = 0;
14075 if ((pSession->pCurRoamProfile != NULL)
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070014076 && (CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014077 qdf_mem_copy(&pMsg->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014078 &pSession->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014079 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014080 qdf_mem_copy(&pMsg->peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014081 bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014082 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014083 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014084 qdf_mem_copy(&pMsg->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014085 bssId, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014086 qdf_mem_copy(&pMsg->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014087 bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014088 }
14089 pMsg->reasonCode = reasonCode;
14090 /*
14091 * The state will be DISASSOC_HANDOFF only when we are doing
14092 * handoff. Here we should not send the disassoc over the air
14093 * to the AP
14094 */
14095 if (CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -080014096 && csr_roam_is11r_assoc(pMac, sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014097 /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
14098 pMsg->doNotSendOverTheAir = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR;
14099 }
14100 return cds_send_mb_message_to_mac(pMsg);
14101}
14102
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014103QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014104csr_send_mb_get_associated_stas_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014105 QDF_MODULE_ID modId,
14106 struct qdf_mac_addr bssid,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014107 void *pUsrContext,
14108 void *pfnSapEventCallback,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014109 uint8_t *pAssocStasBuf)
14110{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014111 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014112 tSirSmeGetAssocSTAsReq *pMsg;
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014113
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014114 pMsg = qdf_mem_malloc(sizeof(*pMsg));
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014115 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014116 return QDF_STATUS_E_NOMEM;
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014117
14118 pMsg->messageType = eWNI_SME_GET_ASSOC_STAS_REQ;
Anurag Chouhanc5548422016-02-24 18:33:27 +053014119 qdf_copy_macaddr(&pMsg->bssid, &bssid);
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014120 pMsg->modId = modId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014121 qdf_mem_copy(pMsg->pUsrContext, pUsrContext, sizeof(void *));
14122 qdf_mem_copy(pMsg->pSapEventCallback,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014123 pfnSapEventCallback, sizeof(void *));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014124 qdf_mem_copy(pMsg->pAssocStasArray, pAssocStasBuf, sizeof(void *));
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014125 pMsg->length = sizeof(*pMsg);
14126 status = cds_send_mb_message_to_mac(pMsg);
14127
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014128 return status;
14129}
14130
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014131QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014132csr_send_mb_get_wpspbc_sessions(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014133 struct qdf_mac_addr bssid, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014134 void *pfnSapEventCallback,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014135 struct qdf_mac_addr remove_mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014136{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014137 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014138 tSirSmeGetWPSPBCSessionsReq *pMsg;
14139
14140 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014141 pMsg = qdf_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014142 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014143 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014144 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014145 status = QDF_STATUS_SUCCESS;
14146 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014147 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014148 qdf_mem_set(pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014149 pMsg->messageType = eWNI_SME_GET_WPSPBC_SESSION_REQ;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014150 qdf_mem_copy(pMsg->pUsrContext, pUsrContext, sizeof(void *));
14151 qdf_mem_copy(pMsg->pSapEventCallback, pfnSapEventCallback,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014152 sizeof(void *));
Anurag Chouhanc5548422016-02-24 18:33:27 +053014153 qdf_copy_macaddr(&pMsg->bssid, &bssid);
14154 qdf_copy_macaddr(&pMsg->remove_mac, &remove_mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014155 pMsg->length = sizeof(struct sSirSmeGetWPSPBCSessionsReq);
14156 status = cds_send_mb_message_to_mac(pMsg);
14157 } while (0);
14158 return status;
14159}
14160
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014161QDF_STATUS csr_send_chng_mcc_beacon_interval(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014162{
14163 tpSirChangeBIParams pMsg;
14164 uint16_t len = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014165 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014166 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14167
14168 if (!pSession) {
14169 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014170 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014171 }
14172 /* NO need to update the Beacon Params if update beacon parameter flag is not set */
14173 if (!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014174 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014175
14176 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval =
14177 false;
14178
14179 /* Create the message and send to lim */
14180 len = sizeof(tSirChangeBIParams);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014181 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014182 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014183 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014184 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014185 status = QDF_STATUS_SUCCESS;
14186 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014187 qdf_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014188 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
14189 pMsg->length = len;
14190
Anurag Chouhanc5548422016-02-24 18:33:27 +053014191 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014192 sms_log(pMac, LOG1,
14193 FL("CSR Attempting to change BI for Bssid= "
Srinivas Girigowda8e717d32015-11-24 15:54:33 -080014194 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pMsg->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014195 pMsg->sessionId = sessionId;
14196 sms_log(pMac, LOG1, FL(" session %d BeaconInterval %d"),
14197 sessionId,
14198 pMac->roam.roamSession[sessionId].bssParams.
14199 beaconInterval);
14200 pMsg->beaconInterval =
14201 pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
14202 status = cds_send_mb_message_to_mac(pMsg);
14203 }
14204 return status;
14205}
14206
14207#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014208QDF_STATUS csr_set_ht2040_mode(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014209 ePhyChanBondState cbMode, bool obssEnabled)
14210{
14211 tpSirSetHT2040Mode pMsg;
14212 uint16_t len = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014213 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014214 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14215
14216 if (!pSession) {
14217 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014218 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014219 }
14220
14221 /* Create the message and send to lim */
14222 len = sizeof(tSirSetHT2040Mode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014223 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014224 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014225 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014226 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014227 status = QDF_STATUS_SUCCESS;
14228 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014229 qdf_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014230 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
14231 pMsg->length = len;
14232
Anurag Chouhanc5548422016-02-24 18:33:27 +053014233 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014234 sms_log(pMac, LOG1,
14235 FL("CSR Attempting to set HT20/40 mode for Bssid= "
Srinivas Girigowdac52474d2015-11-24 15:49:31 -080014236 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pMsg->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014237 pMsg->sessionId = sessionId;
14238 sms_log(pMac, LOG1, FL(" session %d HT20/40 mode %d"),
14239 sessionId, cbMode);
14240 pMsg->cbMode = cbMode;
14241 pMsg->obssEnabled = obssEnabled;
14242 status = cds_send_mb_message_to_mac(pMsg);
14243 }
14244 return status;
14245}
14246#endif
14247
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014248QDF_STATUS csr_send_mb_deauth_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014249 tSirMacAddr bssId, uint16_t reasonCode)
14250{
14251 tSirSmeDeauthReq *pMsg;
14252 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14253
14254 if (!CSR_IS_SESSION_VALID(pMac, sessionId))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014255 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014256
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014257 pMsg = qdf_mem_malloc(sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014258 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014259 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014260
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014261 qdf_mem_set(pMsg, sizeof(tSirSmeDeauthReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014262 pMsg->messageType = eWNI_SME_DEAUTH_REQ;
14263 pMsg->length = sizeof(tSirSmeDeauthReq);
14264 pMsg->sessionId = sessionId;
14265 pMsg->transactionId = 0;
14266
14267 if ((pSession->pCurRoamProfile != NULL)
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070014268 && (CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014269 qdf_mem_copy(&pMsg->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014270 &pSession->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014271 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014272 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014273 qdf_mem_copy(&pMsg->bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014274 bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014275 }
14276
14277 /* Set the peer MAC address before sending the message to LIM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014278 qdf_mem_copy(&pMsg->peer_macaddr.bytes, bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014279 pMsg->reasonCode = reasonCode;
14280
14281 return cds_send_mb_message_to_mac(pMsg);
14282}
14283
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014284QDF_STATUS csr_send_mb_disassoc_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014285 tpSirSmeDisassocInd pDisassocInd)
14286{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014287 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014288 tSirSmeDisassocCnf *pMsg;
14289 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014290 pMsg = qdf_mem_malloc(sizeof(tSirSmeDisassocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014291 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014292 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014293 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014294 status = QDF_STATUS_SUCCESS;
14295 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014296 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014297 qdf_mem_set(pMsg, sizeof(tSirSmeDisassocCnf), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014298 pMsg->messageType = eWNI_SME_DISASSOC_CNF;
14299 pMsg->statusCode = eSIR_SME_SUCCESS;
14300 pMsg->length = sizeof(tSirSmeDisassocCnf);
Anurag Chouhanc5548422016-02-24 18:33:27 +053014301 qdf_copy_macaddr(&pMsg->peer_macaddr,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080014302 &pDisassocInd->peer_macaddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014303 status = QDF_STATUS_SUCCESS;
14304 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014305 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014306 break;
14307 }
14308
Anurag Chouhanc5548422016-02-24 18:33:27 +053014309 qdf_copy_macaddr(&pMsg->bssid, &pDisassocInd->bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014310 status = QDF_STATUS_SUCCESS;
14311 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014312 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014313 break;
14314 }
14315
14316 status = cds_send_mb_message_to_mac(pMsg);
14317 } while (0);
14318 return status;
14319}
14320
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014321QDF_STATUS csr_send_mb_deauth_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014322 tpSirSmeDeauthInd pDeauthInd)
14323{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014324 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014325 tSirSmeDeauthCnf *pMsg;
14326 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014327 pMsg = qdf_mem_malloc(sizeof(tSirSmeDeauthCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014328 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014329 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014330 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014331 status = QDF_STATUS_SUCCESS;
14332 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014333 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014334 qdf_mem_set(pMsg, sizeof(tSirSmeDeauthCnf), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014335 pMsg->messageType = eWNI_SME_DEAUTH_CNF;
14336 pMsg->statusCode = eSIR_SME_SUCCESS;
14337 pMsg->length = sizeof(tSirSmeDeauthCnf);
Anurag Chouhanc5548422016-02-24 18:33:27 +053014338 qdf_copy_macaddr(&pMsg->bssid, &pDeauthInd->bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014339 status = QDF_STATUS_SUCCESS;
14340 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014341 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014342 break;
14343 }
Anurag Chouhanc5548422016-02-24 18:33:27 +053014344 qdf_copy_macaddr(&pMsg->peer_macaddr,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -080014345 &pDeauthInd->peer_macaddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014346 status = QDF_STATUS_SUCCESS;
14347 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014348 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014349 break;
14350 }
14351 status = cds_send_mb_message_to_mac(pMsg);
14352 } while (0);
14353 return status;
14354}
14355
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014356QDF_STATUS csr_send_assoc_cnf_msg(tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd,
14357 QDF_STATUS Halstatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014358{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014359 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014360 tSirSmeAssocCnf *pMsg;
14361
14362 sms_log(pMac, LOG1,
14363 FL("Posting eWNI_SME_ASSOC_CNF to LIM.HalStatus :%d"),
14364 Halstatus);
14365 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014366 pMsg = qdf_mem_malloc(sizeof(tSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014367 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014368 return QDF_STATUS_E_NOMEM;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014369 qdf_mem_set(pMsg, sizeof(tSirSmeAssocCnf), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014370 pMsg->messageType = eWNI_SME_ASSOC_CNF;
14371 pMsg->length = sizeof(tSirSmeAssocCnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014372 if (QDF_IS_STATUS_SUCCESS(Halstatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014373 pMsg->statusCode = eSIR_SME_SUCCESS;
14374 else
14375 pMsg->statusCode = eSIR_SME_ASSOC_REFUSED;
14376 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014377 qdf_mem_copy(pMsg->bssid.bytes, pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014378 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014379 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014380 qdf_mem_copy(pMsg->peer_macaddr.bytes, pAssocInd->peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014381 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014382 /* aid */
14383 pMsg->aid = pAssocInd->aid;
14384 /* alternateBssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014385 qdf_mem_copy(pMsg->alternate_bssid.bytes, pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014386 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014387 /* alternateChannelId */
14388 pMsg->alternateChannelId = 11;
14389 /* pMsg is freed by cds_send_mb_message_to_mac in anycase*/
14390 status = cds_send_mb_message_to_mac(pMsg);
14391 } while (0);
14392 return status;
14393}
14394
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014395QDF_STATUS csr_send_assoc_ind_to_upper_layer_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014396 tpSirSmeAssocInd pAssocInd,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014397 QDF_STATUS Halstatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014398 uint8_t sessionId)
14399{
14400 tSirMsgQ msgQ;
14401 tSirSmeAssocIndToUpperLayerCnf *pMsg;
14402 uint8_t *pBuf;
14403 tSirResultCodes statusCode;
14404 uint16_t wTmp;
14405 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014406 pMsg = qdf_mem_malloc(sizeof(tSirSmeAssocIndToUpperLayerCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014407 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014408 return QDF_STATUS_E_NOMEM;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014409 qdf_mem_set(pMsg, sizeof(tSirSmeAssocIndToUpperLayerCnf), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014410
14411 pMsg->messageType = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
14412 pMsg->length = sizeof(tSirSmeAssocIndToUpperLayerCnf);
14413
14414 pMsg->sessionId = sessionId;
14415
14416 pBuf = (uint8_t *) &pMsg->statusCode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014417 if (QDF_IS_STATUS_SUCCESS(Halstatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014418 statusCode = eSIR_SME_SUCCESS;
14419 else
14420 statusCode = eSIR_SME_ASSOC_REFUSED;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014421 qdf_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014422 pBuf += sizeof(tSirResultCodes);
14423 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014424 qdf_mem_copy((tSirMacAddr *) pBuf, pAssocInd->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014425 sizeof(tSirMacAddr));
14426 pBuf += sizeof(tSirMacAddr);
14427 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014428 qdf_mem_copy((tSirMacAddr *) pBuf, pAssocInd->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014429 sizeof(tSirMacAddr));
14430 pBuf += sizeof(tSirMacAddr);
14431 /* StaId */
14432 wTmp = pAssocInd->staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014433 qdf_mem_copy(pBuf, &wTmp, sizeof(uint16_t));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014434 pBuf += sizeof(uint16_t);
14435 /* alternateBssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014436 qdf_mem_copy((tSirMacAddr *) pBuf, pAssocInd->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014437 sizeof(tSirMacAddr));
14438 pBuf += sizeof(tSirMacAddr);
14439 /* alternateChannelId */
14440 *pBuf = 11;
14441 pBuf += sizeof(uint8_t);
14442 /* Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information */
14443 /* Wmm */
14444 *pBuf = pAssocInd->wmmEnabledSta;
14445 pBuf += sizeof(uint8_t);
14446 /* RSN IE */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014447 qdf_mem_copy((tSirRSNie *) pBuf, &pAssocInd->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014448 sizeof(tSirRSNie));
14449 pBuf += sizeof(tSirRSNie);
14450#ifdef FEATURE_WLAN_WAPI
14451 /* WAPI IE */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014452 qdf_mem_copy((tSirWAPIie *) pBuf, &pAssocInd->wapiIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014453 sizeof(tSirWAPIie));
14454 pBuf += sizeof(tSirWAPIie);
14455#endif
14456 /* Additional IE */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014457 qdf_mem_copy((void *)pBuf, &pAssocInd->addIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014458 sizeof(tSirAddie));
14459 pBuf += sizeof(tSirAddie);
14460 /* reassocReq */
14461 *pBuf = pAssocInd->reassocReq;
14462 pBuf += sizeof(uint8_t);
14463 /* timingMeasCap */
14464 *pBuf = pAssocInd->timingMeasCap;
14465 pBuf += sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014466 qdf_mem_copy((void *)pBuf, &pAssocInd->chan_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014467 sizeof(tSirSmeChanInfo));
14468 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
14469 msgQ.bodyptr = pMsg;
14470 msgQ.bodyval = 0;
14471 sys_process_mmh_msg(pMac, &msgQ);
14472 } while (0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014473 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014474}
14475
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014476QDF_STATUS csr_send_mb_set_context_req_msg(tpAniSirGlobal pMac,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080014477 uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014478 struct qdf_mac_addr peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080014479 uint8_t numKeys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014480 tAniEdType edType, bool fUnicast,
14481 tAniKeyDirection aniKeyDirection,
14482 uint8_t keyId, uint8_t keyLength,
14483 uint8_t *pKey, uint8_t paeRole,
14484 uint8_t *pKeyRsc)
14485{
14486 tSirSmeSetContextReq *pMsg;
14487 uint16_t msgLen;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014488 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014489 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14490 sms_log(pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
14491 keyLength, edType);
14492 do {
14493 if ((1 != numKeys) && (0 != numKeys))
14494 break;
14495 /*
14496 * All of these fields appear in every SET_CONTEXT message.
14497 * Below we'll add in the size for each key set. Since we only support
14498 * up to one key, we always allocate memory for 1 key.
14499 */
14500 msgLen = sizeof(struct sSirSmeSetContextReq);
14501
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014502 pMsg = qdf_mem_malloc(msgLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014503 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014504 return QDF_STATUS_E_NOMEM;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014505 qdf_mem_set(pMsg, msgLen, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014506 pMsg->messageType = eWNI_SME_SETCONTEXT_REQ;
14507 pMsg->length = msgLen;
14508 pMsg->sessionId = (uint8_t) sessionId;
14509 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053014510 qdf_copy_macaddr(&pMsg->peer_macaddr, &peer_macaddr);
14511 qdf_copy_macaddr(&pMsg->bssid,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080014512 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014513
14514 /**
14515 * Set the pMsg->keyMaterial.length field
14516 * (this length is defined as all data that follows the
14517 * edType field in the tSirKeyMaterial keyMaterial; field).
14518 *
14519 * NOTE: This keyMaterial.length contains the length of a
14520 * MAX size key, though the keyLength can be shorter than this
14521 * max size. Is LIM interpreting this ok ?
14522 */
14523 pMsg->keyMaterial.length =
14524 sizeof(pMsg->keyMaterial.numKeys) +
14525 (numKeys * sizeof(pMsg->keyMaterial.key));
14526 pMsg->keyMaterial.edType = edType;
14527 pMsg->keyMaterial.numKeys = numKeys;
14528 pMsg->keyMaterial.key[0].keyId = keyId;
14529 pMsg->keyMaterial.key[0].unicast = fUnicast;
14530 pMsg->keyMaterial.key[0].keyDirection = aniKeyDirection;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014531 qdf_mem_copy(pMsg->keyMaterial.key[0].keyRsc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014532 pKeyRsc, CSR_MAX_RSC_LEN);
14533 /* 0 is Supplicant */
14534 pMsg->keyMaterial.key[0].paeRole = paeRole;
14535 pMsg->keyMaterial.key[0].keyLength = keyLength;
14536 if (keyLength && pKey) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014537 qdf_mem_copy(pMsg->keyMaterial.key[0].key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014538 pKey, keyLength);
14539 sms_log(pMac, LOG1,
14540 FL("SME set keyIndx (%d) encType (%d) key"),
14541 keyId, edType);
14542 sir_dump_buf(pMac, SIR_SMS_MODULE_ID, LOG1, pKey,
14543 keyLength);
14544 }
14545 status = cds_send_mb_message_to_mac(pMsg);
14546 } while (0);
14547 return status;
14548}
14549
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014550QDF_STATUS csr_send_mb_start_bss_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014551 eCsrRoamBssType bssType,
14552 tCsrRoamStartBssParams *pParam,
14553 tSirBssDescription *pBssDesc)
14554{
14555 tSirSmeStartBssReq *pMsg;
14556 uint16_t wTmp;
14557 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14558
14559 if (!pSession) {
14560 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014561 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014562 }
14563
14564 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
14565 pSession->joinFailStatusCode.reasonCode = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014566 pMsg = qdf_mem_malloc(sizeof(tSirSmeStartBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014567 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014568 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014569
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014570 qdf_mem_set(pMsg, sizeof(tSirSmeStartBssReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014571 pMsg->messageType = eWNI_SME_START_BSS_REQ;
14572 pMsg->sessionId = sessionId;
14573 pMsg->length = sizeof(tSirSmeStartBssReq);
14574 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053014575 qdf_copy_macaddr(&pMsg->bssid, &pParam->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014576 /* selfMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053014577 qdf_copy_macaddr(&pMsg->self_macaddr, &pSession->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014578 /* beaconInterval */
14579 if (pBssDesc && pBssDesc->beaconInterval)
14580 wTmp = pBssDesc->beaconInterval;
14581 else if (pParam->beaconInterval)
14582 wTmp = pParam->beaconInterval;
14583 else
14584 wTmp = WNI_CFG_BEACON_INTERVAL_STADEF;
14585
14586 if (csr_isconcurrentsession_valid(pMac, sessionId, pParam->bssPersona)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014587 == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014588 csr_validate_mcc_beacon_interval(pMac,
14589 pParam->operationChn,
14590 &wTmp,
14591 sessionId,
14592 pParam->bssPersona);
14593 /* Update the beacon Interval */
14594 pParam->beaconInterval = wTmp;
14595 } else {
14596 sms_log(pMac, LOGE,
14597 FL("****Start BSS failed persona already exists***"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014598 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014599 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014600 }
14601 pMsg->beaconInterval = wTmp;
14602 pMsg->dot11mode =
14603 csr_translate_to_wni_cfg_dot11_mode(pMac,
14604 pParam->uCfgDot11Mode);
14605#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
14606 pMsg->cc_switch_mode = pMac->roam.configParam.cc_switch_mode;
14607#endif
14608 pMsg->bssType = csr_translate_bsstype_to_mac_type(bssType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014609 qdf_mem_copy(&pMsg->ssId, &pParam->ssId, sizeof(pParam->ssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014610 pMsg->channelId = pParam->operationChn;
14611 /* What should we really do for the cbmode. */
14612 pMsg->cbMode = (ePhyChanBondState) pParam->cbMode;
14613 pMsg->vht_channel_width = pParam->ch_params.ch_width;
14614 pMsg->center_freq_seg0 = pParam->ch_params.center_freq_seg0;
14615 pMsg->center_freq_seg1 = pParam->ch_params.center_freq_seg1;
14616 pMsg->sec_ch_offset = pParam->ch_params.sec_ch_offset;
14617 pMsg->privacy = pParam->privacy;
14618 pMsg->apUapsdEnable = pParam->ApUapsdEnable;
14619 pMsg->ssidHidden = pParam->ssidHidden;
14620 pMsg->fwdWPSPBCProbeReq = (uint8_t) pParam->fwdWPSPBCProbeReq;
14621 pMsg->protEnabled = (uint8_t) pParam->protEnabled;
14622 pMsg->obssProtEnabled = (uint8_t) pParam->obssProtEnabled;
14623 /* set cfg related to protection */
14624 pMsg->ht_capab = pParam->ht_protection;
14625 pMsg->authType = pParam->authType;
14626 pMsg->dtimPeriod = pParam->dtimPeriod;
14627 pMsg->wps_state = pParam->wps_state;
14628 pMsg->isCoalesingInIBSSAllowed = pMac->isCoalesingInIBSSAllowed;
14629 pMsg->bssPersona = pParam->bssPersona;
14630 pMsg->txLdpcIniFeatureEnabled = pMac->roam.configParam.txLdpcEnable;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -080014631 pMsg->txbf_ini_enabled =
14632 (uint8_t)pMac->roam.configParam.txBFEnable &&
14633 (uint8_t)pMac->roam.configParam.enable_txbf_sap_mode;
14634 pMsg->txbf_csn_val = (uint8_t)pMac->roam.configParam.txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014635#ifdef WLAN_FEATURE_11W
14636 pMsg->pmfCapable = pParam->mfpCapable;
14637 pMsg->pmfRequired = pParam->mfpRequired;
14638#endif
14639
14640 if (pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014641 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014642 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014643 }
14644 pMsg->rsnIE.length = pParam->nRSNIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014645 qdf_mem_copy(pMsg->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014646 pParam->pRSNIE,
14647 pParam->nRSNIELength);
14648 pMsg->nwType = (tSirNwType)pParam->sirNwType;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014649 qdf_mem_copy(&pMsg->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014650 &pParam->operationalRateSet,
14651 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014652 qdf_mem_copy(&pMsg->extendedRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014653 &pParam->extendedRateSet,
14654 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014655 qdf_mem_copy(&pMsg->htConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014656 &pSession->htConfig,
14657 sizeof(tSirHTConfig));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014658 qdf_mem_copy(&pMsg->addIeParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014659 &pParam->addIeParams,
14660 sizeof(pParam->addIeParams));
14661 pMsg->obssEnabled = pMac->roam.configParam.obssEnabled;
14662 pMsg->sap_dot11mc = pParam->sap_dot11mc;
14663
14664 return cds_send_mb_message_to_mac(pMsg);
14665}
14666
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014667QDF_STATUS csr_send_mb_stop_bss_req_msg(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014668{
14669 tSirSmeStopBssReq *pMsg;
14670 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14671
14672 if (!pSession) {
14673 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014674 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014675 }
14676
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014677 pMsg = qdf_mem_malloc(sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014678 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014679 return QDF_STATUS_E_NOMEM;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014680 qdf_mem_set(pMsg, sizeof(tSirSmeStopBssReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014681 pMsg->messageType = eWNI_SME_STOP_BSS_REQ;
14682 pMsg->sessionId = sessionId;
14683 pMsg->length = sizeof(tSirSmeStopBssReq);
14684 pMsg->transactionId = 0;
14685 pMsg->reasonCode = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053014686 qdf_copy_macaddr(&pMsg->bssid, &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014687 return cds_send_mb_message_to_mac(pMsg);
14688}
14689
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014690QDF_STATUS csr_reassoc(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014691 tCsrRoamModifyProfileFields *pModProfileFields,
14692 uint32_t *pRoamId, bool fForce)
14693{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014694 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014695 uint32_t roamId = 0;
14696 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14697 if ((csr_is_conn_state_connected(pMac, sessionId)) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014698 (fForce || (qdf_mem_cmp(&pModProfileFields,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014699 &pSession->connectedProfile.
14700 modifyProfileFields,
14701 sizeof(tCsrRoamModifyProfileFields))))) {
14702 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14703 if (pRoamId) {
14704 *pRoamId = roamId;
14705 }
14706
14707 status =
14708 csr_roam_issue_reassoc(pMac, sessionId, NULL,
14709 pModProfileFields,
14710 eCsrSmeIssuedReassocToSameAP,
14711 roamId, false);
14712 }
14713 return status;
14714}
14715
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014716static QDF_STATUS csr_roam_session_opened(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014717 uint32_t sessionId)
14718{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014719 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014720 tCsrRoamInfo roamInfo;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014721 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014722 status = csr_roam_call_callback(pMac, sessionId, &roamInfo, 0,
14723 eCSR_ROAM_SESSION_OPENED,
14724 eCSR_ROAM_RESULT_NONE);
14725 return status;
14726}
14727
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014728QDF_STATUS csr_process_add_sta_session_rsp(tpAniSirGlobal pMac, uint8_t *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014729{
14730 tListElem *pEntry = NULL;
14731 tSmeCmd *pCommand = NULL;
14732 struct add_sta_self_params *rsp;
14733 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014734 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014735
14736 if (pMsg == NULL) {
14737 sms_log(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014738 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014739 }
14740 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
14741 if (!pEntry) {
14742 sms_log(pMac, LOGE, "in %s NO commands are ACTIVE ...",
14743 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014744 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014745 }
14746 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
14747 if (eSmeCommandAddStaSession != pCommand->command) {
14748 sms_log(pMac, LOGE, "in %s Cmd not in active list ...",
14749 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014750 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014751 }
14752 rsp = (struct add_sta_self_params *) pMsg;
14753 sms_log(pMac, LOG1, "Add Sta self rsp status = %d", rsp->status);
14754
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014755 if (QDF_STATUS_SUCCESS == rsp->status &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014756 (WMI_VDEV_TYPE_STA == rsp->type ||
14757 (WMI_VDEV_TYPE_AP == rsp->type &&
14758 WMI_UNIFIED_VDEV_SUBTYPE_P2P_DEVICE == rsp->sub_type))) {
14759 sms_log(pMac, LOG1, FL("send SET IE msg to PE"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014760 msg = qdf_mem_malloc(sizeof(*msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014761 if (NULL == msg) {
14762 sms_log(pMac, LOGE, FL("Memory allocation failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014763 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014764 }
14765
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014766 qdf_mem_set(msg, sizeof(*msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014767 msg->msg_type = eWNI_SME_SET_IE_REQ;
14768 msg->session_id = rsp->session_id;
14769 msg->length = sizeof(*msg);
14770 status = cds_send_mb_message_to_mac(msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014771 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014772 sms_log(pMac, LOGE,
14773 FL("Failed to send down the set IE req "));
14774 }
14775
14776 csr_roam_session_opened(pMac, pCommand->sessionId);
14777 /* Remove this command out of the active list */
14778 if (csr_ll_remove_entry(&pMac->sme.smeCmdActiveList, pEntry,
14779 LL_ACCESS_LOCK)) {
14780 /* Now put this command back on the avilable command list */
14781 csr_release_command(pMac, pCommand);
14782 }
14783 sme_process_pending_queue(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014784 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014785}
14786
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014787QDF_STATUS csr_issue_add_sta_for_session_req(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014788 tSirMacAddr sessionMacAddr,
14789 uint32_t type, uint32_t subType)
14790{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014791 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014792 tSmeCmd *pCommand;
14793 pCommand = csr_get_command_buffer(pMac);
14794 if (NULL == pCommand) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014795 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014796 } else {
14797 pCommand->command = eSmeCommandAddStaSession;
14798 pCommand->sessionId = (uint8_t) sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014799 qdf_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014800 sessionMacAddr, sizeof(tSirMacAddr));
14801 pCommand->u.addStaSessionCmd.currDeviceMode =
14802 pMac->sme.currDeviceMode;
14803 pCommand->u.addStaSessionCmd.type = type;
14804 pCommand->u.addStaSessionCmd.subType = subType;
14805 status = csr_queue_sme_command(pMac, pCommand, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014806 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014807 /* Should be panic?? */
14808 sms_log(pMac, LOGE,
14809 FL(" fail to send message status = %d"), status);
14810 }
14811 }
14812 return status;
14813}
14814
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014815QDF_STATUS csr_process_add_sta_session_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014816 tSmeCmd *pCommand)
14817{
14818 tAddStaForSessionCmd *pAddStaReq =
14819 &pCommand->u.addStaSessionCmd;
14820 uint8_t sessionId = pCommand->sessionId;
14821 struct add_sta_self_params *add_sta_self_req;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014822 QDF_STATUS status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014823 tSirMsgQ msg;
14824
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014825 add_sta_self_req = qdf_mem_malloc(sizeof(struct add_sta_self_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014826 if (NULL == add_sta_self_req) {
14827 lim_log(pMac, LOGP,
14828 FL
14829 ("Unable to allocate memory for tAddSelfStaParams"));
14830 return status;
14831 }
14832
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014833 qdf_mem_copy(add_sta_self_req->self_mac_addr, pAddStaReq->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014834 sizeof(tSirMacAddr));
14835 add_sta_self_req->curr_device_mode = pAddStaReq->currDeviceMode;
14836 add_sta_self_req->session_id = sessionId;
14837 add_sta_self_req->type = pAddStaReq->type;
14838 add_sta_self_req->sub_type = pAddStaReq->subType;
14839
14840 msg.type = WMA_ADD_STA_SELF_REQ;
14841 msg.reserved = 0;
14842 msg.bodyptr = add_sta_self_req;
14843 msg.bodyval = 0;
14844
14845 lim_log(pMac, LOG1,
14846 FL
14847 ("Send WMA_ADD_STA_SELF_REQ for selfMac=" MAC_ADDRESS_STR),
14848 MAC_ADDR_ARRAY(add_sta_self_req->self_mac_addr));
14849 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
14850 status = wma_post_ctrl_msg(pMac, &msg);
14851
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014852 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014853 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014854 qdf_mem_free(add_sta_self_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014855 add_sta_self_req = NULL;
14856 }
14857 return status;
14858}
14859
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014860QDF_STATUS csr_roam_open_session(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014861 csr_roam_completeCallback callback,
14862 void *pContext,
14863 uint8_t *pSelfMacAddr, uint8_t *pbSessionId,
14864 uint32_t type, uint32_t subType)
14865{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014866 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014867 uint32_t i, value = 0;
14868 union {
14869 uint16_t nCfgValue16;
14870 tSirMacHTCapabilityInfo htCapInfo;
14871 } uHTCapabilityInfo;
14872 tCsrRoamSession *pSession;
14873 *pbSessionId = CSR_SESSION_ID_INVALID;
14874
14875 for (i = 0; i < pMac->sme.max_intf_count; i++) {
Peng Xu66162de2016-02-11 17:01:20 -080014876 sms_log(pMac, LOG1, FL("session:%d active:%d"), i,
14877 pMac->roam.roamSession[i].sessionActive);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014878 if (!CSR_IS_SESSION_VALID(pMac, i)) {
14879 pSession = CSR_GET_SESSION(pMac, i);
14880 if (!pSession) {
14881 sms_log(pMac, LOGE,
14882 FL
14883 ("Session does not exist for interface %d"),
14884 i);
14885 break;
14886 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014887 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014888 pSession->sessionActive = true;
14889 pSession->sessionId = (uint8_t) i;
14890
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014891 /* Initialize FT related data structures only in STA mode */
14892 sme_ft_open(pMac, pSession->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014893
14894 pSession->callback = callback;
14895 pSession->pContext = pContext;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014896 qdf_mem_copy(&pSession->selfMacAddr, pSelfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014897 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014898 *pbSessionId = (uint8_t) i;
14899 status =
Anurag Chouhan210db072016-02-22 18:42:15 +053014900 qdf_mc_timer_init(&pSession->hTimerRoaming,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014901 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014902 csr_roam_roaming_timer_handler,
14903 &pSession->roamingTimerInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014904 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014905 sms_log(pMac, LOGE,
14906 FL
14907 ("cannot allocate memory for Roaming timer"));
14908 break;
14909 }
14910 /* get the HT capability info */
14911 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_CAP_INFO, &value)
14912 != eSIR_SUCCESS) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053014913 QDF_TRACE(QDF_MODULE_ID_QDF,
14914 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014915 "%s: could not get HT capability info",
14916 __func__);
14917 break;
14918 }
14919#ifdef FEATURE_WLAN_BTAMP_UT_RF
Anurag Chouhan210db072016-02-22 18:42:15 +053014920 status = qdf_mc_timer_init(&pSession->hTimerJoinRetry,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014921 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014922 csr_roam_join_retry_timer_handler,
14923 &pSession->
14924 joinRetryTimerInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014925 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014926 sms_log(pMac, LOGE,
14927 FL
14928 ("cannot allocate memory for join retry timer"));
14929 break;
14930 }
14931#endif
14932 uHTCapabilityInfo.nCfgValue16 = 0xFFFF & value;
14933 pSession->htConfig.ht_rx_ldpc =
14934 uHTCapabilityInfo.htCapInfo.advCodingCap;
14935 pSession->htConfig.ht_tx_stbc =
14936 uHTCapabilityInfo.htCapInfo.txSTBC;
14937 pSession->htConfig.ht_rx_stbc =
14938 uHTCapabilityInfo.htCapInfo.rxSTBC;
14939 pSession->htConfig.ht_sgi = true;
14940 status =
14941 csr_issue_add_sta_for_session_req(pMac, i, pSelfMacAddr,
14942 type, subType);
14943 break;
14944 }
14945 }
14946 if (pMac->sme.max_intf_count == i) {
14947 /* No session is available */
14948 sms_log(pMac, LOGE,
14949 "%s: Reached max interfaces: %d! Session creation will fail",
14950 __func__, pMac->sme.max_intf_count);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014951 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014952 }
14953 return status;
14954}
14955
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014956QDF_STATUS csr_process_del_sta_session_rsp(tpAniSirGlobal pMac, uint8_t *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014957{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014958 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014959 tListElem *pEntry = NULL;
14960 tSmeCmd *pCommand = NULL;
14961 struct del_sta_self_params *rsp;
14962 uint8_t sessionId;
14963
14964 if (pMsg == NULL) {
14965 sms_log(pMac, LOGE, FL("msg ptr is NULL"));
14966 return status;
14967 }
14968 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
14969 if (!pEntry) {
14970 sms_log(pMac, LOGE, FL("NO commands are ACTIVE ..."));
14971 return status;
14972 }
14973 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
14974 sessionId = pCommand->sessionId;
14975 if (eSmeCommandDelStaSession != pCommand->command) {
14976 sms_log(pMac, LOGE, FL("NO Del sta session command ACTIVE"));
14977 return status;
14978 }
14979 rsp = (struct del_sta_self_params *) pMsg;
14980 sms_log(pMac, LOG1, FL("Del Sta rsp status = %d"), rsp->status);
14981 /* This session is done. */
14982 csr_cleanup_session(pMac, sessionId);
14983 if (pCommand->u.delStaSessionCmd.callback) {
14984 status = sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014985 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014986 sms_log(pMac, LOG1, FL("Failed to Release Lock"));
14987 else {
14988 pCommand->u.delStaSessionCmd.
14989 callback(pCommand->u.delStaSessionCmd.pContext);
14990 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014991 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014992 sms_log(pMac, LOG1, FL("Failed to get Lock"));
14993 return status;
14994 }
14995 }
14996 }
14997 /* Remove this command out of the active list */
14998 if (csr_ll_remove_entry(&pMac->sme.smeCmdActiveList, pEntry,
14999 LL_ACCESS_LOCK)) {
15000 /* Now put this command back on the avilable command list */
15001 csr_release_command(pMac, pCommand);
15002 }
15003 sme_process_pending_queue(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015004 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015005 return status;
15006}
15007
15008
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015009QDF_STATUS csr_issue_del_sta_for_session_req(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015010 tSirMacAddr sessionMacAddr,
15011 csr_roamSessionCloseCallback callback,
15012 void *pContext)
15013{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015014 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015015 tSmeCmd *pCommand;
15016 pCommand = csr_get_command_buffer(pMac);
15017 if (NULL == pCommand) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015018 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015019 } else {
15020 pCommand->command = eSmeCommandDelStaSession;
15021 pCommand->sessionId = (uint8_t) sessionId;
15022 pCommand->u.delStaSessionCmd.callback = callback;
15023 pCommand->u.delStaSessionCmd.pContext = pContext;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015024 qdf_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015025 sessionMacAddr, sizeof(tSirMacAddr));
15026 status = csr_queue_sme_command(pMac, pCommand, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015027 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015028 /* Should be panic?? */
15029 sms_log(pMac, LOGE,
15030 FL(" fail to send message status = %d"), status);
15031 }
15032 }
15033 return status;
15034}
15035
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015036QDF_STATUS csr_process_del_sta_session_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015037 tSmeCmd *pCommand)
15038{
15039 struct del_sta_self_params *del_sta_self_req;
15040 tSirMsgQ msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015041 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015042 del_sta_self_req = qdf_mem_malloc(sizeof(struct del_sta_self_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015043 if (NULL == del_sta_self_req) {
15044 lim_log(pMac, LOGP,
15045 FL(" mem alloc failed for tDelStaSelfParams"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015046 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015047 }
15048
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015049 qdf_mem_copy(del_sta_self_req->self_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015050 pCommand->u.delStaSessionCmd.selfMacAddr,
15051 sizeof(tSirMacAddr));
15052
15053 del_sta_self_req->session_id = pCommand->sessionId;
15054 msg.type = WMA_DEL_STA_SELF_REQ;
15055 msg.reserved = 0;
15056 msg.bodyptr = del_sta_self_req;
15057 msg.bodyval = 0;
15058
15059 sms_log(pMac, LOG1,
15060 FL("sending WMA_DEL_STA_SELF_REQ"));
15061 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
15062 status = wma_post_ctrl_msg(pMac, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015063 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015064 sms_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015065 qdf_mem_free(del_sta_self_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015066 }
15067 return status;
15068}
15069
15070static void purge_csr_session_cmd_list(tpAniSirGlobal pMac, uint32_t sessionId)
15071{
15072 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
15073 tListElem *pEntry, *pNext;
15074 tSmeCmd *pCommand;
15075 tDblLinkList localList;
15076
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015077 qdf_mem_zero(&localList, sizeof(tDblLinkList));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015078 if (!QDF_IS_STATUS_SUCCESS(csr_ll_open(pMac->hHdd, &localList))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015079 sms_log(pMac, LOGE, FL(" failed to open list"));
15080 return;
15081 }
15082 csr_ll_lock(pList);
15083 pEntry = csr_ll_peek_head(pList, LL_ACCESS_NOLOCK);
15084 while (pEntry != NULL) {
15085 pNext = csr_ll_next(pList, pEntry, LL_ACCESS_NOLOCK);
15086 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
15087 if (pCommand->sessionId == sessionId) {
15088 if (csr_ll_remove_entry(pList, pEntry, LL_ACCESS_NOLOCK)) {
15089 csr_ll_insert_tail(&localList, pEntry,
15090 LL_ACCESS_NOLOCK);
15091 }
15092 }
15093 pEntry = pNext;
15094 }
15095 csr_ll_unlock(pList);
15096
15097 while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) {
15098 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
15099 csr_abort_command(pMac, pCommand, true);
15100 }
15101 csr_ll_close(&localList);
15102}
15103
15104void csr_cleanup_session(tpAniSirGlobal pMac, uint32_t sessionId)
15105{
15106 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
15107 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15108
15109 csr_roam_stop(pMac, sessionId);
15110
15111 /* Clean up FT related data structures */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015112 sme_ft_close(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015113 csr_free_connect_bss_desc(pMac, sessionId);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -080015114 csr_roam_free_connect_profile(&pSession->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015115 csr_roam_free_connected_info(pMac, &pSession->connectedInfo);
Anurag Chouhan210db072016-02-22 18:42:15 +053015116 qdf_mc_timer_destroy(&pSession->hTimerRoaming);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015117#ifdef FEATURE_WLAN_BTAMP_UT_RF
Anurag Chouhan210db072016-02-22 18:42:15 +053015118 qdf_mc_timer_destroy(&pSession->hTimerJoinRetry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015119#endif
15120 purge_sme_session_cmd_list(pMac, sessionId,
15121 &pMac->sme.smeCmdPendingList);
15122 purge_sme_session_cmd_list(pMac, sessionId,
15123 &pMac->sme.
15124 smeScanCmdPendingList);
15125
15126 purge_csr_session_cmd_list(pMac, sessionId);
15127 csr_init_session(pMac, sessionId);
15128 }
15129}
15130
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015131QDF_STATUS csr_roam_close_session(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015132 bool fSync,
15133 csr_roamSessionCloseCallback callback,
15134 void *pContext)
15135{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015136 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015137 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
15138 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15139 if (fSync) {
15140 csr_cleanup_session(pMac, sessionId);
15141 } else {
15142 purge_sme_session_cmd_list(pMac, sessionId,
15143 &pMac->sme.smeCmdPendingList);
15144 purge_sme_session_cmd_list(pMac, sessionId,
15145 &pMac->sme.smeScanCmdPendingList);
15146
15147 purge_csr_session_cmd_list(pMac, sessionId);
15148 status = csr_issue_del_sta_for_session_req(pMac,
15149 sessionId,
15150 pSession->selfMacAddr.bytes,
15151 callback, pContext);
15152 }
15153 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015154 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015155 }
15156 return status;
15157}
15158
15159static void csr_init_session(tpAniSirGlobal pMac, uint32_t sessionId)
15160{
15161 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15162
15163 if (!pSession) {
15164 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
15165 return;
15166 }
15167
15168 pSession->sessionActive = false;
15169 pSession->sessionId = CSR_SESSION_ID_INVALID;
15170 pSession->callback = NULL;
15171 pSession->pContext = NULL;
15172 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
15173 csr_free_roam_profile(pMac, sessionId);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -080015174 csr_roam_free_connect_profile(&pSession->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015175 csr_roam_free_connected_info(pMac, &pSession->connectedInfo);
15176 csr_free_connect_bss_desc(pMac, sessionId);
15177 csr_scan_enable(pMac);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015178 qdf_mem_set(&pSession->selfMacAddr, sizeof(struct qdf_mac_addr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015179 if (pSession->pWpaRsnReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015180 qdf_mem_free(pSession->pWpaRsnReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015181 pSession->pWpaRsnReqIE = NULL;
15182 }
15183 pSession->nWpaRsnReqIeLength = 0;
15184 if (pSession->pWpaRsnRspIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015185 qdf_mem_free(pSession->pWpaRsnRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015186 pSession->pWpaRsnRspIE = NULL;
15187 }
15188 pSession->nWpaRsnRspIeLength = 0;
15189#ifdef FEATURE_WLAN_WAPI
15190 if (pSession->pWapiReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015191 qdf_mem_free(pSession->pWapiReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015192 pSession->pWapiReqIE = NULL;
15193 }
15194 pSession->nWapiReqIeLength = 0;
15195 if (pSession->pWapiRspIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015196 qdf_mem_free(pSession->pWapiRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015197 pSession->pWapiRspIE = NULL;
15198 }
15199 pSession->nWapiRspIeLength = 0;
15200#endif /* FEATURE_WLAN_WAPI */
15201 if (pSession->pAddIEScan) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015202 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015203 pSession->pAddIEScan = NULL;
15204 }
15205 pSession->nAddIEScanLength = 0;
15206 if (pSession->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015207 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015208 pSession->pAddIEAssoc = NULL;
15209 }
15210 pSession->nAddIEAssocLength = 0;
15211}
15212
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015213QDF_STATUS csr_roam_get_session_id_from_bssid(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015214 struct qdf_mac_addr *bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015215 uint32_t *pSessionId)
15216{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015217 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015218 uint32_t i;
15219 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
15220 if (CSR_IS_SESSION_VALID(pMac, i)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053015221 if (qdf_is_macaddr_equal(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015222 &pMac->roam.roamSession[i].connectedProfile.
15223 bssid)) {
15224 /* Found it */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015225 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015226 *pSessionId = i;
15227 break;
15228 }
15229 }
15230 }
15231 return status;
15232}
15233
15234/* This function assumes that we only support one IBSS session. We cannot use BSSID to identify */
15235/* session because for IBSS, the bssid changes. */
15236static uint32_t csr_find_ibss_session(tpAniSirGlobal pMac)
15237{
15238 uint32_t i, nRet = CSR_SESSION_ID_INVALID;
15239 tCsrRoamSession *pSession;
15240 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
15241 if (CSR_IS_SESSION_VALID(pMac, i)) {
15242 pSession = CSR_GET_SESSION(pMac, i);
15243 if (pSession->pCurRoamProfile
15244 &&
15245 (csr_is_bss_type_ibss
15246 (pSession->connectedProfile.BSSType))) {
15247 /* Found it */
15248 nRet = i;
15249 break;
15250 }
15251 }
15252 }
15253 return nRet;
15254}
15255
Anurag Chouhan6d760662016-02-20 16:05:43 +053015256static void csr_roam_link_up(tpAniSirGlobal pMac, struct qdf_mac_addr bssid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015257{
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080015258 uint32_t sessionId = 0;
15259
15260 /*
15261 * Update the current BSS info in ho control block based on connected
15262 * profile info from pmac global structure
15263 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015264
15265 sms_log(pMac, LOGW,
15266 " csr_roam_link_up: WLAN link UP with AP= " MAC_ADDRESS_STR,
15267 MAC_ADDR_ARRAY(bssid.bytes));
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080015268 /* Check for user misconfig of RSSI trigger threshold */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015269 pMac->roam.configParam.vccRssiThreshold =
15270 (0 == pMac->roam.configParam.vccRssiThreshold) ?
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080015271 CSR_VCC_RSSI_THRESHOLD :
15272 pMac->roam.configParam.vccRssiThreshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015273 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080015274 /* Check for user misconfig of UL MAC Loss trigger threshold */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015275 pMac->roam.configParam.vccUlMacLossThreshold =
15276 (0 == pMac->roam.configParam.vccUlMacLossThreshold) ?
15277 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.
15278 vccUlMacLossThreshold;
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080015279 /* Indicate the neighbor roal algorithm about the connect indication */
15280 csr_roam_get_session_id_from_bssid(pMac, &bssid,
15281 &sessionId);
15282 csr_neighbor_roam_indicate_connect(pMac, sessionId,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015283 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015284}
15285
15286static void csr_roam_link_down(tpAniSirGlobal pMac, uint32_t sessionId)
15287{
15288 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15289
15290 if (!pSession) {
15291 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
15292 return;
15293 }
15294 /* Only to handle the case for Handover on infra link */
15295 if (eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType) {
15296 return;
15297 }
15298 /*
15299 * Incase of station mode, immediately stop data transmission whenever
15300 * link down is detected.
15301 */
15302 if (csr_roam_is_sta_mode(pMac, sessionId)
15303 && !CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -080015304 && !csr_roam_is11r_assoc(pMac, sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015305 sms_log(pMac, LOG1, FL("Inform Link lost for session %d"),
15306 sessionId);
15307 csr_roam_call_callback(pMac, sessionId, NULL, 0,
15308 eCSR_ROAM_LOSTLINK,
15309 eCSR_ROAM_RESULT_LOSTLINK);
15310 }
15311 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers */
15312 csr_roam_dereg_statistics_req(pMac);
15313 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015314 /* Indicate the neighbor roal algorithm about the disconnect indication */
15315 csr_neighbor_roam_indicate_disconnect(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015316
15317 /* Remove this code once SLM_Sessionization is supported */
15318 /* BMPS_WORKAROUND_NOT_NEEDED */
15319 if (!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
15320 csr_is_infra_ap_started(pMac) &&
15321 pMac->roam.configParam.doBMPSWorkaround) {
15322 pMac->roam.configParam.doBMPSWorkaround = 0;
15323 }
15324
15325}
15326
15327void csr_roam_tl_stats_timer_handler(void *pv)
15328{
15329 tpAniSirGlobal pMac = PMAC_STRUCT(pv);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015330 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015331 pMac->roam.tlStatsReqInfo.timerRunning = false;
15332
15333 sms_log(pMac, LOG1,
15334 FL
15335 (" TL stat timer is no-op. It needs to support multiple stations"));
15336
15337 if (!pMac->roam.tlStatsReqInfo.timerRunning) {
15338 if (pMac->roam.tlStatsReqInfo.periodicity) {
15339 /* start timer */
15340 status =
Anurag Chouhan210db072016-02-22 18:42:15 +053015341 qdf_mc_timer_start(&pMac->roam.tlStatsReqInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015342 hTlStatsTimer,
15343 pMac->roam.tlStatsReqInfo.
15344 periodicity);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015345 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015346 sms_log(pMac, LOGE,
15347 FL
15348 ("csr_roam_tl_stats_timer_handler:cannot start TlStatsTimer timer"));
15349 return;
15350 }
15351 pMac->roam.tlStatsReqInfo.timerRunning = true;
15352 }
15353 }
15354}
15355
15356void csr_roam_pe_stats_timer_handler(void *pv)
15357{
15358 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *) pv;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015359 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015360 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015361 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015362 pPeStatsReqListEntry->timerRunning = false;
15363 if (pPeStatsReqListEntry->timerStopFailed == true) {
15364 /* If we entered here, meaning the timer could not be successfully */
15365 /* stopped in csr_roam_remove_entry_from_pe_stats_req_list(). So do it here. */
15366
15367 /* Destroy the timer */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015368 qdf_status =
Anurag Chouhan210db072016-02-22 18:42:15 +053015369 qdf_mc_timer_destroy(&pPeStatsReqListEntry->hPeStatsTimer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015370 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015371 sms_log(pMac, LOGE,
15372 FL
15373 ("csr_roam_pe_stats_timer_handler:failed to destroy hPeStatsTimer timer"));
15374 }
15375 /* Free the entry */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015376 qdf_mem_free(pPeStatsReqListEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015377 pPeStatsReqListEntry = NULL;
15378 } else {
15379 if (!pPeStatsReqListEntry->rspPending) {
15380 status =
15381 csr_send_mb_stats_req_msg(pMac,
15382 pPeStatsReqListEntry->
15383 statsMask & ~(1 <<
15384 eCsrGlobalClassDStats),
15385 pPeStatsReqListEntry->staId,
15386 pPeStatsReqListEntry->
15387 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015388 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015389 sms_log(pMac, LOGE,
15390 FL
15391 ("csr_roam_pe_stats_timer_handler:failed to send down stats req to PE"));
15392 } else {
15393 pPeStatsReqListEntry->rspPending = true;
15394 }
15395 }
15396 /* send down a req */
15397 if (pPeStatsReqListEntry->periodicity &&
Anurag Chouhan210db072016-02-22 18:42:15 +053015398 (QDF_TIMER_STATE_STOPPED ==
15399 qdf_mc_timer_get_current_state(&pPeStatsReqListEntry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015400 hPeStatsTimer))) {
15401 if (pPeStatsReqListEntry->periodicity <
15402 pMac->roam.configParam.
15403 statsReqPeriodicityInPS) {
15404 pPeStatsReqListEntry->periodicity =
15405 pMac->roam.configParam.
15406 statsReqPeriodicityInPS;
15407 }
15408 /* start timer */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015409 qdf_status =
Anurag Chouhan210db072016-02-22 18:42:15 +053015410 qdf_mc_timer_start(&pPeStatsReqListEntry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015411 hPeStatsTimer,
15412 pPeStatsReqListEntry->
15413 periodicity);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015414 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015415 sms_log(pMac, LOGE,
15416 FL
15417 ("csr_roam_pe_stats_timer_handler:cannot start hPeStatsTimer timer"));
15418 return;
15419 }
15420 pPeStatsReqListEntry->timerRunning = true;
15421
15422 }
15423
15424 }
15425}
15426
15427void csr_roam_stats_client_timer_handler(void *pv)
15428{
15429 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *) pv;
Anurag Chouhan210db072016-02-22 18:42:15 +053015430 if (QDF_TIMER_STATE_STOPPED ==
15431 qdf_mc_timer_get_current_state(&pStaEntry->timer)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053015432 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015433 FL("roam stats client timer is stopped"));
15434 }
15435}
15436
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015437QDF_STATUS csr_send_mb_stats_req_msg(tpAniSirGlobal pMac, uint32_t statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015438 uint8_t staId, uint8_t sessionId)
15439{
15440 tAniGetPEStatsReq *pMsg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015441 QDF_STATUS status = QDF_STATUS_SUCCESS;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015442 pMsg = qdf_mem_malloc(sizeof(tAniGetPEStatsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015443 if (NULL == pMsg) {
15444 sms_log(pMac, LOGE, FL("Failed to allocate mem for stats req "));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015445 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015446 }
15447 /* need to initiate a stats request to PE */
15448 pMsg->msgType = eWNI_SME_GET_STATISTICS_REQ;
15449 pMsg->msgLen = (uint16_t) sizeof(tAniGetPEStatsReq);
15450 pMsg->staId = staId;
15451 pMsg->statsMask = statsMask;
15452 pMsg->sessionId = sessionId;
15453 status = cds_send_mb_message_to_mac(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015454 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015455 sms_log(pMac, LOG1, FL("Failed to send down the stats req "));
15456 }
15457 return status;
15458}
15459
15460/**
15461 * csr_update_stats() - updates correct stats struct in mac_ctx
15462 * @mac: mac global context
15463 * @stats_type: stats type
15464 * @sme_stats_rsp: stats rsp msg packet
15465 * @stats: input stats data buffer to fill in mac_ctx struct
15466 * @length: out param - stats length
15467 *
15468 * This function fills corresponding stats struct in mac_cts based on stats type
15469 * passed
15470 *
15471 * Return: void
15472 */
15473static void
15474csr_update_stats(tpAniSirGlobal mac, uint8_t stats_type,
15475 tAniGetPEStatsRsp *sme_stats_rsp,
15476 uint8_t **stats, uint32_t *length)
15477{
15478 switch (stats_type) {
15479 case eCsrSummaryStats:
15480 sms_log(mac, LOG2, FL("summary stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015481 qdf_mem_copy((uint8_t *) &mac->roam.summaryStatsInfo, *stats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015482 sizeof(tCsrSummaryStatsInfo));
15483 *stats += sizeof(tCsrSummaryStatsInfo);
15484 *length -= sizeof(tCsrSummaryStatsInfo);
15485 break;
15486 case eCsrGlobalClassAStats:
15487 sms_log(mac, LOG2, FL("ClassA stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015488 qdf_mem_copy((uint8_t *) &mac->roam.classAStatsInfo, *stats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015489 sizeof(tCsrGlobalClassAStatsInfo));
15490 *stats += sizeof(tCsrGlobalClassAStatsInfo);
15491 *length -= sizeof(tCsrGlobalClassAStatsInfo);
15492 break;
15493 case eCsrGlobalClassBStats:
15494 sms_log(mac, LOG2, FL("ClassB stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015495 qdf_mem_copy((uint8_t *) &mac->roam.classBStatsInfo, *stats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015496 sizeof(tCsrGlobalClassBStatsInfo));
15497 *stats += sizeof(tCsrGlobalClassBStatsInfo);
15498 *length -= sizeof(tCsrGlobalClassBStatsInfo);
15499 break;
15500 case eCsrGlobalClassCStats:
15501 sms_log(mac, LOG2, FL("ClassC stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015502 qdf_mem_copy((uint8_t *) &mac->roam.classCStatsInfo, *stats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015503 sizeof(tCsrGlobalClassCStatsInfo));
15504 *stats += sizeof(tCsrGlobalClassCStatsInfo);
15505 *length -= sizeof(tCsrGlobalClassCStatsInfo);
15506 break;
15507 case eCsrPerStaStats:
15508 sms_log(mac, LOG2, FL("PerSta stats"));
15509 if (CSR_MAX_STA > sme_stats_rsp->staId) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015510 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015511 &mac->roam.perStaStatsInfo[sme_stats_rsp->staId],
15512 *stats, sizeof(tCsrPerStaStatsInfo));
15513 } else {
15514 sms_log(mac, LOGE, FL("out bound staId:%d. failed to copy PerSta stats"),
15515 sme_stats_rsp->staId);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053015516 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015517 }
15518 *stats += sizeof(tCsrPerStaStatsInfo);
15519 *length -= sizeof(tCsrPerStaStatsInfo);
15520 break;
15521 default:
15522 sms_log(mac, LOGW, FL("unknown stats type"));
15523 break;
15524 }
15525}
15526
15527/**
15528 * csr_roam_stats_rsp_processor() - processes stats rsp msg
15529 * @pMac mac global context
15530 * @pSirMsg: incoming message
15531 *
15532 * Return: void
15533 */
15534void csr_roam_stats_rsp_processor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
15535{
15536 tAniGetPEStatsRsp *pSmeStatsRsp;
15537 tListElem *pEntry = NULL;
15538 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15539 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15540 uint32_t tempMask = 0;
15541 uint8_t counter = 0;
15542 uint8_t *pStats = NULL;
15543 uint32_t length = 0;
15544 void *p_cds_gctx;
15545 int8_t rssi = 0, snr = 0;
15546 uint32_t *pRssi = NULL, *pSnr = NULL;
15547 uint32_t linkCapacity;
15548 pSmeStatsRsp = (tAniGetPEStatsRsp *) pSirMsg;
15549
15550 if (pSmeStatsRsp->rc) {
15551 sms_log(pMac, LOGW, FL("stats rsp from PE shows failure"));
15552 goto post_update;
15553 }
15554 tempMask = pSmeStatsRsp->statsMask;
15555 pStats = ((uint8_t *) &pSmeStatsRsp->statsMask) +
15556 sizeof(pSmeStatsRsp->statsMask);
15557 /*
15558 * subtract all statistics from this length, and after processing the
15559 * entire 'stat' part of the message, if the length is not zero, then
15560 * rssi is piggy packed in this 'stats' message.
15561 */
15562 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
15563 /* new stats info from PE, fill up the stats strucutres in PMAC */
15564 while (tempMask) {
15565 if (tempMask & 1) {
15566 csr_update_stats(pMac, counter, pSmeStatsRsp,
15567 &pStats, &length);
15568 }
15569 tempMask >>= 1;
15570 counter++;
15571 }
15572 p_cds_gctx = cds_get_global_context();
15573 if (length != 0) {
15574 pRssi = (uint32_t *) pStats;
15575 rssi = (int8_t) *pRssi;
15576 pStats += sizeof(uint32_t);
15577 length -= sizeof(uint32_t);
15578 } else {
15579 /* If riva is not sending rssi, continue to use the hack */
15580 rssi = RSSI_HACK_BMPS;
15581 }
15582
15583 if (length != 0) {
15584 linkCapacity = *(uint32_t *) pStats;
15585 pStats += sizeof(uint32_t);
15586 length -= sizeof(uint32_t);
15587 } else {
15588 linkCapacity = 0;
15589 }
15590
15591 if (length != 0) {
15592 pSnr = (uint32_t *) pStats;
15593 snr = (int8_t) *pSnr;
15594 } else {
15595 snr = SNR_HACK_BMPS;
15596 }
15597
15598post_update:
15599 /* make sure to update the pe stats req list */
15600 pEntry = csr_roam_find_in_pe_stats_req_list(pMac, pSmeStatsRsp->statsMask);
15601 if (pEntry) {
15602 pPeStaEntry = GET_BASE_ADDR(pEntry, tCsrPeStatsReqInfo, link);
15603 pPeStaEntry->rspPending = false;
15604
15605 }
15606 /* check the one timer cases */
15607 pEntry = csr_roam_check_client_req_list(pMac, pSmeStatsRsp->statsMask);
15608 if (pEntry) {
15609 pTempStaEntry =
15610 GET_BASE_ADDR(pEntry, tCsrStatsClientReqInfo, link);
15611 if (pTempStaEntry->timerExpired) {
15612 /* send up the stats report */
15613 csr_roam_report_statistics(pMac, pTempStaEntry->statsMask,
15614 pTempStaEntry->callback,
15615 pTempStaEntry->staId,
15616 pTempStaEntry->pContext);
15617 /* also remove from the client list */
15618 csr_roam_remove_stat_list_entry(pMac, pEntry);
15619 pTempStaEntry = NULL;
15620 }
15621 }
15622}
15623
15624tListElem *csr_roam_find_in_pe_stats_req_list(tpAniSirGlobal pMac, uint32_t statsMask)
15625{
15626 tListElem *pEntry = NULL;
15627 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15628 pEntry = csr_ll_peek_head(&pMac->roam.peStatsReqList, LL_ACCESS_LOCK);
15629 if (!pEntry) {
15630 /* list empty */
15631 sms_log(pMac, LOG2,
15632 "csr_roam_find_in_pe_stats_req_list: List empty, no request to PE");
15633 return NULL;
15634 }
15635 while (pEntry) {
15636 pTempStaEntry = GET_BASE_ADDR(pEntry, tCsrPeStatsReqInfo, link);
15637 if (pTempStaEntry->statsMask == statsMask) {
15638 sms_log(pMac, LOG3,
15639 "csr_roam_find_in_pe_stats_req_list: match found");
15640 break;
15641 }
15642 pEntry =
15643 csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
15644 LL_ACCESS_NOLOCK);
15645 }
15646 return pEntry;
15647}
15648
15649tListElem *csr_roam_checkn_update_client_req_list(tpAniSirGlobal pMac,
15650 tCsrStatsClientReqInfo *pStaEntry,
15651 bool update)
15652{
15653 tListElem *pEntry;
15654 tCsrStatsClientReqInfo *pTempStaEntry;
15655 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList, LL_ACCESS_LOCK);
15656 if (!pEntry) {
15657 /* list empty */
15658 sms_log(pMac, LOG2,
15659 "csr_roam_checkn_update_client_req_list: List empty, no request from "
15660 "upper layer client(s)");
15661 return NULL;
15662 }
15663 while (pEntry) {
15664 pTempStaEntry =
15665 GET_BASE_ADDR(pEntry, tCsrStatsClientReqInfo, link);
15666 if ((pTempStaEntry->requesterId == pStaEntry->requesterId)
15667 && (pTempStaEntry->statsMask == pStaEntry->statsMask)) {
15668 sms_log(pMac, LOG3,
15669 "csr_roam_checkn_update_client_req_list: match found");
15670 if (update) {
15671 pTempStaEntry->periodicity =
15672 pStaEntry->periodicity;
15673 pTempStaEntry->callback = pStaEntry->callback;
15674 pTempStaEntry->pContext = pStaEntry->pContext;
15675 }
15676 break;
15677 }
15678 pEntry =
15679 csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
15680 LL_ACCESS_NOLOCK);
15681 }
15682 return pEntry;
15683}
15684
15685tListElem *csr_roam_check_client_req_list(tpAniSirGlobal pMac, uint32_t statsMask)
15686{
15687 tListElem *pEntry;
15688 tCsrStatsClientReqInfo *pTempStaEntry;
15689 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList, LL_ACCESS_LOCK);
15690 if (!pEntry) {
15691 /* list empty */
15692 sms_log(pMac, LOG2,
15693 "csr_roam_check_client_req_list: List empty, no request from "
15694 "upper layer client(s)");
15695 return NULL;
15696 }
15697 while (pEntry) {
15698 pTempStaEntry =
15699 GET_BASE_ADDR(pEntry, tCsrStatsClientReqInfo, link);
15700 if ((pTempStaEntry->
15701 statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask) {
15702 sms_log(pMac, LOG3,
15703 "csr_roam_check_client_req_list: match found");
15704 break;
15705 }
15706 pEntry =
15707 csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
15708 LL_ACCESS_NOLOCK);
15709 }
15710 return pEntry;
15711}
15712
15713void csr_roam_vcc_trigger(tpAniSirGlobal pMac)
15714{
15715 eCsrRoamLinkQualityInd newVccLinkQuality;
15716 uint32_t ul_mac_loss = 0;
15717 uint32_t ul_mac_loss_trigger_threshold;
15718 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15719 /*-------------------------------------------------------------------------
15720 Link quality is currently binary based on OBIWAN recommended triggers
15721 Check for a change in link quality and notify client if necessary
15722 -------------------------------------------------------------------------*/
15723 ul_mac_loss_trigger_threshold =
15724 pMac->roam.configParam.vccUlMacLossThreshold;
15725 if (0 == ul_mac_loss_trigger_threshold) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053015726 QDF_ASSERT(ul_mac_loss_trigger_threshold != 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015727 return;
15728 }
15729 sms_log(pMac, LOGW, "csr_roam_vcc_trigger: UL_MAC_LOSS_THRESHOLD is %d",
15730 ul_mac_loss_trigger_threshold);
15731 if (ul_mac_loss_trigger_threshold < ul_mac_loss) {
15732 sms_log(pMac, LOGW, "csr_roam_vcc_trigger: link quality is POOR ");
15733 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15734 } else {
15735 sms_log(pMac, LOGW, "csr_roam_vcc_trigger: link quality is GOOD");
15736 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15737 }
15738 sms_log(pMac, LOGW,
15739 "csr_roam_vcc_trigger: link qual : *** UL_MAC_LOSS %d *** ",
15740 ul_mac_loss);
15741 if (newVccLinkQuality != pMac->roam.vccLinkQuality) {
15742 sms_log(pMac, LOGW,
15743 "csr_roam_vcc_trigger: link quality changed: trigger necessary");
15744 if (NULL != pMac->roam.linkQualityIndInfo.callback) {
15745 sms_log(pMac, LOGW,
15746 "csr_roam_vcc_trigger: link quality indication %d",
15747 newVccLinkQuality);
15748
15749 /* we now invoke the callback once to notify client of initial value */
15750 pMac->roam.linkQualityIndInfo.
15751 callback(newVccLinkQuality,
15752 pMac->roam.linkQualityIndInfo.context);
15753 /* event: EVENT_WLAN_VCC */
15754 }
15755 }
15756 pMac->roam.vccLinkQuality = newVccLinkQuality;
15757
15758}
15759
15760tCsrStatsClientReqInfo *csr_roam_insert_entry_into_list(tpAniSirGlobal pMac,
15761 tDblLinkList *pStaList,
15762 tCsrStatsClientReqInfo *
15763 pStaEntry)
15764{
15765 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
15766 /* if same entity requested for same set of stats with different periodicity & */
15767 /* callback update it */
15768 if (NULL == csr_roam_checkn_update_client_req_list(pMac, pStaEntry, true)) {
15769
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015770 pNewStaEntry = qdf_mem_malloc(sizeof(tCsrStatsClientReqInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015771 if (NULL == pNewStaEntry) {
15772 sms_log(pMac, LOGW,
15773 "csr_roam_insert_entry_into_list: couldn't allocate memory for the "
15774 "entry");
15775 return NULL;
15776 }
15777
15778 pNewStaEntry->callback = pStaEntry->callback;
15779 pNewStaEntry->pContext = pStaEntry->pContext;
15780 pNewStaEntry->periodicity = pStaEntry->periodicity;
15781 pNewStaEntry->requesterId = pStaEntry->requesterId;
15782 pNewStaEntry->statsMask = pStaEntry->statsMask;
15783 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15784 pNewStaEntry->pMac = pStaEntry->pMac;
15785 pNewStaEntry->staId = pStaEntry->staId;
15786 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15787
15788 csr_ll_insert_tail(pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK);
15789 }
15790 return pNewStaEntry;
15791}
15792
15793tCsrPeStatsReqInfo *csr_roam_insert_entry_into_pe_stats_req_list(tpAniSirGlobal pMac,
15794 tDblLinkList *
15795 pStaList,
15796 tCsrPeStatsReqInfo *
15797 pStaEntry)
15798{
15799 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015800 pNewStaEntry = qdf_mem_malloc(sizeof(tCsrPeStatsReqInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015801 if (NULL == pNewStaEntry) {
15802 sms_log(pMac, LOGW,
15803 "csr_roam_insert_entry_into_pe_stats_req_list: couldn't allocate memory for the "
15804 "entry");
15805 return NULL;
15806 }
15807
15808 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15809 pNewStaEntry->numClient = pStaEntry->numClient;
15810 pNewStaEntry->periodicity = pStaEntry->periodicity;
15811 pNewStaEntry->statsMask = pStaEntry->statsMask;
15812 pNewStaEntry->pMac = pStaEntry->pMac;
15813 pNewStaEntry->staId = pStaEntry->staId;
15814 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15815 pNewStaEntry->rspPending = pStaEntry->rspPending;
15816
15817 csr_ll_insert_tail(pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK);
15818 return pNewStaEntry;
15819}
15820
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015821QDF_STATUS csr_get_rssi(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015822 tCsrRssiCallback callback,
15823 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015824 struct qdf_mac_addr bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015825 int8_t lastRSSI, void *pContext, void *p_cds_context)
15826{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015827 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015828 cds_msg_t msg;
15829 uint32_t sessionId;
15830
15831 tAniGetRssiReq *pMsg;
15832 sms_log(pMac, LOG2, FL("called"));
15833
15834 status = csr_roam_get_session_id_from_bssid(pMac, &bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015835 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015836 callback(lastRSSI, staId, pContext);
15837 sms_log(pMac, LOGE, FL("Failed to get SessionId"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015838 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015839 }
15840
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015841 pMsg = qdf_mem_malloc(sizeof(tAniGetRssiReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015842 if (NULL == pMsg) {
15843 sms_log(pMac, LOGE,
15844 " csr_get_rssi: failed to allocate mem for req ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015845 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015846 }
15847
15848 pMsg->msgType = eWNI_SME_GET_RSSI_REQ;
15849 pMsg->msgLen = (uint16_t) sizeof(tAniGetRssiReq);
15850 pMsg->sessionId = sessionId;
15851 pMsg->staId = staId;
15852 pMsg->rssiCallback = callback;
15853 pMsg->pDevContext = pContext;
15854 pMsg->p_cds_context = p_cds_context;
15855 /*
15856 * store RSSI at time of calling, so that if RSSI request cannot
15857 * be sent to firmware, this value can be used to return immediately
15858 */
15859 pMsg->lastRSSI = lastRSSI;
15860 msg.type = eWNI_SME_GET_RSSI_REQ;
15861 msg.bodyptr = pMsg;
15862 msg.reserved = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015863 if (QDF_STATUS_SUCCESS != cds_mq_post_message(CDS_MQ_ID_SME, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015864 sms_log(pMac, LOGE, " csr_get_rssi failed to post msg to self ");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015865 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015866 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015867 }
15868 sms_log(pMac, LOG2, FL("returned"));
15869 return status;
15870}
15871
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015872QDF_STATUS csr_get_snr(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015873 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015874 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015875{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015876 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015877 cds_msg_t msg;
15878 uint32_t sessionId;
15879
15880 tAniGetSnrReq *pMsg;
15881
15882 sms_log(pMac, LOG2, FL("called"));
15883
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015884 pMsg = (tAniGetSnrReq *) qdf_mem_malloc(sizeof(tAniGetSnrReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015885 if (NULL == pMsg) {
15886 sms_log(pMac, LOGE, "%s: failed to allocate mem for req",
15887 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015888 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015889 }
15890
15891 csr_roam_get_session_id_from_bssid(pMac, &bssId, &sessionId);
15892
15893 pMsg->msgType = eWNI_SME_GET_SNR_REQ;
15894 pMsg->msgLen = (uint16_t) sizeof(tAniGetSnrReq);
15895 pMsg->sessionId = sessionId;
15896 pMsg->staId = staId;
15897 pMsg->snrCallback = callback;
15898 pMsg->pDevContext = pContext;
15899 msg.type = eWNI_SME_GET_SNR_REQ;
15900 msg.bodyptr = pMsg;
15901 msg.reserved = 0;
15902
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015903 if (QDF_STATUS_SUCCESS != cds_mq_post_message(CDS_MQ_ID_SME, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015904 sms_log(pMac, LOGE, "%s failed to post msg to self", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015905 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015906 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015907 }
15908
15909 sms_log(pMac, LOG2, FL("returned"));
15910 return status;
15911}
15912
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015913/**
15914 * csr_deregister_client_request() - deregisters a get stats request
15915 * @mac_ctx: mac global context
15916 * @sta_entry: stats request entry
15917 *
15918 * Return: status of operation
15919 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015920static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015921csr_deregister_client_request(tpAniSirGlobal mac_ctx,
15922 tCsrStatsClientReqInfo *sta_entry)
15923{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015924 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015925 tListElem *entry = NULL;
15926 tCsrStatsClientReqInfo *ptr_sta_entry = NULL;
15927
15928 entry = csr_roam_checkn_update_client_req_list(mac_ctx, sta_entry,
15929 false);
15930 if (!entry) {
15931 sms_log(mac_ctx, LOGW,
15932 FL("callback is empty in the request & couldn't find any existing request in statsClientReqList"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015933 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015934 }
15935 /* clean up & return */
15936 ptr_sta_entry = GET_BASE_ADDR(entry, tCsrStatsClientReqInfo, link);
15937 if (NULL != ptr_sta_entry->pPeStaEntry) {
15938 ptr_sta_entry->pPeStaEntry->numClient--;
15939 /* check if we need to delete the entry from peStatsReqList */
15940 if (!ptr_sta_entry->pPeStaEntry->numClient)
15941 csr_roam_remove_entry_from_pe_stats_req_list(mac_ctx,
15942 ptr_sta_entry->pPeStaEntry);
15943 }
15944 /* check if we need to stop the tl stats timer too */
15945 mac_ctx->roam.tlStatsReqInfo.numClient--;
15946 if (!mac_ctx->roam.tlStatsReqInfo.numClient) {
15947 if (mac_ctx->roam.tlStatsReqInfo.timerRunning) {
Anurag Chouhan210db072016-02-22 18:42:15 +053015948 status = qdf_mc_timer_stop(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015949 &mac_ctx->roam.tlStatsReqInfo.hTlStatsTimer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015950 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015951 sms_log(mac_ctx, LOGE,
15952 FL("cannot stop TlStatsTimer timer"));
15953 return status;
15954 }
15955 }
15956 mac_ctx->roam.tlStatsReqInfo.periodicity = 0;
15957 mac_ctx->roam.tlStatsReqInfo.timerRunning = false;
15958 }
Anurag Chouhan210db072016-02-22 18:42:15 +053015959 qdf_mc_timer_stop(&ptr_sta_entry->timer);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053015960 /* Destroy the qdf timer... */
Anurag Chouhan210db072016-02-22 18:42:15 +053015961 status = qdf_mc_timer_destroy(&ptr_sta_entry->timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015962 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015963 sms_log(mac_ctx, LOGE,
15964 FL("failed to destroy Client req timer"));
15965
15966 csr_roam_remove_stat_list_entry(mac_ctx, entry);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015967 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015968}
15969
15970/**
15971 * csr_insert_stats_request_to_list() - inserts request to existing list
15972 * @mac_ctx: mac global context
15973 * @sta_entry: stats request entry
15974 * @periodicity: periodicity of stats
15975 *
15976 * Return: status of operation
15977 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015978static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015979csr_insert_stats_request_to_list(tpAniSirGlobal mac_ctx,
15980 tCsrStatsClientReqInfo *sta_entry,
15981 uint32_t periodicity)
15982{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015983 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015984 tCsrStatsClientReqInfo *ptr_sta_entry = csr_roam_insert_entry_into_list(
15985 mac_ctx, &mac_ctx->roam.statsClientReqList,
15986 sta_entry);
15987 if (!ptr_sta_entry) {
15988 sms_log(mac_ctx, LOGW,
15989 FL("Failed to insert req in statsClientReqList"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015990 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015991 }
15992 /* Init & start timer if needed */
15993 ptr_sta_entry->periodicity = periodicity;
15994 if (ptr_sta_entry->periodicity) {
Anurag Chouhan210db072016-02-22 18:42:15 +053015995 status = qdf_mc_timer_init(&ptr_sta_entry->timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015996 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015997 csr_roam_stats_client_timer_handler,
15998 ptr_sta_entry);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015999 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016000 sms_log(mac_ctx, LOGE,
16001 FL("cannot init StatsClient timer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016002 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016003 }
Anurag Chouhan210db072016-02-22 18:42:15 +053016004 status = qdf_mc_timer_start(&ptr_sta_entry->timer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016005 ptr_sta_entry->periodicity);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016006 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016007 sms_log(mac_ctx, LOGE,
16008 FL("cannot start StatsClient timer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016009 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016010 }
16011 }
16012 return status;
16013}
16014
16015/**
16016 * csr_get_statistics_from_tl() - fetch stats from tl layer
16017 * @mac_ctx: mac global context
16018 * @cache: indicate if cached stats are required
16019 * @staId: station id
16020 * @periodicity: periodicity of stats
16021 *
16022 * Return: status of operation
16023 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016024static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016025csr_get_statistics_from_tl(tpAniSirGlobal mac_ctx,
16026 bool cache,
16027 uint8_t staId,
16028 uint32_t periodicity)
16029{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016030 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016031
16032 if (cache && mac_ctx->roam.tlStatsReqInfo.numClient) {
16033 sms_log(mac_ctx, LOGE, FL("Looking for cached stats from TL"));
16034 mac_ctx->roam.tlStatsReqInfo.numClient++;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016035 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016036 }
16037
16038 /* update periodicity */
16039 if (mac_ctx->roam.tlStatsReqInfo.periodicity)
16040 mac_ctx->roam.tlStatsReqInfo.periodicity =
Anurag Chouhan6d760662016-02-20 16:05:43 +053016041 QDF_MIN(periodicity,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016042 mac_ctx->roam.tlStatsReqInfo.periodicity);
16043 else
16044 mac_ctx->roam.tlStatsReqInfo.periodicity = periodicity;
16045
16046 if (mac_ctx->roam.tlStatsReqInfo.periodicity
16047 < CSR_MIN_TL_STAT_QUERY_PERIOD) {
16048 mac_ctx->roam.tlStatsReqInfo.periodicity =
16049 CSR_MIN_TL_STAT_QUERY_PERIOD;
16050 }
16051
16052 if (!mac_ctx->roam.tlStatsReqInfo.timerRunning) {
16053
16054 if (mac_ctx->roam.tlStatsReqInfo.periodicity) {
16055 /* start timer */
Anurag Chouhan210db072016-02-22 18:42:15 +053016056 status = qdf_mc_timer_start(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016057 &mac_ctx->roam.tlStatsReqInfo.hTlStatsTimer,
16058 mac_ctx->roam.tlStatsReqInfo.periodicity);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016059 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016060 sms_log(mac_ctx, LOGE,
16061 FL("cannot start TlStatsTimer timer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016062 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016063 }
16064 mac_ctx->roam.tlStatsReqInfo.timerRunning = true;
16065 }
16066 }
16067 mac_ctx->roam.tlStatsReqInfo.numClient++;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016068 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016069}
16070
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016071QDF_STATUS csr_get_statistics(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016072 eCsrStatsRequesterType requesterId,
16073 uint32_t statsMask,
16074 tCsrStatsCallback callback,
16075 uint32_t periodicity,
16076 bool cache,
16077 uint8_t staId,
16078 void *pContext,
16079 uint8_t sessionId)
16080{
16081 tCsrStatsClientReqInfo staEntry;
16082 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
16083 bool found = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016084 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016085 bool insertInClientList = false;
16086 uint32_t temp_mask = 0;
16087
16088 if (csr_is_all_session_disconnected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016089 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016090
16091 if (csr_neighbor_middle_of_roaming(pMac, sessionId)) {
16092 sms_log(pMac, LOG1, FL("in the middle of roaming states"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016093 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016094 }
16095
16096 if ((!statsMask) && (!callback)) {
16097 sms_log(pMac, LOGW,
16098 FL("statsMask & callback empty in the request"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016099 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016100 }
16101 /* for the search list method for deregister */
16102 staEntry.requesterId = requesterId;
16103 staEntry.statsMask = statsMask;
16104 /* requester wants to deregister or just an error */
16105 if ((statsMask) && (!callback))
16106 return csr_deregister_client_request(pMac, &staEntry);
16107
16108 if (cache && !periodicity) {
16109 /* return the cached stats */
16110 csr_roam_report_statistics(pMac, statsMask, callback, staId,
16111 pContext);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016112 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016113 }
16114 /* add the request in the client req list */
16115 staEntry.callback = callback;
16116 staEntry.pContext = pContext;
16117 staEntry.periodicity = periodicity;
16118 staEntry.pPeStaEntry = NULL;
16119 staEntry.staId = staId;
16120 staEntry.pMac = pMac;
16121 staEntry.timerExpired = false;
16122 staEntry.sessionId = sessionId;
16123
16124 /* if periodic report requested with non cached result from PE/TL */
16125 if (periodicity) {
16126 /* if looking for stats from PE */
16127 temp_mask = statsMask & ~(1 << eCsrGlobalClassDStats);
16128 if (temp_mask) {
16129 /* check if same req made already & waiting for rsp */
16130 pPeStaEntry = csr_roam_check_pe_stats_req_list(pMac,
16131 temp_mask, periodicity, &found,
16132 staId, sessionId);
16133 if (!pPeStaEntry)
16134 /* bail out, maxed out on num of req for PE */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016135 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016136 else
16137 staEntry.pPeStaEntry = pPeStaEntry;
16138 }
16139 /*
16140 * request stats from TL rightaway if requested by client,
16141 * update tlStatsReqInfo if needed
16142 */
16143 temp_mask = statsMask & (1 << eCsrGlobalClassDStats);
16144 if (temp_mask) {
16145 status = csr_get_statistics_from_tl(pMac, cache, staId,
16146 periodicity);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016147 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016148 return status;
16149 }
16150 insertInClientList = true;
16151 }
16152 /* if one time report requested with non cached result from PE/TL */
16153 else if (!cache && !periodicity) {
16154 temp_mask = statsMask & ~(1 << eCsrGlobalClassDStats);
16155 if (temp_mask) {
16156 /* send down a req */
16157 status = csr_send_mb_stats_req_msg(pMac,
16158 temp_mask, staId, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016159 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016160 sms_log(pMac, LOGE,
16161 FL("failed to send down stats req"));
16162 /*
16163 * so that when the stats rsp comes back from PE we
16164 * respond to upper layer right away
16165 */
16166 staEntry.timerExpired = true;
16167 insertInClientList = true;
16168 }
16169 /* if looking for stats from TL only */
16170 if (!insertInClientList) {
16171 /* return the stats */
16172 csr_roam_report_statistics(pMac, statsMask, callback,
16173 staId, pContext);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016174 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016175 }
16176 }
16177 if (insertInClientList)
16178 return csr_insert_stats_request_to_list(pMac, &staEntry,
16179 periodicity);
16180
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016181 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016182}
16183
16184static tSirRetStatus
16185csr_roam_scan_offload_populate_mac_header(tpAniSirGlobal pMac,
16186 uint8_t *pBD,
16187 uint8_t type,
16188 uint8_t subType,
16189 tSirMacAddr peerAddr,
16190 tSirMacAddr selfMacAddr)
16191{
16192 tSirRetStatus statusCode = eSIR_SUCCESS;
16193 tpSirMacMgmtHdr pMacHdr;
16194
16195 /* Prepare MAC management header */
16196 pMacHdr = (tpSirMacMgmtHdr) (pBD);
16197
16198 /* Prepare FC */
16199 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
16200 pMacHdr->fc.type = type;
16201 pMacHdr->fc.subType = subType;
16202
16203 /* Prepare Address 1 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016204 qdf_mem_copy((uint8_t *) pMacHdr->da, (uint8_t *) peerAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016205 sizeof(tSirMacAddr));
16206
16207 sir_copy_mac_addr(pMacHdr->sa, selfMacAddr);
16208
16209 /* Prepare Address 3 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016210 qdf_mem_copy((uint8_t *) pMacHdr->bssId, (uint8_t *) peerAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016211 sizeof(tSirMacAddr));
16212 return statusCode;
16213} /*** csr_roam_scan_offload_populate_mac_header() ***/
16214
16215static tSirRetStatus
16216csr_roam_scan_offload_prepare_probe_req_template(tpAniSirGlobal pMac,
16217 uint8_t nChannelNum,
16218 uint32_t dot11mode,
16219 tSirMacAddr selfMacAddr,
16220 uint8_t *pFrame,
16221 uint16_t *pusLen,
16222 tCsrRoamSession *psession)
16223{
16224 tDot11fProbeRequest pr;
16225 uint32_t nStatus, nBytes, nPayload;
16226 tSirRetStatus nSirStatus;
16227 /*Bcast tx */
16228 tSirMacAddr bssId = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
16229 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16230
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016231 qdf_mem_set((uint8_t *) &pr, sizeof(pr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016232
16233 populate_dot11f_supp_rates(pMac, nChannelNum, &pr.SuppRates, NULL);
16234
16235 if (WNI_CFG_DOT11_MODE_11B != dot11mode) {
16236 populate_dot11f_ext_supp_rates1(pMac, nChannelNum,
16237 &pr.ExtSuppRates);
16238 }
16239
16240 if (IS_DOT11_MODE_HT(dot11mode)) {
16241 populate_dot11f_ht_caps(pMac, NULL, &pr.HTCaps);
16242 pr.HTCaps.advCodingCap = psession->htConfig.ht_rx_ldpc;
16243 pr.HTCaps.txSTBC = psession->htConfig.ht_tx_stbc;
16244 pr.HTCaps.rxSTBC = psession->htConfig.ht_rx_stbc;
16245 if (!psession->htConfig.ht_sgi) {
16246 pr.HTCaps.shortGI20MHz = pr.HTCaps.shortGI40MHz = 0;
16247 }
16248 }
16249
16250 nStatus = dot11f_get_packed_probe_request_size(pMac, &pr, &nPayload);
16251 if (DOT11F_FAILED(nStatus)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016252 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016253 "Failed to calculate the packed size f"
16254 "or a Probe Request (0x%08x).\n", nStatus);
16255
16256 nPayload = sizeof(tDot11fProbeRequest);
16257 } else if (DOT11F_WARNED(nStatus)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016258 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016259 "There were warnings while calculating"
16260 "the packed size for a Probe Request ("
16261 "0x%08x).\n", nStatus);
16262 }
16263
16264 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
16265
16266 /* Prepare outgoing frame */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016267 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016268
16269 nSirStatus =
16270 csr_roam_scan_offload_populate_mac_header(pMac, pFrame,
16271 SIR_MAC_MGMT_FRAME,
16272 SIR_MAC_MGMT_PROBE_REQ, bssId,
16273 selfMacAddr);
16274
16275 if (eSIR_SUCCESS != nSirStatus) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016276 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016277 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
16278 nSirStatus);
16279 return nSirStatus;
16280 }
16281
16282 nStatus = dot11f_pack_probe_request(pMac, &pr, pFrame +
16283 sizeof(tSirMacMgmtHdr),
16284 nPayload, &nPayload);
16285 if (DOT11F_FAILED(nStatus)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016286 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016287 "Failed to pack a Probe Request (0x%08x).\n",
16288 nStatus);
16289 return eSIR_FAILURE;
16290 } else if (DOT11F_WARNED(nStatus)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016291 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016292 "There were warnings while packing a Probe Request (0x%08x).\n",
16293 nStatus);
16294 }
16295
16296 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
16297 return eSIR_SUCCESS;
16298}
16299
16300#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016301QDF_STATUS csr_roam_set_key_mgmt_offload(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016302 uint32_t sessionId,
16303 bool nRoamKeyMgmtOffloadEnabled)
16304{
16305 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16306 if (!pSession) {
16307 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016308 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016309 }
16310 pSession->RoamKeyMgmtOffloadEnabled = nRoamKeyMgmtOffloadEnabled;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016311 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016312}
16313
16314/**
16315 * csr_update_roam_scan_offload_request() - updates req msg with roam offload
16316 * paramters
16317 * @pMac: mac global context
16318 * @req_buf: out param, roam offload scan request packet
16319 * @session: roam session
16320 *
16321 * Return: void
16322 */
16323static void
16324csr_update_roam_scan_offload_request(tpAniSirGlobal mac_ctx,
16325 tSirRoamOffloadScanReq *req_buf,
16326 tCsrRoamSession *session)
16327{
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016328 qdf_mem_copy(req_buf->PSK_PMK, session->psk_pmk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016329 sizeof(req_buf->PSK_PMK));
16330 req_buf->pmk_len = session->pmk_len;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016331 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016332 "LFR3: PMK Length = %d", req_buf->pmk_len);
16333 req_buf->R0KH_ID_Length = session->ftSmeContext.r0kh_id_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016334 qdf_mem_copy(req_buf->R0KH_ID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016335 session->ftSmeContext.r0kh_id,
16336 req_buf->R0KH_ID_Length);
16337 req_buf->Prefer5GHz = mac_ctx->roam.configParam.nRoamPrefer5GHz;
16338 req_buf->RoamRssiCatGap = mac_ctx->roam.configParam.bCatRssiOffset;
16339 req_buf->Select5GHzMargin = mac_ctx->roam.configParam.nSelect5GHzMargin;
16340 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
16341 (uint32_t *) &req_buf->ReassocFailureTimeout)
16342 != eSIR_SUCCESS) {
16343 sms_log(mac_ctx, LOGE,
16344 FL("could not retrieve ReassocFailureTimeout value"));
16345 req_buf->ReassocFailureTimeout =
16346 DEFAULT_REASSOC_FAILURE_TIMEOUT;
16347 }
16348#ifdef FEATURE_WLAN_ESE
16349 if (csr_is_auth_type_ese(req_buf->ConnectedNetwork.authentication)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016350 qdf_mem_copy(req_buf->KRK, session->eseCckmInfo.krk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016351 SIR_KRK_KEY_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016352 qdf_mem_copy(req_buf->BTK, session->eseCckmInfo.btk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016353 SIR_BTK_KEY_LEN);
16354 }
16355#endif
16356 req_buf->AcUapsd.acbe_uapsd =
16357 SIR_UAPSD_GET(ACBE, mac_ctx->lim.gUapsdPerAcBitmask);
16358 req_buf->AcUapsd.acbk_uapsd =
16359 SIR_UAPSD_GET(ACBK, mac_ctx->lim.gUapsdPerAcBitmask);
16360 req_buf->AcUapsd.acvi_uapsd =
16361 SIR_UAPSD_GET(ACVI, mac_ctx->lim.gUapsdPerAcBitmask);
16362 req_buf->AcUapsd.acvo_uapsd =
16363 SIR_UAPSD_GET(ACVO, mac_ctx->lim.gUapsdPerAcBitmask);
16364}
16365#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
16366
16367/**
16368 * csr_check_band_channel_match() - check if passed band and channel match
16369 * paramters
16370 * @band: band to match with channel
16371 * @channel: channel to match with band
16372 *
16373 * Return: bool if match else false
16374 */
16375static bool
16376csr_check_band_channel_match(eCsrBand band, uint8_t channel)
16377{
16378 if (eCSR_BAND_ALL == band)
16379 return true;
16380
16381 if (eCSR_BAND_24 == band && CDS_IS_CHANNEL_24GHZ(channel))
16382 return true;
16383
16384 if (eCSR_BAND_5G == band && CDS_IS_CHANNEL_5GHZ(channel))
16385 return true;
16386
16387 return false;
16388}
16389
16390/**
16391 * csr_fetch_ch_lst_from_ini() - fetch channel list from ini and update req msg
16392 * paramters
16393 * @mac_ctx: global mac ctx
16394 * @roam_info: roam info struct
16395 * @req_buf: out param, roam offload scan request packet
16396 *
16397 * Return: result of operation
16398 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016399static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016400csr_fetch_ch_lst_from_ini(tpAniSirGlobal mac_ctx,
16401 tpCsrNeighborRoamControlInfo roam_info,
16402 tSirRoamOffloadScanReq *req_buf)
16403{
16404 eCsrBand band;
16405 uint8_t i = 0;
16406 uint8_t num_channels = 0;
16407 uint8_t *ch_lst = roam_info->cfgParams.channelInfo.ChannelList;
16408 /*
16409 * The INI channels need to be filtered with respect to the current band
16410 * that is supported.
16411 */
16412 band = mac_ctx->roam.configParam.bandCapability;
16413 if ((eCSR_BAND_24 != band) && (eCSR_BAND_5G != band)
16414 && (eCSR_BAND_ALL != band)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016415 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016416 FL("Invalid band(%d), roam scan offload req aborted"),
16417 band);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016418 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016419 }
16420
16421 for (i = 0; i < roam_info->cfgParams.channelInfo.numOfChannels; i++) {
16422 if (!csr_check_band_channel_match(band, *ch_lst))
16423 continue;
16424 /* Allow DFS channels only if the DFS roaming is enabled */
16425 if (((mac_ctx->roam.configParam.allowDFSChannelRoam !=
16426 CSR_ROAMING_DFS_CHANNEL_DISABLED)
16427 || (!CDS_IS_DFS_CH(*ch_lst)))
16428 && csr_roam_is_channel_valid(mac_ctx, *ch_lst)
16429 && *ch_lst && (num_channels < SIR_ROAM_MAX_CHANNELS)) {
16430 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
16431 *ch_lst;
16432 }
16433 ch_lst++;
16434 }
16435 req_buf->ConnectedNetwork.ChannelCount = num_channels;
16436 req_buf->ChannelCacheType = CHANNEL_LIST_STATIC;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016437 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016438}
16439
16440/**
16441 * csr_fetch_ch_lst_from_occupied_lst() - fetch channel list from occupied list
16442 * and update req msg
16443 * paramters
16444 * @mac_ctx: global mac ctx
16445 * @session_id: session id
16446 * @reason: reason to roam
16447 * @req_buf: out param, roam offload scan request packet
16448 * @roam_info: roam info struct
16449 *
16450 * Return: void
16451 */
16452static void
16453csr_fetch_ch_lst_from_occupied_lst(tpAniSirGlobal mac_ctx,
16454 uint8_t session_id,
16455 uint8_t reason,
16456 tSirRoamOffloadScanReq *req_buf,
16457 tpCsrNeighborRoamControlInfo roam_info)
16458{
16459 uint8_t i = 0;
16460 uint8_t num_channels = 0;
16461 uint8_t *ch_lst =
16462 mac_ctx->scan.occupiedChannels[session_id].channelList;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016463 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016464 "Num of channels before filtering=%d",
16465 mac_ctx->scan.occupiedChannels[session_id].numChannels);
16466 for (i = 0; i < mac_ctx->scan.occupiedChannels[session_id].numChannels;
16467 i++) {
16468 if (((mac_ctx->roam.configParam.allowDFSChannelRoam !=
16469 CSR_ROAMING_DFS_CHANNEL_DISABLED)
16470 || (!CDS_IS_DFS_CH(*ch_lst)))
16471 && *ch_lst && (num_channels < SIR_ROAM_MAX_CHANNELS)) {
16472 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
16473 *ch_lst;
16474 }
16475 if (*ch_lst)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016476 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016477 "DFSRoam=%d, ChnlState=%d, Chnl=%d, num_ch=%d",
16478 mac_ctx->roam.configParam.allowDFSChannelRoam,
16479 cds_get_channel_state(*ch_lst), *ch_lst,
16480 num_channels);
16481 ch_lst++;
16482 }
16483 req_buf->ConnectedNetwork.ChannelCount = num_channels;
16484 /*
16485 * If the profile changes as to what it was earlier, inform the FW
16486 * through FLUSH as ChannelCacheType in which case, the FW will flush
16487 * the occupied channels for the earlier profile and try to learn them
16488 * afresh
16489 */
16490 if (reason == REASON_FLUSH_CHANNEL_LIST)
16491 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16492 else {
16493 if (csr_neighbor_roam_is_new_connected_profile(mac_ctx,
16494 session_id))
16495 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16496 else
16497 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16498 }
16499}
16500
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016501/**
16502 * csr_fetch_valid_ch_lst() - fetch channel list from valid channel list and
16503 * update req msg
16504 * paramters
16505 * @mac_ctx: global mac ctx
16506 * @req_buf: out param, roam offload scan request packet
16507 *
16508 * Return: void
16509 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016510static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016511csr_fetch_valid_ch_lst(tpAniSirGlobal mac_ctx,
16512 tSirRoamOffloadScanReq *req_buf)
16513{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016514 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016515 uint32_t host_channels = 0;
16516 uint8_t *ch_lst = NULL;
16517 uint8_t i = 0, num_channels = 0;
16518
16519 host_channels = sizeof(mac_ctx->roam.validChannelList);
16520 status = csr_get_cfg_valid_channels(mac_ctx,
16521 mac_ctx->roam.validChannelList,
16522 &host_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016523 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016524 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016525 FL("Failed to get the valid channel list"));
16526 return status;
16527 }
16528 ch_lst = mac_ctx->roam.validChannelList;
16529 mac_ctx->roam.numValidChannels = host_channels;
16530 for (i = 0; i < mac_ctx->roam.numValidChannels; i++) {
16531 if (((mac_ctx->roam.configParam.allowDFSChannelRoam
16532 != CSR_ROAMING_DFS_CHANNEL_DISABLED) ||
16533 (!CDS_IS_DFS_CH(*ch_lst))) && *ch_lst) {
16534 req_buf->ValidChannelList[num_channels++] = *ch_lst;
16535 }
16536 ch_lst++;
16537 }
16538 req_buf->ValidChannelCount = num_channels;
16539 return status;
16540}
16541
16542/**
16543 * csr_create_roam_scan_offload_request() - init roam offload scan request
16544 *
16545 * paramters
16546 * @mac_ctx: global mac ctx
16547 * @command: roam scan offload command input
16548 * @session_id: session id
16549 * @reason: reason to roam
16550 * @session: roam session
16551 * @roam_info: roam info struct
16552 *
16553 * Return: roam offload scan request packet buffer
16554 */
16555static tSirRoamOffloadScanReq *
16556csr_create_roam_scan_offload_request(tpAniSirGlobal mac_ctx,
16557 uint8_t command,
16558 uint8_t session_id,
16559 uint8_t reason,
16560 tCsrRoamSession *session,
16561 tpCsrNeighborRoamControlInfo roam_info)
16562{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016563 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016564 uint8_t i, j, dot11_mode;
16565 bool ese_neighbor_list_recvd = false;
16566 uint8_t ch_cache_str[128] = { 0 };
16567 tSirRoamOffloadScanReq *req_buf = NULL;
16568 tpCsrChannelInfo curr_ch_lst_info =
16569 &roam_info->roamChannelInfo.currentChannelListInfo;
16570#ifdef FEATURE_WLAN_ESE
16571 /*
16572 * this flag will be true if connection is ESE and no neighbor
16573 * list received or if the connection is not ESE
16574 */
16575 ese_neighbor_list_recvd = ((roam_info->isESEAssoc)
16576 && (roam_info->roamChannelInfo.IAPPNeighborListReceived
16577 == false))
16578 || (roam_info->isESEAssoc == false);
16579#endif /* FEATURE_WLAN_ESE */
16580
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016581 req_buf = qdf_mem_malloc(sizeof(tSirRoamOffloadScanReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016582 if (NULL == req_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016583 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016584 FL("Mem alloc for roam scan offload req failed."));
16585 return NULL;
16586 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016587 qdf_mem_zero(req_buf, sizeof(tSirRoamOffloadScanReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016588 req_buf->Command = command;
16589 /*
16590 * If command is STOP, then pass down ScanOffloadEnabled as Zero. This
16591 * will handle the case of host driver reloads, but Riva still up and
16592 * running
16593 */
16594 if (command == ROAM_SCAN_OFFLOAD_STOP) {
16595 /*
16596 * clear the roaming parameters that are per connection.
16597 * For a new connection, they have to be programmed again.
16598 */
16599 if (csr_neighbor_middle_of_roaming((tHalHandle)mac_ctx,
16600 session_id))
16601 req_buf->middle_of_roaming = 1;
16602 else
16603 csr_roam_reset_roam_params(mac_ctx);
16604 req_buf->RoamScanOffloadEnabled = 0;
16605 } else {
16606 req_buf->RoamScanOffloadEnabled =
16607 mac_ctx->roam.configParam.isRoamOffloadScanEnabled;
16608 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016609 qdf_mem_copy(req_buf->ConnectedNetwork.currAPbssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016610 roam_info->currAPbssid.bytes, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016611 req_buf->ConnectedNetwork.ssId.length =
16612 mac_ctx->roam.roamSession[session_id].
16613 connectedProfile.SSID.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016614 qdf_mem_copy(req_buf->ConnectedNetwork.ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016615 mac_ctx->roam.roamSession[session_id].
16616 connectedProfile.SSID.ssId,
16617 req_buf->ConnectedNetwork.ssId.length);
16618 req_buf->ConnectedNetwork.authentication =
16619 mac_ctx->roam.roamSession[session_id].connectedProfile.AuthType;
16620 req_buf->ConnectedNetwork.encryption =
16621 mac_ctx->roam.roamSession[session_id].
16622 connectedProfile.EncryptionType;
16623 req_buf->ConnectedNetwork.mcencryption =
16624 mac_ctx->roam.roamSession[session_id].
16625 connectedProfile.mcEncryptionType;
16626#ifdef WLAN_FEATURE_11W
16627 req_buf->ConnectedNetwork.mfp_enabled =
16628 mac_ctx->roam.roamSession[session_id].connectedProfile.MFPEnabled;
16629#endif
16630 req_buf->delay_before_vdev_stop =
16631 roam_info->cfgParams.delay_before_vdev_stop;
16632 req_buf->OpportunisticScanThresholdDiff =
16633 roam_info->cfgParams.nOpportunisticThresholdDiff;
16634 req_buf->RoamRescanRssiDiff =
16635 roam_info->cfgParams.nRoamRescanRssiDiff;
16636 req_buf->RoamRssiDiff = mac_ctx->roam.configParam.RoamRssiDiff;
16637 req_buf->reason = reason;
16638 req_buf->NeighborScanTimerPeriod =
16639 roam_info->cfgParams.neighborScanPeriod;
16640 req_buf->NeighborRoamScanRefreshPeriod =
16641 roam_info->cfgParams.neighborResultsRefreshPeriod;
16642 req_buf->NeighborScanChannelMinTime =
16643 roam_info->cfgParams.minChannelScanTime;
16644 req_buf->NeighborScanChannelMaxTime =
16645 roam_info->cfgParams.maxChannelScanTime;
16646 req_buf->EmptyRefreshScanPeriod =
16647 roam_info->cfgParams.emptyScanRefreshPeriod;
16648 req_buf->RoamBmissFirstBcnt =
16649 roam_info->cfgParams.nRoamBmissFirstBcnt;
16650 req_buf->RoamBmissFinalBcnt =
16651 roam_info->cfgParams.nRoamBmissFinalBcnt;
16652 req_buf->RoamBeaconRssiWeight =
16653 roam_info->cfgParams.nRoamBeaconRssiWeight;
16654 /* MAWC feature */
16655 req_buf->MAWCEnabled = mac_ctx->roam.configParam.MAWCEnabled;
16656#ifdef FEATURE_WLAN_ESE
16657 req_buf->IsESEAssoc =
Srinivas Girigowda18dcf3d2015-12-16 18:11:48 -080016658 csr_roam_is_ese_assoc(mac_ctx, session_id) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016659 ((req_buf->ConnectedNetwork.authentication ==
16660 eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
16661 (csr_is_auth_type_ese(req_buf->
16662 ConnectedNetwork.authentication)));
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016663 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016664 FL("LFR3:IsEseAssoc=%d\n"), req_buf->IsESEAssoc);
16665#endif
16666 if (ese_neighbor_list_recvd || curr_ch_lst_info->numOfChannels == 0) {
16667 /*
16668 * Retrieve the Channel Cache either from ini or from the
16669 * occupied channels list. Give Preference to INI Channels
16670 */
16671 if (roam_info->cfgParams.channelInfo.numOfChannels) {
16672 status = csr_fetch_ch_lst_from_ini(mac_ctx, roam_info,
16673 req_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016674 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016675 qdf_mem_free(req_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016676 return NULL;
16677 }
16678 } else {
16679 csr_fetch_ch_lst_from_occupied_lst(mac_ctx, session_id,
16680 reason, req_buf, roam_info);
16681 }
16682 }
16683#ifdef FEATURE_WLAN_ESE
16684 else {
16685 /*
16686 * If ESE is enabled, and a neighbor Report is received,then
16687 * Ignore the INI Channels or the Occupied Channel List.
16688 * Consider the channels in the neighbor list sent by the ESE AP
16689 */
16690 csr_fetch_ch_lst_from_received_list(mac_ctx, roam_info,
16691 curr_ch_lst_info, req_buf);
16692 }
16693#endif
16694 for (i = 0, j = 0; i < req_buf->ConnectedNetwork.ChannelCount; i++) {
16695 if (j < sizeof(ch_cache_str)) {
16696 j += snprintf(ch_cache_str + j,
16697 sizeof(ch_cache_str) - j, " %d",
16698 req_buf->ConnectedNetwork.
16699 ChannelCache[i]);
16700 } else
16701 break;
16702 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016703 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016704 FL("ChnlCacheType:%d, No of Chnls:%d,Channels: %s"),
16705 req_buf->ChannelCacheType,
16706 req_buf->ConnectedNetwork.ChannelCount, ch_cache_str);
16707
16708 /* Maintain the Valid Channels List */
16709 status = csr_fetch_valid_ch_lst(mac_ctx, req_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016710 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016711 qdf_mem_free(req_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016712 return NULL;
16713 }
16714
16715 req_buf->MDID.mdiePresent =
16716 mac_ctx->roam.roamSession[session_id].
16717 connectedProfile.MDID.mdiePresent;
16718 req_buf->MDID.mobilityDomain =
16719 mac_ctx->roam.roamSession[session_id].
16720 connectedProfile.MDID.mobilityDomain;
16721 req_buf->sessionId = session_id;
16722 req_buf->nProbes = mac_ctx->roam.configParam.nProbes;
16723 req_buf->HomeAwayTime = mac_ctx->roam.configParam.nRoamScanHomeAwayTime;
16724
16725 /*
16726 * Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16727 * where RFS is the RF Switching time. It is twice RFS to consider the
16728 * time to go off channel and return to the home channel.
16729 */
16730 if (req_buf->HomeAwayTime < (req_buf->NeighborScanChannelMaxTime +
16731 (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016732 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016733 FL("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)"),
16734 req_buf->HomeAwayTime,
16735 (req_buf->NeighborScanChannelMaxTime +
16736 (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16737 req_buf->HomeAwayTime = 0;
16738 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016739 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016740 FL("HomeAwayTime:%d"), req_buf->HomeAwayTime);
16741
16742 /*Prepare a probe request for 2.4GHz band and one for 5GHz band */
16743 dot11_mode = (uint8_t) csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
16744 csr_find_best_phy_mode(mac_ctx,
16745 mac_ctx->roam.configParam.phyMode));
16746 csr_roam_scan_offload_prepare_probe_req_template(mac_ctx,
16747 SIR_ROAM_SCAN_24G_DEFAULT_CH, dot11_mode,
16748 session->selfMacAddr.bytes, req_buf->p24GProbeTemplate,
16749 &req_buf->us24GProbeTemplateLen, session);
16750
16751 csr_roam_scan_offload_prepare_probe_req_template(mac_ctx,
16752 SIR_ROAM_SCAN_5G_DEFAULT_CH, dot11_mode,
16753 session->selfMacAddr.bytes,
16754 req_buf->p5GProbeTemplate, &req_buf->us5GProbeTemplateLen,
16755 session);
16756 req_buf->allowDFSChannelRoam =
16757 mac_ctx->roam.configParam.allowDFSChannelRoam;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -070016758 req_buf->early_stop_scan_enable =
16759 mac_ctx->roam.configParam.early_stop_scan_enable;
16760 req_buf->early_stop_scan_min_threshold =
16761 mac_ctx->roam.configParam.early_stop_scan_min_threshold;
16762 req_buf->early_stop_scan_max_threshold =
16763 mac_ctx->roam.configParam.early_stop_scan_max_threshold;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016764 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -070016765 FL("EarlyStopFeature Enable=%d, MinThresh=%d, MaxThresh=%d"),
16766 req_buf->early_stop_scan_enable,
16767 req_buf->early_stop_scan_min_threshold,
16768 req_buf->early_stop_scan_max_threshold);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016769#ifdef WLAN_FEATURE_ROAM_OFFLOAD
16770 req_buf->RoamOffloadEnabled = csr_roamIsRoamOffloadEnabled(mac_ctx);
16771 req_buf->RoamKeyMgmtOffloadEnabled = session->RoamKeyMgmtOffloadEnabled;
16772 /* Roam Offload piggybacks upon the Roam Scan offload command. */
16773 if (req_buf->RoamOffloadEnabled)
16774 csr_update_roam_scan_offload_request(mac_ctx, req_buf, session);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016775 qdf_mem_copy(&req_buf->roam_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016776 &mac_ctx->roam.configParam.roam_params,
16777 sizeof(req_buf->roam_params));
16778#endif
16779 return req_buf;
16780}
16781/**
16782 * check_allowed_ssid_list() - Check the WhiteList
16783 * @req_buffer: Buffer which contains the connected profile SSID.
16784 * @roam_params: Buffer which contains the whitelist SSID's.
16785 *
16786 * Check if the connected profile SSID exists in the whitelist.
16787 * It is assumed that the framework provides this also in the whitelist.
16788 * If it exists there is no issue. Otherwise add it to the list.
16789 *
16790 * Return: None
16791 */
16792static void check_allowed_ssid_list(tSirRoamOffloadScanReq *req_buffer,
16793 struct roam_ext_params *roam_params)
16794{
16795 int i = 0;
16796 bool match = false;
16797 for (i = 0; i < roam_params->num_ssid_allowed_list; i++) {
16798 if ((roam_params->ssid_allowed_list[i].length ==
16799 req_buffer->ConnectedNetwork.ssId.length) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016800 (!qdf_mem_cmp(roam_params->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016801 req_buffer->ConnectedNetwork.ssId.ssId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016802 roam_params->ssid_allowed_list[i].length))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016803 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016804 "Whitelist contains connected profile SSID");
16805 match = true;
16806 break;
16807 }
16808 }
16809 if (!match) {
16810 if (roam_params->num_ssid_allowed_list >=
16811 MAX_SSID_ALLOWED_LIST) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016812 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016813 "Whitelist is FULL. Cannot Add another entry");
16814 return;
16815 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016816 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016817 "Adding Connected profile SSID to whitelist");
16818 /* i is the next available index to add the entry.*/
16819 i = roam_params->num_ssid_allowed_list;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016820 qdf_mem_copy(roam_params->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016821 req_buffer->ConnectedNetwork.ssId.ssId,
16822 req_buffer->ConnectedNetwork.ssId.length);
16823 roam_params->ssid_allowed_list[i].length =
16824 req_buffer->ConnectedNetwork.ssId.length;
16825 roam_params->num_ssid_allowed_list++;
16826 }
16827}
16828
16829/*
16830 * Below Table describe whether RSO command can be send down to fimrware or not.
16831 * Host check it on the basis of previous RSO command sent down to firmware.
16832 *||==========================================================================||
16833 *|| New cmd | LAST SENT COMMAND ---> ||
16834 *||====|=====================================================================||
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080016835 *|| V | START | STOP | RESTART | UPDATE_CFG| ABORT_SCAN ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016836 *|| -------------------------------------------------------------------------||
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080016837 *|| RSO_START | NO | YES | NO | NO | NO ||
16838 *|| RSO_STOP | YES | YES | YES | YES | YES ||
16839 *|| RSO_RESTART | YES | YES | NO | YES | YES ||
16840 *|| RSO_UPDATE_CFG | YES | NO | YES | YES | YES ||
16841 *|| RSO_ABORT_SCAN | YES | NO | YES | YES | YES ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016842 *||==========================================================================||
16843 **/
16844#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
16845#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
16846#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
16847#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080016848#define RSO_ABORT_SCAN_BIT (1<<ROAM_SCAN_OFFLOAD_ABORT_SCAN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016849#define RSO_START_ALLOW_MASK (RSO_STOP_BIT)
16850#define RSO_STOP_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080016851 RSO_STOP_BIT | RSO_START_BIT | RSO_ABORT_SCAN_BIT)
16852#define RSO_RESTART_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_START_BIT | \
16853 RSO_ABORT_SCAN_BIT | RSO_RESTART_BIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016854#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_STOP_BIT | \
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080016855 RSO_START_BIT | RSO_ABORT_SCAN_BIT)
16856#define RSO_ABORT_SCAN_ALLOW_MASK (RSO_START_BIT | RSO_RESTART_BIT | \
16857 RSO_UPDATE_CFG_BIT | RSO_ABORT_SCAN_BIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016858
16859bool csr_is_RSO_cmd_allowed(tpAniSirGlobal mac_ctx, uint8_t command,
16860 uint8_t session_id)
16861{
16862 tpCsrNeighborRoamControlInfo neigh_roam_info =
16863 &mac_ctx->roam.neighborRoamInfo[session_id];
16864 uint8_t desiredMask = 0;
16865 bool ret_val;
16866
16867 switch (command) {
16868 case ROAM_SCAN_OFFLOAD_START:
16869 desiredMask = RSO_START_ALLOW_MASK;
16870 break;
16871 case ROAM_SCAN_OFFLOAD_STOP:
16872 desiredMask = RSO_STOP_ALLOW_MASK;
16873 break;
16874 case ROAM_SCAN_OFFLOAD_RESTART:
16875 desiredMask = RSO_RESTART_ALLOW_MASK;
16876 break;
16877 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
16878 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
16879 break;
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080016880 case ROAM_SCAN_OFFLOAD_ABORT_SCAN:
16881 desiredMask = RSO_ABORT_SCAN_ALLOW_MASK;
16882 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016883 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016884 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016885 FL("Wrong RSO command %d, not allowed"), command);
16886 return 0;/*Cmd Not allowed*/
16887 }
16888 ret_val = desiredMask & (1 << neigh_roam_info->last_sent_cmd);
16889 return ret_val;
16890}
16891
16892/**
16893 * csr_roam_offload_scan() - populates roam offload scan request and sends to
16894 * WMA
16895 *
16896 * paramters
16897 * @mac_ctx: global mac ctx
16898 * @session_id: session id
16899 * @command: roam scan offload command input
16900 * @reason: reason to roam
16901 *
16902 * Return: result of operation
16903 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016904QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016905csr_roam_offload_scan(tpAniSirGlobal mac_ctx, uint8_t session_id,
16906 uint8_t command, uint8_t reason)
16907{
16908 uint8_t *state = NULL;
16909 cds_msg_t msg;
16910 tSirRoamOffloadScanReq *req_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016911 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016912 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
16913 tpCsrNeighborRoamControlInfo roam_info =
16914 &mac_ctx->roam.neighborRoamInfo[session_id];
16915 struct roam_ext_params *roam_params_dst;
16916 struct roam_ext_params *roam_params_src;
16917 uint8_t i;
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080016918 uint8_t op_channel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016919
16920 if (NULL == session) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016921 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016922 FL("session is null"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016923 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016924 }
16925#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080016926 if (session->roam_synch_in_progress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016927 && (ROAM_SCAN_OFFLOAD_STOP == command)) {
16928 /*
16929 * When roam synch is in progress for propagation, there is no
16930 * need to send down the STOP command since the firmware is not
16931 * expecting any WMI commands when the roam synch is in progress
16932 */
16933 b_roam_scan_offload_started = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016934 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016935 }
16936#endif
16937 if (0 == csr_roam_is_roam_offload_scan_enabled(mac_ctx)) {
16938 sms_log(mac_ctx, LOGE, "isRoamOffloadScanEnabled not set");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016939 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016940 }
16941 if (!csr_is_RSO_cmd_allowed(mac_ctx, command, session_id) &&
16942 reason != REASON_ROAM_SET_BLACKLIST_BSSID) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016943 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016944 FL("RSO out-of-sync command %d lastSentCmd %d"),
16945 command, roam_info->last_sent_cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016946 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016947 }
16948
16949 if ((true == b_roam_scan_offload_started)
16950 && (ROAM_SCAN_OFFLOAD_START == command)) {
16951 sms_log(mac_ctx, LOGE, "Roam Scan Offload is already started");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016952 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016953 }
16954 /*
16955 * The Dynamic Config Items Update may happen even if the state is in
16956 * INIT. It is important to ensure that the command is passed down to
16957 * the FW only if the Infra Station is in a connected state.A connected
16958 * station could also be in a PREAUTH or REASSOC states.So, consider not
16959 * sending the command down in INIT state. We also have to ensure that
16960 * if there is a STOP command we always have to inform Riva,
16961 * irrespective of whichever state we are in
16962 */
16963
16964 if ((roam_info->neighborRoamState ==
16965 eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
16966 (command != ROAM_SCAN_OFFLOAD_STOP) &&
16967 (reason != REASON_ROAM_SET_BLACKLIST_BSSID)) {
16968 state = mac_trace_get_neighbour_roam_state(
16969 roam_info->neighborRoamState);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016970 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016971 FL("Scan Command not sent to FW state=%s and cmd=%d"),
16972 state, command);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016973 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016974 }
16975
16976 req_buf = csr_create_roam_scan_offload_request(mac_ctx, command,
16977 session_id, reason,
16978 session, roam_info);
16979 if (!req_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016980 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016981 FL("Failed to create req packet"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016982 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016983 }
16984 roam_params_dst = &req_buf->roam_params;
16985 roam_params_src = &mac_ctx->roam.configParam.roam_params;
16986 if (reason == REASON_ROAM_SET_SSID_ALLOWED)
16987 check_allowed_ssid_list(req_buf, roam_params_src);
16988 /*
16989 * Configure the lookup threshold either from INI or from framework.
16990 * If both are present, give higher priority to the one from framework.
16991 */
16992 if (roam_params_src->alert_rssi_threshold)
16993 req_buf->LookupThreshold =
16994 roam_params_src->alert_rssi_threshold;
16995 else
16996 req_buf->LookupThreshold =
16997 (int8_t)roam_info->cfgParams.neighborLookupThreshold *
16998 (-1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016999 qdf_mem_copy(roam_params_dst, roam_params_src,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017000 sizeof(struct roam_ext_params));
17001 /*
17002 * rssi_diff which is updated via framework is equivalent to the
17003 * INI RoamRssiDiff parameter and hence should be updated.
17004 */
17005 if (roam_params_src->rssi_diff)
17006 req_buf->RoamRssiDiff = roam_params_src->rssi_diff;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017007 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017008 "num_bssid_avoid_list: %d, num_ssid_allowed_list: %d, "
17009 "num_bssid_favored: %d, raise_rssi_thresh_5g: %d, "
17010 "drop_rssi_thresh_5g: %d, raise_rssi_type_5g: %d, "
17011 "raise_factor_5g: %d, drop_rssi_type_5g: %d, "
17012 "drop_factor_5g: %d, max_raise_rssi_5g: %d, "
17013 "max_drop_rssi_5g: %d, rssi_diff: %d, alert_rssi_threshold:%d",
17014 roam_params_dst->num_bssid_avoid_list,
17015 roam_params_dst->num_ssid_allowed_list,
17016 roam_params_dst->num_bssid_favored,
17017 roam_params_dst->raise_rssi_thresh_5g,
17018 roam_params_dst->drop_rssi_thresh_5g,
17019 roam_params_dst->raise_rssi_type_5g,
17020 roam_params_dst->raise_factor_5g,
17021 roam_params_dst->drop_rssi_type_5g,
17022 roam_params_dst->drop_factor_5g,
17023 roam_params_dst->max_raise_rssi_5g,
17024 roam_params_dst->max_drop_rssi_5g,
17025 req_buf->RoamRssiDiff, roam_params_dst->alert_rssi_threshold);
17026
Gupta, Kapilc68ad462016-02-01 19:17:23 +053017027 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
17028 "dense_rssi_thresh_offset: %d, dense_min_aps_cnt:%d, traffic_threshold:%d",
17029 roam_params_dst->dense_rssi_thresh_offset,
17030 roam_params_dst->dense_min_aps_cnt,
17031 roam_params_dst->traffic_threshold);
17032
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017033 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017034 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017035 "Blacklist Bssid: ("MAC_ADDRESS_STR")",
Srinivas Girigowdab0532392015-11-24 11:50:16 -080017036 MAC_ADDR_ARRAY(roam_params_dst->bssid_avoid_list[i].bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017037 }
17038 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017039 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017040 "Whitelist: %.*s",
17041 roam_params_dst->ssid_allowed_list[i].length,
17042 roam_params_dst->ssid_allowed_list[i].ssId);
17043 }
17044 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017045 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017046 "Preferred Bssid: ("MAC_ADDRESS_STR") score: %d",
Srinivas Girigowdab0532392015-11-24 11:50:16 -080017047 MAC_ADDR_ARRAY(roam_params_dst->bssid_favored[i].bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017048 roam_params_dst->bssid_favored_factor[i]);
17049 }
17050
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080017051 op_channel = session->connectedProfile.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017052 req_buf->hi_rssi_scan_max_count =
17053 roam_info->cfgParams.hi_rssi_scan_max_count;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017054 req_buf->hi_rssi_scan_delay =
17055 roam_info->cfgParams.hi_rssi_scan_delay;
17056 req_buf->hi_rssi_scan_rssi_ub =
17057 roam_info->cfgParams.hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080017058 /*
17059 * If the current operation channel is 5G frequency band, then
17060 * there is no need to enable the HI_RSSI feature. This feature
17061 * is useful only if we are connected to a 2.4 GHz AP and we wish
17062 * to connect to a better 5GHz AP is available.
17063 */
17064 if (CDS_IS_CHANNEL_5GHZ(op_channel)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017065 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080017066 "Disabling HI_RSSI feature as connected AP is 5GHz");
17067 req_buf->hi_rssi_scan_rssi_delta = 0;
17068 } else {
17069 req_buf->hi_rssi_scan_rssi_delta =
17070 roam_info->cfgParams.hi_rssi_scan_rssi_delta;
17071 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017072 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080017073 "hi_rssi:delta=%d, max_count=%d, delay=%d, ub=%d",
17074 req_buf->hi_rssi_scan_rssi_delta,
17075 req_buf->hi_rssi_scan_max_count,
17076 req_buf->hi_rssi_scan_delay,
17077 req_buf->hi_rssi_scan_rssi_ub);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017078
17079 msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
17080 msg.reserved = 0;
17081 msg.bodyptr = req_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017082 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +053017083 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017084 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017085 "%s: Not able to post message to WMA",
17086 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017087 qdf_mem_free(req_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017088 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017089 } else {
17090 if (ROAM_SCAN_OFFLOAD_START == command)
17091 b_roam_scan_offload_started = true;
17092 else if (ROAM_SCAN_OFFLOAD_STOP == command)
17093 b_roam_scan_offload_started = false;
17094 }
17095 /* update the last sent cmd */
17096 roam_info->last_sent_cmd = command;
17097
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017098 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017099 "Roam Scan Offload Command %d, Reason %d", command, reason);
17100 return status;
17101}
17102
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017103QDF_STATUS csr_roam_offload_scan_rsp_hdlr(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017104 tpSirRoamOffloadScanRsp scanOffloadRsp)
17105{
17106 switch (scanOffloadRsp->reason) {
17107 case 0:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017108 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017109 "Rsp for Roam Scan Offload with failure status");
17110 break;
17111 case REASON_OS_REQUESTED_ROAMING_NOW:
17112 csr_neighbor_roam_proceed_with_handoff_req(pMac,
17113 scanOffloadRsp->sessionId);
17114 break;
17115
17116 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017117 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017118 "Rsp for Roam Scan Offload with reason %d",
17119 scanOffloadRsp->reason);
17120 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017121 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017122}
17123
17124tCsrPeStatsReqInfo *csr_roam_check_pe_stats_req_list(tpAniSirGlobal pMac,
17125 uint32_t statsMask,
17126 uint32_t periodicity,
17127 bool *pFound,
17128 uint8_t staId, uint8_t sessionId)
17129{
17130 bool found = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017131 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017132 tCsrPeStatsReqInfo staEntry;
17133 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
17134 tListElem *pStaEntry = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017135 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017136 *pFound = false;
17137
17138 pStaEntry = csr_roam_find_in_pe_stats_req_list(pMac, statsMask);
17139 if (pStaEntry) {
17140 pTempStaEntry =
17141 GET_BASE_ADDR(pStaEntry, tCsrPeStatsReqInfo, link);
17142 if (pTempStaEntry->periodicity) {
17143 pTempStaEntry->periodicity =
Anurag Chouhan6d760662016-02-20 16:05:43 +053017144 QDF_MIN(periodicity,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017145 pTempStaEntry->periodicity);
17146 } else {
17147 pTempStaEntry->periodicity = periodicity;
17148 }
17149 pTempStaEntry->numClient++;
17150 found = true;
17151 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017152 qdf_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017153 staEntry.numClient = 1;
17154 staEntry.periodicity = periodicity;
17155 staEntry.pMac = pMac;
17156 staEntry.rspPending = false;
17157 staEntry.staId = staId;
17158 staEntry.statsMask = statsMask;
17159 staEntry.timerRunning = false;
17160 staEntry.sessionId = sessionId;
17161 pTempStaEntry =
17162 csr_roam_insert_entry_into_pe_stats_req_list(pMac,
17163 &pMac->roam.
17164 peStatsReqList,
17165 &staEntry);
17166 if (!pTempStaEntry) {
17167 /* msg */
17168 sms_log(pMac, LOGW,
17169 "csr_roam_check_pe_stats_req_list: Failed to insert req in peStatsReqList");
17170 return NULL;
17171 }
17172 }
17173 pTempStaEntry->periodicity =
17174 pMac->roam.configParam.statsReqPeriodicityInPS;
17175
17176 if (!pTempStaEntry->timerRunning) {
17177 /* send down a req in case of one time req, for periodic ones wait for timer to expire */
17178 if (!pTempStaEntry->rspPending && !pTempStaEntry->periodicity) {
17179 status = csr_send_mb_stats_req_msg(pMac,
17180 statsMask & ~(1 <<
17181 eCsrGlobalClassDStats),
17182 staId, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017183 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017184 sms_log(pMac, LOGE,
17185 FL
17186 ("csr_roam_check_pe_stats_req_list:failed to send down stats req to PE"));
17187 } else {
17188 pTempStaEntry->rspPending = true;
17189 }
17190 }
17191 if (pTempStaEntry->periodicity) {
17192 if (!found) {
17193
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017194 qdf_status =
Anurag Chouhan210db072016-02-22 18:42:15 +053017195 qdf_mc_timer_init(&pTempStaEntry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017196 hPeStatsTimer,
Anurag Chouhan6d760662016-02-20 16:05:43 +053017197 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017198 csr_roam_pe_stats_timer_handler,
17199 pTempStaEntry);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017200 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017201 sms_log(pMac, LOGE,
17202 FL
17203 ("csr_roam_check_pe_stats_req_list:cannot init hPeStatsTimer timer"));
17204 return NULL;
17205 }
17206 }
17207 /* start timer */
17208 sms_log(pMac, LOG1,
17209 "csr_roam_check_pe_stats_req_list:peStatsTimer period %d",
17210 pTempStaEntry->periodicity);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017211 qdf_status =
Anurag Chouhan210db072016-02-22 18:42:15 +053017212 qdf_mc_timer_start(&pTempStaEntry->hPeStatsTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017213 pTempStaEntry->periodicity);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017214 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017215 sms_log(pMac, LOGE,
17216 FL
17217 ("csr_roam_check_pe_stats_req_list:cannot start hPeStatsTimer timer"));
17218 return NULL;
17219 }
17220 pTempStaEntry->timerRunning = true;
17221 }
17222 }
17223 *pFound = found;
17224 return pTempStaEntry;
17225}
17226
17227/*
17228 pStaEntry is no longer invalid upon the return of this function.
17229 */
17230static void csr_roam_remove_stat_list_entry(tpAniSirGlobal pMac, tListElem *pEntry)
17231{
17232 if (pEntry) {
17233 if (csr_ll_remove_entry
17234 (&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017235 qdf_mem_free(GET_BASE_ADDR
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017236 (pEntry, tCsrStatsClientReqInfo, link));
17237 }
17238 }
17239}
17240
17241void csr_roam_remove_entry_from_pe_stats_req_list(tpAniSirGlobal pMac,
17242 tCsrPeStatsReqInfo *pPeStaEntry)
17243{
17244 tListElem *pEntry;
17245 tCsrPeStatsReqInfo *pTempStaEntry;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017246 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017247 pEntry = csr_ll_peek_head(&pMac->roam.peStatsReqList, LL_ACCESS_LOCK);
17248 if (!pEntry) {
17249 sms_log(pMac, LOGE, FL(" List empty, no stats req for PE"));
17250 return;
17251 }
17252 while (pEntry) {
17253 pTempStaEntry = GET_BASE_ADDR(pEntry, tCsrPeStatsReqInfo, link);
17254 if (NULL == pTempStaEntry
17255 || (pTempStaEntry->statsMask !=
17256 pPeStaEntry->statsMask)) {
17257 pEntry = csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
17258 LL_ACCESS_NOLOCK);
17259 continue;
17260 }
17261 sms_log(pMac, LOGW, FL("Match found"));
17262 if (pTempStaEntry->timerRunning) {
Anurag Chouhan210db072016-02-22 18:42:15 +053017263 qdf_status = qdf_mc_timer_stop(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017264 &pTempStaEntry->hPeStatsTimer);
17265 /*
17266 * If we are not able to stop the timer here, just
17267 * remove the entry from the linked list. Destroy the
17268 * timer object and free the memory in the timer CB
17269 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017270 if (qdf_status == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017271 /* the timer is successfully stopped */
17272 pTempStaEntry->timerRunning = false;
17273 /* Destroy the timer */
Anurag Chouhan210db072016-02-22 18:42:15 +053017274 qdf_status = qdf_mc_timer_destroy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017275 &pTempStaEntry->hPeStatsTimer);
17276 } else {
17277 /*
17278 * the timer could not be stopped. Hence destroy
17279 * and free the memory for the PE stat entry in
17280 * the timer CB.
17281 */
17282 pTempStaEntry->timerStopFailed = true;
17283 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017284 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017285 sms_log(pMac, LOGE,
17286 FL("failed to stop/destroy timer"));
17287 }
17288 }
17289
17290 if (csr_ll_remove_entry(&pMac->roam.peStatsReqList, pEntry,
17291 LL_ACCESS_LOCK)) {
17292 /*
17293 * Only free the memory if we could stop the timer
17294 * successfully
17295 */
17296 if (!pTempStaEntry->timerStopFailed) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017297 qdf_mem_free(pTempStaEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017298 pTempStaEntry = NULL;
17299 }
17300 break;
17301 }
17302 pEntry = csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
17303 LL_ACCESS_NOLOCK);
17304 } /* end of while loop */
17305 return;
17306}
17307
17308void csr_roam_report_statistics(tpAniSirGlobal pMac, uint32_t statsMask,
17309 tCsrStatsCallback callback, uint8_t staId,
17310 void *pContext)
17311{
17312 uint8_t stats[500];
17313 uint8_t *pStats = NULL;
17314 uint32_t tempMask = 0;
17315 uint8_t counter = 0;
17316 if (!callback) {
17317 sms_log(pMac, LOGE, FL("Cannot report callback NULL"));
17318 return;
17319 }
17320 if (!statsMask) {
17321 sms_log(pMac, LOGE, FL("Cannot report statsMask is 0"));
17322 return;
17323 }
17324 pStats = stats;
17325 tempMask = statsMask;
17326 while (tempMask) {
17327 if (tempMask & 1) {
17328 /* new stats info from PE, fill up the stats strucutres in PMAC */
17329 switch (counter) {
17330 case eCsrSummaryStats:
17331 sms_log(pMac, LOG2, FL("Summary stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017332 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017333 (uint8_t *) &pMac->roam.
17334 summaryStatsInfo,
17335 sizeof(tCsrSummaryStatsInfo));
17336 pStats += sizeof(tCsrSummaryStatsInfo);
17337 break;
17338 case eCsrGlobalClassAStats:
17339 sms_log(pMac, LOG2, FL("ClassA stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017340 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017341 (uint8_t *) &pMac->roam.
17342 classAStatsInfo,
17343 sizeof(tCsrGlobalClassAStatsInfo));
17344 pStats += sizeof(tCsrGlobalClassAStatsInfo);
17345 break;
17346 case eCsrGlobalClassBStats:
17347 sms_log(pMac, LOG2, FL("ClassB stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017348 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017349 (uint8_t *) &pMac->roam.
17350 classBStatsInfo,
17351 sizeof(tCsrGlobalClassBStatsInfo));
17352 pStats += sizeof(tCsrGlobalClassBStatsInfo);
17353 break;
17354 case eCsrGlobalClassCStats:
17355 sms_log(pMac, LOG2, FL("ClassC stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017356 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017357 (uint8_t *) &pMac->roam.
17358 classCStatsInfo,
17359 sizeof(tCsrGlobalClassCStatsInfo));
17360 pStats += sizeof(tCsrGlobalClassCStatsInfo);
17361 break;
17362 case eCsrGlobalClassDStats:
17363 sms_log(pMac, LOG2, FL("ClassD stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017364 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017365 (uint8_t *) &pMac->roam.
17366 classDStatsInfo,
17367 sizeof(tCsrGlobalClassDStatsInfo));
17368 pStats += sizeof(tCsrGlobalClassDStatsInfo);
17369 break;
17370 case eCsrPerStaStats:
17371 sms_log(pMac, LOG2, FL("PerSta stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017372 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017373 (uint8_t *) &pMac->roam.
17374 perStaStatsInfo[staId],
17375 sizeof(tCsrPerStaStatsInfo));
17376 pStats += sizeof(tCsrPerStaStatsInfo);
17377 break;
17378 default:
17379 sms_log(pMac, LOGE,
17380 FL("Unknown stats type and counter %d"),
17381 counter);
17382 break;
17383 }
17384 }
17385 tempMask >>= 1;
17386 counter++;
17387 }
17388 callback(stats, pContext);
17389}
17390
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017391QDF_STATUS csr_roam_dereg_statistics_req(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017392{
17393 tListElem *pEntry = NULL;
17394 tListElem *pPrevEntry = NULL;
17395 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017396 QDF_STATUS status = QDF_STATUS_SUCCESS;
17397 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017398 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList, LL_ACCESS_LOCK);
17399 if (!pEntry) {
17400 /* list empty */
17401 sms_log(pMac, LOGW,
17402 "csr_roam_dereg_statistics_req: List empty, no request from "
17403 "upper layer client(s)");
17404 return status;
17405 }
17406 while (pEntry) {
17407 if (pPrevEntry) {
17408 pTempStaEntry =
17409 GET_BASE_ADDR(pPrevEntry, tCsrStatsClientReqInfo,
17410 link);
17411 /* send up the stats report */
17412 csr_roam_report_statistics(pMac, pTempStaEntry->statsMask,
17413 pTempStaEntry->callback,
17414 pTempStaEntry->staId,
17415 pTempStaEntry->pContext);
17416 csr_roam_remove_stat_list_entry(pMac, pPrevEntry);
17417 }
17418 pTempStaEntry =
17419 GET_BASE_ADDR(pEntry, tCsrStatsClientReqInfo, link);
17420 if (pTempStaEntry->pPeStaEntry) {
17421 /* pPeStaEntry can be NULL */
17422 pTempStaEntry->pPeStaEntry->numClient--;
17423 /* check if we need to delete the entry from peStatsReqList too */
17424 if (!pTempStaEntry->pPeStaEntry->numClient) {
17425 csr_roam_remove_entry_from_pe_stats_req_list(pMac,
17426 pTempStaEntry->
17427 pPeStaEntry);
17428 }
17429 }
17430 /* check if we need to stop the tl stats timer too */
17431 pMac->roam.tlStatsReqInfo.numClient--;
17432 if (!pMac->roam.tlStatsReqInfo.numClient) {
17433 if (pMac->roam.tlStatsReqInfo.timerRunning) {
17434 status =
Anurag Chouhan210db072016-02-22 18:42:15 +053017435 qdf_mc_timer_stop(&pMac->roam.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017436 tlStatsReqInfo.
17437 hTlStatsTimer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017438 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017439 sms_log(pMac, LOGE,
17440 FL
17441 ("csr_roam_dereg_statistics_req:cannot stop TlStatsTimer timer"));
17442 /* we will continue */
17443 }
17444 }
17445 pMac->roam.tlStatsReqInfo.periodicity = 0;
17446 pMac->roam.tlStatsReqInfo.timerRunning = false;
17447 }
17448 if (pTempStaEntry->periodicity) {
17449 /* While creating StaEntry in csr_get_statistics, */
17450 /* Initializing and starting timer only when periodicity is set. */
17451 /* So Stop and Destroy timer only when periodicity is set. */
17452
Anurag Chouhan210db072016-02-22 18:42:15 +053017453 qdf_mc_timer_stop(&pTempStaEntry->timer);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053017454 /* Destroy the qdf timer... */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017455 qdf_status =
Anurag Chouhan210db072016-02-22 18:42:15 +053017456 qdf_mc_timer_destroy(&pTempStaEntry->timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017457 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017458 sms_log(pMac, LOGE,
17459 FL
17460 ("csr_roam_dereg_statistics_req:failed to destroy Client req timer"));
17461 }
17462 }
17463
17464 pPrevEntry = pEntry;
17465 pEntry =
17466 csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
17467 LL_ACCESS_NOLOCK);
17468 }
17469 /* the last one */
17470 if (pPrevEntry) {
17471 pTempStaEntry =
17472 GET_BASE_ADDR(pPrevEntry, tCsrStatsClientReqInfo, link);
17473 /* send up the stats report */
17474 csr_roam_report_statistics(pMac, pTempStaEntry->statsMask,
17475 pTempStaEntry->callback,
17476 pTempStaEntry->staId,
17477 pTempStaEntry->pContext);
17478 csr_roam_remove_stat_list_entry(pMac, pPrevEntry);
17479 }
17480 return status;
17481
17482}
17483
17484tSmeCmd *csr_get_command_buffer(tpAniSirGlobal pMac)
17485{
17486 tSmeCmd *pCmd = sme_get_command_buffer(pMac);
17487 if (pCmd) {
17488 pMac->roam.sPendingCommands++;
17489 }
17490 return pCmd;
17491}
17492
17493void csr_release_command(tpAniSirGlobal pMac, tSmeCmd *pCommand)
17494{
17495 if (pMac->roam.sPendingCommands > 0) {
17496 /* All command allocated through csr_get_command_buffer need to */
17497 /* decrement the pending count when releasing. */
17498 pMac->roam.sPendingCommands--;
17499 sme_release_command(pMac, pCommand);
17500 } else {
17501 sms_log(pMac, LOGE, FL("no pending commands"));
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017502 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017503 }
17504}
17505
17506/* Return SUCCESS is the command is queued, failed */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017507QDF_STATUS csr_queue_sme_command(tpAniSirGlobal pMac, tSmeCmd *pCommand,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017508 bool fHighPriority)
17509{
17510 bool fNoCmdPending;
17511
17512 if (!SME_IS_START(pMac)) {
17513 sms_log(pMac, LOGE, FL("Sme in stop state"));
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017514 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017515 return QDF_STATUS_E_PERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017516 }
17517
17518 if ((eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd) {
17519 sms_log(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
17520 pCommand->u.scanCmd.reason);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017521 return QDF_STATUS_CSR_WRONG_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017522 }
17523
17524 if ((pCommand->command == eSmeCommandScan)
17525 || (pCommand->command == eSmeCommandRemainOnChannel)) {
17526 sms_log(pMac, LOGW,
17527 FL("scan pending list count %d scan_id %d"),
17528 pMac->sme.smeScanCmdPendingList.Count,
17529 pCommand->u.scanCmd.scanID);
17530 csr_ll_insert_tail(&pMac->sme.smeScanCmdPendingList,
17531 &pCommand->Link, LL_ACCESS_LOCK);
17532 /* process the command queue... */
17533 sme_process_pending_queue(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017534 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017535 }
17536 /* Make sure roamCmdPendingList is not empty first */
17537 fNoCmdPending =
17538 csr_ll_is_list_empty(&pMac->roam.roamCmdPendingList, false);
17539 if (fNoCmdPending) {
17540 sme_push_command(pMac, pCommand, fHighPriority);
17541 } else {
17542 /* no list lock is needed since SME lock is held */
17543 if (!fHighPriority) {
17544 csr_ll_insert_tail(&pMac->roam.roamCmdPendingList,
17545 &pCommand->Link, false);
17546 } else {
17547 csr_ll_insert_head(&pMac->roam.roamCmdPendingList,
17548 &pCommand->Link, false);
17549 }
17550 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017551 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017552}
17553
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017554QDF_STATUS csr_roam_update_apwpsie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017555 tSirAPWPSIEs *pAPWPSIES)
17556{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017557 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017558 tSirUpdateAPWPSIEsReq *pMsg;
17559
17560 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17561 if (NULL == pSession) {
17562 sms_log(pMac, LOGE,
Srinivas Girigowda5d486002015-11-25 12:18:44 -080017563 FL("Session does not exist for session id %d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017564 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017565 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017566 }
17567
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017568 pMsg = qdf_mem_malloc(sizeof(*pMsg));
Srinivas Girigowda5d486002015-11-25 12:18:44 -080017569 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017570 return QDF_STATUS_E_NOMEM;
Srinivas Girigowda5d486002015-11-25 12:18:44 -080017571
17572 pMsg->messageType = eWNI_SME_UPDATE_APWPSIE_REQ;
17573 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053017574 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Srinivas Girigowda5d486002015-11-25 12:18:44 -080017575 pMsg->sessionId = sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017576 qdf_mem_copy(&pMsg->APWPSIEs, pAPWPSIES, sizeof(tSirAPWPSIEs));
Srinivas Girigowda5d486002015-11-25 12:18:44 -080017577 pMsg->length = sizeof(*pMsg);
17578 status = cds_send_mb_message_to_mac(pMsg);
17579
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017580 return status;
17581}
17582
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017583QDF_STATUS csr_roam_update_wparsni_es(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017584 tSirRSNie *pAPSirRSNie)
17585{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017586 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017587 tSirUpdateAPWPARSNIEsReq *pMsg;
17588 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17589 if (NULL == pSession) {
17590 sms_log(pMac, LOGE,
17591 FL(" Session does not exist for session id %d"),
17592 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017593 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017594 }
17595 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017596 pMsg = qdf_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017597 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017598 return QDF_STATUS_E_NOMEM;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017599 qdf_mem_set(pMsg, sizeof(tSirUpdateAPWPARSNIEsReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017600 pMsg->messageType = eWNI_SME_SET_APWPARSNIEs_REQ;
17601 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053017602 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017603 pMsg->sessionId = sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017604 qdf_mem_copy(&pMsg->APWPARSNIEs, pAPSirRSNie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017605 sizeof(tSirRSNie));
17606 pMsg->length = sizeof(struct sSirUpdateAPWPARSNIEsReq);
17607 status = cds_send_mb_message_to_mac(pMsg);
17608 } while (0);
17609 return status;
17610}
17611
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017612/*
17613 pBuf points to the beginning of the message
17614 LIM packs disassoc rsp as below,
17615 messageType - 2 bytes
17616 messageLength - 2 bytes
17617 sessionId - 1 byte
17618 transactionId - 2 bytes (uint16_t)
17619 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17620 peerMacAddr - 6 bytes
17621 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17622 */
17623static void csr_ser_des_unpack_diassoc_rsp(uint8_t *pBuf, tSirSmeDisassocRsp *pRsp)
17624{
17625 if (pBuf && pRsp) {
17626 pBuf += 4; /* skip type and length */
17627 pRsp->sessionId = *pBuf++;
Anurag Chouhanc5548422016-02-24 18:33:27 +053017628 qdf_get_u16(pBuf, (uint16_t *) &pRsp->transactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017629 pBuf += 2;
Anurag Chouhanc5548422016-02-24 18:33:27 +053017630 qdf_get_u32(pBuf, (uint32_t *) &pRsp->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017631 pBuf += 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017632 qdf_mem_copy(pRsp->peer_macaddr.bytes, pBuf, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017633 }
17634}
17635
Anurag Chouhan6d760662016-02-20 16:05:43 +053017636/* Returns whether a session is in QDF_STA_MODE...or not */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017637bool csr_roam_is_sta_mode(tpAniSirGlobal pMac, uint32_t sessionId)
17638{
17639 tCsrRoamSession *pSession = NULL;
17640 pSession = CSR_GET_SESSION(pMac, sessionId);
17641 if (!pSession) {
17642 sms_log(pMac, LOGE, FL(" %s: session %d not found "), __func__,
17643 sessionId);
17644 return false;
17645 }
17646 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
17647 sms_log(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17648 return false;
17649 }
17650 if (eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType) {
17651 return false;
17652 }
17653 /* There is a possibility that the above check may fail,because
17654 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17655 * when it is connected.So,we may sneak through the above check even
17656 * if we are not a STA mode INFRA station. So, if we sneak through
17657 * the above condition, we can use the following check if we are
17658 * really in STA Mode.*/
17659
17660 if (NULL != pSession->pCurRoamProfile) {
Anurag Chouhan6d760662016-02-20 16:05:43 +053017661 if (pSession->pCurRoamProfile->csrPersona == QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017662 return true;
17663 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017664 return false;
17665 }
17666 }
17667
17668 return false;
17669}
17670
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017671QDF_STATUS csr_handoff_request(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017672 uint8_t sessionId,
17673 tCsrHandoffRequest *pHandoffInfo)
17674{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017675 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017676 cds_msg_t msg;
17677
17678 tAniHandoffReq *pMsg;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017679 pMsg = qdf_mem_malloc(sizeof(tAniHandoffReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017680 if (NULL == pMsg) {
17681 sms_log(pMac, LOGE,
17682 " csr_handoff_request: failed to allocate mem for req ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017683 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017684 }
17685 pMsg->msgType = eWNI_SME_HANDOFF_REQ;
17686 pMsg->msgLen = (uint16_t) sizeof(tAniHandoffReq);
17687 pMsg->sessionId = sessionId;
17688 pMsg->channel = pHandoffInfo->channel;
17689 pMsg->handoff_src = pHandoffInfo->src;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017690 qdf_mem_copy(pMsg->bssid, pHandoffInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017691 msg.type = eWNI_SME_HANDOFF_REQ;
17692 msg.bodyptr = pMsg;
17693 msg.reserved = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017694 if (QDF_STATUS_SUCCESS != cds_mq_post_message(CDS_MQ_ID_SME, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017695 sms_log(pMac, LOGE,
17696 " csr_handoff_request failed to post msg to self ");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017697 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017698 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017699 }
17700 return status;
17701}
17702
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080017703/**
17704 * csr_roam_channel_change_req() - Post channel change request to LIM
17705 * @pMac: mac context
17706 * @bssid: SAP bssid
17707 * @ch_params: channel information
17708 * @profile: CSR profile
17709 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -080017710 * This API is primarily used to post Channel Change Req for SAP
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080017711 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017712 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017713 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017714QDF_STATUS csr_roam_channel_change_req(tpAniSirGlobal pMac,
Amar Singhale4f28ee2015-10-21 14:36:56 -070017715 struct qdf_mac_addr bssid,
17716 struct ch_params_s *ch_params,
17717 tCsrRoamProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017718{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017719 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017720 tSirChanChangeRequest *pMsg;
17721 tCsrRoamStartBssParams param;
17722
17723 csr_roam_get_bss_start_parms(pMac, profile, &param);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017724 pMsg = qdf_mem_malloc(sizeof(tSirChanChangeRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017725 if (!pMsg) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017726 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017727 }
17728
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017729 qdf_mem_set((void *)pMsg, sizeof(tSirChanChangeRequest), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017730
17731 pMsg->messageType = eWNI_SME_CHANNEL_CHANGE_REQ;
17732 pMsg->messageLen = sizeof(tSirChanChangeRequest);
17733 pMsg->targetChannel = profile->ChannelInfo.ChannelList[0];
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080017734 pMsg->sec_ch_offset = ch_params->sec_ch_offset;
17735 pMsg->ch_width = profile->ch_params.ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017736 pMsg->dot11mode = csr_translate_to_wni_cfg_dot11_mode(pMac,
17737 pMac->roam.configParam.uCfgDot11Mode);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080017738 pMsg->center_freq_seg_0 = ch_params->center_freq_seg0;
17739 pMsg->center_freq_seg_1 = ch_params->center_freq_seg1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017740 qdf_mem_copy(pMsg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
17741 qdf_mem_copy(&pMsg->operational_rateset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017742 &param.operationalRateSet, sizeof(pMsg->operational_rateset));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017743 qdf_mem_copy(&pMsg->extended_rateset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017744 &param.extendedRateSet, sizeof(pMsg->extended_rateset));
17745 status = cds_send_mb_message_to_mac(pMsg);
17746
17747 return status;
17748}
17749
17750/*
17751 * Post Beacon Tx Start request to LIM
17752 * immediately after SAP CAC WAIT is
17753 * completed without any RADAR indications.
17754 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017755QDF_STATUS csr_roam_start_beacon_req(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +053017756 struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017757 uint8_t dfsCacWaitStatus)
17758{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017759 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017760 tSirStartBeaconIndication *pMsg;
17761
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017762 pMsg = qdf_mem_malloc(sizeof(tSirStartBeaconIndication));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017763
17764 if (!pMsg) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017765 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017766 }
17767
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017768 qdf_mem_set((void *)pMsg, sizeof(tSirStartBeaconIndication), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017769 pMsg->messageType = eWNI_SME_START_BEACON_REQ;
17770 pMsg->messageLen = sizeof(tSirStartBeaconIndication);
17771 pMsg->beaconStartStatus = dfsCacWaitStatus;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017772 qdf_mem_copy(pMsg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017773
17774 status = cds_send_mb_message_to_mac(pMsg);
17775
17776 return status;
17777}
17778
17779/*----------------------------------------------------------------------------
17780 \fn csr_roam_modify_add_ies
17781 \brief This function sends msg to modify the additional IE buffers in PE
17782 \param pMac - pMac global structure
17783 \param pModifyIE - pointer to tSirModifyIE structure
17784 \param updateType - Type of buffer
17785 \- return Success or failure
17786 -----------------------------------------------------------------------------*/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017787QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017788csr_roam_modify_add_ies(tpAniSirGlobal pMac,
17789 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
17790{
17791 tpSirModifyIEsInd pModifyAddIEInd = NULL;
17792 uint8_t *pLocalBuffer = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017793 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017794
17795 /* following buffer will be freed by consumer (PE) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017796 pLocalBuffer = qdf_mem_malloc(pModifyIE->ieBufferlength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017797
17798 if (NULL == pLocalBuffer) {
17799 sms_log(pMac, LOGE, FL("Memory Allocation Failure!!!"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017800 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017801 }
17802
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017803 pModifyAddIEInd = qdf_mem_malloc(sizeof(tSirModifyIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017804 if (NULL == pModifyAddIEInd) {
17805 sms_log(pMac, LOGE, FL("Memory Allocation Failure!!!"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017806 qdf_mem_free(pLocalBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017807 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017808 }
17809
17810 /*copy the IE buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017811 qdf_mem_copy(pLocalBuffer, pModifyIE->pIEBuffer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017812 pModifyIE->ieBufferlength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017813 qdf_mem_zero(pModifyAddIEInd, sizeof(tSirModifyIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017814
17815 pModifyAddIEInd->msgType = eWNI_SME_MODIFY_ADDITIONAL_IES;
17816 pModifyAddIEInd->msgLen = sizeof(tSirModifyIEsInd);
17817
Anurag Chouhanc5548422016-02-24 18:33:27 +053017818 qdf_copy_macaddr(&pModifyAddIEInd->modifyIE.bssid, &pModifyIE->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017819
17820 pModifyAddIEInd->modifyIE.smeSessionId = pModifyIE->smeSessionId;
17821 pModifyAddIEInd->modifyIE.notify = pModifyIE->notify;
17822 pModifyAddIEInd->modifyIE.ieID = pModifyIE->ieID;
17823 pModifyAddIEInd->modifyIE.ieIDLen = pModifyIE->ieIDLen;
17824 pModifyAddIEInd->modifyIE.pIEBuffer = pLocalBuffer;
17825 pModifyAddIEInd->modifyIE.ieBufferlength = pModifyIE->ieBufferlength;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080017826 pModifyAddIEInd->modifyIE.oui_length = pModifyIE->oui_length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017827
17828 pModifyAddIEInd->updateType = updateType;
17829
17830 status = cds_send_mb_message_to_mac(pModifyAddIEInd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017831 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017832 sms_log(pMac, LOGE,
17833 FL("Failed to send eWNI_SME_UPDATE_ADDTIONAL_IES msg"
17834 "!!! status %d"), status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017835 qdf_mem_free(pLocalBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017836 }
17837 return status;
17838}
17839
17840/*----------------------------------------------------------------------------
17841 \fn csr_roam_update_add_ies
17842 \brief This function sends msg to updates the additional IE buffers in PE
17843 \param pMac - pMac global structure
17844 \param sessionId - SME session id
17845 \param bssid - BSSID
17846 \param additionIEBuffer - buffer containing addition IE from hostapd
17847 \param length - length of buffer
17848 \param updateType - Type of buffer
17849 \param append - append or replace completely
17850 \- return Success or failure
17851 -----------------------------------------------------------------------------*/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017852QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017853csr_roam_update_add_ies(tpAniSirGlobal pMac,
17854 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
17855{
17856 tpSirUpdateIEsInd pUpdateAddIEs = NULL;
17857 uint8_t *pLocalBuffer = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017858 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017859
17860 if (pUpdateIE->ieBufferlength != 0) {
17861 /* Following buffer will be freed by consumer (PE) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017862 pLocalBuffer = qdf_mem_malloc(pUpdateIE->ieBufferlength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017863 if (NULL == pLocalBuffer) {
17864 sms_log(pMac, LOGE, FL("Memory Allocation Failure!!!"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017865 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017866 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017867 qdf_mem_copy(pLocalBuffer, pUpdateIE->pAdditionIEBuffer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017868 pUpdateIE->ieBufferlength);
17869 }
17870
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017871 pUpdateAddIEs = qdf_mem_malloc(sizeof(tSirUpdateIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017872 if (NULL == pUpdateAddIEs) {
17873 sms_log(pMac, LOGE, FL("Memory Allocation Failure!!!"));
17874 if (pLocalBuffer != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017875 qdf_mem_free(pLocalBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017876 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017877 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017878 }
17879
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017880 qdf_mem_zero(pUpdateAddIEs, sizeof(tSirUpdateIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017881
17882 pUpdateAddIEs->msgType = eWNI_SME_UPDATE_ADDITIONAL_IES;
17883 pUpdateAddIEs->msgLen = sizeof(tSirUpdateIEsInd);
17884
Anurag Chouhanc5548422016-02-24 18:33:27 +053017885 qdf_copy_macaddr(&pUpdateAddIEs->updateIE.bssid, &pUpdateIE->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017886
17887 pUpdateAddIEs->updateIE.smeSessionId = pUpdateIE->smeSessionId;
17888 pUpdateAddIEs->updateIE.append = pUpdateIE->append;
17889 pUpdateAddIEs->updateIE.notify = pUpdateIE->notify;
17890 pUpdateAddIEs->updateIE.ieBufferlength = pUpdateIE->ieBufferlength;
17891 pUpdateAddIEs->updateIE.pAdditionIEBuffer = pLocalBuffer;
17892
17893 pUpdateAddIEs->updateType = updateType;
17894
17895 status = cds_send_mb_message_to_mac(pUpdateAddIEs);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017896 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017897 sms_log(pMac, LOGE,
17898 FL("Failed to send eWNI_SME_UPDATE_ADDTIONAL_IES msg"
17899 "!!! status %d"), status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017900 qdf_mem_free(pLocalBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017901 }
17902 return status;
17903}
17904
17905/**
Abhishek Singh518323d2015-10-19 17:42:01 +053017906 * csr_send_ext_change_channel()- function to post send ECSA
17907 * action frame to lim.
17908 * @mac_ctx: pointer to global mac structure
17909 * @channel: new channel to switch
17910 * @session_id: senssion it should be sent on.
17911 *
17912 * This function is called to post ECSA frame to lim.
17913 *
17914 * Return: success if msg posted to LIM else return failure
17915 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017916QDF_STATUS csr_send_ext_change_channel(tpAniSirGlobal mac_ctx, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +053017917 uint8_t session_id)
17918{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017919 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +053017920 struct sir_sme_ext_cng_chan_req *msg;
17921
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017922 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh518323d2015-10-19 17:42:01 +053017923 if (NULL == msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017924 return QDF_STATUS_E_NOMEM;
Abhishek Singh518323d2015-10-19 17:42:01 +053017925
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017926 qdf_mem_zero(msg, sizeof(*msg));
Abhishek Singh518323d2015-10-19 17:42:01 +053017927 msg->message_type = eWNI_SME_EXT_CHANGE_CHANNEL;
17928 msg->length = sizeof(*msg);
17929 msg->new_channel = channel;
17930 msg->session_id = session_id;
17931 status = cds_send_mb_message_to_mac(msg);
17932 return status;
17933}
17934
17935/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017936 * csr_roam_send_chan_sw_ie_request() - Request to transmit CSA IE
17937 * @mac_ctx: Global MAC context
17938 * @bssid: BSSID
17939 * @target_channel: Channel on which to send the IE
17940 * @csa_ie_reqd: Include/Exclude CSA IE.
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080017941 * @ch_params: operating Channel related information
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017942 *
17943 * This function sends request to transmit channel switch announcement
17944 * IE to lower layers
17945 *
17946 * Return: success or failure
17947 **/
Amar Singhale4f28ee2015-10-21 14:36:56 -070017948QDF_STATUS csr_roam_send_chan_sw_ie_request(tpAniSirGlobal mac_ctx,
17949 struct qdf_mac_addr bssid,
17950 uint8_t target_channel,
17951 uint8_t csa_ie_reqd,
17952 struct ch_params_s *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017953{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017954 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017955 tSirDfsCsaIeRequest *msg;
17956
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017957 msg = qdf_mem_malloc(sizeof(tSirDfsCsaIeRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017958 if (!msg) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017959 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017960 }
17961
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017962 qdf_mem_set((void *)msg, sizeof(tSirDfsCsaIeRequest), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017963 msg->msgType = eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ;
17964 msg->msgLen = sizeof(tSirDfsCsaIeRequest);
17965
17966 msg->targetChannel = target_channel;
17967 msg->csaIeRequired = csa_ie_reqd;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017968 qdf_mem_copy(msg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
Amar Singhale4f28ee2015-10-21 14:36:56 -070017969 qdf_mem_copy(&msg->ch_params, ch_params, sizeof(struct ch_params_s));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017970
17971 status = cds_send_mb_message_to_mac(msg);
17972
17973 return status;
17974}
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080017975#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
17976/**
17977 * csr_roaming_report_diag_event() - Diag events for LFR3
17978 * @mac_ctx: MAC context
17979 * @roam_synch_ind_ptr: Roam Synch Indication Pointer
17980 * @reason: Reason for this event to happen
17981 *
17982 * The major events in the host for LFR3 roaming such as
17983 * roam synch indication, roam synch completion and
17984 * roam synch handoff fail will be indicated to the
17985 * diag framework using this API.
17986 *
17987 * Return: None
17988 */
17989void csr_roaming_report_diag_event(tpAniSirGlobal mac_ctx,
17990 roam_offload_synch_ind *roam_synch_ind_ptr,
17991 eCsrDiagWlanStatusEventReason reason)
17992{
17993 WLAN_HOST_DIAG_EVENT_DEF(roam_connection,
17994 host_event_wlan_status_payload_type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017995 qdf_mem_set(&roam_connection,
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080017996 sizeof(host_event_wlan_status_payload_type), 0);
17997 switch (reason) {
17998 case eCSR_REASON_ROAM_SYNCH_IND:
17999 roam_connection.eventId = eCSR_WLAN_STATUS_CONNECT;
18000 if (roam_synch_ind_ptr) {
18001 roam_connection.rssi = roam_synch_ind_ptr->rssi;
18002 roam_connection.channel =
18003 cds_freq_to_chan(roam_synch_ind_ptr->chan_freq);
18004 }
18005 break;
18006 case eCSR_REASON_ROAM_SYNCH_CNF:
18007 roam_connection.eventId = eCSR_WLAN_STATUS_CONNECT;
18008 break;
18009 case eCSR_REASON_ROAM_HO_FAIL:
18010 roam_connection.eventId = eCSR_WLAN_STATUS_DISCONNECT;
18011 break;
18012 default:
18013 sms_log(mac_ctx, LOGE,
18014 FL("LFR3: Unsupported reason %d"), reason);
18015 return;
18016 }
18017 roam_connection.reason = reason;
18018 WLAN_HOST_DIAG_EVENT_REPORT(&roam_connection, EVENT_WLAN_STATUS);
18019}
18020#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018021
18022#ifdef WLAN_FEATURE_ROAM_OFFLOAD
18023/*----------------------------------------------------------------------------
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018024* fn csr_process_ho_fail_ind
18025* brief This function will process the Hand Off Failure indication
18026* received from the firmware. It will trigger a disconnect on
18027* the session which the firmware reported a hand off failure
18028* param pMac global structure
18029* param pMsgBuf - Contains the session ID for which the handler should apply
18030* --------------------------------------------------------------------------*/
18031void csr_process_ho_fail_ind(tpAniSirGlobal pMac, void *pMsgBuf)
18032{
18033 tSirSmeHOFailureInd *pSmeHOFailInd = (tSirSmeHOFailureInd *) pMsgBuf;
18034 uint32_t sessionId;
18035
18036 if (pSmeHOFailInd)
18037 sessionId = pSmeHOFailInd->sessionId;
18038 else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018039 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018040 "LFR3: Hand-Off Failure Ind is NULL");
18041 return;
18042 }
18043 /* Roaming is supported only on Infra STA Mode. */
18044 if (!csr_roam_is_sta_mode(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018045 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018046 "LFR3:HO Fail cannot be handled for session %d",
18047 sessionId);
18048 return;
18049 }
18050 csr_roam_synch_clean_up(pMac, sessionId);
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080018051 csr_roaming_report_diag_event(pMac, NULL,
18052 eCSR_REASON_ROAM_HO_FAIL);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018053 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018054 "LFR3:Issue Disconnect on session %d", sessionId);
18055 csr_roam_disconnect(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
18056}
18057#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
18058
18059/**
18060 * csr_update_op_class_array() - update op class for each band
18061 * @mac_ctx: mac global context
18062 * @op_classes: out param, operating class array to update
18063 * @channel_info: channel info
18064 * @ch_name: channel band name to display in debug messages
18065 * @i: out param, stores number of operating classes
18066 *
18067 * Return: void
18068 */
18069static void
18070csr_update_op_class_array(tpAniSirGlobal mac_ctx,
18071 uint8_t *op_classes,
18072 tCsrChannel *channel_info,
18073 char *ch_name,
18074 uint8_t *i)
18075{
18076 uint8_t j = 0, idx = 0, class = 0;
18077 bool found = false;
18078 uint8_t num_channels = channel_info->numChannels;
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053018079 uint8_t ch_bandwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018080
18081 sms_log(mac_ctx, LOG1,
18082 FL("Num of %s channels, %d"),
18083 ch_name, num_channels);
18084
18085 for (idx = 0; idx < num_channels
Naveen Rawat3b6068c2016-04-14 19:01:06 -070018086 && *i < (CDS_MAX_SUPP_OPER_CLASSES - 1); idx++) {
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053018087 for (ch_bandwidth = BW20; ch_bandwidth < BWALL;
18088 ch_bandwidth++) {
Amar Singhal22995112016-01-22 10:42:33 -080018089 class = cds_reg_dmn_get_opclass_from_channel(
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053018090 mac_ctx->scan.countryCodeCurrent,
18091 channel_info->channelList[idx],
18092 ch_bandwidth);
18093 sms_log(mac_ctx, LOG4, FL("for chan %d, op class: %d"),
18094 channel_info->channelList[idx], class);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018095
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053018096 found = false;
Naveen Rawat3b6068c2016-04-14 19:01:06 -070018097 for (j = 0; j < CDS_MAX_SUPP_OPER_CLASSES - 1;
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053018098 j++) {
18099 if (op_classes[j] == class) {
18100 found = true;
18101 break;
18102 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018103 }
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053018104
18105 if (!found) {
18106 op_classes[*i] = class;
18107 *i = *i + 1;
18108 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018109 }
18110 }
18111}
18112
18113/**
18114 * csr_update_op_class_array() - update op class for all bands
18115 * @hHal: global hal context
18116 *
18117 * Return: void
18118 */
18119void csr_init_operating_classes(tHalHandle hHal)
18120{
18121 uint8_t i = 0;
18122 uint8_t j = 0;
18123 uint8_t swap = 0;
18124 uint8_t numClasses = 0;
Naveen Rawat3b6068c2016-04-14 19:01:06 -070018125 uint8_t opClasses[CDS_MAX_SUPP_OPER_CLASSES] = {0,};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018126 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
18127
18128 sms_log(pMac, LOG1, FL("Current Country = %c%c"),
18129 pMac->scan.countryCodeCurrent[0],
18130 pMac->scan.countryCodeCurrent[1]);
18131
18132 csr_update_op_class_array(pMac, opClasses,
18133 &pMac->scan.base_channels, "20MHz", &i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018134 numClasses = i;
18135
18136 /* As per spec the operating classes should be in ascending order.
18137 * Bubble sort is fine since we don't have many classes
18138 */
18139 for (i = 0; i < (numClasses - 1); i++) {
18140 for (j = 0; j < (numClasses - i - 1); j++) {
18141 /* For decreasing order use < */
18142 if (opClasses[j] > opClasses[j + 1]) {
18143 swap = opClasses[j];
18144 opClasses[j] = opClasses[j + 1];
18145 opClasses[j + 1] = swap;
18146 }
18147 }
18148 }
18149
18150 sms_log(pMac, LOG1, FL("Number of unique supported op classes %d"),
18151 numClasses);
18152 for (i = 0; i < numClasses; i++) {
18153 sms_log(pMac, LOG1, FL("supported opClasses[%d] = %d"), i,
18154 opClasses[i]);
18155 }
18156
18157 /* Set the ordered list of op classes in regdomain
18158 * for use by other modules
18159 */
Amar Singhal22995112016-01-22 10:42:33 -080018160 cds_reg_dmn_set_curr_opclasses(numClasses, &opClasses[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018161}
18162
18163/**
18164 * csr_find_session_by_type() - This function will find given session type from
18165 * all sessions.
18166 * @mac_ctx: pointer to mac context.
18167 * @type: session type
18168 *
18169 * Return: session id for give session type.
18170 **/
18171static uint32_t
Anurag Chouhan6d760662016-02-20 16:05:43 +053018172csr_find_session_by_type(tpAniSirGlobal mac_ctx, enum tQDF_ADAPTER_MODE type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018173{
18174 uint32_t i, session_id = CSR_SESSION_ID_INVALID;
18175 tCsrRoamSession *session_ptr;
18176 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
18177 if (!CSR_IS_SESSION_VALID(mac_ctx, i))
18178 continue;
18179
18180 session_ptr = CSR_GET_SESSION(mac_ctx, i);
18181 if (type == session_ptr->bssParams.bssPersona) {
18182 session_id = i;
18183 break;
18184 }
18185 }
18186 return session_id;
18187}
18188/**
18189 * csr_is_conn_allow_2g_band() - This function will check if station's conn
18190 * is allowed in 2.4Ghz band.
18191 * @mac_ctx: pointer to mac context.
18192 * @chnl: station's channel.
18193 *
18194 * This function will check if station's connection is allowed in 5Ghz band
18195 * after comparing it with SAP's operating channel. If SAP's operating
18196 * channel and Station's channel is different than this function will return
18197 * false else true.
18198 *
18199 * Return: true or false.
18200 **/
18201static bool csr_is_conn_allow_2g_band(tpAniSirGlobal mac_ctx, uint32_t chnl)
18202{
18203 uint32_t sap_session_id;
18204 tCsrRoamSession *sap_session;
18205
18206 if (0 == chnl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018207 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018208 FL("channel is zero, connection not allowed"));
18209
18210 return false;
18211 }
18212
Anurag Chouhan6d760662016-02-20 16:05:43 +053018213 sap_session_id = csr_find_session_by_type(mac_ctx, QDF_SAP_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018214 if (CSR_SESSION_ID_INVALID != sap_session_id) {
18215 sap_session = CSR_GET_SESSION(mac_ctx, sap_session_id);
18216 if ((0 != sap_session->bssParams.operationChn) &&
18217 (sap_session->bssParams.operationChn != chnl)) {
18218
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018219 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018220 FL
18221 ("Can't allow STA to connect, chnls not same"));
18222 return false;
18223 }
18224 }
18225 return true;
18226}
18227
18228/**
18229 * csr_is_conn_allow_5g_band() - This function will check if station's conn
18230 * is allowed in 5Ghz band.
18231 * @mac_ctx: pointer to mac context.
18232 * @chnl: station's channel.
18233 *
18234 * This function will check if station's connection is allowed in 5Ghz band
18235 * after comparing it with P2PGO's operating channel. If P2PGO's operating
18236 * channel and Station's channel is different than this function will return
18237 * false else true.
18238 *
18239 * Return: true or false.
18240 **/
18241static bool csr_is_conn_allow_5g_band(tpAniSirGlobal mac_ctx, uint32_t chnl)
18242{
18243 uint32_t p2pgo_session_id;
18244 tCsrRoamSession *p2pgo_session;
18245
18246 if (0 == chnl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018247 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018248 FL
18249 ("channel is zero, connection not allowed"));
18250 return false;
18251 }
18252
Anurag Chouhan6d760662016-02-20 16:05:43 +053018253 p2pgo_session_id = csr_find_session_by_type(mac_ctx, QDF_P2P_GO_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018254 if (CSR_SESSION_ID_INVALID != p2pgo_session_id) {
18255 p2pgo_session = CSR_GET_SESSION(mac_ctx, p2pgo_session_id);
18256 if ((0 != p2pgo_session->bssParams.operationChn) &&
18257 (eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED !=
18258 p2pgo_session->connectState) &&
18259 (p2pgo_session->bssParams.operationChn !=
18260 chnl)) {
18261
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018262 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018263 FL
18264 ("Can't allow STA to connect, chnls not same"));
18265 return false;
18266 }
18267 }
18268 return true;
18269}
18270
18271/**
18272 * csr_clear_joinreq_param() - This function will clear station's params
18273 * for stored join request to csr.
18274 * @hal_handle: pointer to hal context.
18275 * @session_id: station's session id.
18276 *
18277 * This function will clear station's allocated memory for cached join
18278 * request.
18279 *
18280 * Return: true or false based on function's overall success.
18281 **/
18282bool csr_clear_joinreq_param(tpAniSirGlobal mac_ctx,
18283 uint32_t session_id)
18284{
18285 tCsrRoamSession *sta_session;
18286 tScanResultList *bss_list;
18287
18288 if (NULL == mac_ctx)
18289 return false;
18290
18291 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
18292 if (NULL == sta_session)
18293 return false;
18294
18295 /* Release the memory allocated by previous join request */
18296 bss_list =
18297 (tScanResultList *)&sta_session->stored_roam_profile.
18298 bsslist_handle;
18299 if (NULL != bss_list) {
18300 csr_scan_result_purge(mac_ctx,
18301 sta_session->stored_roam_profile.bsslist_handle);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018302 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018303 FL("bss list is released for session %d"), session_id);
18304 sta_session->stored_roam_profile.bsslist_handle = NULL;
18305 }
18306 sta_session->stored_roam_profile.bsslist_handle = NULL;
18307 csr_release_profile(mac_ctx, &sta_session->stored_roam_profile.profile);
18308 sta_session->stored_roam_profile.reason = 0;
18309 sta_session->stored_roam_profile.roam_id = 0;
18310 sta_session->stored_roam_profile.imediate_flag = false;
18311 sta_session->stored_roam_profile.clear_flag = false;
18312 return true;
18313}
18314
18315/**
18316 * csr_store_joinreq_param() - This function will store station's join
18317 * request to that station's session.
18318 * @mac_ctx: pointer to mac context.
18319 * @profile: pointer to station's roam profile.
18320 * @scan_cache: pointer to station's scan cache.
18321 * @roam_id: reference to roam_id variable being passed.
18322 * @session_id: station's session id.
18323 *
18324 * This function will store station's join request to one of the
18325 * csr structure and add it to station's session.
18326 *
18327 * Return: true or false based on function's overall success.
18328 **/
18329bool csr_store_joinreq_param(tpAniSirGlobal mac_ctx,
18330 tCsrRoamProfile *profile,
18331 tScanResultHandle scan_cache,
18332 uint32_t *roam_id,
18333 uint32_t session_id)
18334{
18335 tCsrRoamSession *sta_session;
18336
18337 if (NULL == mac_ctx)
18338 return false;
18339
18340 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
18341 if (NULL == sta_session)
18342 return false;
18343
18344 sta_session->stored_roam_profile.session_id = session_id;
18345 csr_roam_copy_profile(mac_ctx,
18346 &sta_session->stored_roam_profile.profile, profile);
18347 /* new bsslist_handle's memory will be relased later */
18348 sta_session->stored_roam_profile.bsslist_handle = scan_cache;
18349 sta_session->stored_roam_profile.reason = eCsrHddIssued;
18350 sta_session->stored_roam_profile.roam_id = *roam_id;
18351 sta_session->stored_roam_profile.imediate_flag = false;
18352 sta_session->stored_roam_profile.clear_flag = false;
18353
18354 return true;
18355}
18356
18357/**
18358 * csr_issue_stored_joinreq() - This function will issues station's stored
18359 * the join request.
18360 * @mac_ctx: pointer to mac context.
18361 * @roam_id: reference to roam_id variable being passed.
18362 * @session_id: station's session id.
18363 *
18364 * This function will issue station's stored join request, from this point
18365 * onwards the flow will be just like normal connect request.
18366 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018367 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018368 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018369QDF_STATUS csr_issue_stored_joinreq(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018370 uint32_t *roam_id,
18371 uint32_t session_id)
18372{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018373 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018374 tCsrRoamSession *sta_session;
18375 uint32_t new_roam_id;
18376
18377 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
18378 if (NULL == sta_session)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018379 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018380 new_roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
18381 *roam_id = new_roam_id;
18382 status = csr_roam_issue_connect(mac_ctx,
18383 sta_session->stored_roam_profile.session_id,
18384 &sta_session->stored_roam_profile.profile,
18385 sta_session->stored_roam_profile.bsslist_handle,
18386 sta_session->stored_roam_profile.reason,
18387 new_roam_id,
18388 sta_session->stored_roam_profile.imediate_flag,
18389 sta_session->stored_roam_profile.clear_flag);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018390 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018391 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018392 FL
18393 ("CSR failed issuing connect cmd with status = 0x%08X"),
18394 status);
18395 csr_clear_joinreq_param(mac_ctx, session_id);
18396 }
18397 return status;
18398}
18399
18400/**
18401 * csr_process_set_hw_mode() - Set HW mode command to PE
18402 * @mac: Globacl MAC pointer
18403 * @command: Command received from SME
18404 *
18405 * Posts the set HW mode command to PE. This message passing
18406 * through PE is required for PE's internal management
18407 *
18408 * Return: None
18409 */
18410void csr_process_set_hw_mode(tpAniSirGlobal mac, tSmeCmd *command)
18411{
18412 uint32_t len;
18413 struct s_sir_set_hw_mode *cmd;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018414 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018415 tSirMsgQ msg;
18416 struct sir_set_hw_mode_resp *param;
18417
18418 /* Setting HW mode is for the entire system.
18419 * So, no need to check session
18420 */
18421
18422 if (!command) {
18423 sms_log(mac, LOGE, FL("Set HW mode param is NULL"));
18424 goto fail;
18425 }
18426
18427 len = sizeof(*cmd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018428 cmd = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018429 if (!cmd) {
18430 sms_log(mac, LOGE, FL("Memory allocation failed"));
18431 /* Probably the fail response will also fail during malloc.
18432 * Still proceeding to send response!
18433 */
18434 goto fail;
18435 }
18436
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053018437 /* For hidden SSID case, if there is any scan command pending
18438 * it needs to be cleared before issuing set HW mode
18439 */
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053018440 if (command->u.set_hw_mode_cmd.reason == SIR_UPDATE_REASON_HIDDEN_STA) {
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053018441 sms_log(mac, LOGE, FL("clear any pending scan command"));
18442 status = csr_scan_abort_mac_scan_not_for_connect(mac,
18443 command->u.set_hw_mode_cmd.session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018444 if (!QDF_IS_STATUS_SUCCESS(status)) {
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053018445 sms_log(mac, LOGE, FL("Failed to clear scan cmd"));
18446 goto fail;
18447 }
18448 }
18449
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018450 qdf_mem_set(cmd, len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018451
18452 cmd->messageType = eWNI_SME_SET_HW_MODE_REQ;
18453 cmd->length = len;
18454 cmd->set_hw.hw_mode_index = command->u.set_hw_mode_cmd.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053018455 cmd->set_hw.reason = command->u.set_hw_mode_cmd.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018456 /*
18457 * Below callback and context info are not needed for PE as of now.
18458 * Storing the passed value in the same s_sir_set_hw_mode format.
18459 */
18460 cmd->set_hw.set_hw_mode_cb = command->u.set_hw_mode_cmd.set_hw_mode_cb;
18461
18462 sms_log(mac, LOG1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053018463 FL("Posting set hw mode req to PE session:%d reason:%d"),
18464 command->u.set_hw_mode_cmd.session_id,
18465 command->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018466
18467 status = cds_send_mb_message_to_mac(cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018468 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018469 sms_log(mac, LOGE, FL("Posting to PE failed"));
18470 return;
18471 }
18472 return;
18473fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018474 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018475 if (!param) {
18476 sms_log(mac, LOGE,
18477 FL("Malloc fail: Fail to send response to SME"));
18478 return;
18479 }
18480 sms_log(mac, LOGE, FL("Sending set HW fail response to SME"));
18481 param->status = SET_HW_MODE_STATUS_ECANCELED;
18482 param->cfgd_hw_mode_index = 0;
18483 param->num_vdev_mac_entries = 0;
18484 msg.type = eWNI_SME_SET_HW_MODE_RESP;
18485 msg.bodyptr = param;
18486 msg.bodyval = 0;
18487 sys_process_mmh_msg(mac, &msg);
18488}
18489
18490/**
18491 * csr_process_set_dual_mac_config() - Set HW mode command to PE
18492 * @mac: Global MAC pointer
18493 * @command: Command received from SME
18494 *
18495 * Posts the set dual mac config command to PE.
18496 *
18497 * Return: None
18498 */
18499void csr_process_set_dual_mac_config(tpAniSirGlobal mac, tSmeCmd *command)
18500{
18501 uint32_t len;
18502 struct sir_set_dual_mac_cfg *cmd;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018503 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018504 tSirMsgQ msg;
18505 struct sir_dual_mac_config_resp *param;
18506
18507 /* Setting MAC configuration is for the entire system.
18508 * So, no need to check session
18509 */
18510
18511 if (!command) {
18512 sms_log(mac, LOGE, FL("Set HW mode param is NULL"));
18513 goto fail;
18514 }
18515
18516 len = sizeof(*cmd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018517 cmd = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018518 if (!cmd) {
18519 sms_log(mac, LOGE, FL("Memory allocation failed"));
18520 /* Probably the fail response will also fail during malloc.
18521 * Still proceeding to send response!
18522 */
18523 goto fail;
18524 }
18525
18526 cmd->message_type = eWNI_SME_SET_DUAL_MAC_CFG_REQ;
18527 cmd->length = len;
18528 cmd->set_dual_mac.scan_config = command->u.set_dual_mac_cmd.scan_config;
18529 cmd->set_dual_mac.fw_mode_config =
18530 command->u.set_dual_mac_cmd.fw_mode_config;
18531 /*
18532 * Below callback and context info are not needed for PE as of now.
18533 * Storing the passed value in the same sir_set_dual_mac_cfg format.
18534 */
18535 cmd->set_dual_mac.set_dual_mac_cb =
18536 command->u.set_dual_mac_cmd.set_dual_mac_cb;
18537
18538 sms_log(mac, LOG1,
18539 FL("Posting eWNI_SME_SET_DUAL_MAC_CFG_REQ to PE: %x %x"),
18540 cmd->set_dual_mac.scan_config,
18541 cmd->set_dual_mac.fw_mode_config);
18542
18543 status = cds_send_mb_message_to_mac(cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018544 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018545 sms_log(mac, LOGE, FL("Posting to PE failed"));
18546 return;
18547 }
18548 return;
18549fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018550 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018551 if (!param) {
18552 sms_log(mac, LOGE,
18553 FL("Malloc fail: Fail to send response to SME"));
18554 return;
18555 }
18556 sms_log(mac, LOGE, FL("Sending set dual mac fail response to SME"));
18557 param->status = SET_HW_MODE_STATUS_ECANCELED;
18558 msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
18559 msg.bodyptr = param;
18560 msg.bodyval = 0;
18561 sys_process_mmh_msg(mac, &msg);
18562}
18563
18564/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -080018565 * csr_process_set_antenna_mode() - Set antenna mode command to
18566 * PE
18567 * @mac: Global MAC pointer
18568 * @command: Command received from SME
18569 *
18570 * Posts the set dual mac config command to PE.
18571 *
18572 * Return: None
18573 */
18574void csr_process_set_antenna_mode(tpAniSirGlobal mac, tSmeCmd *command)
18575{
18576 uint32_t len;
18577 struct sir_set_antenna_mode *cmd;
18578 QDF_STATUS status;
18579 tSirMsgQ msg;
18580 struct sir_antenna_mode_resp *param;
18581
18582 /* Setting MAC configuration is for the entire system.
18583 * So, no need to check session
18584 */
18585
18586 if (!command) {
18587 sms_log(mac, LOGE, FL("Set antenna mode param is NULL"));
18588 goto fail;
18589 }
18590
18591 len = sizeof(*cmd);
18592 cmd = qdf_mem_malloc(len);
18593 if (!cmd) {
18594 sms_log(mac, LOGE, FL("Memory allocation failed"));
18595 goto fail;
18596 }
18597
18598 cmd->message_type = eWNI_SME_SET_ANTENNA_MODE_REQ;
18599 cmd->length = len;
18600 cmd->set_antenna_mode = command->u.set_antenna_mode_cmd;
18601
18602 sms_log(mac, LOG1,
18603 FL("Posting eWNI_SME_SET_ANTENNA_MODE_REQ to PE: %d %d"),
18604 cmd->set_antenna_mode.num_rx_chains,
18605 cmd->set_antenna_mode.num_tx_chains);
18606
18607 status = cds_send_mb_message_to_mac(cmd);
18608 if (QDF_STATUS_SUCCESS != status) {
18609 sms_log(mac, LOGE, FL("Posting to PE failed"));
18610 /*
18611 * cds_send_mb_message_to_mac would've released the mem
18612 * allocated by cmd.
18613 */
18614 goto fail;
18615 }
18616
18617 return;
18618fail:
18619 param = qdf_mem_malloc(sizeof(*param));
18620 if (!param) {
18621 sms_log(mac, LOGE,
18622 FL("Malloc fail: Fail to send response to SME"));
18623 return;
18624 }
18625 sms_log(mac, LOGE, FL("Sending set dual mac fail response to SME"));
18626 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
18627 msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
18628 msg.bodyptr = param;
18629 msg.bodyval = 0;
18630 sys_process_mmh_msg(mac, &msg);
18631}
18632
18633/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018634 * csr_process_nss_update_req() - Update nss command to PE
18635 * @mac: Globacl MAC pointer
18636 * @command: Command received from SME
18637 *
18638 * Posts the nss update command to PE. This message passing
18639 * through PE is required for PE's internal management
18640 *
18641 * Return: None
18642 */
18643void csr_process_nss_update_req(tpAniSirGlobal mac, tSmeCmd *command)
18644{
18645 uint32_t len;
18646 struct sir_nss_update_request *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018647 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018648 tSirMsgQ msg_return;
18649 struct sir_beacon_tx_complete_rsp *param;
18650
18651 tCsrRoamSession *session =
18652 CSR_GET_SESSION(mac, command->sessionId);
18653
18654 if (!session) {
18655 sms_log(mac, LOGE, FL("Session not found"));
18656 goto fail;
18657 }
18658
18659 if (!command) {
18660 sms_log(mac, LOGE, FL("nss update param is NULL"));
18661 goto fail;
18662 }
18663
18664 len = sizeof(*msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018665 msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018666 if (!msg) {
18667 sms_log(mac, LOGE, FL("Memory allocation failed"));
18668 /* Probably the fail response is also fail during malloc.
18669 * Still proceeding to send response!
18670 */
18671 goto fail;
18672 }
18673
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018674 qdf_mem_set((void *)msg, sizeof(*msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018675 msg->msgType = eWNI_SME_NSS_UPDATE_REQ;
18676 msg->msgLen = sizeof(*msg);
18677
18678 msg->new_nss = command->u.nss_update_cmd.new_nss;
18679 msg->vdev_id = command->u.nss_update_cmd.session_id;
18680
18681 sms_log(mac, LOG1,
18682 FL("Posting eWNI_SME_NSS_UPDATE_REQ to PE"));
18683
18684 status = cds_send_mb_message_to_mac(msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018685 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018686 sms_log(mac, LOGE, FL("Posting to PE failed"));
18687 return;
18688 }
18689 return;
18690fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018691 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018692 if (!param) {
18693 sms_log(mac, LOGE,
18694 FL("Malloc fail: Fail to send response to SME"));
18695 return;
18696 }
18697 sms_log(mac, LOGE, FL("Sending nss update fail response to SME"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018698 param->tx_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018699 param->session_id = command->u.nss_update_cmd.session_id;
18700 msg_return.type = eWNI_SME_NSS_UPDATE_RSP;
18701 msg_return.bodyptr = param;
18702 msg_return.bodyval = 0;
18703 sys_process_mmh_msg(mac, &msg_return);
18704}
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018705#ifdef FEATURE_WLAN_TDLS
18706/**
18707 * csr_roam_fill_tdls_info() - Fill TDLS information
18708 * @roam_info: Roaming information buffer
18709 * @join_rsp: Join response which has TDLS info
18710 *
18711 * Return: None
18712 */
18713void csr_roam_fill_tdls_info(tCsrRoamInfo *roam_info, tpSirSmeJoinRsp join_rsp)
18714{
18715 roam_info->tdls_prohibited = join_rsp->tdls_prohibited;
18716 roam_info->tdls_chan_swit_prohibited =
18717 join_rsp->tdls_chan_swit_prohibited;
18718}
18719#endif
18720
18721/**
18722 * csr_roam_synch_callback() - SME level callback for roam synch propagation
18723 * @mac_ctx: MAC Context
18724 * @roam_synch_data: Roam synch data buffer pointer
18725 * @bss_desc: BSS descriptor pointer
18726 * @reason: Reason for calling the callback
18727 *
18728 * This callback is registered with WMA and used after roaming happens in
18729 * firmware and the call to this routine completes the roam synch
18730 * propagation at both CSR and HDD levels. The HDD level propagation
18731 * is achieved through the already defined callback for assoc completion
18732 * handler.
18733 *
18734 * Return: None.
18735 */
18736void csr_roam_synch_callback(tpAniSirGlobal mac_ctx,
18737 roam_offload_synch_ind *roam_synch_data,
18738 tpSirBssDescription bss_desc, uint8_t reason)
18739{
18740 uint8_t session_id = roam_synch_data->roamedVdevId;
18741 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
18742 tDot11fBeaconIEs *ies_local = NULL;
18743 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
18744 tCsrRoamInfo *roam_info;
18745 tCsrRoamConnectedProfile *conn_profile = NULL;
18746 sme_QosAssocInfo assoc_info;
Anurag Chouhan6d760662016-02-20 16:05:43 +053018747 struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018748 tpAddBssParams add_bss_params;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018749 QDF_STATUS status = QDF_STATUS_SUCCESS;
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +053018750#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
18751 tSirSmeHTProfile *src_profile = NULL;
18752 tCsrRoamHTProfile *dst_profile = NULL;
18753#endif
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018754
18755 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018756 if (!QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018757 sms_log(mac_ctx, LOGE, FL("LFR3: Locking failed, bailing out"));
18758 return;
18759 }
18760 if (!session) {
18761 sms_log(mac_ctx, LOGE, FL("LFR3: Session not found"));
18762 sme_release_global_lock(&mac_ctx->sme);
18763 return;
18764 }
18765 session->roam_synch_in_progress = true;
18766 if (reason == ROAMING_TX_QUEUE_DISABLE) {
18767 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
18768 eCSR_ROAM_FT_START, eSIR_SME_SUCCESS);
18769 sme_release_global_lock(&mac_ctx->sme);
18770 return;
18771 }
18772 session->roam_synch_data = roam_synch_data;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018773 if (!QDF_IS_STATUS_SUCCESS(csr_get_parsed_bss_description_ies(mac_ctx,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018774 bss_desc, &ies_local))) {
18775 sms_log(mac_ctx, LOGE, FL("LFR3: fail to parse IEs"));
18776 session->roam_synch_in_progress = false;
18777 sme_release_global_lock(&mac_ctx->sme);
18778 return;
18779 }
18780 conn_profile = &session->connectedProfile;
18781 csr_roam_stop_network(mac_ctx, session_id,
18782 session->pCurRoamProfile,
18783 bss_desc,
18784 ies_local);
18785 ps_global_info->remain_in_power_active_till_dhcp = false;
18786 session->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018787 roam_info = qdf_mem_malloc(sizeof(tCsrRoamInfo));
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018788 if (NULL == roam_info) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018789 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018790 FL("LFR3: Mem Alloc failed for roam info"));
18791 session->roam_synch_in_progress = false;
18792 sme_release_global_lock(&mac_ctx->sme);
18793 return;
18794 }
18795 csr_scan_save_roam_offload_ap_to_scan_cache(mac_ctx, roam_synch_data,
18796 bss_desc);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018797 qdf_mem_zero(roam_info, sizeof(tCsrRoamInfo));
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018798 roam_info->sessionId = session_id;
18799 csr_roam_call_callback(mac_ctx, roam_synch_data->roamedVdevId,
18800 roam_info, 0, eCSR_ROAM_TDLS_STATUS_UPDATE,
18801 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018802 qdf_mem_copy(&roam_info->bssid.bytes, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053018803 sizeof(struct qdf_mac_addr));
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018804 csr_roam_save_connected_infomation(mac_ctx, session_id,
18805 session->pCurRoamProfile,
18806 bss_desc,
18807 ies_local);
18808 csr_roam_save_security_rsp_ie(mac_ctx, session_id,
18809 session->pCurRoamProfile->negotiatedAuthType,
18810 bss_desc, ies_local);
18811 roam_info->isESEAssoc = conn_profile->isESEAssoc;
18812 if (CSR_IS_ENC_TYPE_STATIC
18813 (session->pCurRoamProfile->negotiatedUCEncryptionType) &&
18814 !session->pCurRoamProfile->bWPSAssociation) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018815 if (!QDF_IS_STATUS_SUCCESS(
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018816 csr_roam_issue_set_context_req(mac_ctx,
18817 session_id,
18818 session->pCurRoamProfile->negotiatedUCEncryptionType,
18819 bss_desc,
18820 &(bss_desc->bssId),
18821 false, true,
18822 eSIR_TX_RX, 0, 0, NULL, 0))) {
18823 /* NO keys. these key parameters don't matter */
18824 sms_log(mac_ctx, LOGE,
18825 FL("Set context for unicast fail"));
18826 csr_roam_substate_change(mac_ctx,
18827 eCSR_ROAM_SUBSTATE_NONE, session_id);
18828 }
18829 csr_roam_issue_set_context_req(mac_ctx, session_id,
18830 session->pCurRoamProfile->negotiatedMCEncryptionType,
18831 bss_desc,
18832 &bcast_mac.bytes, false, false,
18833 eSIR_TX_RX, 0, 0, NULL, 0);
18834 }
18835 if ((roam_synch_data->authStatus
18836 == CSR_ROAM_AUTH_STATUS_AUTHENTICATED)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018837 QDF_TRACE(QDF_MODULE_ID_SME,
18838 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018839 FL("LFR3:Don't start waitforkey timer"));
18840 csr_roam_substate_change(mac_ctx,
18841 eCSR_ROAM_SUBSTATE_NONE, session_id);
18842 } else {
18843 roam_info->fAuthRequired = true;
18844 csr_roam_substate_change(mac_ctx,
18845 eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY,
18846 session_id);
18847
18848 ps_global_info->remain_in_power_active_till_dhcp = true;
18849 mac_ctx->roam.WaitForKeyTimerInfo.sessionId = session_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018850 if (!QDF_IS_STATUS_SUCCESS(csr_roam_start_wait_for_key_timer(
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018851 mac_ctx, CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD))
18852 ) {
18853 sms_log(mac_ctx, LOGE, FL
18854 ("Failed wait for key timer start"));
18855 csr_roam_substate_change(mac_ctx,
18856 eCSR_ROAM_SUBSTATE_NONE,
18857 session_id);
18858 }
18859 }
18860 roam_info->nBeaconLength = 0;
18861 roam_info->nAssocReqLength = roam_synch_data->reassoc_req_length -
18862 SIR_MAC_HDR_LEN_3A - SIR_MAC_REASSOC_SSID_OFFSET;
18863 roam_info->nAssocRspLength = roam_synch_data->reassocRespLength -
18864 SIR_MAC_HDR_LEN_3A;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018865 roam_info->pbFrames = qdf_mem_malloc(roam_info->nBeaconLength +
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018866 roam_info->nAssocReqLength + roam_info->nAssocRspLength);
18867 if (NULL == roam_info->pbFrames) {
18868 sms_log(mac_ctx, LOGE, FL("no memory available"));
18869 session->roam_synch_in_progress = false;
18870 if (roam_info)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018871 qdf_mem_free(roam_info);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018872 sme_release_global_lock(&mac_ctx->sme);
18873 return;
18874 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018875 qdf_mem_zero(roam_info->pbFrames, roam_info->nBeaconLength +
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018876 roam_info->nAssocReqLength + roam_info->nAssocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018877 qdf_mem_copy(roam_info->pbFrames,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018878 (uint8_t *)roam_synch_data +
18879 roam_synch_data->reassoc_req_offset +
18880 SIR_MAC_HDR_LEN_3A + SIR_MAC_REASSOC_SSID_OFFSET,
18881 roam_info->nAssocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018882 qdf_mem_copy(roam_info->pbFrames + roam_info->nAssocReqLength,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018883 (uint8_t *)roam_synch_data +
18884 roam_synch_data->reassocRespOffset +
18885 SIR_MAC_HDR_LEN_3A,
18886 roam_info->nAssocRspLength);
18887
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018888 QDF_TRACE(QDF_MODULE_ID_SME,
18889 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018890 FL("LFR3:Clear Connected info"));
18891 csr_roam_free_connected_info(mac_ctx,
18892 &session->connectedInfo);
18893 conn_profile->vht_channel_width =
18894 roam_synch_data->join_rsp->vht_channel_width;
18895 add_bss_params = (tpAddBssParams)roam_synch_data->add_bss_params;
18896 session->connectedInfo.staId = add_bss_params->staContext.staIdx;
18897 roam_info->staId = session->connectedInfo.staId;
18898 roam_info->ucastSig =
18899 (uint8_t) roam_synch_data->join_rsp->ucastSig;
18900 roam_info->bcastSig =
18901 (uint8_t) roam_synch_data->join_rsp->bcastSig;
18902 roam_info->timingMeasCap =
18903 roam_synch_data->join_rsp->timingMeasCap;
18904 roam_info->chan_info.nss = roam_synch_data->join_rsp->nss;
18905 roam_info->chan_info.rate_flags =
18906 roam_synch_data->join_rsp->max_rate_flags;
18907 csr_roam_fill_tdls_info(roam_info, roam_synch_data->join_rsp);
18908 sms_log(mac_ctx, LOG1,
18909 FL("tdls:prohibit: %d, chan_swit_prohibit: %d"),
18910 roam_info->tdls_prohibited,
18911 roam_info->tdls_chan_swit_prohibited);
18912#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
18913 src_profile = &roam_synch_data->join_rsp->HTProfile;
18914 dst_profile = &conn_profile->HTProfile;
18915 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053018916 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018917 csr_roam_copy_ht_profile(dst_profile,
18918 src_profile);
18919#endif
18920 assoc_info.pBssDesc = bss_desc;
18921 roam_info->statusCode = eSIR_SME_SUCCESS;
18922 roam_info->reasonCode = eSIR_SME_SUCCESS;
18923 assoc_info.pProfile = session->pCurRoamProfile;
18924 mac_ctx->roam.roamSession[session_id].connectState =
18925 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
18926 sme_qos_csr_event_ind(mac_ctx, session_id,
18927 SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
18928 sme_qos_csr_event_ind(mac_ctx, session_id,
18929 SME_QOS_CSR_REASSOC_REQ, NULL);
18930 sme_qos_csr_event_ind(mac_ctx, session_id,
18931 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
18932 mac_ctx->roam.roamSession[session_id].connectState =
18933 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
18934 sme_qos_csr_event_ind(mac_ctx, session_id,
18935 SME_QOS_CSR_REASSOC_COMPLETE, &assoc_info);
18936 roam_info->pBssDesc = bss_desc;
18937 conn_profile->acm_mask = sme_qos_get_acm_mask(mac_ctx,
18938 bss_desc, NULL);
18939 if (conn_profile->modifyProfileFields.uapsd_mask) {
Varun Reddy Yeturu90444892016-02-04 10:43:20 -080018940 sms_log(mac_ctx, LOG1,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018941 " uapsd_mask (0x%X) set, request UAPSD now",
18942 conn_profile->modifyProfileFields.uapsd_mask);
18943 sme_ps_start_uapsd(mac_ctx, session_id,
18944 NULL, NULL);
18945 }
18946 conn_profile->dot11Mode = session->bssParams.uCfgDot11Mode;
18947 roam_info->u.pConnectedProfile = conn_profile;
18948
18949 if (!IS_FEATURE_SUPPORTED_BY_FW
18950 (SLM_SESSIONIZATION) &&
18951 (csr_is_concurrent_session_running(mac_ctx))) {
18952 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
18953 }
18954 roam_info->roamSynchInProgress = true;
18955 roam_info->synchAuthStatus = roam_synch_data->authStatus;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018956 qdf_mem_copy(roam_info->kck, roam_synch_data->kck, SIR_KCK_KEY_LEN);
18957 qdf_mem_copy(roam_info->kek, roam_synch_data->kek, SIR_KEK_KEY_LEN);
18958 qdf_mem_copy(roam_info->replay_ctr, roam_synch_data->replay_ctr,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018959 SIR_REPLAY_CTR_LEN);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018960 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018961 FL("LFR3: Copy KCK, KEK and Replay Ctr"));
18962 roam_info->subnet_change_status =
18963 CSR_GET_SUBNET_STATUS(roam_synch_data->roamReason);
18964 csr_roam_call_callback(mac_ctx, session_id, roam_info, 0,
18965 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
18966 csr_reset_pmkid_candidate_list(mac_ctx, session_id);
18967#ifdef FEATURE_WLAN_WAPI
18968 csr_reset_bkid_candidate_list(mac_ctx, session_id);
18969#endif
18970 if (!CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018971 QDF_TRACE(QDF_MODULE_ID_SME,
18972 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018973 FL
18974 ("NO CSR_IS_WAIT_FOR_KEY -> csr_roam_link_up"));
18975 csr_roam_link_up(mac_ctx, conn_profile->bssid);
18976 }
18977 session->fRoaming = false;
18978 session->roam_synch_in_progress = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018979 qdf_mem_free(roam_info->pbFrames);
18980 qdf_mem_free(roam_info);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018981 sme_release_global_lock(&mac_ctx->sme);
18982}