blob: fbc4e43a9c7aa153db89b95da1784b26bd45eb64 [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_regdomain_common.h"
53#include "cds_utils.h"
54#include "sir_types.h"
55#include "cfg_api.h"
56#include "sme_power_save_api.h"
57#include "wma.h"
58#include "cds_concurrency.h"
59
60#define CSR_NUM_IBSS_START_CHANNELS_50 4
61#define CSR_NUM_IBSS_START_CHANNELS_24 3
62/* 5 seconds, for WPA, WPA2, CCKM */
Anurag Chouhan210db072016-02-22 18:42:15 +053063#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD (15 * QDF_MC_TIMER_TO_SEC_UNIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064/* 120 seconds, for WPS */
Anurag Chouhan210db072016-02-22 18:42:15 +053065#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD (120 * QDF_MC_TIMER_TO_SEC_UNIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066
67/*---------------------------------------------------------------------------
68 OBIWAN recommends [8 10]% : pick 9%
69 ---------------------------------------------------------------------------*/
70#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
71/*---------------------------------------------------------------------------
72 OBIWAN recommends -85dBm
73 ---------------------------------------------------------------------------*/
74#define CSR_VCC_RSSI_THRESHOLD 80
75#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 /* ms */
76#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 /* ms */
77#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 /* ms */
78/* Flag to send/do not send disassoc frame over the air */
79#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
80#define RSSI_HACK_BMPS (-40)
81#define MAX_CB_VALUE_IN_INI (2)
82
83#define MAX_SOCIAL_CHANNELS 3
84/* Choose the largest possible value that can be accomodates in 8 bit signed */
85/* variable. */
86#define SNR_HACK_BMPS (127)
87
88static bool b_roam_scan_offload_started;
89
90/*--------------------------------------------------------------------------
91 Static Type declarations
92 ------------------------------------------------------------------------*/
93static tCsrRoamSession csr_roam_roam_session[CSR_ROAM_SESSION_MAX];
94
95/*--------------------------------------------------------------------------
96 Type declarations
97 ------------------------------------------------------------------------*/
98#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
99int diag_auth_type_from_csr_type(eCsrAuthType authType)
100{
101 int n = AUTH_OPEN;
102 switch (authType) {
103 case eCSR_AUTH_TYPE_SHARED_KEY:
104 n = AUTH_SHARED;
105 break;
106 case eCSR_AUTH_TYPE_WPA:
107 n = AUTH_WPA_EAP;
108 break;
109 case eCSR_AUTH_TYPE_WPA_PSK:
110 n = AUTH_WPA_PSK;
111 break;
112 case eCSR_AUTH_TYPE_RSN:
113#ifdef WLAN_FEATURE_11W
114 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
115#endif
116 n = AUTH_WPA2_EAP;
117 break;
118 case eCSR_AUTH_TYPE_RSN_PSK:
119#ifdef WLAN_FEATURE_11W
120 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
121#endif
122 n = AUTH_WPA2_PSK;
123 break;
124#ifdef FEATURE_WLAN_WAPI
125 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
126 n = AUTH_WAPI_CERT;
127 break;
128 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
129 n = AUTH_WAPI_PSK;
130 break;
131#endif /* FEATURE_WLAN_WAPI */
132 default:
133 break;
134 }
135 return n;
136}
137
138int diag_enc_type_from_csr_type(eCsrEncryptionType encType)
139{
140 int n = ENC_MODE_OPEN;
141 switch (encType) {
142 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
143 case eCSR_ENCRYPT_TYPE_WEP40:
144 n = ENC_MODE_WEP40;
145 break;
146 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
147 case eCSR_ENCRYPT_TYPE_WEP104:
148 n = ENC_MODE_WEP104;
149 break;
150 case eCSR_ENCRYPT_TYPE_TKIP:
151 n = ENC_MODE_TKIP;
152 break;
153 case eCSR_ENCRYPT_TYPE_AES:
154 n = ENC_MODE_AES;
155 break;
156#ifdef FEATURE_WLAN_WAPI
157 case eCSR_ENCRYPT_TYPE_WPI:
158 n = ENC_MODE_SMS4;
159 break;
160#endif /* FEATURE_WLAN_WAPI */
161 default:
162 break;
163 }
164 return n;
165}
166#endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */
167static const uint8_t
168 csr_start_ibss_channels50[CSR_NUM_IBSS_START_CHANNELS_50] = { 36, 40, 44, 48 };
169static const uint8_t
170 csr_start_ibss_channels24[CSR_NUM_IBSS_START_CHANNELS_24] = { 1, 6, 11 };
171static void init_config_param(tpAniSirGlobal pMac);
172static bool csr_roam_process_results(tpAniSirGlobal pMac, tSmeCmd *pCommand,
173 eCsrRoamCompleteResult Result,
174 void *Context);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530175static QDF_STATUS csr_roam_start_ibss(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176 tCsrRoamProfile *pProfile,
177 bool *pfSameIbss);
178static void csr_roam_update_connected_profile_from_new_bss(tpAniSirGlobal pMac,
179 uint32_t sessionId,
180 tSirSmeNewBssInfo *
181 pNewBss);
182static void csr_roam_prepare_bss_params(tpAniSirGlobal pMac, uint32_t sessionId,
183 tCsrRoamProfile *pProfile,
184 tSirBssDescription *pBssDesc,
185 tBssConfigParam *pBssConfig,
186 tDot11fBeaconIEs *pIes);
187static ePhyChanBondState csr_get_cb_mode_from_ies(tpAniSirGlobal pMac,
188 uint8_t primaryChn,
189 tDot11fBeaconIEs *pIes);
190
191static void csr_roaming_state_config_cnf_processor(tpAniSirGlobal pMac,
192 uint32_t result);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530193QDF_STATUS csr_roam_open(tpAniSirGlobal pMac);
194QDF_STATUS csr_roam_close(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800195void csr_roamMICErrorTimerHandler(void *pv);
196void csr_roamTKIPCounterMeasureTimerHandler(void *pv);
197bool csr_roam_is_same_profile_keys(tpAniSirGlobal pMac,
198 tCsrRoamConnectedProfile *pConnProfile,
199 tCsrRoamProfile *pProfile2);
200
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530201static QDF_STATUS csr_roam_start_roaming_timer(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800202 uint32_t sessionId,
203 uint32_t interval);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530204static QDF_STATUS csr_roam_stop_roaming_timer(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205 uint32_t sessionId);
206static void csr_roam_roaming_timer_handler(void *pv);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530207QDF_STATUS csr_roam_start_wait_for_key_timer(tpAniSirGlobal pMac, uint32_t interval);
208QDF_STATUS csr_roam_stop_wait_for_key_timer(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209static void csr_roam_wait_for_key_time_out_handler(void *pv);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530210static QDF_STATUS csr_init11d_info(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
211static QDF_STATUS csr_init_channel_power_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212 tCsr11dinfo *ps11dinfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530213static QDF_STATUS csr_roam_free_connected_info(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800214 tCsrRoamConnectedInfo *
215 pConnectedInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530216QDF_STATUS csr_send_mb_set_context_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530217 struct qdf_mac_addr peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -0800218 uint8_t numKeys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800219 tAniEdType edType, bool fUnicast,
220 tAniKeyDirection aniKeyDirection,
221 uint8_t keyId, uint8_t keyLength,
222 uint8_t *pKey, uint8_t paeRole,
223 uint8_t *pKeyRsc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530224static QDF_STATUS csr_roam_issue_reassociate(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 uint32_t sessionId,
226 tSirBssDescription *pSirBssDesc,
227 tDot11fBeaconIEs *pIes,
228 tCsrRoamProfile *pProfile);
229void csr_roamStatisticsTimerHandler(void *pv);
230void csr_roamStatsGlobalClassDTimerHandler(void *pv);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530231static void csr_roam_link_up(tpAniSirGlobal pMac, struct qdf_mac_addr bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232static void csr_roam_link_down(tpAniSirGlobal pMac, uint32_t sessionId);
233void csr_roam_vcc_trigger(tpAniSirGlobal pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530234QDF_STATUS csr_send_mb_stats_req_msg(tpAniSirGlobal pMac, uint32_t statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235 uint8_t staId, uint8_t sessionId);
236/*
237 pStaEntry is no longer invalid upon the return of this function.
238 */
239static void csr_roam_remove_stat_list_entry(tpAniSirGlobal pMac, tListElem *pEntry);
240static eCsrCfgDot11Mode csr_roam_get_phy_mode_band_for_bss(tpAniSirGlobal pMac,
241 tCsrRoamProfile *pProfile,
242 uint8_t operationChn,
243 eCsrBand *pBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530244static QDF_STATUS csr_roam_get_qos_info_from_bss(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 tSirBssDescription *pBssDesc);
246tCsrStatsClientReqInfo *csr_roam_insert_entry_into_list(tpAniSirGlobal pMac,
247 tDblLinkList *pStaList,
248 tCsrStatsClientReqInfo *
249 pStaEntry);
250void csr_roam_stats_client_timer_handler(void *pv);
251tCsrPeStatsReqInfo *csr_roam_check_pe_stats_req_list(tpAniSirGlobal pMac,
252 uint32_t statsMask,
253 uint32_t periodicity,
254 bool *pFound, uint8_t staId,
255 uint8_t sessionId);
256void csr_roam_report_statistics(tpAniSirGlobal pMac, uint32_t statsMask,
257 tCsrStatsCallback callback, uint8_t staId,
258 void *pContext);
259void csr_roam_tl_stats_timer_handler(void *pv);
260void csr_roam_pe_stats_timer_handler(void *pv);
261tListElem *csr_roam_check_client_req_list(tpAniSirGlobal pMac, uint32_t statsMask);
262void csr_roam_remove_entry_from_pe_stats_req_list(tpAniSirGlobal pMac,
263 tCsrPeStatsReqInfo *pPeStaEntry);
264tListElem *csr_roam_find_in_pe_stats_req_list(tpAniSirGlobal pMac, uint32_t statsMask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530265QDF_STATUS csr_roam_dereg_statistics_req(tpAniSirGlobal pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800266static uint32_t csr_find_ibss_session(tpAniSirGlobal pMac);
Peng Xuf5d60c82015-10-02 17:17:03 -0700267static uint32_t csr_find_session_by_type(tpAniSirGlobal,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530268 enum tQDF_ADAPTER_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269static bool csr_is_conn_allow_2g_band(tpAniSirGlobal pMac, uint32_t chnl);
270static bool csr_is_conn_allow_5g_band(tpAniSirGlobal pMac, uint32_t chnl);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530271static QDF_STATUS csr_roam_start_wds(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272 tCsrRoamProfile *pProfile,
273 tSirBssDescription *pBssDesc);
274static void csr_init_session(tpAniSirGlobal pMac, uint32_t sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530275static QDF_STATUS csr_roam_issue_set_key_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800276 uint32_t sessionId,
277 tCsrRoamSetKey *pSetKey,
278 uint32_t roamId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530279static QDF_STATUS csr_roam_get_qos_info_from_bss(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800280 tSirBssDescription *pBssDesc);
281void csr_roam_reissue_roam_command(tpAniSirGlobal pMac);
282static void csr_ser_des_unpack_diassoc_rsp(uint8_t *pBuf,
283 tSirSmeDisassocRsp *pRsp);
284void csr_reinit_preauth_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
285void csr_init_operating_classes(tHalHandle hHal);
286
287/* Initialize global variables */
288static void csr_roam_init_globals(tpAniSirGlobal pMac)
289{
290 if (pMac) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530291 qdf_mem_zero(&csr_roam_roam_session, sizeof(csr_roam_roam_session));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292 pMac->roam.roamSession = csr_roam_roam_session;
293 }
294 return;
295}
296
297static void csr_roam_de_init_globals(tpAniSirGlobal pMac)
298{
299 if (pMac) {
300 pMac->roam.roamSession = NULL;
301 }
302 return;
303}
304
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530305QDF_STATUS csr_open(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800306{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530307 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308 uint32_t i;
309
310 do {
311 /* Initialize CSR Roam Globals */
312 csr_roam_init_globals(pMac);
313 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
314 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_STOP, i);
315
316 init_config_param(pMac);
317 status = csr_scan_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530318 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319 break;
320 status = csr_roam_open(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530321 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322 break;
323 pMac->roam.nextRoamId = 1; /* Must not be 0 */
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.statsClientReqList)))
327 break;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530328 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800329 (csr_ll_open(pMac->hHdd,
330 &pMac->roam.peStatsReqList)))
331 break;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530332 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333 (csr_ll_open(pMac->hHdd,
334 &pMac->roam.roamCmdPendingList)))
335 break;
336 } while (0);
337
338 return status;
339}
340
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530341QDF_STATUS csr_init_chan_list(tpAniSirGlobal mac, uint8_t *alpha2)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530343 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344
345 mac->scan.countryCodeDefault[0] = alpha2[0];
346 mac->scan.countryCodeDefault[1] = alpha2[1];
347 mac->scan.countryCodeDefault[2] = alpha2[2];
348
349 sms_log(mac, LOGE, FL("init time country code %.2s"),
350 mac->scan.countryCodeDefault);
351
Amar Singhale4f28ee2015-10-21 14:36:56 -0700352 mac->scan.domainIdDefault = 0;
353 mac->scan.domainIdCurrent = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530355 qdf_mem_copy(mac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356 mac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530357 qdf_mem_copy(mac->scan.countryCodeElected,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800358 mac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
359 status = csr_get_channel_and_power_list(mac);
360 csr_clear_votes_for_country_info(mac);
361 return status;
362}
363
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530364QDF_STATUS csr_set_reg_info(tHalHandle hHal, uint8_t *apCntryCode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530366 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
368 v_REGDOMAIN_t regId;
369 uint8_t cntryCodeLength;
370 if (NULL == apCntryCode) {
371 sms_log(pMac, LOGE, FL(" Invalid country Code Pointer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530372 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800373 }
374 sms_log(pMac, LOG1, FL(" country Code %.2s"), apCntryCode);
375
376 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
377 status = csr_get_regulatory_domain_for_country(pMac, apCntryCode, &regId,
Amar Singhala297bfa2015-10-15 15:07:29 -0700378 SOURCE_USERSPACE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530379 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380 sms_log(pMac, LOGE,
381 FL(" fail to get regId for country Code %.2s"),
382 apCntryCode);
383 return status;
384 }
385 status = wma_set_reg_domain(hHal, regId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530386 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387 sms_log(pMac, LOGE,
388 FL(" fail to get regId for country Code %.2s"),
389 apCntryCode);
390 return status;
391 }
392 pMac->scan.domainIdDefault = regId;
393 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
394 /* Clear CC field */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530395 qdf_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396
397 /* Copy 2 or 3 bytes country code */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530398 qdf_mem_copy(pMac->scan.countryCodeDefault, apCntryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399 cntryCodeLength);
400
401 /* If 2 bytes country code, 3rd byte must be filled with space */
402 if ((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530403 qdf_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800404 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530405 qdf_mem_copy(pMac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406 pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN);
407 status = csr_get_channel_and_power_list(pMac);
408 return status;
409}
410
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530411QDF_STATUS csr_set_channels(tHalHandle hHal, tCsrConfigParam *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800412{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530413 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800414 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
415 uint8_t index = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530416 qdf_mem_copy(pParam->Csr11dinfo.countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417 pMac->scan.countryCodeCurrent, WNI_CFG_COUNTRY_CODE_LEN);
418 for (index = 0; index < pMac->scan.base_channels.numChannels;
419 index++) {
420 pParam->Csr11dinfo.Channels.channelList[index] =
421 pMac->scan.base_channels.channelList[index];
422 pParam->Csr11dinfo.ChnPower[index].firstChannel =
423 pMac->scan.base_channels.channelList[index];
424 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
425 pParam->Csr11dinfo.ChnPower[index].maxtxPower =
Amar Singhala297bfa2015-10-15 15:07:29 -0700426 pMac->scan.defaultPowerTable[index].power;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 }
428 pParam->Csr11dinfo.Channels.numChannels =
429 pMac->scan.base_channels.numChannels;
430
431 return status;
432}
433
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530434QDF_STATUS csr_close(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530436 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437
438 csr_roam_close(pMac);
439 csr_scan_close(pMac);
440 csr_ll_close(&pMac->roam.statsClientReqList);
441 csr_ll_close(&pMac->roam.peStatsReqList);
442 csr_ll_close(&pMac->roam.roamCmdPendingList);
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530443 if (pMac->sme.saved_scan_cmd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530444 qdf_mem_free(pMac->sme.saved_scan_cmd);
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530445 pMac->sme.saved_scan_cmd = NULL;
446 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800447 /* DeInit Globals */
448 csr_roam_de_init_globals(pMac);
449 return status;
450}
451
Amar Singhala297bfa2015-10-15 15:07:29 -0700452static int8_t csr_find_channel_pwr(struct channel_power *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800453 pdefaultPowerTable,
454 uint8_t ChannelNum)
455{
456 uint8_t i;
457 /* TODO: if defaultPowerTable is guaranteed to be in ascending */
458 /* order of channel numbers, we can employ binary search */
459 for (i = 0; i < WNI_CFG_VALID_CHANNEL_LIST_LEN; i++) {
Amar Singhala297bfa2015-10-15 15:07:29 -0700460 if (pdefaultPowerTable[i].chan_num == ChannelNum)
461 return pdefaultPowerTable[i].power;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800462 }
463 /* could not find the channel list in default list */
464 /* this should not have occured */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530465 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466 return 0;
467}
Naveen Rawat16b82872015-12-14 17:59:16 -0800468
469/**
470 * csr_roam_arrange_ch_list() - Updates the channel list modified with greedy
471 * order for 5 Ghz preference and DFS channels.
472 * @mac_ctx: pointer to mac context.
473 * @chan_list: channel list updated with greedy channel order.
474 * @num_channel: Number of channels in list
475 *
476 * To allow Early Stop Roaming Scan feature to co-exist with 5G preference,
477 * this function moves 5G channels ahead of 2G channels. This function can
478 * also move 2G channels, ahead of DFS channel or vice versa. Order is
479 * maintained among same category channels
480 *
481 * Return: None
482 */
483void csr_roam_arrange_ch_list(tpAniSirGlobal mac_ctx,
484 tSirUpdateChanParam *chan_list, uint8_t num_channel)
485{
486 bool prefer_5g = CSR_IS_ROAM_PREFER_5GHZ(mac_ctx);
487 bool prefer_dfs = CSR_IS_DFS_CH_ROAM_ALLOWED(mac_ctx);
488 int i, j = 0;
489 tSirUpdateChanParam *tmp_list = NULL;
490
491 if (!prefer_5g)
492 return;
493
494 tmp_list = (tSirUpdateChanParam *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530495 qdf_mem_malloc(sizeof(tSirUpdateChanParam) * num_channel);
Naveen Rawat16b82872015-12-14 17:59:16 -0800496 if (tmp_list == NULL) {
497 sms_log(mac_ctx, LOGE, FL("Memory allocation failed"));
498 return;
499 }
500
501 /* Fist copy Non-DFS 5g channels */
502 for (i = 0; i < num_channel; i++) {
503 if (CDS_IS_CHANNEL_5GHZ(chan_list[i].chanId) &&
504 !CDS_IS_DFS_CH(chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530505 qdf_mem_copy(&tmp_list[j++],
Naveen Rawat16b82872015-12-14 17:59:16 -0800506 &chan_list[i], sizeof(tSirUpdateChanParam));
507 chan_list[i].chanId = INVALID_CHANNEL_ID;
508 }
509 }
510 if (prefer_dfs) {
511 /* next copy DFS channels (remaining channels in 5G) */
512 for (i = 0; i < num_channel; i++) {
513 if (CDS_IS_CHANNEL_5GHZ(chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530514 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800515 sizeof(tSirUpdateChanParam));
516 chan_list[i].chanId = INVALID_CHANNEL_ID;
517 }
518 }
519 } else {
520 /* next copy 2G channels */
521 for (i = 0; i < num_channel; i++) {
522 if (CDS_IS_CHANNEL_24GHZ(chan_list[i].chanId)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530523 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800524 sizeof(tSirUpdateChanParam));
525 chan_list[i].chanId = INVALID_CHANNEL_ID;
526 }
527 }
528 }
529 /* copy rest of the channels in same order to tmp list */
530 for (i = 0; i < num_channel; i++) {
531 if (chan_list[i].chanId != INVALID_CHANNEL_ID) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530532 qdf_mem_copy(&tmp_list[j++], &chan_list[i],
Naveen Rawat16b82872015-12-14 17:59:16 -0800533 sizeof(tSirUpdateChanParam));
534 chan_list[i].chanId = INVALID_CHANNEL_ID;
535 }
536 }
537 /* copy tmp list to original channel list buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530538 qdf_mem_copy(chan_list, tmp_list,
Naveen Rawat16b82872015-12-14 17:59:16 -0800539 sizeof(tSirUpdateChanParam) * num_channel);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530540 qdf_mem_free(tmp_list);
Naveen Rawat16b82872015-12-14 17:59:16 -0800541}
542
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700543/**
544 * csr_roam_sort_channel_for_early_stop() - Sort the channels
Naveen Rawat16b82872015-12-14 17:59:16 -0800545 * @mac_ctx: mac global context
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700546 * @chan_list: Original channel list from the upper layers
547 * @num_channel: Number of original channels
548 *
549 * For Early stop scan feature, the channel list should be in an order,
550 * where-in there is a maximum chance to detect an AP in the initial
551 * channels in the list so that the scanning can be stopped early as the
552 * feature demands.
553 * Below fixed greedy channel list has been provided
554 * based on most of the enterprise wifi installations across the globe.
555 *
556 * Identify all the greedy channels within the channel list from user space.
557 * Identify all the non-greedy channels in the user space channel list.
558 * Merge greedy channels followed by non-greedy channels back into the
559 * chan_list.
560 *
561 * Return: None
562 */
Naveen Rawat16b82872015-12-14 17:59:16 -0800563void csr_roam_sort_channel_for_early_stop(tpAniSirGlobal mac_ctx,
564 tSirUpdateChanList *chan_list, uint8_t num_channel)
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700565{
566 tSirUpdateChanList *chan_list_greedy, *chan_list_non_greedy;
567 uint8_t i, j;
568 static const uint8_t fixed_greedy_chan_list[] = {1, 6, 11, 36, 48, 40,
569 44, 10, 2, 9, 149, 157, 161, 3, 4, 8, 153, 165, 7, 5, 136, 140,
570 52, 116, 56, 104, 64, 60, 100, 120, 13, 14, 112, 132, 151, 155};
571 uint8_t num_fixed_greedy_chan;
572 uint8_t num_greedy_chan = 0;
573 uint8_t num_non_greedy_chan = 0;
574 uint8_t match_found = false;
575 uint32_t buf_size;
576
577 buf_size = sizeof(tSirUpdateChanList) +
578 (sizeof(tSirUpdateChanParam) * num_channel);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530579 chan_list_greedy = qdf_mem_malloc(buf_size);
580 chan_list_non_greedy = qdf_mem_malloc(buf_size);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700581 if (!chan_list_greedy || !chan_list_non_greedy) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530582 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700583 "Failed to allocate memory for tSirUpdateChanList");
584 return;
585 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530586 qdf_mem_zero(chan_list_greedy, buf_size);
587 qdf_mem_zero(chan_list_non_greedy, buf_size);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700588 /*
589 * fixed_greedy_chan_list is an evaluated channel list based on most of
590 * the enterprise wifi deployments and the order of the channels
591 * determines the highest possibility of finding an AP.
592 * chan_list is the channel list provided by upper layers based on the
593 * regulatory domain.
594 */
595 num_fixed_greedy_chan = sizeof(fixed_greedy_chan_list)/sizeof(uint8_t);
596 /*
597 * Browse through the chan_list and put all the non-greedy channels
598 * into a seperate list by name chan_list_non_greedy
599 */
600 for (i = 0; i < num_channel; i++) {
601 for (j = 0; j < num_fixed_greedy_chan; j++) {
602 if (chan_list->chanParam[i].chanId ==
603 fixed_greedy_chan_list[j]) {
604 match_found = true;
605 break;
606 }
607 }
608 if (!match_found) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530609 qdf_mem_copy(
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700610 &chan_list_non_greedy->chanParam[num_non_greedy_chan],
611 &chan_list->chanParam[i],
612 sizeof(tSirUpdateChanParam));
613 num_non_greedy_chan++;
614 } else {
615 match_found = false;
616 }
617 }
618 /*
619 * Browse through the fixed_greedy_chan_list and put all the greedy
620 * channels in the chan_list into a seperate list by name
621 * chan_list_greedy
622 */
623 for (i = 0; i < num_fixed_greedy_chan; i++) {
624 for (j = 0; j < num_channel; j++) {
625 if (fixed_greedy_chan_list[i] ==
626 chan_list->chanParam[j].chanId) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530627 qdf_mem_copy(
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700628 &chan_list_greedy->chanParam[num_greedy_chan],
629 &chan_list->chanParam[j],
630 sizeof(tSirUpdateChanParam));
631 num_greedy_chan++;
632 break;
633 }
634 }
635 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530636 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700637 "greedy=%d, non-greedy=%d, tot=%d",
638 num_greedy_chan, num_non_greedy_chan, num_channel);
639 if ((num_greedy_chan + num_non_greedy_chan) != num_channel) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530640 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700641 "incorrect sorting of channels");
642 goto scan_list_sort_error;
643 }
644 /* Copy the Greedy channels first */
645 i = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530646 qdf_mem_copy(&chan_list->chanParam[i],
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700647 &chan_list_greedy->chanParam[i],
648 num_greedy_chan * sizeof(tSirUpdateChanParam));
649 /* Copy the remaining Non Greedy channels */
650 i = num_greedy_chan;
651 j = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530652 qdf_mem_copy(&chan_list->chanParam[i],
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700653 &chan_list_non_greedy->chanParam[j],
654 num_non_greedy_chan * sizeof(tSirUpdateChanParam));
Naveen Rawat16b82872015-12-14 17:59:16 -0800655
656 /* Update channel list for 5g preference and allow DFS roam */
657 csr_roam_arrange_ch_list(mac_ctx, chan_list->chanParam, num_channel);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700658scan_list_sort_error:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530659 qdf_mem_free(chan_list_greedy);
660 qdf_mem_free(chan_list_non_greedy);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700661}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530663QDF_STATUS csr_update_channel_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664{
665 tSirUpdateChanList *pChanList;
666 tCsrScanStruct *pScan = &pMac->scan;
667 uint8_t numChan = pScan->base_channels.numChannels;
668 uint8_t num_channel = 0;
669 uint32_t bufLen;
670 cds_msg_t msg;
671 uint8_t i, j, social_channel[MAX_SOCIAL_CHANNELS] = { 1, 6, 11 };
672 uint8_t channel_state;
673
674 if (CSR_IS_5G_BAND_ONLY(pMac)) {
675 for (i = 0; i < MAX_SOCIAL_CHANNELS; i++) {
676 if (cds_get_channel_state(social_channel[i])
677 == CHANNEL_STATE_ENABLE)
678 numChan++;
679 }
680 }
681
682 bufLen = sizeof(tSirUpdateChanList) +
683 (sizeof(tSirUpdateChanParam) * (numChan));
684
685 csr_init_operating_classes((tHalHandle) pMac);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530686 pChanList = (tSirUpdateChanList *) qdf_mem_malloc(bufLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687 if (!pChanList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530688 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689 "Failed to allocate memory for tSirUpdateChanList");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530690 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800691 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530692 qdf_mem_zero(pChanList, bufLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800693
694 for (i = 0; i < pScan->base_channels.numChannels; i++) {
695 /* Scan is not performed on DSRC channels*/
Amar Singhal7a1726a2015-10-14 16:28:11 -0700696 if (pScan->base_channels.channelList[i] >= CDS_MIN_11P_CHANNEL)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697 continue;
698 if (pScan->fcc_constraint) {
699 if (pScan->base_channels.channelList[i] == 12)
700 continue;
701 if (pScan->base_channels.channelList[i] == 13)
702 continue;
703 }
704 channel_state =
705 cds_get_channel_state(
706 pScan->base_channels.channelList[i]);
707 if ((CHANNEL_STATE_ENABLE == channel_state) ||
708 pMac->scan.fEnableDFSChnlScan) {
709 pChanList->chanParam[num_channel].chanId =
710 pScan->base_channels.channelList[i];
711 pChanList->chanParam[num_channel].pwr =
712 csr_find_channel_pwr(pScan->defaultPowerTable,
713 pChanList->chanParam[num_channel].chanId);
714 if (CHANNEL_STATE_ENABLE == channel_state)
715 pChanList->chanParam[num_channel].dfsSet =
716 false;
717 else
718 pChanList->chanParam[num_channel].dfsSet =
719 true;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530720 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700721 "channel:%d, pwr=%d, DFS=%d\n",
722 pChanList->chanParam[num_channel].chanId,
723 pChanList->chanParam[num_channel].pwr,
724 pChanList->chanParam[num_channel].dfsSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800725 num_channel++;
726 }
727 }
728
729 if (CSR_IS_5G_BAND_ONLY(pMac)) {
730 for (j = 0; j < MAX_SOCIAL_CHANNELS; j++) {
731 if (cds_get_channel_state(social_channel[j])
732 == CHANNEL_STATE_ENABLE) {
733 pChanList->chanParam[num_channel].chanId =
734 social_channel[j];
735 pChanList->chanParam[num_channel].pwr =
736 csr_find_channel_pwr(pScan->defaultPowerTable,
737 social_channel[j]);
738 pChanList->chanParam[num_channel].dfsSet = false;
739 num_channel++;
740 }
741 }
742 }
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700743 if (pMac->roam.configParam.early_stop_scan_enable)
Naveen Rawat16b82872015-12-14 17:59:16 -0800744 csr_roam_sort_channel_for_early_stop(pMac, pChanList,
745 num_channel);
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700746 else
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530747 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -0700748 FL("Early Stop Scan Feature not supported"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749
750 msg.type = WMA_UPDATE_CHAN_LIST_REQ;
751 msg.reserved = 0;
752 msg.bodyptr = pChanList;
753 pChanList->numChan = num_channel;
754
Anurag Chouhan6d760662016-02-20 16:05:43 +0530755 if (QDF_STATUS_SUCCESS != cds_mq_post_message(QDF_MODULE_ID_WMA, &msg)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530756 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 "%s: Failed to post msg to WMA", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530758 qdf_mem_free(pChanList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530759 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760 }
761
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530762 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763}
764
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530765QDF_STATUS csr_start(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530767 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768 uint32_t i;
769
770 do {
771 /* save the global cds context */
772 pMac->roam.g_cds_context = cds_get_global_context();
773 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
774 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_IDLE, i);
775
776 status = csr_roam_start(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530777 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800778 break;
779
780 pMac->roam.sPendingCommands = 0;
781 csr_scan_enable(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800782 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++)
783 status = csr_neighbor_roam_init(pMac, i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784 pMac->roam.tlStatsReqInfo.numClient = 0;
785 pMac->roam.tlStatsReqInfo.periodicity = 0;
786 pMac->roam.tlStatsReqInfo.timerRunning = false;
787 /* init the link quality indication also */
788 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530789 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800790 sms_log(pMac, LOGW,
791 " csr_start: Couldn't Init HO control blk ");
792 break;
793 }
794
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530795 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796 "Scan offload is enabled, update default chan list");
797 status = csr_update_channel_list(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798 } while (0);
799 return status;
800}
801
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530802QDF_STATUS csr_stop(tpAniSirGlobal pMac, tHalStopType stopType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803{
804 uint32_t sessionId;
805
806 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++) {
807 csr_roam_close_session(pMac, sessionId, true, NULL, NULL);
808 }
809 csr_scan_disable(pMac);
810 pMac->scan.fCancelIdleScan = false;
811 pMac->scan.fRestartIdleScan = false;
812 csr_ll_purge(&pMac->roam.roamCmdPendingList, true);
813
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
815 csr_neighbor_roam_close(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
817 if (CSR_IS_SESSION_VALID(pMac, sessionId))
818 csr_scan_flush_result(pMac);
819
820 /* Reset the domain back to the deault */
821 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
822
823 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++) {
824 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_STOP, sessionId);
825 pMac->roam.curSubState[sessionId] = eCSR_ROAM_SUBSTATE_NONE;
826 }
827
828 /* When HAL resets all the context information
829 * in HAL is lost, so we might need to send the
830 * scan offload request again when it comes
831 * out of reset for scan offload to be functional
832 */
833 if (HAL_STOP_TYPE_SYS_RESET == stopType) {
834 b_roam_scan_offload_started = false;
835 }
836
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530837 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838}
839
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530840QDF_STATUS csr_ready(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530842 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843 /* If the gScanAgingTime is set to '0' then scan results aging timeout
844 based on timer feature is not enabled */
845
846 if (0 != pMac->scan.scanResultCfgAgingTime) {
847 csr_scan_start_result_cfg_aging_timer(pMac);
848 }
849 status = csr_apply_channel_and_power_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530850 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800851 sms_log(pMac, LOGE,
852 "csr_apply_channel_and_power_list failed during csr_ready with status=%d",
853 status);
854 }
855 return status;
856}
857
858void csr_set_default_dot11_mode(tpAniSirGlobal pMac)
859{
860 uint32_t wniDot11mode = 0;
861 wniDot11mode =
862 csr_translate_to_wni_cfg_dot11_mode(pMac,
863 pMac->roam.configParam.uCfgDot11Mode);
864 cfg_set_int(pMac, WNI_CFG_DOT11_MODE, wniDot11mode);
865}
866
867void csr_set_global_cfgs(tpAniSirGlobal pMac)
868{
869
870 cfg_set_int(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD,
871 csr_get_frag_thresh(pMac));
872 cfg_set_int(pMac, WNI_CFG_RTS_THRESHOLD, csr_get_rts_thresh(pMac));
873 cfg_set_int(pMac, WNI_CFG_11D_ENABLED,
874 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.
875 configParam.Is11dSupportEnabled : pMac->roam.configParam.
876 Is11dSupportEnabled));
877 cfg_set_int(pMac, WNI_CFG_11H_ENABLED,
878 pMac->roam.configParam.Is11hSupportEnabled);
879 /* 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
880 * Once session is established we will use the session related params stored in PE session for CB mode
881 */
882 cfg_set_int(pMac, WNI_CFG_CHANNEL_BONDING_MODE,
883 !!(pMac->roam.configParam.channelBondingMode5GHz));
884 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
885 pMac->roam.configParam.HeartbeatThresh24);
886
887 /* Update the operating mode to configured value during initialization, */
888 /* So that client can advertise full capabilities in Probe request frame. */
889 csr_set_default_dot11_mode(pMac);
890}
891
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530892QDF_STATUS csr_roam_open(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530894 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895 uint32_t i;
896 tCsrRoamSession *pSession;
897 do {
898 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
899 pSession = CSR_GET_SESSION(pMac, i);
900 pSession->roamingTimerInfo.pMac = pMac;
901 pSession->roamingTimerInfo.sessionId =
902 CSR_SESSION_ID_INVALID;
903 }
904 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
905 pMac->roam.WaitForKeyTimerInfo.sessionId =
906 CSR_SESSION_ID_INVALID;
907 status =
Anurag Chouhan210db072016-02-22 18:42:15 +0530908 qdf_mc_timer_init(&pMac->roam.hTimerWaitForKey,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530909 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 csr_roam_wait_for_key_time_out_handler,
911 &pMac->roam.WaitForKeyTimerInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530912 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913 sms_log(pMac, LOGE,
914 FL
915 ("cannot allocate memory for WaitForKey time out timer"));
916 break;
917 }
918 status =
Anurag Chouhan210db072016-02-22 18:42:15 +0530919 qdf_mc_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530920 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 csr_roam_tl_stats_timer_handler, pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530922 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800923 sms_log(pMac, LOGE,
924 FL
925 ("cannot allocate memory for summary Statistics timer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530926 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927 }
928 } while (0);
929 return status;
930}
931
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530932QDF_STATUS csr_roam_close(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933{
934 uint32_t sessionId;
935 for (sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++) {
936 csr_roam_close_session(pMac, sessionId, true, NULL, NULL);
937 }
Anurag Chouhan210db072016-02-22 18:42:15 +0530938 qdf_mc_timer_stop(&pMac->roam.hTimerWaitForKey);
939 qdf_mc_timer_destroy(&pMac->roam.hTimerWaitForKey);
940 qdf_mc_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
941 qdf_mc_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530942 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943}
944
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530945QDF_STATUS csr_roam_start(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946{
947 (void)pMac;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530948 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949}
950
951void csr_roam_stop(tpAniSirGlobal pMac, uint32_t sessionId)
952{
953 csr_roam_stop_roaming_timer(pMac, sessionId);
954 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers */
955 csr_roam_dereg_statistics_req(pMac);
956}
957
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530958QDF_STATUS csr_roam_get_connect_state(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959 eCsrConnectState *pState)
960{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530961 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962 if (CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530963 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 *pState = pMac->roam.roamSession[sessionId].connectState;
965 }
966 return status;
967}
968
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530969QDF_STATUS csr_roam_copy_connect_profile(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 uint32_t sessionId, tCsrRoamConnectedProfile *pProfile)
971{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530972 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 uint32_t size = 0;
974 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
975 tCsrRoamConnectedProfile *connected_prof;
976
977 if (!pSession) {
978 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530979 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800980 }
981 if (!pProfile) {
982 sms_log(pMac, LOGE, FL("profile not found"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530983 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984 }
985
986 if (pSession->pConnectBssDesc) {
987 size = pSession->pConnectBssDesc->length +
988 sizeof(pSession->pConnectBssDesc->length);
989 if (size) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530990 pProfile->pBssDesc = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 if (NULL != pProfile->pBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530992 qdf_mem_copy(pProfile->pBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993 pSession->pConnectBssDesc,
994 size);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530995 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530997 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998 }
999 } else {
1000 pProfile->pBssDesc = NULL;
1001 }
1002 connected_prof = &(pSession->connectedProfile);
1003 pProfile->AuthType = connected_prof->AuthType;
1004 pProfile->EncryptionType = connected_prof->EncryptionType;
1005 pProfile->mcEncryptionType = connected_prof->mcEncryptionType;
1006 pProfile->BSSType = connected_prof->BSSType;
1007 pProfile->operationChannel = connected_prof->operationChannel;
1008 pProfile->CBMode = connected_prof->CBMode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301009 qdf_mem_copy(&pProfile->bssid, &connected_prof->bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301010 sizeof(struct qdf_mac_addr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301011 qdf_mem_copy(&pProfile->SSID, &connected_prof->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 sizeof(tSirMacSSid));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013 if (connected_prof->MDID.mdiePresent) {
1014 pProfile->MDID.mdiePresent = 1;
1015 pProfile->MDID.mobilityDomain =
1016 connected_prof->MDID.mobilityDomain;
1017 } else {
1018 pProfile->MDID.mdiePresent = 0;
1019 pProfile->MDID.mobilityDomain = 0;
1020 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021#ifdef FEATURE_WLAN_ESE
1022 pProfile->isESEAssoc = connected_prof->isESEAssoc;
1023 if (csr_is_auth_type_ese(connected_prof->AuthType)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301024 qdf_mem_copy(pProfile->eseCckmInfo.krk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 connected_prof->eseCckmInfo.krk,
1026 SIR_KRK_KEY_LEN);
1027#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301028 qdf_mem_copy(pProfile->eseCckmInfo.btk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029 connected_prof->eseCckmInfo.btk,
1030 SIR_BTK_KEY_LEN);
1031#endif
1032 pProfile->eseCckmInfo.reassoc_req_num =
1033 connected_prof->eseCckmInfo.reassoc_req_num;
1034 pProfile->eseCckmInfo.krk_plumbed =
1035 connected_prof->eseCckmInfo.krk_plumbed;
1036 }
1037#endif
Krunal Sonib2f13042015-11-02 18:41:08 -08001038#ifdef WLAN_FEATURE_11W
1039 pProfile->MFPEnabled = connected_prof->MFPEnabled;
1040 pProfile->MFPRequired = connected_prof->MFPRequired;
1041 pProfile->MFPCapable = connected_prof->MFPCapable;
1042#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043 }
1044 return status;
1045}
1046
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301047QDF_STATUS csr_roam_get_connect_profile(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 tCsrRoamConnectedProfile *pProfile)
1049{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301050 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051
1052 if ((csr_is_conn_state_connected(pMac, sessionId)) ||
1053 (csr_is_conn_state_ibss(pMac, sessionId))) {
1054 if (pProfile) {
1055 status =
1056 csr_roam_copy_connect_profile(pMac, sessionId,
1057 pProfile);
1058 }
1059 }
1060 return status;
1061}
1062
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001063void csr_roam_free_connect_profile(tCsrRoamConnectedProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064{
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001065 if (profile->pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301066 qdf_mem_free(profile->pBssDesc);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001067 if (profile->pAddIEAssoc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301068 qdf_mem_free(profile->pAddIEAssoc);
1069 qdf_mem_set(profile, sizeof(tCsrRoamConnectedProfile), 0);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001070 profile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071}
1072
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301073static QDF_STATUS csr_roam_free_connected_info(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074 tCsrRoamConnectedInfo *
1075 pConnectedInfo)
1076{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301077 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 if (pConnectedInfo->pbFrames) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301079 qdf_mem_free(pConnectedInfo->pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 pConnectedInfo->pbFrames = NULL;
1081 }
1082 pConnectedInfo->nBeaconLength = 0;
1083 pConnectedInfo->nAssocReqLength = 0;
1084 pConnectedInfo->nAssocRspLength = 0;
1085 pConnectedInfo->staId = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086 pConnectedInfo->nRICRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087#ifdef FEATURE_WLAN_ESE
1088 pConnectedInfo->nTspecIeLength = 0;
1089#endif
1090 return status;
1091}
1092
1093void csr_release_command_preauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1094{
1095 csr_reinit_preauth_cmd(pMac, pCommand);
1096 csr_release_command(pMac, pCommand);
1097}
1098
1099void csr_release_command_roam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1100{
1101 csr_reinit_roam_cmd(pMac, pCommand);
1102 csr_release_command(pMac, pCommand);
1103}
1104
1105void csr_release_command_scan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1106{
Anurag Chouhan210db072016-02-22 18:42:15 +05301107 qdf_mc_timer_stop(&pCommand->u.scanCmd.csr_scan_timer);
1108 qdf_mc_timer_destroy(&pCommand->u.scanCmd.csr_scan_timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001109 csr_reinit_scan_cmd(pMac, pCommand);
1110 csr_release_command(pMac, pCommand);
1111}
1112
1113void csr_release_command_wm_status_change(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1114{
1115 csr_reinit_wm_status_change_cmd(pMac, pCommand);
1116 csr_release_command(pMac, pCommand);
1117}
1118
1119void csr_reinit_set_key_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1120{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301121 qdf_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001122}
1123
1124void csr_release_command_set_key(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1125{
1126 csr_reinit_set_key_cmd(pMac, pCommand);
1127 csr_release_command(pMac, pCommand);
1128}
1129
1130/**
1131 * csr_release_roc_req_cmd() - Release the command
1132 * @mac_ctx: Global MAC Context
1133 *
1134 * Release the remain on channel request command from the queue
1135 *
1136 * Return: None
1137 */
1138void csr_release_roc_req_cmd(tpAniSirGlobal mac_ctx)
1139{
1140 tListElem *entry;
1141 tSmeCmd *cmd = NULL;
1142
1143 entry = csr_ll_peek_head(&mac_ctx->sme.smeCmdActiveList,
1144 LL_ACCESS_LOCK);
1145 if (entry) {
1146 cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
1147 if (eSmeCommandRemainOnChannel == cmd->command) {
1148 remainOnChanCallback callback =
1149 cmd->u.remainChlCmd.callback;
1150 /* process the msg */
1151 if (callback)
1152 callback(mac_ctx,
1153 cmd->u.remainChlCmd.callbackCtx, 0,
1154 cmd->u.remainChlCmd.scan_id);
1155 sms_log(mac_ctx, LOGE,
1156 FL("Remove RoC Request from Active Cmd List"));
1157 /* Put this cmd back on the available command list */
1158 if (csr_ll_remove_entry(&mac_ctx->sme.smeCmdActiveList,
1159 entry, LL_ACCESS_LOCK))
1160 sme_release_command(mac_ctx, cmd);
1161 }
1162 }
1163}
1164
1165void csr_abort_command(tpAniSirGlobal pMac, tSmeCmd *pCommand, bool fStopping)
1166{
1167
1168 if (eSmeCsrCommandMask & pCommand->command) {
1169 switch (pCommand->command) {
1170 case eSmeCommandScan:
1171 /* We need to inform the requester before dropping the scan command */
1172 sms_log(pMac, LOGW,
1173 "%s: Drop scan reason %d callback %p", __func__,
1174 pCommand->u.scanCmd.reason,
1175 pCommand->u.scanCmd.callback);
1176 if (NULL != pCommand->u.scanCmd.callback) {
1177 sms_log(pMac, LOGW, "%s callback scan requester",
1178 __func__);
1179 csr_scan_call_callback(pMac, pCommand,
1180 eCSR_SCAN_ABORT);
1181 }
1182 csr_release_command_scan(pMac, pCommand);
1183 break;
1184 case eSmeCommandRoam:
1185 csr_release_command_roam(pMac, pCommand);
1186 break;
1187
1188 case eSmeCommandWmStatusChange:
1189 csr_release_command_wm_status_change(pMac, pCommand);
1190 break;
1191
1192 case eSmeCommandSetKey:
1193 csr_release_command_set_key(pMac, pCommand);
1194 break;
1195
1196 default:
1197 sms_log(pMac, LOGW, " CSR abort standard command %d",
1198 pCommand->command);
1199 csr_release_command(pMac, pCommand);
1200 break;
1201 }
1202 }
1203}
1204
1205void csr_roam_substate_change(tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate,
1206 uint32_t sessionId)
1207{
1208 sms_log(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1209 mac_trace_getcsr_roam_sub_state(NewSubstate),
1210 mac_trace_getcsr_roam_sub_state(pMac->roam.curSubState[sessionId]));
1211 if (pMac->roam.curSubState[sessionId] == NewSubstate) {
1212 return;
1213 }
1214 pMac->roam.curSubState[sessionId] = NewSubstate;
1215}
1216
1217eCsrRoamState csr_roam_state_change(tpAniSirGlobal pMac,
1218 eCsrRoamState NewRoamState, uint8_t sessionId)
1219{
1220 eCsrRoamState PreviousState;
1221
1222 sms_log(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1223 mac_trace_getcsr_roam_state(NewRoamState),
1224 mac_trace_getcsr_roam_state(pMac->roam.curState[sessionId]));
1225 PreviousState = pMac->roam.curState[sessionId];
1226
1227 if (NewRoamState != pMac->roam.curState[sessionId]) {
1228 /* Whenever we transition OUT of the Roaming state, clear the Roaming substate... */
1229 if (CSR_IS_ROAM_JOINING(pMac, sessionId)) {
1230 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
1231 sessionId);
1232 }
1233
1234 pMac->roam.curState[sessionId] = NewRoamState;
1235 }
1236 return PreviousState;
1237}
1238
1239void csr_assign_rssi_for_category(tpAniSirGlobal pMac, int8_t bestApRssi,
1240 uint8_t catOffset)
1241{
1242 int i;
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08001243 sms_log(pMac, LOG2, FL("best AP RSSI:%d, cat offset:%d"),
1244 bestApRssi, catOffset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245 if (catOffset) {
1246 pMac->roam.configParam.bCatRssiOffset = catOffset;
1247 for (i = 0; i < CSR_NUM_RSSI_CAT; i++) {
1248 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i -
1249 1] =
1250 (int)bestApRssi -
1251 pMac->roam.configParam.nSelect5GHzMargin -
1252 (int)(i * catOffset);
1253 }
1254 }
1255}
1256
1257static void init_config_param(tpAniSirGlobal pMac)
1258{
1259 int i;
1260 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
1261 pMac->roam.configParam.channelBondingMode24GHz =
1262 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1263 pMac->roam.configParam.channelBondingMode5GHz =
1264 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
1265
1266 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_AUTO;
1267 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1268 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_AUTO;
1269 pMac->roam.configParam.FragmentationThreshold =
1270 eCSR_DOT11_FRAG_THRESH_DEFAULT;
1271 pMac->roam.configParam.HeartbeatThresh24 = 40;
1272 pMac->roam.configParam.HeartbeatThresh50 = 40;
1273 pMac->roam.configParam.Is11dSupportEnabled = false;
1274 pMac->roam.configParam.Is11dSupportEnabledOriginal = false;
1275 pMac->roam.configParam.Is11eSupportEnabled = true;
1276 pMac->roam.configParam.Is11hSupportEnabled = true;
1277 pMac->roam.configParam.RTSThreshold = 2346;
1278 pMac->roam.configParam.shortSlotTime = true;
1279 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1280 pMac->roam.configParam.ProprietaryRatesEnabled = true;
1281 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1282 pMac->roam.configParam.scanAgeTimeNCNPS =
1283 CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1284 pMac->roam.configParam.scanAgeTimeNCPS =
1285 CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1286 pMac->roam.configParam.scanAgeTimeCNPS =
1287 CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1288 pMac->roam.configParam.scanAgeTimeCPS =
1289 CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1290 for (i = 0; i < CSR_NUM_RSSI_CAT; i++) {
1291 pMac->roam.configParam.BssPreferValue[i] = i;
1292 }
1293 csr_assign_rssi_for_category(pMac, CSR_BEST_RSSI_VALUE,
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08001294 CSR_DEFAULT_RSSI_DB_GAP);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1296 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = false;
1297 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1298 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1299 pMac->roam.configParam.nPassiveMaxChnTime =
1300 CSR_PASSIVE_MAX_CHANNEL_TIME;
1301 pMac->roam.configParam.nPassiveMinChnTime =
1302 CSR_PASSIVE_MIN_CHANNEL_TIME;
1303#ifdef WLAN_AP_STA_CONCURRENCY
1304 pMac->roam.configParam.nActiveMaxChnTimeConc =
1305 CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1306 pMac->roam.configParam.nActiveMinChnTimeConc =
1307 CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1308 pMac->roam.configParam.nPassiveMaxChnTimeConc =
1309 CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1310 pMac->roam.configParam.nPassiveMinChnTimeConc =
1311 CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1312 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
1313 pMac->roam.configParam.nNumStaChanCombinedConc =
1314 CSR_NUM_STA_CHAN_COMBINED_CONC;
1315 pMac->roam.configParam.nNumP2PChanCombinedConc =
1316 CSR_NUM_P2P_CHAN_COMBINED_CONC;
1317#endif
1318 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1319 pMac->roam.configParam.statsReqPeriodicity =
1320 CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1321 pMac->roam.configParam.statsReqPeriodicityInPS =
1322 CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1325 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold =
1326 120;
1327 pMac->roam.configParam.neighborRoamConfig.nOpportunisticThresholdDiff =
1328 30;
1329 pMac->roam.configParam.neighborRoamConfig.nRoamRescanRssiDiff = 5;
1330 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1331 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1332 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod =
1333 200;
1334 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1335 numChannels = 3;
1336 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1337 channelList[0] = 1;
1338 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1339 channelList[1] = 6;
1340 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.
1341 channelList[2] = 11;
1342 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; /* 20 seconds */
1343 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
1344 pMac->roam.configParam.neighborRoamConfig.nRoamBmissFirstBcnt = 10;
1345 pMac->roam.configParam.neighborRoamConfig.nRoamBmissFinalBcnt = 10;
1346 pMac->roam.configParam.neighborRoamConfig.nRoamBeaconRssiWeight = 14;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 pMac->roam.configParam.nVhtChannelWidth =
1348 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001349
1350 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1351 pMac->roam.configParam.fScanTwice = false;
1352
1353 /* Remove this code once SLM_Sessionization is supported */
1354 /* BMPS_WORKAROUND_NOT_NEEDED */
1355 pMac->roam.configParam.doBMPSWorkaround = 0;
1356
1357 pMac->roam.configParam.nInitialDwellTime = 0;
1358 pMac->roam.configParam.initial_scan_no_dfs_chnl = 0;
1359}
1360
1361eCsrBand csr_get_current_band(tHalHandle hHal)
1362{
1363 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
1364 return pMac->roam.configParam.bandCapability;
1365}
1366
1367#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
1368/*
1369 This function flushes the roam scan cache
1370 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301371QDF_STATUS csr_flush_roam_scan_roam_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372 uint8_t sessionId)
1373{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301374 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375 tpCsrNeighborRoamControlInfo pNeighborRoamInfo
1376 = &pMac->roam.neighborRoamInfo[sessionId];
1377 /* Free up the memory first (if required) */
1378 if (NULL !=
1379 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.
1380 ChannelList) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301381 qdf_mem_free(pNeighborRoamInfo->roamChannelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382 currentChannelListInfo.ChannelList);
1383 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.
1384 ChannelList = NULL;
1385 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.
1386 numOfChannels = 0;
1387 }
1388 return status;
1389}
1390#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
1391
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392/*
1393 This function flushes the roam scan cache
1394 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301395QDF_STATUS csr_flush_cfg_bg_scan_roam_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396 uint8_t sessionId)
1397{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301398 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
1400 &pMac->roam.neighborRoamInfo[sessionId];
1401
1402 /* Free up the memory first (if required) */
1403 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301404 qdf_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405 ChannelList);
1406 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
1407 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1408 }
1409 return status;
1410}
1411
1412/*
1413 This function flushes the roam scan cache and creates fresh cache
1414 based on the input channel list
1415 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301416QDF_STATUS csr_create_bg_scan_roam_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417 uint8_t sessionId,
1418 const uint8_t *pChannelList,
1419 const uint8_t numChannels)
1420{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301421 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
1423 &pMac->roam.neighborRoamInfo[sessionId];
1424
1425 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1426
1427 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301428 qdf_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429 numOfChannels);
1430
1431 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList) {
1432 sms_log(pMac, LOGE,
1433 FL("Memory Allocation for CFG Channel List failed"));
1434 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301435 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436 }
1437
1438 /* Update the roam global structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301439 qdf_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 pChannelList,
1441 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1442 return status;
1443}
1444
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445
1446#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
1447/*
1448 * This function modifies the roam scan channel list as per AP neighbor
1449 * report; AP neighbor report may be empty or may include only other AP
1450 * channels; in any case, we merge the channel list with the learned occupied
1451 * channels list.
1452 * if the band is 2.4G, then make sure channel list contains only 2.4G
1453 * valid channels if the band is 5G, then make sure channel list contains
1454 * only 5G valid channels
1455 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301456QDF_STATUS csr_create_roam_scan_channel_list(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457 uint8_t sessionId,
1458 uint8_t *pChannelList,
1459 uint8_t numChannels,
1460 const eCsrBand eBand)
1461{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301462 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463 tpCsrNeighborRoamControlInfo pNeighborRoamInfo
1464 = &pMac->roam.neighborRoamInfo[sessionId];
1465 uint8_t outNumChannels = 0;
1466 uint8_t inNumChannels = numChannels;
1467 uint8_t *inPtr = pChannelList;
1468 uint8_t i = 0;
1469 uint8_t ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
1470 uint8_t tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = { 0 };
1471 uint8_t mergedOutputNumOfChannels = 0;
1472 tpCsrChannelInfo currChannelListInfo
1473 = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1474 /*
1475 * Create a Union of occupied channel list learnt by the DUT along
1476 * with the Neighbor report Channels. This increases the chances of
1477 * the DUT to get a candidate AP while roaming even if the Neighbor
1478 * Report is not able to provide sufficient information.
1479 */
1480 if (pMac->scan.occupiedChannels[sessionId].numChannels) {
1481 csr_neighbor_roam_merge_channel_lists(pMac,
1482 &pMac->scan.
1483 occupiedChannels[sessionId].
1484 channelList[0],
1485 pMac->scan.
1486 occupiedChannels[sessionId].
1487 numChannels, inPtr,
1488 inNumChannels,
1489 &mergedOutputNumOfChannels);
1490 inNumChannels = mergedOutputNumOfChannels;
1491 }
1492 if (eCSR_BAND_24 == eBand) {
1493 for (i = 0; i < inNumChannels; i++) {
1494 if (CDS_IS_CHANNEL_24GHZ(inPtr[i])
1495 && csr_roam_is_channel_valid(pMac, inPtr[i])) {
1496 ChannelList[outNumChannels++] = inPtr[i];
1497 }
1498 }
1499 } else if (eCSR_BAND_5G == eBand) {
1500 for (i = 0; i < inNumChannels; i++) {
1501 /* Add 5G Non-DFS channel */
1502 if (CDS_IS_CHANNEL_5GHZ(inPtr[i]) &&
1503 csr_roam_is_channel_valid(pMac, inPtr[i]) &&
1504 !CDS_IS_DFS_CH(inPtr[i])) {
1505 ChannelList[outNumChannels++] = inPtr[i];
1506 }
1507 }
1508 } else if (eCSR_BAND_ALL == eBand) {
1509 for (i = 0; i < inNumChannels; i++) {
1510 if (csr_roam_is_channel_valid(pMac, inPtr[i]) &&
1511 !CDS_IS_DFS_CH(inPtr[i])) {
1512 ChannelList[outNumChannels++] = inPtr[i];
1513 }
1514 }
1515 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301516 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 "Invalid band, No operation carried out (Band %d)",
1518 eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301519 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001520 }
1521 /*
1522 * if roaming within band is enabled, then select only the
1523 * in band channels .
1524 * This is required only if the band capability is set to ALL,
1525 * E.g., if band capability is only 2.4G then all the channels in the
1526 * list are already filtered for 2.4G channels, hence ignore this check
1527 */
1528 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac)) {
1529 csr_neighbor_roam_channels_filter_by_current_band(pMac,
1530 sessionId,
1531 ChannelList,
1532 outNumChannels,
1533 tmpChannelList,
1534 &outNumChannels);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301535 qdf_mem_copy(ChannelList, tmpChannelList, outNumChannels);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 }
1537 /* Prepare final roam scan channel list */
1538 if (outNumChannels) {
1539 /* Clear the channel list first */
1540 if (NULL != currChannelListInfo->ChannelList) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301541 qdf_mem_free(currChannelListInfo->ChannelList);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542 currChannelListInfo->ChannelList = NULL;
1543 currChannelListInfo->numOfChannels = 0;
1544 }
1545 currChannelListInfo->ChannelList
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301546 = qdf_mem_malloc(outNumChannels * sizeof(uint8_t));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547 if (NULL == currChannelListInfo->ChannelList) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301548 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549 "Failed to allocate memory for roam scan channel list");
1550 currChannelListInfo->numOfChannels = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301551 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301553 qdf_mem_copy(currChannelListInfo->ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 ChannelList, outNumChannels);
1555 }
1556 return status;
1557}
1558#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
1559
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301560QDF_STATUS csr_set_band(tHalHandle hHal, uint8_t sessionId, eCsrBand eBand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001561{
1562 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301563 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 if (CSR_IS_PHY_MODE_A_ONLY(pMac) && (eBand == eCSR_BAND_24)) {
1565 /* DOT11 mode configured to 11a only and received
1566 request to change the band to 2.4 GHz */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301567 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568 "failed to set band cfg80211 = %u, band = %u",
1569 pMac->roam.configParam.uCfgDot11Mode, eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301570 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 }
1572 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1573 CSR_IS_PHY_MODE_G_ONLY(pMac)) && (eBand == eCSR_BAND_5G)) {
1574 /* DOT11 mode configured to 11b/11g only and received
1575 request to change the band to 5 GHz */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301576 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001577 "failed to set band dot11mode = %u, band = %u",
1578 pMac->roam.configParam.uCfgDot11Mode, eBand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301579 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301581 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
1583 pMac->roam.configParam.eBand = eBand;
1584 pMac->roam.configParam.bandCapability = eBand;
1585
1586 status = csr_get_channel_and_power_list(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301587 if (QDF_STATUS_SUCCESS == status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588 csr_apply_channel_and_power_list(pMac);
1589 return status;
1590}
1591
1592/* The funcns csr_convert_cb_ini_value_to_phy_cb_state and csr_convert_phy_cb_state_to_ini_value have been
1593 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1594 * Ideally we should have kept the ini value and enum value same and representing the same
1595 * cb values as in 11n standard i.e.
1596 * Set to 1 (SCA) if the secondary channel is above the primary channel
1597 * Set to 3 (SCB) if the secondary channel is below the primary channel
1598 * Set to 0 (SCN) if no secondary channel is present
1599 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1600 * 0 - secondary none
1601 * 1 - secondary LOW
1602 * 2 - secondary HIGH
1603 * and convert to enum value used within the driver in csr_change_default_config_param using this funcn
1604 * The enum values are as follows:
1605 * PHY_SINGLE_CHANNEL_CENTERED = 0
1606 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1607 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1608 */
1609ePhyChanBondState csr_convert_cb_ini_value_to_phy_cb_state(uint32_t cbIniValue)
1610{
1611
1612 ePhyChanBondState phyCbState;
1613 switch (cbIniValue) {
1614 /* secondary none */
1615 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
1616 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1617 break;
1618 /* secondary LOW */
1619 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
1620 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1621 break;
1622 /* secondary HIGH */
1623 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
1624 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1625 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1627 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1628 break;
1629 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1630 phyCbState =
1631 PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1632 break;
1633 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1634 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1635 break;
1636 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1637 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1638 break;
1639 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1640 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1641 break;
1642 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1643 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1644 break;
1645 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1646 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1647 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001648 default:
1649 /* If an invalid value is passed, disable CHANNEL BONDING */
1650 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1651 break;
1652 }
1653 return phyCbState;
1654}
1655
1656uint32_t csr_convert_phy_cb_state_to_ini_value(ePhyChanBondState phyCbState)
1657{
1658
1659 uint32_t cbIniValue;
1660 switch (phyCbState) {
1661 /* secondary none */
1662 case PHY_SINGLE_CHANNEL_CENTERED:
1663 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
1664 break;
1665 /* secondary LOW */
1666 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1667 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
1668 break;
1669 /* secondary HIGH */
1670 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1671 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
1672 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001673 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1674 cbIniValue =
1675 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1676 break;
1677 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1678 cbIniValue =
1679 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1680 break;
1681 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1682 cbIniValue =
1683 eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1684 break;
1685 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1686 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1687 break;
1688 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1689 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1690 break;
1691 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1692 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1693 break;
1694 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1695 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1696 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 default:
1698 /* return some invalid value */
1699 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
1700 break;
1701 }
1702 return cbIniValue;
1703}
1704
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301705QDF_STATUS csr_change_default_config_param(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706 tCsrConfigParam *pParam)
1707{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301708 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709
1710 if (pParam) {
1711 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1712 cfg_set_int(pMac, WNI_CFG_WME_ENABLED,
1713 (pParam->WMMSupportMode == eCsrRoamWmmNoQos) ? 0 : 1);
1714 pMac->roam.configParam.Is11eSupportEnabled =
1715 pParam->Is11eSupportEnabled;
1716 pMac->roam.configParam.FragmentationThreshold =
1717 pParam->FragmentationThreshold;
1718 pMac->roam.configParam.Is11dSupportEnabled =
1719 pParam->Is11dSupportEnabled;
1720 pMac->roam.configParam.Is11dSupportEnabledOriginal =
1721 pParam->Is11dSupportEnabled;
1722 pMac->roam.configParam.Is11hSupportEnabled =
1723 pParam->Is11hSupportEnabled;
1724
1725 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
1726 pMac->roam.configParam.mcc_rts_cts_prot_enable =
1727 pParam->mcc_rts_cts_prot_enable;
1728 pMac->roam.configParam.mcc_bcast_prob_resp_enable =
1729 pParam->mcc_bcast_prob_resp_enable;
1730 pMac->roam.configParam.fAllowMCCGODiffBI =
1731 pParam->fAllowMCCGODiffBI;
1732
1733 /* channelBondingMode5GHz plays a dual role right now
1734 * 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
1735 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1736 */
1737 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI) {
1738 sms_log(pMac, LOGW,
1739 "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED",
1740 pParam->channelBondingMode24GHz);
1741 }
1742 pMac->roam.configParam.channelBondingMode24GHz =
1743 csr_convert_cb_ini_value_to_phy_cb_state(pParam->
1744 channelBondingMode24GHz);
1745 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI) {
1746 sms_log(pMac, LOGW,
1747 "Invalid CB value from ini in 5GHz band %d, CB DISABLED",
1748 pParam->channelBondingMode5GHz);
1749 }
1750 pMac->roam.configParam.channelBondingMode5GHz =
1751 csr_convert_cb_ini_value_to_phy_cb_state(pParam->
1752 channelBondingMode5GHz);
1753 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1754 pMac->roam.configParam.phyMode = pParam->phyMode;
1755 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1756 pMac->roam.configParam.HeartbeatThresh24 =
1757 pParam->HeartbeatThresh24;
1758 pMac->roam.configParam.HeartbeatThresh50 =
1759 pParam->HeartbeatThresh50;
1760 pMac->roam.configParam.ProprietaryRatesEnabled =
1761 pParam->ProprietaryRatesEnabled;
1762 pMac->roam.configParam.TxRate = pParam->TxRate;
1763 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1764 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1765 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1766 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1767 pMac->roam.configParam.neighborRoamConfig.
1768 delay_before_vdev_stop =
1769 pParam->neighborRoamConfig.delay_before_vdev_stop;
1770
1771 /* if HDD passed down non zero values then only update, */
1772 /* otherwise keep using the defaults */
1773 if (pParam->initial_scan_no_dfs_chnl) {
1774 pMac->roam.configParam.initial_scan_no_dfs_chnl =
1775 pParam->initial_scan_no_dfs_chnl;
1776 }
1777 if (pParam->nInitialDwellTime) {
1778 pMac->roam.configParam.nInitialDwellTime =
1779 pParam->nInitialDwellTime;
1780 }
1781 if (pParam->nActiveMaxChnTime) {
1782 pMac->roam.configParam.nActiveMaxChnTime =
1783 pParam->nActiveMaxChnTime;
1784 cfg_set_int(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1785 pParam->nActiveMaxChnTime);
1786 }
1787 if (pParam->nActiveMinChnTime) {
1788 pMac->roam.configParam.nActiveMinChnTime =
1789 pParam->nActiveMinChnTime;
1790 cfg_set_int(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1791 pParam->nActiveMinChnTime);
1792 }
1793 if (pParam->nPassiveMaxChnTime) {
1794 pMac->roam.configParam.nPassiveMaxChnTime =
1795 pParam->nPassiveMaxChnTime;
1796 cfg_set_int(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1797 pParam->nPassiveMaxChnTime);
1798 }
1799 if (pParam->nPassiveMinChnTime) {
1800 pMac->roam.configParam.nPassiveMinChnTime =
1801 pParam->nPassiveMinChnTime;
1802 cfg_set_int(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1803 pParam->nPassiveMinChnTime);
1804 }
1805#ifdef WLAN_AP_STA_CONCURRENCY
1806 if (pParam->nActiveMaxChnTimeConc) {
1807 pMac->roam.configParam.nActiveMaxChnTimeConc =
1808 pParam->nActiveMaxChnTimeConc;
1809 }
1810 if (pParam->nActiveMinChnTimeConc) {
1811 pMac->roam.configParam.nActiveMinChnTimeConc =
1812 pParam->nActiveMinChnTimeConc;
1813 }
1814 if (pParam->nPassiveMaxChnTimeConc) {
1815 pMac->roam.configParam.nPassiveMaxChnTimeConc =
1816 pParam->nPassiveMaxChnTimeConc;
1817 }
1818 if (pParam->nPassiveMinChnTimeConc) {
1819 pMac->roam.configParam.nPassiveMinChnTimeConc =
1820 pParam->nPassiveMinChnTimeConc;
1821 }
1822 if (pParam->nRestTimeConc) {
1823 pMac->roam.configParam.nRestTimeConc =
1824 pParam->nRestTimeConc;
1825 }
1826 if (pParam->nNumStaChanCombinedConc) {
1827 pMac->roam.configParam.nNumStaChanCombinedConc =
1828 pParam->nNumStaChanCombinedConc;
1829 }
1830 if (pParam->nNumP2PChanCombinedConc) {
1831 pMac->roam.configParam.nNumP2PChanCombinedConc =
1832 pParam->nNumP2PChanCombinedConc;
1833 }
1834#endif
1835 pMac->roam.configParam.eBand = pParam->eBand;
1836 pMac->roam.configParam.uCfgDot11Mode =
1837 csr_get_cfg_dot11_mode_from_csr_phy_mode(NULL,
1838 pMac->roam.configParam.
1839 phyMode,
1840 pMac->roam.configParam.
1841 ProprietaryRatesEnabled);
1842 /* if HDD passed down non zero values for age params, then only update, */
1843 /* otherwise keep using the defaults */
1844 if (pParam->nScanResultAgeCount) {
1845 pMac->roam.configParam.agingCount =
1846 pParam->nScanResultAgeCount;
1847 }
1848 if (pParam->scanAgeTimeNCNPS) {
1849 pMac->roam.configParam.scanAgeTimeNCNPS =
1850 pParam->scanAgeTimeNCNPS;
1851 }
1852 if (pParam->scanAgeTimeNCPS) {
1853 pMac->roam.configParam.scanAgeTimeNCPS =
1854 pParam->scanAgeTimeNCPS;
1855 }
1856 if (pParam->scanAgeTimeCNPS) {
1857 pMac->roam.configParam.scanAgeTimeCNPS =
1858 pParam->scanAgeTimeCNPS;
1859 }
1860 if (pParam->scanAgeTimeCPS) {
1861 pMac->roam.configParam.scanAgeTimeCPS =
1862 pParam->scanAgeTimeCPS;
1863 }
Sandeep Puligillae0875662016-02-12 16:09:21 -08001864 if (pParam->obss_width_interval) {
1865 pMac->roam.configParam.obss_width_interval =
1866 pParam->obss_width_interval;
1867 cfg_set_int(pMac,
1868 WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
1869 pParam->obss_width_interval);
1870 }
1871 if (pParam->obss_active_dwelltime) {
1872 pMac->roam.configParam.obss_active_dwelltime =
1873 pParam->obss_active_dwelltime;
1874 cfg_set_int(pMac,
1875 WNI_CFG_OBSS_HT40_SCAN_ACTIVE_DWELL_TIME,
1876 pParam->obss_active_dwelltime);
1877 }
1878 if (pParam->obss_passive_dwelltime) {
1879 pMac->roam.configParam.obss_passive_dwelltime =
1880 pParam->obss_passive_dwelltime;
1881 cfg_set_int(pMac,
1882 WNI_CFG_OBSS_HT40_SCAN_PASSIVE_DWELL_TIME,
1883 pParam->obss_passive_dwelltime);
1884 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08001886 pMac->first_scan_bucket_threshold =
1887 pParam->first_scan_bucket_threshold;
1888 csr_assign_rssi_for_category(pMac,
1889 pMac->first_scan_bucket_threshold,
1890 pParam->bCatRssiOffset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1892 pMac->roam.configParam.fSupplicantCountryCodeHasPriority =
1893 pParam->fSupplicantCountryCodeHasPriority;
1894 pMac->roam.configParam.vccRssiThreshold =
1895 pParam->vccRssiThreshold;
1896 pMac->roam.configParam.vccUlMacLossThreshold =
1897 pParam->vccUlMacLossThreshold;
1898 pMac->roam.configParam.statsReqPeriodicity =
1899 pParam->statsReqPeriodicity;
1900 pMac->roam.configParam.statsReqPeriodicityInPS =
1901 pParam->statsReqPeriodicityInPS;
1902 /* Assign this before calling csr_init11d_info */
1903 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
1904 if (csr_is11d_supported(pMac)) {
1905 status = csr_init11d_info(pMac, &pParam->Csr11dinfo);
1906 } else {
1907 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1908 }
1909
1910 /* Initialize the power + channel information if 11h is enabled.
1911 If 11d is enabled this information has already been initialized */
1912 if (csr_is11h_supported(pMac) && !csr_is11d_supported(pMac)) {
1913 csr_init_channel_power_list(pMac, &pParam->Csr11dinfo);
1914 }
1915
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301916 qdf_mem_copy(&pMac->roam.configParam.csr11rConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917 &pParam->csr11rConfig,
1918 sizeof(tCsr11rConfigParams));
1919 sms_log(pMac, LOG1, "IsFTResourceReqSupp = %d",
1920 pMac->roam.configParam.csr11rConfig.
1921 IsFTResourceReqSupported);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001922 pMac->roam.configParam.isFastTransitionEnabled =
1923 pParam->isFastTransitionEnabled;
1924 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
1925 pMac->roam.configParam.nRoamPrefer5GHz =
1926 pParam->nRoamPrefer5GHz;
1927 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
1928 pMac->roam.configParam.isWESModeEnabled =
1929 pParam->isWESModeEnabled;
1930 pMac->roam.configParam.nProbes = pParam->nProbes;
1931 pMac->roam.configParam.nRoamScanHomeAwayTime =
1932 pParam->nRoamScanHomeAwayTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933 pMac->roam.configParam.isRoamOffloadScanEnabled =
1934 pParam->isRoamOffloadScanEnabled;
1935 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
1936 pParam->bFastRoamInConIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 pMac->roam.configParam.isFastRoamIniFeatureEnabled =
1938 pParam->isFastRoamIniFeatureEnabled;
1939 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001940
1941#ifdef FEATURE_WLAN_ESE
1942 pMac->roam.configParam.isEseIniFeatureEnabled =
1943 pParam->isEseIniFeatureEnabled;
1944#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301945 qdf_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 &pParam->neighborRoamConfig,
1947 sizeof(tCsrNeighborRoamConfigParams));
1948 sms_log(pMac, LOG1, "nNeighborScanTimerPerioid = %d",
1949 pMac->roam.configParam.neighborRoamConfig.
1950 nNeighborScanTimerPeriod);
1951 sms_log(pMac, LOG1, "nNeighborLookupRssiThreshold = %d",
1952 pMac->roam.configParam.neighborRoamConfig.
1953 nNeighborLookupRssiThreshold);
1954 sms_log(pMac, LOG1, "nOpportunisticThresholdDiff = %d",
1955 pMac->roam.configParam.neighborRoamConfig.
1956 nOpportunisticThresholdDiff);
1957 sms_log(pMac, LOG1, "nRoamRescanRssiDiff = %d",
1958 pMac->roam.configParam.neighborRoamConfig.
1959 nRoamRescanRssiDiff);
1960 sms_log(pMac, LOG1, "nNeighborScanMinChanTime = %d",
1961 pMac->roam.configParam.neighborRoamConfig.
1962 nNeighborScanMinChanTime);
1963 sms_log(pMac, LOG1, "nNeighborScanMaxChanTime = %d",
1964 pMac->roam.configParam.neighborRoamConfig.
1965 nNeighborScanMaxChanTime);
1966 sms_log(pMac, LOG1, "nMaxNeighborRetries = %d",
1967 pMac->roam.configParam.neighborRoamConfig.
1968 nMaxNeighborRetries);
1969 sms_log(pMac, LOG1, "nNeighborResultsRefreshPeriod = %d",
1970 pMac->roam.configParam.neighborRoamConfig.
1971 nNeighborResultsRefreshPeriod);
1972 sms_log(pMac, LOG1, "nEmptyScanRefreshPeriod = %d",
1973 pMac->roam.configParam.neighborRoamConfig.
1974 nEmptyScanRefreshPeriod);
1975 {
1976 int i;
1977 sms_log(pMac, LOG1,
1978 FL("Num of Channels in CFG Channel List: %d"),
1979 pMac->roam.configParam.neighborRoamConfig.
1980 neighborScanChanList.numChannels);
1981 for (i = 0;
1982 i <
1983 pMac->roam.configParam.neighborRoamConfig.
1984 neighborScanChanList.numChannels; i++) {
1985 sms_log(pMac, LOG1, "%d ",
1986 pMac->roam.configParam.
1987 neighborRoamConfig.neighborScanChanList.
1988 channelList[i]);
1989 }
1990 }
1991 sms_log(pMac, LOG1, "nRoamBmissFirstBcnt = %d",
1992 pMac->roam.configParam.neighborRoamConfig.
1993 nRoamBmissFirstBcnt);
1994 sms_log(pMac, LOG1, "nRoamBmissFinalBcnt = %d",
1995 pMac->roam.configParam.neighborRoamConfig.
1996 nRoamBmissFinalBcnt);
1997 sms_log(pMac, LOG1, "nRoamBeaconRssiWeight = %d",
1998 pMac->roam.configParam.neighborRoamConfig.
1999 nRoamBeaconRssiWeight);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 pMac->roam.configParam.addTSWhenACMIsOff =
2001 pParam->addTSWhenACMIsOff;
2002 pMac->scan.fValidateList = pParam->fValidateList;
2003 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
2004 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
2005 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
2006 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
2007 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
2008 pMac->scan.max_scan_count = pParam->max_scan_count;
2009 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
2010 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
2011 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
2012 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
2013 * single session
2014 */
2015 /* Remove this code once SLM_Sessionization is supported */
2016 /* BMPS_WORKAROUND_NOT_NEEDED */
2017 pMac->roam.configParam.doBMPSWorkaround = 0;
2018
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019 pMac->roam.configParam.nVhtChannelWidth =
2020 pParam->nVhtChannelWidth;
2021 pMac->roam.configParam.txBFEnable = pParam->enableTxBF;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08002022 pMac->roam.configParam.enable_txbf_sap_mode =
2023 pParam->enable_txbf_sap_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
2025 pMac->roam.configParam.enable2x2 = pParam->enable2x2;
2026 pMac->roam.configParam.enableVhtFor24GHz =
2027 pParam->enableVhtFor24GHz;
2028 pMac->roam.configParam.txMuBformee = pParam->enableMuBformee;
2029 pMac->roam.configParam.enableVhtpAid = pParam->enableVhtpAid;
2030 pMac->roam.configParam.enableVhtGid = pParam->enableVhtGid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 pMac->roam.configParam.enableAmpduPs = pParam->enableAmpduPs;
2032 pMac->roam.configParam.enableHtSmps = pParam->enableHtSmps;
2033 pMac->roam.configParam.htSmps = pParam->htSmps;
2034 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
2035 pMac->roam.configParam.ignore_peer_erp_info =
2036 pParam->ignore_peer_erp_info;
2037 pMac->roam.configParam.isAmsduSupportInAMPDU =
2038 pParam->isAmsduSupportInAMPDU;
2039 pMac->roam.configParam.nSelect5GHzMargin =
2040 pParam->nSelect5GHzMargin;
2041 pMac->roam.configParam.isCoalesingInIBSSAllowed =
2042 pParam->isCoalesingInIBSSAllowed;
2043#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
2044 pMac->roam.configParam.cc_switch_mode = pParam->cc_switch_mode;
2045#endif
2046 pMac->roam.configParam.allowDFSChannelRoam =
2047 pParam->allowDFSChannelRoam;
2048#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2049 pMac->roam.configParam.isRoamOffloadEnabled =
2050 pParam->isRoamOffloadEnabled;
2051#endif
2052 pMac->roam.configParam.obssEnabled = pParam->obssEnabled;
2053 pMac->roam.configParam.conc_custom_rule1 =
2054 pParam->conc_custom_rule1;
2055 pMac->roam.configParam.conc_custom_rule2 =
2056 pParam->conc_custom_rule2;
2057 pMac->roam.configParam.is_sta_connection_in_5gz_enabled =
2058 pParam->is_sta_connection_in_5gz_enabled;
2059 pMac->roam.configParam.sendDeauthBeforeCon =
2060 pParam->sendDeauthBeforeCon;
2061
2062 pMac->enable_dot11p = pParam->enable_dot11p;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07002063 pMac->roam.configParam.early_stop_scan_enable =
2064 pParam->early_stop_scan_enable;
2065 pMac->roam.configParam.early_stop_scan_min_threshold =
2066 pParam->early_stop_scan_min_threshold;
2067 pMac->roam.configParam.early_stop_scan_max_threshold =
2068 pParam->early_stop_scan_max_threshold;
Krunal Soni1878d3a2016-01-14 13:00:44 -08002069 pMac->isCoalesingInIBSSAllowed =
2070 pParam->isCoalesingInIBSSAllowed;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -07002071
Gupta, Kapilc68ad462016-02-01 19:17:23 +05302072 pMac->roam.configParam.roam_params.dense_rssi_thresh_offset =
2073 pParam->roam_dense_rssi_thresh_offset;
2074 pMac->roam.configParam.roam_params.dense_min_aps_cnt =
2075 pParam->roam_dense_min_aps;
2076 pMac->roam.configParam.roam_params.traffic_threshold =
2077 pParam->roam_dense_traffic_thresh;
2078
Krunal Soni1878d3a2016-01-14 13:00:44 -08002079 /* update p2p offload status */
2080 pMac->pnoOffload = pParam->pnoOffload;
2081
2082 pMac->fEnableDebugLog = pParam->fEnableDebugLog;
2083
2084 /* update interface configuration */
2085 pMac->sme.max_intf_count = pParam->max_intf_count;
2086
2087 pMac->enable5gEBT = pParam->enable5gEBT;
2088 pMac->sme.enableSelfRecovery = pParam->enableSelfRecovery;
2089
2090 pMac->f_sta_miracast_mcc_rest_time_val =
2091 pParam->f_sta_miracast_mcc_rest_time_val;
2092#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
2093 pMac->sap.sap_channel_avoidance =
2094 pParam->sap_channel_avoidance;
2095#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
2096
2097 pMac->f_prefer_non_dfs_on_radar =
2098 pParam->f_prefer_non_dfs_on_radar;
2099
2100 pMac->sme.ps_global_info.ps_enabled =
2101 pParam->is_ps_enabled;
2102
2103 pMac->policy_manager_enabled = pParam->policy_manager_enabled;
2104 pMac->fine_time_meas_cap = pParam->fine_time_meas_cap;
2105 pMac->dual_mac_feature_disable =
2106 pParam->dual_mac_feature_disable;
2107 sme_update_roam_pno_channel_prediction_config(pMac, pParam,
2108 SME_CONFIG_TO_ROAM_CONFIG);
2109 pMac->roam.configParam.early_stop_scan_enable =
2110 pParam->early_stop_scan_enable;
2111 pMac->roam.configParam.early_stop_scan_min_threshold =
2112 pParam->early_stop_scan_min_threshold;
2113 pMac->roam.configParam.early_stop_scan_max_threshold =
2114 pParam->early_stop_scan_max_threshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115
Gupta, Kapilc68ad462016-02-01 19:17:23 +05302116 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 return status;
2118}
2119
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302120QDF_STATUS csr_get_config_param(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121{
2122 int i;
2123 tCsrConfig *cfg_params = &pMac->roam.configParam;
2124
2125 if (!pParam)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302126 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127
2128 pParam->WMMSupportMode = cfg_params->WMMSupportMode;
2129 pParam->Is11eSupportEnabled = cfg_params->Is11eSupportEnabled;
2130 pParam->FragmentationThreshold = cfg_params->FragmentationThreshold;
2131 pParam->Is11dSupportEnabled = cfg_params->Is11dSupportEnabled;
2132 pParam->Is11dSupportEnabledOriginal =
2133 cfg_params->Is11dSupportEnabledOriginal;
2134 pParam->Is11hSupportEnabled = cfg_params->Is11hSupportEnabled;
2135 pParam->channelBondingMode24GHz = csr_convert_phy_cb_state_to_ini_value(
2136 cfg_params->channelBondingMode24GHz);
2137 pParam->channelBondingMode5GHz = csr_convert_phy_cb_state_to_ini_value(
2138 cfg_params->channelBondingMode5GHz);
2139 pParam->RTSThreshold = cfg_params->RTSThreshold;
2140 pParam->phyMode = cfg_params->phyMode;
2141 pParam->shortSlotTime = cfg_params->shortSlotTime;
2142 pParam->HeartbeatThresh24 = cfg_params->HeartbeatThresh24;
2143 pParam->HeartbeatThresh50 = cfg_params->HeartbeatThresh50;
2144 pParam->ProprietaryRatesEnabled = cfg_params->ProprietaryRatesEnabled;
2145 pParam->TxRate = cfg_params->TxRate;
2146 pParam->AdHocChannel24 = cfg_params->AdHocChannel24;
2147 pParam->AdHocChannel5G = cfg_params->AdHocChannel5G;
2148 pParam->bandCapability = cfg_params->bandCapability;
2149 pParam->cbChoice = cfg_params->cbChoice;
2150 pParam->nActiveMaxChnTime = cfg_params->nActiveMaxChnTime;
2151 pParam->nActiveMinChnTime = cfg_params->nActiveMinChnTime;
2152 pParam->nPassiveMaxChnTime = cfg_params->nPassiveMaxChnTime;
2153 pParam->nPassiveMinChnTime = cfg_params->nPassiveMinChnTime;
2154#ifdef WLAN_AP_STA_CONCURRENCY
2155 pParam->nActiveMaxChnTimeConc = cfg_params->nActiveMaxChnTimeConc;
2156 pParam->nActiveMinChnTimeConc = cfg_params->nActiveMinChnTimeConc;
2157 pParam->nPassiveMaxChnTimeConc = cfg_params->nPassiveMaxChnTimeConc;
2158 pParam->nPassiveMinChnTimeConc = cfg_params->nPassiveMinChnTimeConc;
2159 pParam->nRestTimeConc = cfg_params->nRestTimeConc;
2160 pParam->nNumStaChanCombinedConc = cfg_params->nNumStaChanCombinedConc;
2161 pParam->nNumP2PChanCombinedConc = cfg_params->nNumP2PChanCombinedConc;
2162#endif
2163 pParam->eBand = cfg_params->eBand;
2164 pParam->nScanResultAgeCount = cfg_params->agingCount;
2165 pParam->scanAgeTimeNCNPS = cfg_params->scanAgeTimeNCNPS;
2166 pParam->scanAgeTimeNCPS = cfg_params->scanAgeTimeNCPS;
2167 pParam->scanAgeTimeCNPS = cfg_params->scanAgeTimeCNPS;
2168 pParam->scanAgeTimeCPS = cfg_params->scanAgeTimeCPS;
2169 pParam->bCatRssiOffset = cfg_params->bCatRssiOffset;
2170 pParam->nRoamingTime = cfg_params->nRoamingTime;
2171 pParam->fSupplicantCountryCodeHasPriority =
2172 cfg_params->fSupplicantCountryCodeHasPriority;
2173 pParam->vccRssiThreshold = cfg_params->vccRssiThreshold;
2174 pParam->vccUlMacLossThreshold = cfg_params->vccUlMacLossThreshold;
2175 pParam->nTxPowerCap = cfg_params->nTxPowerCap;
2176 pParam->statsReqPeriodicity = cfg_params->statsReqPeriodicity;
2177 pParam->statsReqPeriodicityInPS = cfg_params->statsReqPeriodicityInPS;
2178 pParam->addTSWhenACMIsOff = cfg_params->addTSWhenACMIsOff;
2179 pParam->fValidateList = cfg_params->fValidateList;
2180 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
2181 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
2182 pParam->fScanTwice = cfg_params->fScanTwice;
2183 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
2184 pParam->fEnableMCCMode = cfg_params->fenableMCCMode;
2185 pParam->fAllowMCCGODiffBI = cfg_params->fAllowMCCGODiffBI;
2186 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302187 qdf_mem_copy(&pParam->neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188 &cfg_params->neighborRoamConfig,
2189 sizeof(tCsrNeighborRoamConfigParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 pParam->nVhtChannelWidth = cfg_params->nVhtChannelWidth;
2191 pParam->enableTxBF = cfg_params->txBFEnable;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08002192 pParam->enable_txbf_sap_mode =
2193 cfg_params->enable_txbf_sap_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194 pParam->txBFCsnValue = cfg_params->txBFCsnValue;
2195 pParam->enableMuBformee = cfg_params->txMuBformee;
2196 pParam->enableVhtFor24GHz = cfg_params->enableVhtFor24GHz;
2197 pParam->ignore_peer_erp_info = cfg_params->ignore_peer_erp_info;
2198 pParam->enable2x2 = cfg_params->enable2x2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302199 qdf_mem_copy(&cfg_params->csr11rConfig, &pParam->csr11rConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 sizeof(tCsr11rConfigParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201 pParam->isFastTransitionEnabled = cfg_params->isFastTransitionEnabled;
2202 pParam->RoamRssiDiff = cfg_params->RoamRssiDiff;
2203 pParam->nRoamPrefer5GHz = cfg_params->nRoamPrefer5GHz;
2204 pParam->nRoamIntraBand = cfg_params->nRoamIntraBand;
2205 pParam->isWESModeEnabled = cfg_params->isWESModeEnabled;
2206 pParam->nProbes = cfg_params->nProbes;
2207 pParam->nRoamScanHomeAwayTime = cfg_params->nRoamScanHomeAwayTime;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208 pParam->isRoamOffloadScanEnabled = cfg_params->isRoamOffloadScanEnabled;
2209 pParam->bFastRoamInConIniFeatureEnabled =
2210 cfg_params->bFastRoamInConIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 pParam->isFastRoamIniFeatureEnabled =
2212 cfg_params->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213#ifdef FEATURE_WLAN_ESE
2214 pParam->isEseIniFeatureEnabled = cfg_params->isEseIniFeatureEnabled;
2215#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302216 qdf_mem_copy(&pParam->neighborRoamConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217 &cfg_params->neighborRoamConfig,
2218 sizeof(tCsrNeighborRoamConfigParams));
2219 sms_log(pMac, LOG1,
2220 FL("Num of Channels in CFG Channel List: %d"),
2221 cfg_params->neighborRoamConfig.
2222 neighborScanChanList.numChannels);
2223 for (i = 0; i < cfg_params->neighborRoamConfig.
2224 neighborScanChanList.numChannels; i++) {
2225 sms_log(pMac, LOG1, "%d ",
2226 cfg_params->neighborRoamConfig.
2227 neighborScanChanList.channelList[i]);
2228 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229
2230#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
2231 pParam->cc_switch_mode = cfg_params->cc_switch_mode;
2232#endif
2233 pParam->enableTxLdpc = cfg_params->txLdpcEnable;
2234 pParam->isAmsduSupportInAMPDU = cfg_params->isAmsduSupportInAMPDU;
2235 pParam->nSelect5GHzMargin = cfg_params->nSelect5GHzMargin;
2236 pParam->isCoalesingInIBSSAllowed = cfg_params->isCoalesingInIBSSAllowed;
2237 pParam->allowDFSChannelRoam = cfg_params->allowDFSChannelRoam;
2238 pParam->nInitialDwellTime = cfg_params->nInitialDwellTime;
2239 pParam->initial_scan_no_dfs_chnl = cfg_params->initial_scan_no_dfs_chnl;
2240#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2241 pParam->isRoamOffloadEnabled = cfg_params->isRoamOffloadEnabled;
2242#endif
2243 pParam->enable_dot11p = pMac->enable_dot11p;
2244 csr_set_channels(pMac, pParam);
2245 pParam->obssEnabled = cfg_params->obssEnabled;
Gupta, Kapilc68ad462016-02-01 19:17:23 +05302246 pParam->roam_dense_rssi_thresh_offset =
2247 cfg_params->roam_params.dense_rssi_thresh_offset;
2248 pParam->roam_dense_min_aps =
2249 cfg_params->roam_params.dense_min_aps_cnt;
2250 pParam->roam_dense_traffic_thresh =
2251 cfg_params->roam_params.traffic_threshold;
2252
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002253 pParam->conc_custom_rule1 = cfg_params->conc_custom_rule1;
2254 pParam->conc_custom_rule2 = cfg_params->conc_custom_rule2;
2255 pParam->is_sta_connection_in_5gz_enabled =
2256 cfg_params->is_sta_connection_in_5gz_enabled;
2257 pParam->sendDeauthBeforeCon =
2258 cfg_params->sendDeauthBeforeCon;
2259 pParam->max_scan_count = pMac->scan.max_scan_count;
Varun Reddy Yeturu044bda22015-11-21 22:03:40 -08002260 pParam->first_scan_bucket_threshold =
2261 pMac->first_scan_bucket_threshold;
Krunal Soni1878d3a2016-01-14 13:00:44 -08002262#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
2263 pParam->sap_channel_avoidance = pMac->sap.sap_channel_avoidance;
2264#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
2265 pParam->max_intf_count = pMac->sme.max_intf_count;
2266 pParam->enableSelfRecovery = pMac->sme.enableSelfRecovery;
2267 pParam->pnoOffload = pMac->pnoOffload;
2268 pParam->f_prefer_non_dfs_on_radar =
2269 pMac->f_prefer_non_dfs_on_radar;
2270 pParam->policy_manager_enabled = pMac->policy_manager_enabled;
2271 pParam->fine_time_meas_cap = pMac->fine_time_meas_cap;
2272 pParam->dual_mac_feature_disable =
2273 pMac->dual_mac_feature_disable;
2274 pParam->is_ps_enabled = pMac->sme.ps_global_info.ps_enabled;
2275 pParam->fEnableDebugLog = pMac->fEnableDebugLog;
2276 pParam->enable5gEBT = pMac->enable5gEBT;
2277 pParam->f_sta_miracast_mcc_rest_time_val =
2278 pMac->f_sta_miracast_mcc_rest_time_val;
2279 sme_update_roam_pno_channel_prediction_config(pMac, pParam,
2280 ROAM_CONFIG_TO_SME_CONFIG);
2281 pParam->early_stop_scan_enable =
2282 pMac->roam.configParam.early_stop_scan_enable;
2283 pParam->early_stop_scan_min_threshold =
2284 pMac->roam.configParam.early_stop_scan_min_threshold;
2285 pParam->early_stop_scan_max_threshold =
2286 pMac->roam.configParam.early_stop_scan_max_threshold;
Sandeep Puligillae0875662016-02-12 16:09:21 -08002287 pParam->obss_width_interval =
2288 pMac->roam.configParam.obss_width_interval;
2289 pParam->obss_active_dwelltime =
2290 pMac->roam.configParam.obss_active_dwelltime;
2291 pParam->obss_passive_dwelltime =
2292 pMac->roam.configParam.obss_passive_dwelltime;
2293
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302294 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295}
2296
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302297QDF_STATUS csr_set_phy_mode(tHalHandle hHal, uint32_t phyMode, eCsrBand eBand,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 bool *pfRestartNeeded)
2299{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302300 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
2302 bool fRestartNeeded = false;
2303 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
2304 if (eCSR_BAND_24 == eBand) {
2305 if (CSR_IS_RADIO_A_ONLY(pMac))
2306 goto end;
2307 if (eCSR_DOT11_MODE_11a & phyMode)
2308 goto end;
2309 }
2310 if (eCSR_BAND_5G == eBand) {
2311 if (CSR_IS_RADIO_BG_ONLY(pMac))
2312 goto end;
2313 if ((eCSR_DOT11_MODE_11b & phyMode)
2314 || (eCSR_DOT11_MODE_11b_ONLY & phyMode)
2315 || (eCSR_DOT11_MODE_11g & phyMode)
2316 || (eCSR_DOT11_MODE_11g_ONLY & phyMode))
2317 goto end;
2318 }
2319 if (eCSR_DOT11_MODE_AUTO & phyMode)
2320 newPhyMode = eCSR_DOT11_MODE_AUTO;
2321 else {
2322 /* Check for dual band and higher capability first */
2323 if (eCSR_DOT11_MODE_11n_ONLY & phyMode) {
2324 if (eCSR_DOT11_MODE_11n_ONLY != phyMode)
2325 goto end;
2326 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2327 } else if (eCSR_DOT11_MODE_11g_ONLY & phyMode) {
2328 if (eCSR_DOT11_MODE_11g_ONLY != phyMode)
2329 goto end;
2330 if (eCSR_BAND_5G == eBand)
2331 goto end;
2332 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2333 eBand = eCSR_BAND_24;
2334 } else if (eCSR_DOT11_MODE_11b_ONLY & phyMode) {
2335 if (eCSR_DOT11_MODE_11b_ONLY != phyMode)
2336 goto end;
2337 if (eCSR_BAND_5G == eBand)
2338 goto end;
2339 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2340 eBand = eCSR_BAND_24;
2341 } else if (eCSR_DOT11_MODE_11n & phyMode) {
2342 newPhyMode = eCSR_DOT11_MODE_11n;
2343 } else if (eCSR_DOT11_MODE_abg & phyMode) {
2344 newPhyMode = eCSR_DOT11_MODE_abg;
2345 } else if (eCSR_DOT11_MODE_11a & phyMode) {
2346 if ((eCSR_DOT11_MODE_11g & phyMode)
2347 || (eCSR_DOT11_MODE_11b & phyMode)) {
2348 if (eCSR_BAND_ALL == eBand)
2349 newPhyMode = eCSR_DOT11_MODE_abg;
2350 else
2351 goto end;
2352 } else {
2353 newPhyMode = eCSR_DOT11_MODE_11a;
2354 eBand = eCSR_BAND_5G;
2355 }
2356 } else if (eCSR_DOT11_MODE_11g & phyMode) {
2357 newPhyMode = eCSR_DOT11_MODE_11g;
2358 eBand = eCSR_BAND_24;
2359 } else if (eCSR_DOT11_MODE_11b & phyMode) {
2360 newPhyMode = eCSR_DOT11_MODE_11b;
2361 eBand = eCSR_BAND_24;
2362 } else {
2363 /* We will never be here */
2364 sms_log(pMac, LOGE,
2365 FL("can't recognize phymode 0x%08X"),
2366 phyMode);
2367 newPhyMode = eCSR_DOT11_MODE_AUTO;
2368 }
2369 }
2370 /* Done validating */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302371 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002372 /* Now we need to check whether a restart is needed. */
2373 if (eBand != pMac->roam.configParam.eBand) {
2374 fRestartNeeded = true;
2375 goto end;
2376 }
2377 if (newPhyMode != pMac->roam.configParam.phyMode) {
2378 fRestartNeeded = true;
2379 goto end;
2380 }
2381end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302382 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383 pMac->roam.configParam.eBand = eBand;
2384 pMac->roam.configParam.phyMode = newPhyMode;
2385 if (pfRestartNeeded)
2386 *pfRestartNeeded = fRestartNeeded;
2387 }
2388 return status;
2389}
2390
2391/**
2392 * csr_prune_ch_list() - prunes the channel list to keep only a type of channels
2393 * @ch_lst: existing channel list
2394 * @is_24_GHz: indicates if 2.5 GHz or 5 GHz channels are required
2395 *
2396 * Return: void
2397 */
2398void csr_prune_ch_list(tCsrChannel *ch_lst, bool is_24_GHz)
2399{
2400 uint8_t idx = 0, num_channels = 0;
2401 for ( ; idx < ch_lst->numChannels; idx++) {
2402 if (is_24_GHz) {
2403 if (CDS_IS_CHANNEL_24GHZ(ch_lst->channelList[idx])) {
2404 ch_lst->channelList[num_channels] =
2405 ch_lst->channelList[idx];
2406 num_channels++;
2407 }
2408 } else {
2409 if (CDS_IS_CHANNEL_5GHZ(ch_lst->channelList[idx])) {
2410 ch_lst->channelList[num_channels] =
2411 ch_lst->channelList[idx];
2412 num_channels++;
2413 }
2414 }
2415 }
2416 /*
2417 * Cleanup the rest of channels. Note we only need to clean up the
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302418 * channels if we had to trim the list. Calling qdf_mem_set() with a 0
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419 * size is going to throw asserts on the debug builds so let's be a bit
2420 * smarter about that. Zero out the reset of the channels only if we
2421 * need to. The amount of memory to clear is the number of channesl that
2422 * we trimmed (ch_lst->numChannels - num_channels) times the size of a
2423 * channel in the structure.
2424 */
2425 if (ch_lst->numChannels > num_channels) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302426 qdf_mem_set(&ch_lst->channelList[num_channels],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427 sizeof(ch_lst->channelList[0]) *
2428 (ch_lst->numChannels - num_channels), 0);
2429 }
2430 ch_lst->numChannels = num_channels;
2431}
2432
2433/**
2434 * csr_prune_channel_list_for_mode() - prunes the channel list
2435 * @mac_ctx: global mac context
2436 * @ch_lst: existing channel list
2437 *
2438 * Prunes the channel list according to band stored in mac_ctx
2439 *
2440 * Return: void
2441 */
2442void csr_prune_channel_list_for_mode(tpAniSirGlobal mac_ctx,
2443 tCsrChannel *ch_lst)
2444{
2445 /* for dual band NICs, don't need to trim the channel list.... */
2446 if (CSR_IS_OPEARTING_DUAL_BAND(mac_ctx))
2447 return;
2448 /*
2449 * 2.4 GHz band operation requires the channel list to be trimmed to
2450 * the 2.4 GHz channels only
2451 */
2452 if (CSR_IS_24_BAND_ONLY(mac_ctx))
2453 csr_prune_ch_list(ch_lst, true);
2454 else if (CSR_IS_5G_BAND_ONLY(mac_ctx))
2455 csr_prune_ch_list(ch_lst, false);
2456}
2457
2458#define INFRA_AP_DEFAULT_CHANNEL 6
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302459QDF_STATUS csr_is_valid_channel(tpAniSirGlobal pMac, uint8_t chnNum)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002460{
2461 uint8_t index = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302462 QDF_STATUS status = QDF_STATUS_E_NOSUPPORT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463
2464 /* regulatory check */
2465 for (index = 0; index < pMac->scan.base_channels.numChannels;
2466 index++) {
2467 if (pMac->scan.base_channels.channelList[index] == chnNum) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302468 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 break;
2470 }
2471 }
2472
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302473 if (status == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474 /* dfs nol */
2475 for (index = 0;
2476 index <
2477 pMac->sap.SapDfsInfo.numCurrentRegDomainDfsChannels;
2478 index++) {
2479 tSapDfsNolInfo *dfsChan =
2480 &pMac->sap.SapDfsInfo.sapDfsChannelNolList[index];
2481 if ((dfsChan->dfs_channel_number == chnNum)
2482 && (dfsChan->radar_status_flag ==
2483 eSAP_DFS_CHANNEL_UNAVAILABLE)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302484 QDF_TRACE(QDF_MODULE_ID_SME,
2485 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 FL("channel %d is in dfs nol"),
2487 chnNum);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302488 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 break;
2490 }
2491 }
2492 }
2493
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302494 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302495 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 FL("channel %d is not available"), chnNum);
2497 }
2498
2499 return status;
2500}
2501
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302502QDF_STATUS csr_get_channel_and_power_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302504 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505 uint8_t num20MHzChannelsFound = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302506 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002507 uint8_t Index = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002508
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302509 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002510 cds_get_channel_list_with_power(pMac->scan.defaultPowerTable,
Amar Singhal7ccdc4f2015-10-30 15:10:05 -07002511 &num20MHzChannelsFound);
2512
2513 if ((QDF_STATUS_SUCCESS != qdf_status) ||
2514 (num20MHzChannelsFound == 0)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002515 sms_log(pMac, LOGE, FL("failed to get channels "));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302516 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002517 } else {
2518 if (num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN) {
2519 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2520 }
2521 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2522 /* Move the channel list to the global data */
2523 /* structure -- this will be used as the scan list */
2524 for (Index = 0; Index < num20MHzChannelsFound; Index++) {
2525 pMac->scan.base_channels.channelList[Index] =
Amar Singhala297bfa2015-10-15 15:07:29 -07002526 pMac->scan.defaultPowerTable[Index].chan_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002527 }
2528 pMac->scan.base_channels.numChannels =
2529 num20MHzChannelsFound;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530 }
2531 return status;
2532}
2533
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302534QDF_STATUS csr_apply_channel_and_power_list(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002535{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302536 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537
2538 csr_prune_channel_list_for_mode(pMac, &pMac->scan.base_channels);
2539 csr_save_channel_power_for_band(pMac, false);
2540 csr_save_channel_power_for_band(pMac, true);
2541 /* Apply the base channel list, power info, and set the Country code... */
2542 csr_apply_channel_power_info_to_fw(pMac,
2543 &pMac->scan.base_channels,
2544 pMac->scan.countryCodeCurrent);
2545
2546 csr_init_operating_classes((tHalHandle) pMac);
2547 return status;
2548}
2549
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302550QDF_STATUS csr_change_config_params(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551 tCsrUpdateConfigParam *pUpdateConfigParam)
2552{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302553 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554 tCsr11dinfo *ps11dinfo = NULL;
2555 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2556 status = csr_init11d_info(pMac, ps11dinfo);
2557 return status;
2558}
2559
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302560static QDF_STATUS csr_init11d_info(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002561{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302562 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 uint8_t index;
2564 uint32_t count = 0;
2565 tSirMacChanInfo *pChanInfo;
2566 tSirMacChanInfo *pChanInfoStart;
2567 bool applyConfig = true;
2568
2569 pMac->scan.currentCountryRSSI = -128;
2570 if (!ps11dinfo) {
2571 return status;
2572 }
2573 if (ps11dinfo->Channels.numChannels
2574 && (WNI_CFG_VALID_CHANNEL_LIST_LEN >=
2575 ps11dinfo->Channels.numChannels)) {
2576 pMac->scan.base_channels.numChannels =
2577 ps11dinfo->Channels.numChannels;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302578 qdf_mem_copy(pMac->scan.base_channels.channelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579 ps11dinfo->Channels.channelList,
2580 ps11dinfo->Channels.numChannels);
2581 } else {
2582 /* No change */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302583 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 }
2585 /* legacy maintenance */
2586
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302587 qdf_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 WNI_CFG_COUNTRY_CODE_LEN);
2589
2590 /* Tush: at csropen get this initialized with default, during csr reset if this */
2591 /* already set with some value no need initilaize with default again */
2592 if (0 == pMac->scan.countryCodeCurrent[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302593 qdf_mem_copy(pMac->scan.countryCodeCurrent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002594 ps11dinfo->countryCode, WNI_CFG_COUNTRY_CODE_LEN);
2595 }
2596 /* need to add the max power channel list */
2597 pChanInfo =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302598 qdf_mem_malloc(sizeof(tSirMacChanInfo) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 WNI_CFG_VALID_CHANNEL_LIST_LEN);
2600 if (pChanInfo != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302601 qdf_mem_set(pChanInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602 sizeof(tSirMacChanInfo) *
2603 WNI_CFG_VALID_CHANNEL_LIST_LEN, 0);
2604
2605 pChanInfoStart = pChanInfo;
2606 for (index = 0; index < ps11dinfo->Channels.numChannels;
2607 index++) {
2608 pChanInfo->firstChanNum =
2609 ps11dinfo->ChnPower[index].firstChannel;
2610 pChanInfo->numChannels =
2611 ps11dinfo->ChnPower[index].numChannels;
2612 pChanInfo->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302613 QDF_MIN(ps11dinfo->ChnPower[index].maxtxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614 pMac->roam.configParam.nTxPowerCap);
2615 pChanInfo++;
2616 count++;
2617 }
2618 if (count) {
2619 csr_save_to_channel_power2_g_5_g(pMac,
2620 count *
2621 sizeof(tSirMacChanInfo),
2622 pChanInfoStart);
2623 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302624 qdf_mem_free(pChanInfoStart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625 }
2626 /* Only apply them to CFG when not in STOP state. Otherwise they will be applied later */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302627 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628 for (index = 0; index < CSR_ROAM_SESSION_MAX; index++) {
2629 if ((CSR_IS_SESSION_VALID(pMac, index))
2630 && CSR_IS_ROAM_STOP(pMac, index)) {
2631 applyConfig = false;
2632 }
2633 }
2634
2635 if (true == applyConfig) {
2636 /* Apply the base channel list, power info, and set the Country code... */
2637 csr_apply_channel_power_info_to_fw(pMac,
2638 &pMac->scan.
2639 base_channels,
2640 pMac->scan.
2641 countryCodeCurrent);
2642 }
2643 }
2644 return status;
2645}
2646
2647/* Initialize the Channel + Power List in the local cache and in the CFG */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302648QDF_STATUS csr_init_channel_power_list(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649{
2650 uint8_t index;
2651 uint32_t count = 0;
2652 tSirMacChanInfo *pChanInfo;
2653 tSirMacChanInfo *pChanInfoStart;
2654
2655 if (!ps11dinfo || !pMac) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302656 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657 }
2658
2659 pChanInfo =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302660 qdf_mem_malloc(sizeof(tSirMacChanInfo) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661 WNI_CFG_VALID_CHANNEL_LIST_LEN);
2662 if (pChanInfo != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302663 qdf_mem_set(pChanInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 sizeof(tSirMacChanInfo) *
2665 WNI_CFG_VALID_CHANNEL_LIST_LEN, 0);
2666 pChanInfoStart = pChanInfo;
2667
2668 for (index = 0; index < ps11dinfo->Channels.numChannels;
2669 index++) {
2670 pChanInfo->firstChanNum =
2671 ps11dinfo->ChnPower[index].firstChannel;
2672 pChanInfo->numChannels =
2673 ps11dinfo->ChnPower[index].numChannels;
2674 pChanInfo->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302675 QDF_MIN(ps11dinfo->ChnPower[index].maxtxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002676 pMac->roam.configParam.nTxPowerCap);
2677 pChanInfo++;
2678 count++;
2679 }
2680 if (count) {
2681 csr_save_to_channel_power2_g_5_g(pMac,
2682 count *
2683 sizeof(tSirMacChanInfo),
2684 pChanInfoStart);
2685 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302686 qdf_mem_free(pChanInfoStart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002687 }
2688
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302689 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690}
2691
2692/* pCommand may be NULL */
2693/* Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL. */
2694void csr_roam_remove_duplicate_command(tpAniSirGlobal pMac, uint32_t sessionId,
2695 tSmeCmd *pCommand,
2696 eCsrRoamReason eRoamReason)
2697{
2698 tListElem *pEntry, *pNextEntry;
2699 tSmeCmd *pDupCommand;
2700 tDblLinkList localList;
2701
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302702 qdf_mem_zero(&localList, sizeof(tDblLinkList));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302703 if (!QDF_IS_STATUS_SUCCESS(csr_ll_open(pMac->hHdd, &localList))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 sms_log(pMac, LOGE, FL(" failed to open list"));
2705 return;
2706 }
2707 csr_ll_lock(&pMac->sme.smeCmdPendingList);
2708 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
2709 while (pEntry) {
2710 pNextEntry =
2711 csr_ll_next(&pMac->sme.smeCmdPendingList, pEntry,
2712 LL_ACCESS_NOLOCK);
2713 pDupCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
2714 /* Remove the previous command if.. */
2715 /* - the new roam command is for the same RoamReason... */
2716 /* - the new roam command is a NewProfileList. */
2717 /* - the new roam command is a Forced Dissoc */
2718 /* - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID). */
2719 if ((pCommand && (pCommand->sessionId == pDupCommand->sessionId)
2720 && ((pCommand->command == pDupCommand->command) &&
2721 /*
2722 * This peermac check is requried for Softap/GO
2723 * scenarios. For STA scenario below OR check will
2724 * suffice as pCommand will always be NULL for STA
2725 * scenarios
2726 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302727 (!qdf_mem_cmp
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 (pDupCommand->u.roamCmd.peerMac,
2729 pCommand->u.roamCmd.peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302730 QDF_MAC_ADDR_SIZE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731 && (pCommand->u.roamCmd.roamReason ==
2732 pDupCommand->u.roamCmd.roamReason
2733 || eCsrForcedDisassoc ==
2734 pCommand->u.roamCmd.roamReason
2735 || eCsrHddIssued ==
2736 pCommand->u.roamCmd.roamReason)))
2737 ||
2738 /* below the pCommand is NULL */
2739 ((sessionId == pDupCommand->sessionId) &&
2740 (eSmeCommandRoam == pDupCommand->command) &&
2741 ((eCsrForcedDisassoc == eRoamReason) ||
2742 (eCsrHddIssued == eRoamReason))
2743 )
2744 ) {
2745 sms_log(pMac, LOGW, FL(" roamReason = %d"),
2746 pDupCommand->u.roamCmd.roamReason);
2747 /* Remove the 'stale' roam command from the pending list... */
2748 if (csr_ll_remove_entry
2749 (&pMac->sme.smeCmdPendingList, pEntry,
2750 LL_ACCESS_NOLOCK)) {
2751 csr_ll_insert_tail(&localList, pEntry,
2752 LL_ACCESS_NOLOCK);
2753 }
2754 }
2755 pEntry = pNextEntry;
2756 }
2757 csr_ll_unlock(&pMac->sme.smeCmdPendingList);
2758
2759 while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) {
2760 pDupCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
2761 /* Tell caller that the command is cancelled */
2762 csr_roam_call_callback(pMac, pDupCommand->sessionId, NULL,
2763 pDupCommand->u.roamCmd.roamId,
2764 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2765 csr_release_command_roam(pMac, pDupCommand);
2766 }
2767 csr_ll_close(&localList);
2768}
2769
2770/**
2771 * csr_roam_populate_channels() - Helper function to populate channels
2772 * @beacon_ies: pointer to beacon ie
2773 * @roam_info: Roaming related information
2774 * @chan1: center freq 1
2775 * @chan2: center freq2
2776 *
2777 * This function will issue populate chan1 and chan2 based on beacon ie
2778 *
2779 * Return: none.
2780 */
2781static void csr_roam_populate_channels(tDot11fBeaconIEs *beacon_ies,
2782 tCsrRoamInfo *roam_info,
2783 uint8_t *chan1, uint8_t *chan2)
2784{
2785 ePhyChanBondState phy_state;
2786 if (beacon_ies->VHTOperation.present) {
2787 *chan1 = beacon_ies->VHTOperation.chanCenterFreqSeg1;
2788 *chan2 = beacon_ies->VHTOperation.chanCenterFreqSeg2;
2789 roam_info->chan_info.info = MODE_11AC_VHT80;
2790 } else if (beacon_ies->HTInfo.present) {
2791 if (beacon_ies->HTInfo.recommendedTxWidthSet ==
2792 eHT_CHANNEL_WIDTH_40MHZ) {
2793 phy_state = beacon_ies->HTInfo.secondaryChannelOffset;
2794 if (phy_state == PHY_DOUBLE_CHANNEL_LOW_PRIMARY)
2795 *chan1 = beacon_ies->HTInfo.primaryChannel +
2796 CSR_CB_CENTER_CHANNEL_OFFSET;
2797 else if (phy_state == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
2798 *chan1 = beacon_ies->HTInfo.primaryChannel -
2799 CSR_CB_CENTER_CHANNEL_OFFSET;
2800 else
2801 *chan1 = beacon_ies->HTInfo.primaryChannel;
2802
2803 roam_info->chan_info.info = MODE_11NA_HT40;
2804 } else {
2805 *chan1 = beacon_ies->HTInfo.primaryChannel;
2806 roam_info->chan_info.info = MODE_11NA_HT20;
2807 }
2808 *chan2 = 0;
2809 } else {
2810 *chan1 = 0;
2811 *chan2 = 0;
2812 roam_info->chan_info.info = MODE_11A;
2813 }
2814}
2815
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302816QDF_STATUS csr_roam_call_callback(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 tCsrRoamInfo *pRoamInfo, uint32_t roamId,
2818 eRoamCmdStatus u1, eCsrRoamResult u2)
2819{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302820 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2822 uint32_t rssi = 0;
2823 WLAN_HOST_DIAG_EVENT_DEF(connectionStatus,
2824 host_event_wlan_status_payload_type);
2825#endif
2826 tCsrRoamSession *pSession;
2827 tDot11fBeaconIEs *beacon_ies = NULL;
2828 uint8_t chan1, chan2;
2829
2830 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
2831 sms_log(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302832 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302833 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002834 }
2835 pSession = CSR_GET_SESSION(pMac, sessionId);
2836
2837 if (false == pSession->sessionActive) {
2838 sms_log(pMac, LOG1, "%s Session is not Active", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302839 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002840 }
2841
2842 sms_log(pMac, LOG4, "Received RoamCmdStatus %d with Roam Result %d", u1,
2843 u2);
2844
2845 if (eCSR_ROAM_ASSOCIATION_COMPLETION == u1 &&
2846 eCSR_ROAM_RESULT_ASSOCIATED == u2 && pRoamInfo) {
2847 sms_log(pMac, LOGW,
2848 FL("Assoc complete result=%d status=%d reason=%d"),
2849 u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302850 beacon_ies = qdf_mem_malloc(sizeof(tDot11fBeaconIEs));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002851 if ((NULL != beacon_ies) && (NULL != pRoamInfo->pBssDesc)) {
2852 status = csr_parse_bss_description_ies(
2853 (tHalHandle) pMac, pRoamInfo->pBssDesc,
2854 beacon_ies);
2855 csr_roam_populate_channels(beacon_ies, pRoamInfo,
2856 &chan1, &chan2);
2857 if (0 != chan1)
2858 pRoamInfo->chan_info.band_center_freq1 =
2859 cds_chan_to_freq(chan1);
2860 else
2861 pRoamInfo->chan_info.band_center_freq1 = 0;
2862 if (0 != chan2)
2863 pRoamInfo->chan_info.band_center_freq2 =
2864 cds_chan_to_freq(chan2);
2865 else
2866 pRoamInfo->chan_info.band_center_freq2 = 0;
2867 } else {
2868 pRoamInfo->chan_info.band_center_freq1 = 0;
2869 pRoamInfo->chan_info.band_center_freq2 = 0;
2870 pRoamInfo->chan_info.info = 0;
2871 }
2872 pRoamInfo->chan_info.chan_id =
2873 pRoamInfo->u.pConnectedProfile->operationChannel;
2874 pRoamInfo->chan_info.mhz =
2875 cds_chan_to_freq(pRoamInfo->chan_info.chan_id);
2876 pRoamInfo->chan_info.reg_info_1 =
2877 (csr_get_cfg_max_tx_power(pMac,
2878 pRoamInfo->chan_info.chan_id) << 16);
2879 pRoamInfo->chan_info.reg_info_2 =
2880 (csr_get_cfg_max_tx_power(pMac,
2881 pRoamInfo->chan_info.chan_id) << 8);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302882 qdf_mem_free(beacon_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883 } else if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED)
2884 && (pSession->bRefAssocStartCnt)) {
2885 /*
2886 * Decrement bRefAssocStartCnt for FT reassoc failure.
2887 * Reason: For FT reassoc failures, we first call
2888 * csr_roam_call_callback before notifying a failed roam
2889 * completion through csr_roam_complete. The latter in
2890 * turn calls csr_roam_process_results which tries to
2891 * once again call csr_roam_call_callback if bRefAssocStartCnt
2892 * is non-zero. Since this is redundant for FT reassoc
2893 * failure, decrement bRefAssocStartCnt.
2894 */
2895 pSession->bRefAssocStartCnt--;
2896 } else if (u1 == eCSR_ROAM_SET_CHANNEL_RSP && u2 ==
2897 eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS)
2898 pSession->connectedProfile.operationChannel =
2899 pRoamInfo->channelChangeRespEvent->newChannelNumber;
2900
2901 if (NULL != pSession->callback) {
2902 if (pRoamInfo) {
2903 pRoamInfo->sessionId = (uint8_t) sessionId;
2904 /*
2905 * the reasonCode will be passed to supplicant by
2906 * cfg80211_disconnected. Based on the document,
2907 * the reason code passed to supplicant needs to set
2908 * to 0 if unknow. eSIR_BEACON_MISSED reason code is not
2909 * recognizable so that we set to 0 instead.
2910 */
2911 pRoamInfo->reasonCode =
2912 (pRoamInfo->reasonCode == eSIR_BEACON_MISSED) ?
2913 0 : pRoamInfo->reasonCode;
2914 }
2915 status = pSession->callback(pSession->pContext, pRoamInfo,
2916 roamId, u1, u2);
2917 }
2918 /*
2919 * EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2920 * eCSR_ROAM_LOSTLINK,
2921 * eCSR_ROAM_DISASSOCIATED,
2922 */
2923#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302924 qdf_mem_set(&connectionStatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002925 sizeof(host_event_wlan_status_payload_type), 0);
2926
2927 if ((eCSR_ROAM_ASSOCIATION_COMPLETION == u1)
2928 && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo) {
2929 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2930 connectionStatus.bssType =
2931 pRoamInfo->u.pConnectedProfile->BSSType;
2932
2933 if (NULL != pRoamInfo->pBssDesc) {
2934 connectionStatus.rssi =
2935 pRoamInfo->pBssDesc->rssi * (-1);
2936 connectionStatus.channel =
2937 pRoamInfo->pBssDesc->channelId;
2938 }
2939 if (cfg_set_int(pMac, WNI_CFG_CURRENT_RSSI,
2940 connectionStatus.rssi) == eSIR_FAILURE)
2941 sms_log(pMac, LOGE,
2942 FL("Can't pass WNI_CFG_CURRENT_RSSI to cfg"));
2943
2944 connectionStatus.qosCapability =
2945 pRoamInfo->u.pConnectedProfile->qosConnection;
2946 connectionStatus.authType =
2947 (uint8_t) diag_auth_type_from_csr_type(
2948 pRoamInfo->u.pConnectedProfile->AuthType);
2949 connectionStatus.encryptionType =
2950 (uint8_t) diag_enc_type_from_csr_type(
2951 pRoamInfo->u.pConnectedProfile->EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302952 qdf_mem_copy(connectionStatus.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002953 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2954
2955 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302956 qdf_mem_copy(&pMac->sme.eventPayload, &connectionStatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002957 sizeof(host_event_wlan_status_payload_type));
2958 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
2959 EVENT_WLAN_STATUS);
2960 }
2961 if ((eCSR_ROAM_MIC_ERROR_IND == u1)
2962 || (eCSR_ROAM_RESULT_MIC_FAILURE == u2)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302963 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002964 sizeof(host_event_wlan_status_payload_type));
2965 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
2966 WNI_CFG_CURRENT_RSSI, &rssi)))
2967 connectionStatus.rssi = rssi;
2968
2969 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2970 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2971 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
2972 EVENT_WLAN_STATUS);
2973 }
2974 if (eCSR_ROAM_RESULT_FORCED == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302975 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976 sizeof(host_event_wlan_status_payload_type));
2977 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
2978 WNI_CFG_CURRENT_RSSI, &rssi)))
2979 connectionStatus.rssi = rssi;
2980
2981 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2982 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2983 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
2984 EVENT_WLAN_STATUS);
2985 }
2986 if (eCSR_ROAM_RESULT_DISASSOC_IND == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302987 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 sizeof(host_event_wlan_status_payload_type));
2989 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
2990 WNI_CFG_CURRENT_RSSI, &rssi)))
2991 connectionStatus.rssi = rssi;
2992
2993 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2994 connectionStatus.reason = eCSR_REASON_DISASSOC;
2995 if (pRoamInfo)
2996 connectionStatus.reasonDisconnect =
2997 pRoamInfo->reasonCode;
2998
2999 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
3000 EVENT_WLAN_STATUS);
3001 }
3002 if (eCSR_ROAM_RESULT_DEAUTH_IND == u2) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303003 qdf_mem_copy(&connectionStatus, &pMac->sme.eventPayload,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004 sizeof(host_event_wlan_status_payload_type));
3005 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(pMac,
3006 WNI_CFG_CURRENT_RSSI, &rssi)))
3007 connectionStatus.rssi = rssi;
3008
3009 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
3010 connectionStatus.reason = eCSR_REASON_DEAUTH;
3011 if (pRoamInfo)
3012 connectionStatus.reasonDisconnect =
3013 pRoamInfo->reasonCode;
3014 WLAN_HOST_DIAG_EVENT_REPORT(&connectionStatus,
3015 EVENT_WLAN_STATUS);
3016 }
3017#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
3018 return status;
3019}
3020
3021/* Returns whether handoff is currently in progress or not */
3022bool csr_roam_is_handoff_in_progress(tpAniSirGlobal pMac, uint8_t sessionId)
3023{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 return csr_neighbor_roam_is_handoff_in_progress(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003025}
3026
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303027QDF_STATUS csr_roam_issue_disassociate(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003028 eCsrRoamSubState NewSubstate,
3029 bool fMICFailure)
3030{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303031 QDF_STATUS status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303032 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033 uint16_t reasonCode;
3034 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
3035
3036 if (!pSession) {
3037 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303038 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 }
3040
3041 if (fMICFailure) {
3042 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
3043 } else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF) {
3044 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
3045 } else if (eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT == NewSubstate) {
3046 reasonCode = eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
3047 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303048 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 FL
3050 ("set to reason code eSIR_MAC_DISASSOC_LEAVING_BSS_REASON"
3051 " and set back NewSubstate"));
3052 } else {
3053 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
3054 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 if ((csr_roam_is_handoff_in_progress(pMac, sessionId)) &&
3056 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)) {
3057 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
3058 &pMac->roam.neighborRoamInfo[sessionId];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303059 qdf_copy_macaddr(&bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.
3061 bssid);
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -08003062 } else if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303063 qdf_mem_copy(&bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303064 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065 }
3066
3067 sms_log(pMac, LOG2,
3068 FL("CSR Attempting to Disassociate Bssid=" MAC_ADDRESS_STR
3069 " subState = %s reason=%d"), MAC_ADDR_ARRAY(bssId.bytes),
3070 mac_trace_getcsr_roam_sub_state(NewSubstate), reasonCode);
3071
3072 csr_roam_substate_change(pMac, NewSubstate, sessionId);
3073
3074 status = csr_send_mb_disassoc_req_msg(pMac, sessionId, bssId.bytes,
3075 reasonCode);
3076
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303077 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003078 csr_roam_link_down(pMac, sessionId);
3079#ifndef WLAN_MDM_CODE_REDUCTION_OPT
3080 /* no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO */
3081 if (eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate) {
3082 /* notify QoS module that disassoc happening */
3083 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
3084 SME_QOS_CSR_DISCONNECT_REQ, NULL);
3085 }
3086#endif
3087 } else {
3088 sms_log(pMac, LOGW,
3089 FL("csr_send_mb_disassoc_req_msg failed with status %d"),
3090 status);
3091 }
3092
3093 return status;
3094}
3095
3096/* ---------------------------------------------------------------------------
3097 \fn csr_roam_issue_disassociate_sta_cmd
3098 \brief csr function that HDD calls to disassociate a associated station
3099 \param sessionId - session Id for Soft AP
3100 \param pPeerMacAddr - MAC of associated station to delete
3101 \param reason - reason code, be one of the tSirMacReasonCodes
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303102 \return QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 ---------------------------------------------------------------------------*/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303104QDF_STATUS csr_roam_issue_disassociate_sta_cmd(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003105 uint32_t sessionId,
3106 const uint8_t *pPeerMacAddr,
3107 uint32_t reason)
3108{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303109 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 tSmeCmd *pCommand;
3111
3112 do {
3113 pCommand = csr_get_command_buffer(pMac);
3114 if (!pCommand) {
3115 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303116 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117 break;
3118 }
3119 pCommand->command = eSmeCommandRoam;
3120 pCommand->sessionId = (uint8_t) sessionId;
3121 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303122 qdf_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123 pCommand->u.roamCmd.reason = (tSirMacReasonCodes) reason;
3124 status = csr_queue_sme_command(pMac, pCommand, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303125 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 sms_log(pMac, LOGE,
3127 FL(" fail to send message status = %d"), status);
3128 csr_release_command_roam(pMac, pCommand);
3129 }
3130 } while (0);
3131
3132 return status;
3133}
3134
3135/**
3136 * csr_roam_issue_deauthSta() - delete a associated station
3137 * @sessionId: Session Id for Soft AP
3138 * @pDelStaParams: Pointer to parameters of the station to deauthenticate
3139 *
3140 * CSR function that HDD calls to delete a associated station
3141 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303142 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303144QDF_STATUS csr_roam_issue_deauth_sta_cmd(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003145 uint32_t sessionId,
3146 struct tagCsrDelStaParams *pDelStaParams)
3147{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303148 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149 tSmeCmd *pCommand;
3150
3151 do {
3152 pCommand = csr_get_command_buffer(pMac);
3153 if (!pCommand) {
3154 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303155 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156 break;
3157 }
3158 pCommand->command = eSmeCommandRoam;
3159 pCommand->sessionId = (uint8_t) sessionId;
3160 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303161 qdf_mem_copy(pCommand->u.roamCmd.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162 pDelStaParams->peerMacAddr.bytes,
3163 sizeof(tSirMacAddr));
3164 pCommand->u.roamCmd.reason =
3165 (tSirMacReasonCodes)pDelStaParams->reason_code;
3166 status = csr_queue_sme_command(pMac, pCommand, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303167 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168 sms_log(pMac, LOGE,
3169 FL(" fail to send message status = %d"), status);
3170 csr_release_command_roam(pMac, pCommand);
3171 }
3172 } while (0);
3173
3174 return status;
3175}
3176
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303177static QDF_STATUS
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003178csr_send_mb_tkip_counter_measures_req_msg(tpAniSirGlobal pMac,
3179 uint32_t sessionId, bool bEnable,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303180 struct qdf_mac_addr *bssId)
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003181{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303182 QDF_STATUS status = QDF_STATUS_SUCCESS;
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003183 tSirSmeTkipCntrMeasReq *pMsg;
3184 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303185 pMsg = qdf_mem_malloc(sizeof(tSirSmeTkipCntrMeasReq));
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003186 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303187 status = QDF_STATUS_E_NOMEM;
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003188 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303189 status = QDF_STATUS_SUCCESS;
3190 if (!QDF_IS_STATUS_SUCCESS(status))
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003191 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303192 qdf_mem_set(pMsg, sizeof(tSirSmeTkipCntrMeasReq), 0);
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003193 pMsg->messageType = eWNI_SME_TKIP_CNTR_MEAS_REQ;
3194 pMsg->length = sizeof(tSirSmeTkipCntrMeasReq);
3195 pMsg->sessionId = sessionId;
3196 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303197 qdf_copy_macaddr(&pMsg->bssId, bssId);
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003198 pMsg->bEnable = bEnable;
3199 status = cds_send_mb_message_to_mac(pMsg);
3200 } while (0);
3201 return status;
3202}
3203
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303204QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205csr_roam_issue_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t sessionId,
3206 bool bEnable)
3207{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303208 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303209 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
3211 if (!pSession) {
3212 sms_log(pMac, LOGE,
3213 "csr_roam_issue_tkip_counter_measures:CSR Session not found");
3214 return status;
3215 }
3216 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303217 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303218 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219 } else {
3220 sms_log(pMac, LOGE,
3221 "csr_roam_issue_tkip_counter_measures:Connected BSS Description in CSR Session not found");
3222 return status;
3223 }
3224 sms_log(pMac, LOG2,
3225 "CSR issuing tkip counter measures for Bssid = " MAC_ADDRESS_STR
3226 ", Enable = %d", MAC_ADDR_ARRAY(bssId.bytes), bEnable);
3227 status =
3228 csr_send_mb_tkip_counter_measures_req_msg(pMac, sessionId,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003229 bEnable, &bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 return status;
3231}
3232
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303233QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234csr_roam_get_associated_stas(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303235 QDF_MODULE_ID modId, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 void *pfnSapEventCallback, uint8_t *pAssocStasBuf)
3237{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303238 QDF_STATUS status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303239 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
3241 if (!pSession) {
3242 sms_log(pMac, LOGE,
3243 "csr_roam_get_associated_stas:CSR Session not found");
3244 return status;
3245 }
3246 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303247 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303248 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 } else {
3250 sms_log(pMac, LOGE,
3251 "csr_roam_get_associated_stas:Connected BSS Description in CSR Session not found");
3252 return status;
3253 }
3254 sms_log(pMac, LOG2,
3255 "CSR getting associated stations for Bssid = " MAC_ADDRESS_STR,
3256 MAC_ADDR_ARRAY(bssId.bytes));
3257 status =
3258 csr_send_mb_get_associated_stas_req_msg(pMac, sessionId, modId,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003259 bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260 pUsrContext,
3261 pfnSapEventCallback,
3262 pAssocStasBuf);
3263 return status;
3264}
3265
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303266QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003267csr_roam_get_wps_session_overlap(tpAniSirGlobal pMac, uint32_t sessionId,
3268 void *pUsrContext, void *pfnSapEventCallback,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303269 struct qdf_mac_addr pRemoveMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303271 QDF_STATUS status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303272 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
3274
3275 if (!pSession) {
3276 sms_log(pMac, LOGE,
3277 "csr_roam_get_wps_session_overlap:CSR Session not found");
3278 return status;
3279 }
3280 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303281 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303282 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 } else {
3284 sms_log(pMac, LOGE,
3285 "csr_roam_get_wps_session_overlap:Connected BSS Description in CSR Session not found");
3286 return status;
3287 }
3288 sms_log(pMac, LOG2,
3289 "CSR getting WPS Session Overlap for Bssid = " MAC_ADDRESS_STR,
3290 MAC_ADDR_ARRAY(bssId.bytes));
3291
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003292 status = csr_send_mb_get_wpspbc_sessions(pMac, sessionId, bssId,
3293 pUsrContext, pfnSapEventCallback, pRemoveMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294
3295 return status;
3296}
3297
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303298QDF_STATUS csr_roam_issue_deauth(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 eCsrRoamSubState NewSubstate)
3300{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303301 QDF_STATUS status = QDF_STATUS_SUCCESS;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303302 struct qdf_mac_addr bssId = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
3304
3305 if (!pSession) {
3306 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303307 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 }
3309
3310 if (pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303311 qdf_mem_copy(bssId.bytes, pSession->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303312 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313 }
3314 sms_log(pMac, LOG2, "CSR Attempting to Deauth Bssid= " MAC_ADDRESS_STR,
3315 MAC_ADDR_ARRAY(bssId.bytes));
3316 csr_roam_substate_change(pMac, NewSubstate, sessionId);
3317
3318 status =
3319 csr_send_mb_deauth_req_msg(pMac, sessionId, bssId.bytes,
3320 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303321 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322 csr_roam_link_down(pMac, sessionId);
3323 else {
3324 sms_log(pMac, LOGE,
3325 FL
3326 ("csr_send_mb_deauth_req_msg failed with status %d Session ID: %d"
3327 MAC_ADDRESS_STR), status, sessionId,
3328 MAC_ADDR_ARRAY(bssId.bytes));
3329 }
3330
3331 return status;
3332}
3333
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303334QDF_STATUS csr_roam_save_connected_bss_desc(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003335 tSirBssDescription *pBssDesc)
3336{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303337 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003338 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
3339 uint32_t size;
3340
3341 if (!pSession) {
3342 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303343 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 }
3345 /* If no BSS description was found in this connection (happens with start IBSS), then */
3346 /* nix the BSS description that we keep around for the connected BSS) and get out... */
3347 if (NULL == pBssDesc) {
3348 csr_free_connect_bss_desc(pMac, sessionId);
3349 } else {
3350 size = pBssDesc->length + sizeof(pBssDesc->length);
3351 if (NULL != pSession->pConnectBssDesc) {
3352 if (((pSession->pConnectBssDesc->length) +
3353 sizeof(pSession->pConnectBssDesc->length)) <
3354 size) {
3355 /* not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside */
3356 csr_free_connect_bss_desc(pMac, sessionId);
3357 }
3358 }
3359 if (NULL == pSession->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303360 pSession->pConnectBssDesc = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 }
3362 if (NULL == pSession->pConnectBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303363 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364 else
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303365 qdf_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366 }
3367 return status;
3368}
3369
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303370QDF_STATUS csr_roam_prepare_bss_config(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 tCsrRoamProfile *pProfile,
3372 tSirBssDescription *pBssDesc,
3373 tBssConfigParam *pBssConfig,
3374 tDot11fBeaconIEs *pIes)
3375{
3376 eCsrCfgDot11Mode cfgDot11Mode;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303377 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003378 if (pIes == NULL)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303379 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303381 qdf_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003382 sizeof(tSirMacCapabilityInfo));
3383 /* get qos */
3384 pBssConfig->qosType = csr_get_qo_s_from_bss_desc(pMac, pBssDesc, pIes);
3385 /* get SSID */
3386 if (pIes->SSID.present) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303387 qdf_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003388 pIes->SSID.num_ssid);
3389 pBssConfig->SSID.length = pIes->SSID.num_ssid;
3390 } else
3391 pBssConfig->SSID.length = 0;
3392 if (csr_is_nullssid(pBssConfig->SSID.ssId, pBssConfig->SSID.length)) {
3393 sms_log(pMac, LOGW, FL("BSS desc SSID is a wild card"));
3394 /* Return failed if profile doesn't have an SSID either. */
3395 if (pProfile->SSIDs.numOfSSIDs == 0) {
3396 sms_log(pMac, LOGW,
3397 FL("BSS desc and profile doesn't have SSID"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303398 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 }
3400 }
3401 if (CDS_IS_CHANNEL_5GHZ(pBssDesc->channelId))
3402 pBssConfig->eBand = eCSR_BAND_5G;
3403 else
3404 pBssConfig->eBand = eCSR_BAND_24;
3405 /* phymode */
3406 if (csr_is_phy_mode_match(pMac, pProfile->phyMode, pBssDesc,
3407 pProfile, &cfgDot11Mode, pIes)) {
3408 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3409 } else {
3410 sms_log(pMac, LOGW, "Can not find match phy mode");
3411 /* force it */
3412 if (eCSR_BAND_24 == pBssConfig->eBand)
3413 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3414 else
3415 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3416 }
3417 /* Qos */
3418 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3419 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos)) {
3420 /*
3421 * Joining BSS is not 11n capable and WMM is disabled on client.
3422 * Disable QoS and WMM
3423 */
3424 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3425 }
3426
3427 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N)
3428 || (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC))
3429 && ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP)
3430 || (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF)
3431 || (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF))) {
3432 /* Joining BSS is 11n capable and WMM is disabled on AP. */
3433 /* Assume all HT AP's are QOS AP's and enable WMM */
3434 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3435 }
3436 /* auth type */
3437 switch (pProfile->negotiatedAuthType) {
3438 default:
3439 case eCSR_AUTH_TYPE_WPA:
3440 case eCSR_AUTH_TYPE_WPA_PSK:
3441 case eCSR_AUTH_TYPE_WPA_NONE:
3442 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3443 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3444 break;
3445 case eCSR_AUTH_TYPE_SHARED_KEY:
3446 pBssConfig->authType = eSIR_SHARED_KEY;
3447 break;
3448 case eCSR_AUTH_TYPE_AUTOSWITCH:
3449 pBssConfig->authType = eSIR_AUTO_SWITCH;
3450 break;
3451 }
3452 /* short slot time */
3453 if (eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode)
3454 pBssConfig->uShortSlotTime =
3455 pMac->roam.configParam.shortSlotTime;
3456 else
3457 pBssConfig->uShortSlotTime = 0;
3458
3459 if (pBssConfig->BssCap.ibss)
3460 /* We don't support 11h on IBSS */
3461 pBssConfig->f11hSupport = false;
3462 else
3463 pBssConfig->f11hSupport =
3464 pMac->roam.configParam.Is11hSupportEnabled;
3465 /* power constraint */
3466 pBssConfig->uPowerLimit =
3467 csr_get11h_power_constraint(pMac, &pIes->PowerConstraints);
3468 /* heartbeat */
3469 if (CSR_IS_11A_BSS(pBssDesc))
3470 pBssConfig->uHeartBeatThresh =
3471 pMac->roam.configParam.HeartbeatThresh50;
3472 else
3473 pBssConfig->uHeartBeatThresh =
3474 pMac->roam.configParam.HeartbeatThresh24;
3475
3476 /*
3477 * Join timeout: if we find a BeaconInterval in the BssDescription,
3478 * then set the Join Timeout to be 10 x the BeaconInterval.
3479 */
3480 if (pBssDesc->beaconInterval)
3481 /* Make sure it is bigger than the minimal */
3482 pBssConfig->uJoinTimeOut =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303483 QDF_MAX(10 * pBssDesc->beaconInterval,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484 CSR_JOIN_FAILURE_TIMEOUT_MIN);
3485 else
3486 pBssConfig->uJoinTimeOut =
3487 CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3488 /* validate CB */
3489 pBssConfig->cbMode = csr_get_cb_mode_from_ies(pMac, pBssDesc->channelId,
3490 pIes);
3491
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303492 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493}
3494
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303495static QDF_STATUS csr_roam_prepare_bss_config_from_profile(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 tCsrRoamProfile *pProfile,
3497 tBssConfigParam *
3498 pBssConfig,
3499 tSirBssDescription *
3500 pBssDesc)
3501{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303502 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503 uint8_t operationChannel = 0;
3504 uint8_t qAPisEnabled = false;
3505 /* SSID */
3506 pBssConfig->SSID.length = 0;
3507 if (pProfile->SSIDs.numOfSSIDs) {
3508 /* only use the first one */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303509 qdf_mem_copy(&pBssConfig->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510 &pProfile->SSIDs.SSIDList[0].SSID,
3511 sizeof(tSirMacSSid));
3512 } else {
3513 /* SSID must present */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303514 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 }
3516 /* Settomg up the capabilities */
3517 if (csr_is_bss_type_ibss(pProfile->BSSType)) {
3518 pBssConfig->BssCap.ibss = 1;
3519 } else {
3520 pBssConfig->BssCap.ess = 1;
3521 }
3522 if (eCSR_ENCRYPT_TYPE_NONE !=
3523 pProfile->EncryptionType.encryptionType[0]) {
3524 pBssConfig->BssCap.privacy = 1;
3525 }
3526 pBssConfig->eBand = pMac->roam.configParam.eBand;
3527 /* phymode */
3528 if (pProfile->ChannelInfo.ChannelList) {
3529 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3530 }
3531 pBssConfig->uCfgDot11Mode =
3532 csr_roam_get_phy_mode_band_for_bss(pMac, pProfile, operationChannel,
3533 &pBssConfig->eBand);
3534 /* QOS */
3535 /* Is this correct to always set to this // *** */
3536 if (pBssConfig->BssCap.ess == 1) {
3537 /*For Softap case enable WMM */
3538 if (CSR_IS_INFRA_AP(pProfile)
3539 && (eCsrRoamWmmNoQos !=
3540 pMac->roam.configParam.WMMSupportMode)) {
3541 qAPisEnabled = true;
3542 } else
3543 if (csr_roam_get_qos_info_from_bss(pMac, pBssDesc) ==
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303544 QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003545 qAPisEnabled = true;
3546 } else {
3547 qAPisEnabled = false;
3548 }
3549 } else {
3550 qAPisEnabled = true;
3551 }
3552 if ((eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode &&
3553 qAPisEnabled) ||
3554 ((eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode &&
3555 qAPisEnabled))) {
3556 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3557 } else {
3558 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3559 }
3560
3561 /* auth type */
3562 /* Take the preferred Auth type. */
3563 switch (pProfile->AuthType.authType[0]) {
3564 default:
3565 case eCSR_AUTH_TYPE_WPA:
3566 case eCSR_AUTH_TYPE_WPA_PSK:
3567 case eCSR_AUTH_TYPE_WPA_NONE:
3568 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3569 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3570 break;
3571 case eCSR_AUTH_TYPE_SHARED_KEY:
3572 pBssConfig->authType = eSIR_SHARED_KEY;
3573 break;
3574 case eCSR_AUTH_TYPE_AUTOSWITCH:
3575 pBssConfig->authType = eSIR_AUTO_SWITCH;
3576 break;
3577 }
3578 /* short slot time */
3579 if (WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode) {
3580 pBssConfig->uShortSlotTime =
3581 pMac->roam.configParam.shortSlotTime;
3582 } else {
3583 pBssConfig->uShortSlotTime = 0;
3584 }
3585 /* power constraint. We don't support 11h on IBSS */
3586 pBssConfig->f11hSupport = false;
3587 pBssConfig->uPowerLimit = 0;
3588 /* heartbeat */
3589 if (eCSR_BAND_5G == pBssConfig->eBand) {
3590 pBssConfig->uHeartBeatThresh =
3591 pMac->roam.configParam.HeartbeatThresh50;
3592 } else {
3593 pBssConfig->uHeartBeatThresh =
3594 pMac->roam.configParam.HeartbeatThresh24;
3595 }
3596 /* Join timeout */
3597 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3598
3599 return status;
3600}
3601
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303602static QDF_STATUS csr_roam_get_qos_info_from_bss(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603 tSirBssDescription *pBssDesc)
3604{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303605 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 tDot11fBeaconIEs *pIes = NULL;
3607
3608 do {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303609 if (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610 csr_get_parsed_bss_description_ies(
3611 pMac, pBssDesc, &pIes))) {
3612 /* err msg */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303613 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614 "csr_roam_get_qos_info_from_bss() failed");
3615 break;
3616 }
3617 /* check if the AP is QAP & it supports APSD */
3618 if (CSR_IS_QOS_BSS(pIes)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303619 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003620 }
3621 } while (0);
3622
3623 if (NULL != pIes) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303624 qdf_mem_free(pIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625 }
3626
3627 return status;
3628}
3629
3630void csr_set_cfg_privacy(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3631 bool fPrivacy)
3632{
3633 /*
3634 * the only difference between this function and
3635 * the csr_set_cfg_privacyFromProfile() is the setting of the privacy
3636 * CFG based on the advertised privacy setting from the AP for WPA
3637 * associations. See note below in this function...
3638 */
3639 uint32_t PrivacyEnabled = 0, RsnEnabled = 0, WepDefaultKeyId = 0;
3640 uint32_t WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3641 uint32_t Key0Length = 0, Key1Length = 0, Key2Length = 0, Key3Length = 0;
3642
3643 /* Reserve for the biggest key */
3644 uint8_t Key0[WNI_CFG_WEP_DEFAULT_KEY_1_LEN];
3645 uint8_t Key1[WNI_CFG_WEP_DEFAULT_KEY_2_LEN];
3646 uint8_t Key2[WNI_CFG_WEP_DEFAULT_KEY_3_LEN];
3647 uint8_t Key3[WNI_CFG_WEP_DEFAULT_KEY_4_LEN];
3648
3649 switch (pProfile->negotiatedUCEncryptionType) {
3650 case eCSR_ENCRYPT_TYPE_NONE:
3651 /* for NO encryption, turn off Privacy and Rsn. */
3652 PrivacyEnabled = 0;
3653 RsnEnabled = 0;
3654 /* clear out the WEP keys that may be hanging around. */
3655 Key0Length = 0;
3656 Key1Length = 0;
3657 Key2Length = 0;
3658 Key3Length = 0;
3659 break;
3660
3661 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3662 case eCSR_ENCRYPT_TYPE_WEP40:
3663
3664 /* Privacy is ON. NO RSN for Wep40 static key. */
3665 PrivacyEnabled = 1;
3666 RsnEnabled = 0;
3667 /* Set the Wep default key ID. */
3668 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3669 /* Wep key size if 5 bytes (40 bits). */
3670 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3671 /*
3672 * set encryption keys in the CFG database or
3673 * clear those that are not present in this profile.
3674 */
3675 if (pProfile->Keys.KeyLength[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303676 qdf_mem_copy(Key0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003677 pProfile->Keys.KeyMaterial[0],
3678 WNI_CFG_WEP_KEY_LENGTH_5);
3679 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3680 } else {
3681 Key0Length = 0;
3682 }
3683
3684 if (pProfile->Keys.KeyLength[1]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303685 qdf_mem_copy(Key1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003686 pProfile->Keys.KeyMaterial[1],
3687 WNI_CFG_WEP_KEY_LENGTH_5);
3688 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
3689 } else {
3690 Key1Length = 0;
3691 }
3692
3693 if (pProfile->Keys.KeyLength[2]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303694 qdf_mem_copy(Key2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003695 pProfile->Keys.KeyMaterial[2],
3696 WNI_CFG_WEP_KEY_LENGTH_5);
3697 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3698 } else {
3699 Key2Length = 0;
3700 }
3701
3702 if (pProfile->Keys.KeyLength[3]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303703 qdf_mem_copy(Key3,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003704 pProfile->Keys.KeyMaterial[3],
3705 WNI_CFG_WEP_KEY_LENGTH_5);
3706 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3707 } else {
3708 Key3Length = 0;
3709 }
3710 break;
3711
3712 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3713 case eCSR_ENCRYPT_TYPE_WEP104:
3714
3715 /* Privacy is ON. NO RSN for Wep40 static key. */
3716 PrivacyEnabled = 1;
3717 RsnEnabled = 0;
3718 /* Set the Wep default key ID. */
3719 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3720 /* Wep key size if 13 bytes (104 bits). */
3721 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3722 /*
3723 * set encryption keys in the CFG database or clear
3724 * those that are not present in this profile.
3725 */
3726 if (pProfile->Keys.KeyLength[0]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303727 qdf_mem_copy(Key0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728 pProfile->Keys.KeyMaterial[0],
3729 WNI_CFG_WEP_KEY_LENGTH_13);
3730 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3731 } else {
3732 Key0Length = 0;
3733 }
3734
3735 if (pProfile->Keys.KeyLength[1]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303736 qdf_mem_copy(Key1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737 pProfile->Keys.KeyMaterial[1],
3738 WNI_CFG_WEP_KEY_LENGTH_13);
3739 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3740 } else {
3741 Key1Length = 0;
3742 }
3743
3744 if (pProfile->Keys.KeyLength[2]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303745 qdf_mem_copy(Key2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003746 pProfile->Keys.KeyMaterial[2],
3747 WNI_CFG_WEP_KEY_LENGTH_13);
3748 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3749 } else {
3750 Key2Length = 0;
3751 }
3752
3753 if (pProfile->Keys.KeyLength[3]) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303754 qdf_mem_copy(Key3,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003755 pProfile->Keys.KeyMaterial[3],
3756 WNI_CFG_WEP_KEY_LENGTH_13);
3757 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3758 } else {
3759 Key3Length = 0;
3760 }
3761 break;
3762
3763 case eCSR_ENCRYPT_TYPE_TKIP:
3764 case eCSR_ENCRYPT_TYPE_AES:
3765#ifdef FEATURE_WLAN_WAPI
3766 case eCSR_ENCRYPT_TYPE_WPI:
3767#endif /* FEATURE_WLAN_WAPI */
3768 /*
3769 * this is the only difference between this function and
3770 * the csr_set_cfg_privacyFromProfile().
3771 * (setting of the privacy CFG based on the advertised
3772 * privacy setting from AP for WPA/WAPI associations).
3773 */
3774 PrivacyEnabled = (0 != fPrivacy);
3775 /* turn on RSN enabled for WPA associations */
3776 RsnEnabled = 1;
3777 /* clear static WEP keys that may be hanging around. */
3778 Key0Length = 0;
3779 Key1Length = 0;
3780 Key2Length = 0;
3781 Key3Length = 0;
3782 break;
3783 default:
3784 PrivacyEnabled = 0;
3785 RsnEnabled = 0;
3786 break;
3787 }
3788
3789 cfg_set_int(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled);
3790 cfg_set_int(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled);
3791 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length);
3792 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length);
3793 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length);
3794 cfg_set_str(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length);
3795 cfg_set_int(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength);
3796 cfg_set_int(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId);
3797}
3798
3799static void csr_set_cfg_ssid(tpAniSirGlobal pMac, tSirMacSSid *pSSID)
3800{
3801 uint32_t len = 0;
3802 if (pSSID->length <= WNI_CFG_SSID_LEN) {
3803 len = pSSID->length;
3804 }
3805 cfg_set_str(pMac, WNI_CFG_SSID, (uint8_t *) pSSID->ssId, len);
3806}
3807
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303808QDF_STATUS csr_set_qos_to_cfg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809 eCsrMediaAccessType qosType)
3810{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303811 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812 uint32_t QoSEnabled;
3813 uint32_t WmeEnabled;
3814 /* set the CFG enable/disable variables based on the qosType being configured... */
3815 switch (qosType) {
3816 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3817 QoSEnabled = false;
3818 WmeEnabled = true;
3819 break;
3820 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3821 QoSEnabled = false;
3822 WmeEnabled = true;
3823 break;
3824 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3825 QoSEnabled = false;
3826 WmeEnabled = true;
3827 break;
3828 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3829 QoSEnabled = true;
3830 WmeEnabled = false;
3831 break;
3832 case eCSR_MEDIUM_ACCESS_11e_HCF:
3833 QoSEnabled = true;
3834 WmeEnabled = false;
3835 break;
3836 default:
3837 case eCSR_MEDIUM_ACCESS_DCF:
3838 QoSEnabled = false;
3839 WmeEnabled = false;
3840 break;
3841 }
3842 /* save the WMM setting for later use */
3843 pMac->roam.roamSession[sessionId].fWMMConnection = (bool) WmeEnabled;
3844 pMac->roam.roamSession[sessionId].fQOSConnection = (bool) QoSEnabled;
3845 return status;
3846}
3847
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303848static QDF_STATUS csr_get_rate_set(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003849 tCsrRoamProfile *pProfile, eCsrPhyMode phyMode,
3850 tSirBssDescription *pBssDesc,
3851 tDot11fBeaconIEs *pIes,
3852 tSirMacRateSet *pOpRateSet,
3853 tSirMacRateSet *pExRateSet)
3854{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303855 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 int i;
3857 eCsrCfgDot11Mode cfgDot11Mode;
3858 uint8_t *pDstRate;
3859 uint16_t rateBitmap = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303860 qdf_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3861 qdf_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303862 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003863
3864 if (NULL == pIes) {
3865 sms_log(pMac, LOGE, FL("failed to parse BssDesc"));
3866 return status;
3867 }
3868
3869 csr_is_phy_mode_match(pMac, phyMode, pBssDesc, pProfile,
3870 &cfgDot11Mode, pIes);
3871 /*
3872 * Originally, we thought that for 11a networks, the 11a rates
3873 * are always in the Operational Rate set & for 11b and 11g
3874 * networks, the 11b rates appear in the Operational Rate set.
3875 * Consequently, in either case, we would blindly put the rates
3876 * we support into our Operational Rate set.
3877 * (including the basic rates, which we've already verified are
3878 * supported earlier in the roaming decision).
3879 * However, it turns out that this is not always the case.
3880 * Some AP's (e.g. D-Link DI-784) ram 11g rates into the
3881 * Operational Rate set too. Now, we're a little more careful.
3882 */
3883 pDstRate = pOpRateSet->rate;
3884 if (pIes->SuppRates.present) {
3885 for (i = 0; i < pIes->SuppRates.num_rates; i++) {
3886 if (csr_rates_is_dot11_rate_supported(pMac,
3887 pIes->SuppRates.rates[i]) &&
3888 !csr_check_rate_bitmap(
3889 pIes->SuppRates.rates[i],
3890 rateBitmap)) {
3891 csr_add_rate_bitmap(pIes->SuppRates.
3892 rates[i], &rateBitmap);
3893 *pDstRate++ = pIes->SuppRates.rates[i];
3894 pOpRateSet->numRates++;
3895 }
3896 }
3897 }
Abhishek Singh10112382015-12-03 16:06:59 +05303898 /*
3899 * If there are Extended Rates in the beacon, we will reflect the
3900 * extended rates that we support in our Extended Operational Rate
3901 * set.
3902 */
3903 if (pIes->ExtSuppRates.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003904 pDstRate = pExRateSet->rate;
3905 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++) {
3906 if (csr_rates_is_dot11_rate_supported(pMac,
3907 pIes->ExtSuppRates.rates[i]) &&
3908 !csr_check_rate_bitmap(
3909 pIes->ExtSuppRates.rates[i],
3910 rateBitmap)) {
3911 *pDstRate++ = pIes->ExtSuppRates.rates[i];
3912 pExRateSet->numRates++;
3913 }
3914 }
3915 }
3916 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303917 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918 return status;
3919}
3920
3921static void csr_set_cfg_rate_set(tpAniSirGlobal pMac, eCsrPhyMode phyMode,
3922 tCsrRoamProfile *pProfile,
3923 tSirBssDescription *pBssDesc,
3924 tDot11fBeaconIEs *pIes)
3925{
3926 int i;
3927 uint8_t *pDstRate;
3928 eCsrCfgDot11Mode cfgDot11Mode;
3929 uint8_t OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX]; /* leave enough room for the max number of rates */
3930 uint32_t OperationalRatesLength = 0;
3931 uint8_t ExtendedOperationalRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX]; /* leave enough room for the max number of rates */
3932 uint32_t ExtendedOperationalRatesLength = 0;
3933 uint8_t MCSRateIdxSet[SIZE_OF_SUPPORTED_MCS_SET];
3934 uint32_t MCSRateLength = 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303935 QDF_ASSERT(pIes != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 if (NULL != pIes) {
3937 csr_is_phy_mode_match(pMac, phyMode, pBssDesc, pProfile,
3938 &cfgDot11Mode, pIes);
3939 /* Originally, we thought that for 11a networks, the 11a rates are always */
3940 /* in the Operational Rate set & for 11b and 11g networks, the 11b rates */
3941 /* appear in the Operational Rate set. Consequently, in either case, we */
3942 /* would blindly put the rates we support into our Operational Rate set */
3943 /* (including the basic rates, which we have already verified are */
3944 /* supported earlier in the roaming decision). */
3945 /* However, it turns out that this is not always the case. Some AP's */
3946 /* (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set, */
3947 /* too. Now, we're a little more careful: */
3948 pDstRate = OperationalRates;
3949 if (pIes->SuppRates.present) {
3950 for (i = 0; i < pIes->SuppRates.num_rates; i++) {
3951 if (csr_rates_is_dot11_rate_supported
3952 (pMac, pIes->SuppRates.rates[i])
3953 && (OperationalRatesLength <
3954 CSR_DOT11_SUPPORTED_RATES_MAX)) {
3955 *pDstRate++ = pIes->SuppRates.rates[i];
3956 OperationalRatesLength++;
3957 }
3958 }
3959 }
3960 if (eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3961 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3962 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) {
3963 /* If there are Extended Rates in the beacon, we will reflect those */
3964 /* extended rates that we support in out Extended Operational Rate */
3965 /* set: */
3966 pDstRate = ExtendedOperationalRates;
3967 if (pIes->ExtSuppRates.present) {
3968 for (i = 0; i < pIes->ExtSuppRates.num_rates;
3969 i++) {
3970 if (csr_rates_is_dot11_rate_supported
3971 (pMac, pIes->ExtSuppRates.rates[i])
3972 && (ExtendedOperationalRatesLength <
3973 CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX)) {
3974 *pDstRate++ =
3975 pIes->ExtSuppRates.rates[i];
3976 ExtendedOperationalRatesLength++;
3977 }
3978 }
3979 }
3980 }
3981 /* Enable proprietary MAC features if peer node is Airgo node and STA */
3982 /* user wants to use them */
3983 /* For ANI network companions, we need to populate the proprietary rate */
3984 /* set with any proprietary rates we found in the beacon, only if user */
3985 /* allows them... */
3986 /* No proprietary modes... */
3987 /* Get MCS Rate */
3988 pDstRate = MCSRateIdxSet;
3989 if (pIes->HTCaps.present) {
3990 for (i = 0; i < VALID_MAX_MCS_INDEX; i++) {
3991 if ((unsigned int)pIes->HTCaps.
3992 supportedMCSSet[0] & (1 << i)) {
3993 MCSRateLength++;
3994 *pDstRate++ = i;
3995 }
3996 }
3997 }
3998 /* Set the operational rate set CFG variables... */
3999 cfg_set_str(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
4000 OperationalRates, OperationalRatesLength);
4001 cfg_set_str(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
4002 ExtendedOperationalRates,
4003 ExtendedOperationalRatesLength);
4004 cfg_set_str(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
4005 MCSRateLength);
4006 } /* Parsing BSSDesc */
4007 else {
4008 sms_log(pMac, LOGE, FL("failed to parse BssDesc"));
4009 }
4010}
4011
4012static void csr_set_cfg_rate_set_from_profile(tpAniSirGlobal pMac,
4013 tCsrRoamProfile *pProfile)
4014{
4015 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
4016 {8,
4017 {SIR_MAC_RATE_6,
4018 SIR_MAC_RATE_9,
4019 SIR_MAC_RATE_12,
4020 SIR_MAC_RATE_18,
4021 SIR_MAC_RATE_24,
4022 SIR_MAC_RATE_36,
4023 SIR_MAC_RATE_48,
4024 SIR_MAC_RATE_54} } };
4025 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
4026 {4,
4027 {SIR_MAC_RATE_1,
4028 SIR_MAC_RATE_2,
4029 SIR_MAC_RATE_5_5,
4030 SIR_MAC_RATE_11} } };
4031
4032 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
4033 {SIR_MAC_RATE_72,
4034 SIR_MAC_RATE_96,
4035 SIR_MAC_RATE_108} };
4036 eCsrCfgDot11Mode cfgDot11Mode;
4037 eCsrBand eBand;
4038 /* leave enough room for the max number of rates */
4039 uint8_t OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
4040 uint32_t OperationalRatesLength = 0;
4041 /* leave enough room for the max number of rates */
4042 uint8_t ExtendedOperationalRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
4043 uint32_t ExtendedOperationalRatesLength = 0;
4044 /* leave enough room for the max number of proprietary rates */
4045 uint8_t ProprietaryOperationalRates[4];
4046 uint32_t ProprietaryOperationalRatesLength = 0;
4047 uint32_t PropRatesEnable = 0;
4048 uint8_t operationChannel = 0;
4049 if (pProfile->ChannelInfo.ChannelList) {
4050 operationChannel = pProfile->ChannelInfo.ChannelList[0];
4051 }
4052 cfgDot11Mode =
4053 csr_roam_get_phy_mode_band_for_bss(pMac, pProfile, operationChannel,
4054 &eBand);
4055 /* For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g */
4056 /* networks, the 11b rates appear in the Operational Rate set. In either case, */
4057 /* we can blindly put the rates we support into our Operational Rate set */
4058 /* (including the basic rates, which we have already verified are supported */
4059 /* earlier in the roaming decision). */
4060 if (eCSR_BAND_5G == eBand) {
4061 /* 11a rates into the Operational Rate Set. */
4062 OperationalRatesLength =
4063 DefaultSupportedRates11a.supportedRateSet.numRates *
4064 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304065 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004066 DefaultSupportedRates11a.supportedRateSet.rate,
4067 OperationalRatesLength);
4068
4069 /* Nothing in the Extended rate set. */
4070 ExtendedOperationalRatesLength = 0;
4071 /* populate proprietary rates if user allows them */
4072 if (pMac->roam.configParam.ProprietaryRatesEnabled) {
4073 ProprietaryOperationalRatesLength =
4074 DefaultSupportedPropRates.numPropRates *
4075 sizeof(*DefaultSupportedPropRates.propRate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304076 qdf_mem_copy(ProprietaryOperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004077 DefaultSupportedPropRates.propRate,
4078 ProprietaryOperationalRatesLength);
4079 } else {
4080 /* No proprietary modes */
4081 ProprietaryOperationalRatesLength = 0;
4082 }
4083 } else if (eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode) {
4084 /* 11b rates into the Operational Rate Set. */
4085 OperationalRatesLength =
4086 DefaultSupportedRates11b.supportedRateSet.numRates *
4087 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304088 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089 DefaultSupportedRates11b.supportedRateSet.rate,
4090 OperationalRatesLength);
4091 /* Nothing in the Extended rate set. */
4092 ExtendedOperationalRatesLength = 0;
4093 /* No proprietary modes */
4094 ProprietaryOperationalRatesLength = 0;
4095 } else {
4096 /* 11G */
4097
4098 /* 11b rates into the Operational Rate Set. */
4099 OperationalRatesLength =
4100 DefaultSupportedRates11b.supportedRateSet.numRates *
4101 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304102 qdf_mem_copy(OperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004103 DefaultSupportedRates11b.supportedRateSet.rate,
4104 OperationalRatesLength);
4105
4106 /* 11a rates go in the Extended rate set. */
4107 ExtendedOperationalRatesLength =
4108 DefaultSupportedRates11a.supportedRateSet.numRates *
4109 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304110 qdf_mem_copy(ExtendedOperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 DefaultSupportedRates11a.supportedRateSet.rate,
4112 ExtendedOperationalRatesLength);
4113
4114 /* populate proprietary rates if user allows them */
4115 if (pMac->roam.configParam.ProprietaryRatesEnabled) {
4116 ProprietaryOperationalRatesLength =
4117 DefaultSupportedPropRates.numPropRates *
4118 sizeof(*DefaultSupportedPropRates.propRate);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304119 qdf_mem_copy(ProprietaryOperationalRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120 DefaultSupportedPropRates.propRate,
4121 ProprietaryOperationalRatesLength);
4122 } else {
4123 /* No proprietary modes */
4124 ProprietaryOperationalRatesLength = 0;
4125 }
4126 }
4127 /* set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them */
4128 if (ProprietaryOperationalRatesLength
4129 && pMac->roam.configParam.ProprietaryRatesEnabled) {
4130 PropRatesEnable = 1;
4131 } else {
4132 PropRatesEnable = 0;
4133 }
4134
4135 /* Set the operational rate set CFG variables... */
4136 cfg_set_str(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
4137 OperationalRatesLength);
4138 cfg_set_str(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
4139 ExtendedOperationalRates, ExtendedOperationalRatesLength);
4140 cfg_set_str(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
4141 ProprietaryOperationalRates,
4142 ProprietaryOperationalRatesLength);
4143}
4144
4145void csr_roam_ccm_cfg_set_callback(tpAniSirGlobal pMac, int32_t result)
4146{
4147 tListElem *pEntry =
4148 csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
4149 uint32_t sessionId;
4150 tSmeCmd *pCommand = NULL;
4151#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4152 tCsrRoamSession *pSession = NULL;
4153#endif
4154 if (NULL == pEntry) {
4155 sms_log(pMac, LOGW, "CFG_CNF with active list empty");
4156 return;
4157 }
4158 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
4159 sessionId = pCommand->sessionId;
4160#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4161 pSession = &pMac->roam.roamSession[sessionId];
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08004162 if (pSession->roam_synch_in_progress) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304163 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164 "LFR3:csr_roam_cfg_set_callback");
4165 }
4166#endif
4167
4168 if (CSR_IS_ROAM_JOINING(pMac, sessionId)
4169 && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId)) {
4170 csr_roaming_state_config_cnf_processor(pMac, (uint32_t) result);
4171 }
4172}
4173
4174/* This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE */
4175uint32_t csr_roam_get_phy_mode_from_dot11_mode(eCsrCfgDot11Mode dot11Mode,
4176 eCsrBand band)
4177{
4178 if (eCSR_CFG_DOT11_MODE_11B == dot11Mode) {
4179 return WNI_CFG_PHY_MODE_11B;
4180 } else {
4181 if (eCSR_BAND_24 == band)
4182 return WNI_CFG_PHY_MODE_11G;
4183 }
4184 return WNI_CFG_PHY_MODE_11A;
4185}
4186
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187ePhyChanBondState csr_get_htcb_state_from_vhtcb_state(ePhyChanBondState aniCBMode)
4188{
4189 switch (aniCBMode) {
4190 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
4191 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
4192 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
4193 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4194 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
4195 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
4196 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
4197 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4198 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
4199 default:
4200 return PHY_SINGLE_CHANNEL_CENTERED;
4201 }
4202}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203
4204/* pIes may be NULL */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304205QDF_STATUS csr_roam_set_bss_config_cfg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206 tCsrRoamProfile *pProfile,
4207 tSirBssDescription *pBssDesc,
4208 tBssConfigParam *pBssConfig,
4209 tDot11fBeaconIEs *pIes, bool resetCountry)
4210{
4211 tSirRetStatus status;
4212 uint32_t cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4213 uint8_t channel = 0;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08004214 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
4215
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216 /* Make sure we have the domain info for the BSS we try to connect to. */
4217 /* Do we need to worry about sequence for OSs that are not Windows?? */
4218 if (pBssDesc) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05304219 if ((QDF_SAP_MODE !=
Peng Xuf5d60c82015-10-02 17:17:03 -07004220 csr_get_session_persona(pMac, sessionId)) &&
4221 csr_learn_11dcountry_information(
4222 pMac, pBssDesc, pIes, true)) {
4223 csr_apply_country_information(pMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004224 }
4225 if ((csr_is11d_supported(pMac)) && pIes) {
4226 if (!pIes->Country.present) {
4227 csr_apply_channel_power_info_wrapper(pMac);
4228 } else {
4229 /* Let's also update the below to make sure we don't update CC while */
4230 /* connected to an AP which is advertising some CC */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304231 qdf_mem_copy(pMac->scan.currentCountryBssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004232 pBssDesc->bssId,
4233 sizeof(tSirMacAddr));
4234 }
4235 }
4236 }
4237 /* Qos */
4238 csr_set_qos_to_cfg(pMac, sessionId, pBssConfig->qosType);
4239 /* SSID */
4240 csr_set_cfg_ssid(pMac, &pBssConfig->SSID);
4241
4242 /* Auth type */
4243 cfg_set_int(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType);
4244 /* encryption type */
4245 csr_set_cfg_privacy(pMac, pProfile, (bool) pBssConfig->BssCap.privacy);
4246 /* short slot time */
4247 cfg_set_int(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED,
4248 pBssConfig->uShortSlotTime);
4249 /* 11d */
4250 cfg_set_int(pMac, WNI_CFG_11D_ENABLED,
4251 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport :
4252 pProfile->ieee80211d));
4253 cfg_set_int(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT,
4254 pBssConfig->uPowerLimit);
4255 /* CB */
4256
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07004257 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_IBSS(pProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258 channel = pProfile->operationChannel;
4259 } else {
4260 if (pBssDesc) {
4261 channel = pBssDesc->channelId;
4262 }
4263 }
4264 if (0 != channel) {
4265 if (CDS_IS_CHANNEL_24GHZ(channel)) { /* for now if we are on 2.4 Ghz, CB will be always disabled */
4266 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4267 } else {
4268 cfgCb = pBssConfig->cbMode;
4269 }
4270 }
4271 /* Rate */
4272 /* Fixed Rate */
4273 if (pBssDesc) {
4274 csr_set_cfg_rate_set(pMac, (eCsrPhyMode) pProfile->phyMode,
4275 pProfile, pBssDesc, pIes);
4276 } else {
4277 csr_set_cfg_rate_set_from_profile(pMac, pProfile);
4278 }
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08004279 status = cfg_set_int(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT,
4280 pBssConfig->uJoinTimeOut);
4281 /* Any roaming related changes should be above this line */
4282 if (pSession && pSession->roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304283 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284 /* Make this the last CFG to set. The callback will trigger a join_req */
4285 /* Join time out */
4286 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId);
4287
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004288 csr_roam_ccm_cfg_set_callback(pMac, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304289 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004290}
4291
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304292QDF_STATUS csr_roam_stop_network(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004293 tCsrRoamProfile *pProfile,
4294 tSirBssDescription *pBssDesc,
4295 tDot11fBeaconIEs *pIes)
4296{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304297 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004298 tBssConfigParam *pBssConfig;
4299 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
4300
4301 if (!pSession) {
4302 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304303 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004304 }
4305
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304306 pBssConfig = qdf_mem_malloc(sizeof(tBssConfigParam));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307 if (NULL == pBssConfig)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304308 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004309
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304310 qdf_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311 status = csr_roam_prepare_bss_config(pMac, pProfile, pBssDesc,
4312 pBssConfig, pIes);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304313 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 eCsrRoamSubState substate;
4315 substate = eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING;
4316 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
4317 /* This will allow to pass cbMode during join req */
4318 pSession->bssParams.cbMode = pBssConfig->cbMode;
4319 /* For IBSS, we need to prepare some more information */
4320 if (csr_is_bss_type_ibss(pProfile->BSSType) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004321 CSR_IS_INFRA_AP(pProfile))
4322 csr_roam_prepare_bss_params(pMac, sessionId, pProfile,
4323 pBssDesc, pBssConfig, pIes);
4324
4325 /*
4326 * If we are in an IBSS, then stop the IBSS...
4327 * Not worry about WDS connection for now
4328 */
4329 if (csr_is_conn_state_ibss(pMac, sessionId)) {
4330 status = csr_roam_issue_stop_bss(pMac, sessionId,
4331 substate);
4332 } else if (csr_is_conn_state_infra(pMac, sessionId)) {
4333 /*
4334 * the new Bss is an Ibss OR we are roaming from
4335 * Infra to Infra across SSIDs
4336 * (roaming to a new SSID)...
4337 * Not worry about WDS connection for now
4338 */
4339 if (pBssDesc && (csr_is_ibss_bss_desc(pBssDesc) ||
4340 !csr_is_ssid_equal(pMac,
4341 pSession->pConnectBssDesc,
4342 pBssDesc, pIes)))
4343 status = csr_roam_issue_disassociate(pMac,
4344 sessionId, substate, false);
4345 else if (pBssDesc)
4346 /*
4347 * In an infra & going to an infra network with
4348 * the same SSID. This calls for a reassoc seq.
4349 * So issue the CFG sets for this new AP. Set
4350 * parameters for this Bss.
4351 */
4352 status = csr_roam_set_bss_config_cfg(pMac,
4353 sessionId, pProfile, pBssDesc,
4354 pBssConfig, pIes, false);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07004355 } else if (pBssDesc ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004356 CSR_IS_INFRA_AP(pProfile)) {
4357 /*
4358 * Neither in IBSS nor in Infra. We can go ahead and set
4359 * the cfg for tne new network... nothing to stop.
4360 */
4361 bool is11rRoamingFlag = false;
4362 is11rRoamingFlag = csr_roam_is11r_assoc(pMac,
4363 sessionId);
4364 /* Set parameters for this Bss. */
4365 status = csr_roam_set_bss_config_cfg(pMac, sessionId,
4366 pProfile, pBssDesc, pBssConfig, pIes,
4367 is11rRoamingFlag);
4368 }
4369 } /* Success getting BSS config info */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304370 qdf_mem_free(pBssConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004371 return status;
4372}
4373
4374/**
4375 * csr_roam_state_for_same_profile() - Determine roam state for same profile
4376 * @mac_ctx: pointer to mac context
4377 * @profile: Roam profile
4378 * @session: Roam session
4379 * @session_id: session id
4380 * @ies_local: local ies
4381 * @bss_descr: bss description
4382 *
4383 * This function will determine the roam state for same profile
4384 *
4385 * Return: Roaming state.
4386 */
4387static eCsrJoinState csr_roam_state_for_same_profile(tpAniSirGlobal mac_ctx,
4388 tCsrRoamProfile *profile, tCsrRoamSession *session,
4389 uint32_t session_id, tDot11fBeaconIEs *ies_local,
4390 tSirBssDescription *bss_descr)
4391{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304392 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393 tBssConfigParam bssConfig;
4394 if (csr_roam_is_same_profile_keys(mac_ctx, &session->connectedProfile,
4395 profile))
4396 return eCsrReassocToSelfNoCapChange;
4397 /* The key changes */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304398 qdf_mem_set(&bssConfig, sizeof(bssConfig), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399 status = csr_roam_prepare_bss_config(mac_ctx, profile, bss_descr,
4400 &bssConfig, ies_local);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304401 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004402 session->bssParams.uCfgDot11Mode =
4403 bssConfig.uCfgDot11Mode;
4404 session->bssParams.cbMode =
4405 bssConfig.cbMode;
4406 /* reapply the cfg including keys so reassoc happens. */
4407 status = csr_roam_set_bss_config_cfg(mac_ctx, session_id,
4408 profile, bss_descr, &bssConfig,
4409 ies_local, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304410 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 return eCsrContinueRoaming;
4412 }
4413
4414 return eCsrStopRoaming;
4415
4416}
4417
4418eCsrJoinState csr_roam_join(tpAniSirGlobal pMac, uint32_t sessionId,
4419 tCsrScanResultInfo *pScanResult,
4420 tCsrRoamProfile *pProfile)
4421{
4422 eCsrJoinState eRoamState = eCsrContinueRoaming;
4423 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4424 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *) (pScanResult->pvIes);
4425 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
4426
4427 if (!pSession) {
4428 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
4429 return eCsrStopRoaming;
4430 }
4431
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004432 if (!pIesLocal &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304433 !QDF_IS_STATUS_SUCCESS(csr_get_parsed_bss_description_ies(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004434 pBssDesc, &pIesLocal))) {
4435 sms_log(pMac, LOGE, FL("fail to parse IEs"));
4436 return eCsrStopRoaming;
4437 }
4438 if (csr_is_infra_bss_desc(pBssDesc)) {
4439 /*
4440 * If we are connected in infra mode and the join bss descr is
4441 * for the same BssID, then we are attempting to join the AP we
4442 * are already connected with. In that case, see if the Bss or
4443 * sta capabilities have changed and handle the changes
4444 * without disturbing the current association
4445 */
4446
4447 if (csr_is_conn_state_connected_infra(pMac, sessionId) &&
4448 csr_is_bss_id_equal(pMac,
4449 pBssDesc, pSession->pConnectBssDesc) &&
4450 csr_is_ssid_equal(pMac, pSession->pConnectBssDesc,
4451 pBssDesc, pIesLocal)) {
4452 /*
4453 * Check to see if the Auth type has changed in the
4454 * profile. If so, we don't want to reassociate with
4455 * authenticating first. To force this, stop the
4456 * current association (Disassociate) and then re 'Join'
4457 * the AP, wihch will force an Authentication (with the
4458 * new Auth type) followed by a new Association.
4459 */
4460 if (csr_is_same_profile(pMac,
4461 &pSession->connectedProfile, pProfile)) {
4462 sms_log(pMac, LOGW,
4463 FL("detect same profile"));
4464 eRoamState =
4465 csr_roam_state_for_same_profile(pMac,
4466 pProfile, pSession, sessionId,
4467 pIesLocal, pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304468 } else if (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004469 csr_roam_issue_disassociate(pMac,
4470 sessionId,
4471 eCSR_ROAM_SUBSTATE_DISASSOC_REQ,
4472 false))) {
4473 sms_log(pMac, LOGE,
4474 FL("fail disassoc session %d"),
4475 sessionId);
4476 eRoamState = eCsrStopRoaming;
4477 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304478 } else if (!QDF_IS_STATUS_SUCCESS(csr_roam_stop_network(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004479 sessionId, pProfile, pBssDesc, pIesLocal))) {
4480 /* we used to pre-auth here with open auth
4481 * networks but that wasn't working so well.
4482 * stop the existing network before attempting
4483 * to join the new network... */
4484 eRoamState = eCsrStopRoaming;
4485 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304486 } else if (!QDF_IS_STATUS_SUCCESS(csr_roam_stop_network(pMac, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487 pProfile, pBssDesc,
4488 pIesLocal))) {
4489 eRoamState = eCsrStopRoaming;
4490 }
4491
4492 if (pIesLocal && !pScanResult->pvIes)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304493 qdf_mem_free(pIesLocal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494 return eRoamState;
4495}
4496
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304497QDF_STATUS csr_roam_should_roam(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498 tSirBssDescription *pBssDesc, uint32_t roamId)
4499{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304500 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501 tCsrRoamInfo roamInfo;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304502 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004503 roamInfo.pBssDesc = pBssDesc;
4504 status =
4505 csr_roam_call_callback(pMac, sessionId, &roamInfo, roamId,
4506 eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4507 return status;
4508}
4509
4510/* In case no matching BSS is found, use whatever default we can find */
4511static void csr_roam_assign_default_param(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4512{
4513 /* Need to get all negotiated types in place first */
4514 /* auth type */
4515 /* Take the preferred Auth type. */
4516 switch (pCommand->u.roamCmd.roamProfile.AuthType.authType[0]) {
4517 default:
4518 case eCSR_AUTH_TYPE_WPA:
4519 case eCSR_AUTH_TYPE_WPA_PSK:
4520 case eCSR_AUTH_TYPE_WPA_NONE:
4521 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4522 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
4523 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4524 break;
4525
4526 case eCSR_AUTH_TYPE_SHARED_KEY:
4527 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
4528 eCSR_AUTH_TYPE_SHARED_KEY;
4529 break;
4530
4531 case eCSR_AUTH_TYPE_AUTOSWITCH:
4532 pCommand->u.roamCmd.roamProfile.negotiatedAuthType =
4533 eCSR_AUTH_TYPE_AUTOSWITCH;
4534 break;
4535 }
4536 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4537 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4538 /* In this case, the multicast encryption needs to follow the uncast ones. */
4539 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4540 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4541}
4542
4543static void csr_set_abort_roaming_command(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4544{
4545 switch (pCommand->u.roamCmd.roamReason) {
4546 case eCsrLostLink1:
4547 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4548 break;
4549 case eCsrLostLink2:
4550 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4551 break;
4552 case eCsrLostLink3:
4553 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4554 break;
4555 default:
4556 sms_log(pMac, LOGE,
4557 FL(" aborting roaming reason %d not recognized"),
4558 pCommand->u.roamCmd.roamReason);
4559 break;
4560 }
4561}
4562
4563/**
4564 * csr_roam_select_bss() - Handle join scenario based on profile
4565 * @mac_ctx: Global MAC Context
4566 * @roam_bss_entry: The next BSS to join
4567 * @csr_result_info: Result of join
4568 * @csr_scan_result: Global scan result
4569 * @session_id: SME Session ID
4570 * @roam_id: Roaming ID
4571 * @roam_state: Current roaming state
4572 * @bss_list: BSS List
4573 *
4574 * Return: true if the entire BSS list is done, false otherwise.
4575 */
4576static bool csr_roam_select_bss(tpAniSirGlobal mac_ctx,
4577 tListElem *roam_bss_entry, tCsrScanResultInfo **csr_result_info,
4578 tCsrScanResult **csr_scan_result, uint32_t session_id,
4579 uint32_t roam_id, eCsrJoinState *roam_state,
4580 tScanResultList *bss_list)
4581{
4582 uint8_t conc_channel = 0;
4583 bool status = false;
4584 tCsrScanResult *scan_result = NULL;
4585 tCsrScanResultInfo *result = NULL;
4586
4587 while (roam_bss_entry) {
4588 scan_result = GET_BASE_ADDR(roam_bss_entry, tCsrScanResult,
4589 Link);
4590 /*
4591 * If concurrency enabled take the
4592 * concurrent connected channel first.
4593 * Valid multichannel concurrent
4594 * sessions exempted
4595 */
4596 result = &scan_result->Result;
4597 if (cds_concurrent_open_sessions_running() &&
4598 !csr_is_valid_mc_concurrent_session(mac_ctx,
4599 session_id, &result->BssDescriptor)) {
4600 conc_channel = csr_get_concurrent_operation_channel(
4601 mac_ctx);
4602 sms_log(mac_ctx, LOG1, FL("csr Conc Channel = %d"),
4603 conc_channel);
4604 if ((conc_channel) && (conc_channel ==
4605 result->BssDescriptor.channelId)) {
4606 /*
4607 * make this 0 because we do not want the below
4608 * check to pass as we don't want to connect on
4609 * other channel
4610 */
4611 sms_log(mac_ctx, LOG1, FL("Conc chnl match=%d"),
4612 conc_channel);
4613 conc_channel = 0;
4614 }
4615 }
4616
4617 /* Ok to roam this */
4618 if (!conc_channel &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304619 QDF_IS_STATUS_SUCCESS(csr_roam_should_roam(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004620 session_id, &result->BssDescriptor, roam_id))) {
4621 status = false;
4622 break;
4623 } else {
4624 *roam_state = eCsrStopRoamingDueToConcurrency;
4625 status = true;
4626 }
4627 roam_bss_entry = csr_ll_next(&bss_list->List, roam_bss_entry,
4628 LL_ACCESS_LOCK);
4629 }
4630 *csr_result_info = result;
4631 *csr_scan_result = scan_result;
4632 return status;
4633}
4634
4635/**
4636 * csr_roam_join_handle_profile() - Handle join scenario based on profile
4637 * @mac_ctx: Global MAC Context
4638 * @session_id: SME Session ID
4639 * @cmd: Command
4640 * @roam_info_ptr: Pointed to the roaming info for join
4641 * @roam_state: Current roaming state
4642 * @result: Result of join
4643 * @scan_result: Global scan result
4644 *
4645 * Return: None
4646 */
4647static void csr_roam_join_handle_profile(tpAniSirGlobal mac_ctx,
4648 uint32_t session_id, tSmeCmd *cmd, tCsrRoamInfo *roam_info_ptr,
4649 eCsrJoinState *roam_state, tCsrScanResultInfo *result,
4650 tCsrScanResult *scan_result)
4651{
4652#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4653 uint8_t acm_mask = 0;
4654#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304655 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
4657 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
4658 tDot11fBeaconIEs *ies_local = NULL;
4659 /*
4660 * We have something to roam, tell HDD when it is infra.
4661 * For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004662 */
4663 if (CSR_IS_INFRASTRUCTURE(profile)) {
4664 if (roam_info_ptr && session->bRefAssocStartCnt) {
4665 session->bRefAssocStartCnt--;
4666 roam_info_ptr->pProfile = profile;
4667 /*
4668 * Complete the last assoc attempt as a
4669 * new one is about to be tried
4670 */
4671 csr_roam_call_callback(mac_ctx, session_id,
4672 roam_info_ptr, cmd->u.roamCmd.roamId,
4673 eCSR_ROAM_ASSOCIATION_COMPLETION,
4674 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4675 }
4676 /* If roaming has stopped, don't continue the roaming command */
4677 if (!CSR_IS_ROAMING(session) && CSR_IS_ROAMING_COMMAND(cmd)) {
4678 /* No need to complete roaming as it already complete */
4679 sms_log(mac_ctx, LOGW,
4680 FL(
4681 "Roam cmd(reason %d)aborted as roam complete"),
4682 cmd->u.roamCmd.roamReason);
4683 *roam_state = eCsrStopRoaming;
4684 csr_set_abort_roaming_command(mac_ctx, cmd);
4685 return;
4686 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304687 qdf_mem_set(roam_info_ptr, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004688 if (!scan_result)
4689 cmd->u.roamCmd.roamProfile.uapsd_mask = 0;
4690 else
4691 ies_local = scan_result->Result.pvIes;
4692
4693 if (scan_result && !ies_local &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304694 (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695 csr_get_parsed_bss_description_ies(
4696 mac_ctx,
4697 &result->BssDescriptor,
4698 &ies_local)))) {
4699 sms_log(mac_ctx, LOGE, FL(" cannot parse IEs"));
4700 *roam_state = eCsrStopRoaming;
4701 return;
4702 }
4703 roam_info_ptr->pBssDesc = &result->BssDescriptor;
4704 cmd->u.roamCmd.pLastRoamBss = roam_info_ptr->pBssDesc;
4705 /* dont put uapsd_mask if BSS doesn't support uAPSD */
4706 if (scan_result && cmd->u.roamCmd.roamProfile.uapsd_mask
4707 && CSR_IS_QOS_BSS(ies_local)
4708 && CSR_IS_UAPSD_BSS(ies_local)) {
4709#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4710 acm_mask = sme_qos_get_acm_mask(mac_ctx,
4711 &result->BssDescriptor, ies_local);
4712#endif /* WLAN_MDM_CODE_REDUCTION_OPT */
4713 } else {
4714 cmd->u.roamCmd.roamProfile.uapsd_mask = 0;
4715 }
4716 if (ies_local && !result->pvIes)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304717 qdf_mem_free(ies_local);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004718 roam_info_ptr->pProfile = profile;
4719 session->bRefAssocStartCnt++;
4720 csr_roam_call_callback(mac_ctx, session_id, roam_info_ptr,
4721 cmd->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_START,
4722 eCSR_ROAM_RESULT_NONE);
4723 }
4724 if (NULL != cmd->u.roamCmd.pRoamBssEntry) {
4725 /*
4726 * We have BSS
4727 * Need to assign these value because
4728 * they are used in csr_is_same_profile
4729 */
4730 scan_result = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
4731 tCsrScanResult, Link);
4732 /*
4733 * The OSEN IE doesn't provide the cipher suite.Therefore set
4734 * to constant value of AES
4735 */
4736 if (cmd->u.roamCmd.roamProfile.bOSENAssociation) {
4737 cmd->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4738 eCSR_ENCRYPT_TYPE_AES;
4739 cmd->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4740 eCSR_ENCRYPT_TYPE_AES;
4741 } else {
4742 /* Negotiated while building scan result. */
4743 cmd->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4744 scan_result->ucEncryptionType;
4745 cmd->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4746 scan_result->mcEncryptionType;
4747 }
4748 cmd->u.roamCmd.roamProfile.negotiatedAuthType =
4749 scan_result->authType;
4750 if (CSR_IS_START_IBSS(&cmd->u.roamCmd.roamProfile)) {
4751 if (csr_is_same_profile(mac_ctx,
4752 &session->connectedProfile, profile)) {
4753 *roam_state = eCsrStartIbssSameIbss;
4754 return;
4755 }
4756 }
4757 if (cmd->u.roamCmd.fReassocToSelfNoCapChange) {
4758 /* trying to connect to the one already connected */
4759 cmd->u.roamCmd.fReassocToSelfNoCapChange = false;
4760 *roam_state = eCsrReassocToSelfNoCapChange;
4761 return;
4762 }
4763 /* Attempt to Join this Bss... */
4764 *roam_state = csr_roam_join(mac_ctx, session_id,
4765 &scan_result->Result, profile);
4766 return;
4767 }
4768
4769 /* For an IBSS profile, then we need to start the IBSS. */
4770 if (CSR_IS_START_IBSS(profile)) {
4771 bool same_ibss = false;
4772 /* Attempt to start this IBSS... */
4773 csr_roam_assign_default_param(mac_ctx, cmd);
4774 status = csr_roam_start_ibss(mac_ctx, session_id,
4775 profile, &same_ibss);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304776 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777 if (same_ibss)
4778 *roam_state = eCsrStartIbssSameIbss;
4779 else
4780 *roam_state = eCsrContinueRoaming;
4781 } else {
4782 /* it somehow fail need to stop */
4783 *roam_state = eCsrStopRoaming;
4784 }
4785 return;
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07004786 } else if (CSR_IS_INFRA_AP(profile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004787 /* Attempt to start this WDS... */
4788 csr_roam_assign_default_param(mac_ctx, cmd);
4789 /* For AP WDS, we dont have any BSSDescription */
4790 status = csr_roam_start_wds(mac_ctx, session_id, profile, NULL);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304791 if (QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004792 *roam_state = eCsrContinueRoaming;
4793 else
4794 *roam_state = eCsrStopRoaming;
4795 } else {
4796 /* Nothing we can do */
4797 sms_log(mac_ctx, LOGW, FL("cannot continue without BSS list"));
4798 *roam_state = eCsrStopRoaming;
4799 return;
4800 }
4801
4802}
4803/**
4804 * csr_roam_join_next_bss() - Pick the next BSS for join
4805 * @mac_ctx: Global MAC Context
4806 * @cmd: Command
4807 * @use_same_bss: Use Same BSS to Join
4808 *
4809 * Return: The Join State
4810 */
4811static eCsrJoinState csr_roam_join_next_bss(tpAniSirGlobal mac_ctx,
4812 tSmeCmd *cmd, bool use_same_bss)
4813{
4814 tCsrScanResult *scan_result = NULL;
4815 eCsrJoinState roam_state = eCsrStopRoaming;
4816 tScanResultList *bss_list =
4817 (tScanResultList *) cmd->u.roamCmd.hBSSList;
4818 bool done = false;
4819 tCsrRoamInfo roam_info, *roam_info_ptr = NULL;
4820 uint32_t session_id = cmd->sessionId;
4821 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
4822 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
4823 tCsrRoamJoinStatus *join_status;
4824 tCsrScanResultInfo *result = NULL;
4825
4826 if (!session) {
4827 sms_log(mac_ctx, LOGE, FL("session %d not found"), session_id);
4828 return eCsrStopRoaming;
4829 }
4830
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304831 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
4832 qdf_mem_copy(&roam_info.bssid, &session->joinFailStatusCode.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004833 sizeof(tSirMacAddr));
4834 /*
4835 * When handling AP's capability change, continue to associate
4836 * to same BSS and make sure pRoamBssEntry is not Null.
4837 */
4838 if ((NULL != bss_list) &&
4839 ((false == use_same_bss) ||
4840 (cmd->u.roamCmd.pRoamBssEntry == NULL))) {
4841 if (cmd->u.roamCmd.pRoamBssEntry == NULL) {
4842 /* Try the first BSS */
4843 cmd->u.roamCmd.pLastRoamBss = NULL;
4844 cmd->u.roamCmd.pRoamBssEntry =
4845 csr_ll_peek_head(&bss_list->List,
4846 LL_ACCESS_LOCK);
4847 } else {
4848 cmd->u.roamCmd.pRoamBssEntry =
4849 csr_ll_next(&bss_list->List,
4850 cmd->u.roamCmd.pRoamBssEntry,
4851 LL_ACCESS_LOCK);
4852 /*
4853 * Done with all the BSSs.
4854 * In this case, will tell HDD the
4855 * completion
4856 */
4857 if (NULL == cmd->u.roamCmd.pRoamBssEntry)
4858 goto end;
4859 /*
4860 * We need to indicate to HDD that we
4861 * are done with this one.
4862 */
4863 roam_info.pBssDesc = cmd->u.roamCmd.pLastRoamBss;
4864 join_status = &session->joinFailStatusCode;
4865 roam_info.statusCode = join_status->statusCode;
4866 roam_info.reasonCode = join_status->reasonCode;
4867 roam_info_ptr = &roam_info;
4868 }
4869 done = csr_roam_select_bss(mac_ctx,
4870 cmd->u.roamCmd.pRoamBssEntry, &result,
4871 &scan_result, session_id, cmd->u.roamCmd.roamId,
4872 &roam_state, bss_list);
4873 if (done)
4874 goto end;
4875 }
4876 if (!roam_info_ptr)
4877 roam_info_ptr = &roam_info;
4878 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
4879 csr_roam_join_handle_profile(mac_ctx, session_id, cmd, roam_info_ptr,
4880 &roam_state, result, scan_result);
4881end:
4882 if ((eCsrStopRoaming == roam_state) && CSR_IS_INFRASTRUCTURE(profile) &&
4883 (session->bRefAssocStartCnt > 0)) {
4884 /*
4885 * Need to indicate association_completion if association_start
4886 * has been done
4887 */
4888 session->bRefAssocStartCnt--;
4889 /*
4890 * Complete the last assoc attempte as a
4891 * new one is about to be tried
4892 */
4893 roam_info_ptr = &roam_info;
4894 roam_info_ptr->pProfile = profile;
4895 csr_roam_call_callback(mac_ctx, session_id,
4896 roam_info_ptr, cmd->u.roamCmd.roamId,
4897 eCSR_ROAM_ASSOCIATION_COMPLETION,
4898 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4899 }
4900
4901 return roam_state;
4902}
4903
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304904static QDF_STATUS csr_roam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004905{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304906 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907 eCsrJoinState RoamState;
4908 eCsrRoamSubState substate;
4909 uint32_t sessionId = pCommand->sessionId;
4910
4911 /* Attept to join a Bss... */
4912 RoamState = csr_roam_join_next_bss(pMac, pCommand, false);
4913
4914 /* if nothing to join.. */
4915 if ((eCsrStopRoaming == RoamState) ||
4916 (eCsrStopRoamingDueToConcurrency == RoamState)) {
4917 bool fComplete = false;
4918 /* and if connected in Infrastructure mode... */
4919 if (csr_is_conn_state_infra(pMac, sessionId)) {
4920 /* ... then we need to issue a disassociation */
4921 substate = eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN;
4922 status = csr_roam_issue_disassociate(pMac, sessionId,
4923 substate, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304924 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004925 sms_log(pMac, LOGW,
4926 FL("fail issuing disassoc status = %d"),
4927 status);
4928 /*
4929 * roam command is completed by caller in the
4930 * failed case
4931 */
4932 fComplete = true;
4933 }
4934 } else if (csr_is_conn_state_ibss(pMac, sessionId)) {
4935 status = csr_roam_issue_stop_bss(pMac, sessionId,
4936 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304937 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004938 sms_log(pMac, LOGW,
4939 FL("fail issuing stop bss status = %d"),
4940 status);
4941 /*
4942 * roam command is completed by caller in the
4943 * failed case
4944 */
4945 fComplete = true;
4946 }
4947 } else if (csr_is_conn_state_connected_infra_ap(pMac,
4948 sessionId)) {
4949 substate = eCSR_ROAM_SUBSTATE_STOP_BSS_REQ;
4950 status = csr_roam_issue_stop_bss(pMac, sessionId,
4951 substate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304952 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953 sms_log(pMac, LOGW,
4954 FL("fail issuing stop bss status = %d"),
4955 status);
4956 /*
4957 * roam command is completed by caller in the
4958 * failed case
4959 */
4960 fComplete = true;
4961 }
4962 } else {
4963 fComplete = true;
4964 }
4965
4966 if (fComplete) {
4967 /* otherwise, we can complete the Roam command here. */
4968 if (eCsrStopRoamingDueToConcurrency == RoamState)
4969 csr_roam_complete(pMac,
4970 eCsrJoinFailureDueToConcurrency, NULL);
4971 else
4972 csr_roam_complete(pMac,
4973 eCsrNothingToJoin, NULL);
4974 }
4975 } else if (eCsrReassocToSelfNoCapChange == RoamState) {
4976 csr_roam_complete(pMac, eCsrSilentlyStopRoamingSaveState,
4977 NULL);
4978 } else if (eCsrStartIbssSameIbss == RoamState) {
4979 csr_roam_complete(pMac, eCsrSilentlyStopRoaming, NULL);
4980 }
4981
4982 return status;
4983}
4984
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304985QDF_STATUS csr_process_ft_reassoc_roam_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004986 tSmeCmd *pCommand)
4987{
4988 uint32_t sessionId;
4989 tCsrRoamSession *pSession;
4990 tCsrScanResult *pScanResult = NULL;
4991 tSirBssDescription *pBssDesc = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304992 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004993 sessionId = pCommand->sessionId;
4994 pSession = CSR_GET_SESSION(pMac, sessionId);
4995
4996 if (!pSession) {
4997 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304998 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004999 }
5000
5001 if (CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming) {
5002 /* the roaming is cancelled. Simply complete the command */
5003 sms_log(pMac, LOG1, FL("Roam command canceled"));
5004 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305005 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005006 }
5007 if (pCommand->u.roamCmd.pRoamBssEntry) {
5008 pScanResult =
5009 GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry,
5010 tCsrScanResult, Link);
5011 pBssDesc = &pScanResult->Result.BssDescriptor;
5012 } else {
5013 /* the roaming is cancelled. Simply complete the command */
5014 sms_log(pMac, LOG1, FL("Roam command canceled"));
5015 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305016 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005017 }
5018 status = csr_roam_issue_reassociate(pMac, sessionId, pBssDesc,
5019 (tDot11fBeaconIEs *) (pScanResult->
5020 Result.pvIes),
5021 &pCommand->u.roamCmd.roamProfile);
5022 return status;
5023}
5024
5025/**
5026 * csr_roam_trigger_reassociate() - Helper function to trigger reassociate
5027 * @mac_ctx: pointer to mac context
5028 * @cmd: sme command
5029 * @roam_info: Roaming infor structure
5030 * @session_ptr: session pointer
5031 * @session_id: session id
5032 *
5033 * This function will trigger reassociate.
5034 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305035 * Return: QDF_STATUS for success or failure.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005036 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305037static QDF_STATUS csr_roam_trigger_reassociate(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005038 tSmeCmd *cmd, tCsrRoamInfo *roam_info,
5039 tCsrRoamSession *session_ptr, uint32_t session_id)
5040{
5041 tDot11fBeaconIEs *pIes = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305042 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005043
5044 if (session_ptr->pConnectBssDesc) {
5045 status = csr_get_parsed_bss_description_ies(mac_ctx,
5046 session_ptr->pConnectBssDesc, &pIes);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305047 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005048 sms_log(mac_ctx, LOGE, FL("fail to parse IEs"));
5049 } else {
5050 roam_info->reasonCode =
5051 eCsrRoamReasonStaCapabilityChanged;
5052 csr_roam_call_callback(mac_ctx, session_ptr->sessionId,
5053 roam_info, 0, eCSR_ROAM_ROAMING_START,
5054 eCSR_ROAM_RESULT_NONE);
5055 session_ptr->roamingReason = eCsrReassocRoaming;
5056 roam_info->pBssDesc = session_ptr->pConnectBssDesc;
5057 roam_info->pProfile = &cmd->u.roamCmd.roamProfile;
5058 session_ptr->bRefAssocStartCnt++;
5059 csr_roam_call_callback(mac_ctx, session_id, roam_info,
5060 cmd->u.roamCmd.roamId,
5061 eCSR_ROAM_ASSOCIATION_START,
5062 eCSR_ROAM_RESULT_NONE);
5063
5064 sms_log(mac_ctx, LOG1,
5065 FL("calling csr_roam_issue_reassociate"));
5066 status = csr_roam_issue_reassociate(mac_ctx, session_id,
5067 session_ptr->pConnectBssDesc, pIes,
5068 &cmd->u.roamCmd.roamProfile);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305069 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005070 sms_log(mac_ctx, LOGE, FL("failed status %d"),
5071 status);
5072 csr_release_command_roam(mac_ctx, cmd);
5073 }
5074
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305075 qdf_mem_free(pIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005076 pIes = NULL;
5077 }
5078 } else {
5079 sms_log(mac_ctx, LOGE, FL
5080 ("reassoc to same AP failed as connected BSS is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305081 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005082 }
5083 return status;
5084}
5085
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305086QDF_STATUS csr_roam_process_command(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005087{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305088 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005089 tCsrRoamInfo roamInfo;
5090 uint32_t sessionId = pCommand->sessionId;
5091 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
5092
5093 if (!pSession) {
5094 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305095 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005096 }
5097 sms_log(pMac, LOG1, FL("Roam Reason : %d, sessionId: %d"),
5098 pCommand->u.roamCmd.roamReason, sessionId);
5099
5100 switch (pCommand->u.roamCmd.roamReason) {
5101 case eCsrForcedDisassoc:
5102 if (eCSR_ROAMING_STATE_IDLE == pMac->roam.curState[sessionId]) {
5103 sms_log(pMac, LOGE,
5104 FL("Ignore eCsrForcedDisassoc cmd on roam state"
5105 " %d"), eCSR_ROAMING_STATE_IDLE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305106 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005107 }
5108
5109 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
5110 true, false);
5111 csr_free_roam_profile(pMac, sessionId);
5112 break;
5113 case eCsrSmeIssuedDisassocForHandoff:
5114 /* Not to free pMac->roam.pCurRoamProfile (via
5115 * csr_free_roam_profile) because its needed after disconnect */
5116 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
5117 true, false);
5118
5119 break;
5120 case eCsrForcedDisassocMICFailure:
5121 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
5122 true, true);
5123 csr_free_roam_profile(pMac, sessionId);
5124 break;
5125 case eCsrForcedDeauth:
5126 status = csr_roam_process_disassoc_deauth(pMac, pCommand,
5127 false, false);
5128 csr_free_roam_profile(pMac, sessionId);
5129 break;
5130 case eCsrHddIssuedReassocToSameAP:
5131 case eCsrSmeIssuedReassocToSameAP:
5132 status = csr_roam_trigger_reassociate(pMac, pCommand, &roamInfo,
5133 pSession, sessionId);
5134 break;
5135 case eCsrCapsChange:
5136 sms_log(pMac, LOGE, FL("received eCsrCapsChange "));
5137 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
5138 sessionId);
5139 status = csr_roam_issue_disassociate(pMac, sessionId,
5140 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
5141 false);
5142 break;
5143 case eCsrSmeIssuedFTReassoc:
5144 sms_log(pMac, LOG1, FL("received FT Reassoc Req "));
5145 status = csr_process_ft_reassoc_roam_command(pMac, pCommand);
5146 break;
5147
5148 case eCsrStopBss:
5149 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
5150 sessionId);
5151 status = csr_roam_issue_stop_bss(pMac, sessionId,
5152 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
5153 break;
5154
5155 case eCsrForcedDisassocSta:
5156 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
5157 sessionId);
5158 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ,
5159 sessionId);
5160 status = csr_send_mb_disassoc_req_msg(pMac, sessionId,
5161 pCommand->u.roamCmd.peerMac,
5162 pCommand->u.roamCmd.reason);
5163 break;
5164
5165 case eCsrForcedDeauthSta:
5166 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
5167 sessionId);
5168 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ,
5169 sessionId);
5170 status = csr_send_mb_deauth_req_msg(pMac, sessionId,
5171 pCommand->u.roamCmd.peerMac,
5172 pCommand->u.roamCmd.reason);
5173 break;
5174
5175 case eCsrPerformPreauth:
5176 sms_log(pMac, LOG1, FL("Attempting FT PreAuth Req"));
5177 status = csr_roam_issue_ft_preauth_req(pMac, sessionId,
5178 pCommand->u.roamCmd.pLastRoamBss);
5179 break;
5180 default:
5181 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING,
5182 sessionId);
5183
5184 if (pCommand->u.roamCmd.fUpdateCurRoamProfile) {
5185 /* Remember the roaming profile */
5186 csr_free_roam_profile(pMac, sessionId);
5187 pSession->pCurRoamProfile =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305188 qdf_mem_malloc(sizeof(tCsrRoamProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005189 if (NULL != pSession->pCurRoamProfile) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305190 qdf_mem_set(pSession->pCurRoamProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005191 sizeof(tCsrRoamProfile), 0);
5192 csr_roam_copy_profile(pMac,
5193 pSession->pCurRoamProfile,
5194 &pCommand->u.roamCmd.roamProfile);
5195 }
5196 }
5197 /*
5198 * At this point original uapsd_mask is saved in
5199 * pCurRoamProfile. uapsd_mask in the pCommand may change from
5200 * this point on. Attempt to roam with the new scan results
5201 * (if we need to..)
5202 */
5203 status = csr_roam(pMac, pCommand);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305204 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005205 sms_log(pMac, LOGW,
5206 FL("csr_roam() failed with status = 0x%08X"),
5207 status);
5208 break;
5209 }
5210 return status;
5211}
5212
5213void csr_reinit_preauth_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5214{
5215 pCommand->u.roamCmd.pLastRoamBss = NULL;
5216 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5217 /* Because u.roamCmd is union and share with scanCmd and StatusChange */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305218 qdf_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005219}
5220
5221void csr_reinit_roam_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5222{
5223 if (pCommand->u.roamCmd.fReleaseBssList) {
5224 csr_scan_result_purge(pMac, pCommand->u.roamCmd.hBSSList);
5225 pCommand->u.roamCmd.fReleaseBssList = false;
5226 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5227 }
5228 if (pCommand->u.roamCmd.fReleaseProfile) {
5229 csr_release_profile(pMac, &pCommand->u.roamCmd.roamProfile);
5230 pCommand->u.roamCmd.fReleaseProfile = false;
5231 }
5232 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5233 /* Because u.roamCmd is union and share with scanCmd and StatusChange */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305234 qdf_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005235}
5236
5237void csr_reinit_wm_status_change_cmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5238{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305239 qdf_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005240 0);
5241}
5242
5243void csr_roam_complete(tpAniSirGlobal pMac, eCsrRoamCompleteResult Result,
5244 void *Context)
5245{
5246 tListElem *pEntry;
5247 tSmeCmd *pCommand;
5248 bool fReleaseCommand = true;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305249 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005250 "%s: Roam Completion ...", __func__);
5251 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
5252 if (pEntry) {
5253 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
5254 /* If the head of the queue is Active and it is a ROAM command, remove */
5255 /* and put this on the Free queue. */
5256 if (eSmeCommandRoam == pCommand->command) {
5257 /* we need to process the result first before removing it from active list because state changes */
5258 /* still happening insides roamQProcessRoamResults so no other roam command should be issued */
5259 fReleaseCommand =
5260 csr_roam_process_results(pMac, pCommand, Result,
5261 Context);
5262 if (fReleaseCommand) {
5263 if (csr_ll_remove_entry
5264 (&pMac->sme.smeCmdActiveList, pEntry,
5265 LL_ACCESS_LOCK)) {
5266 csr_release_command_roam(pMac, pCommand);
5267 } else {
5268 sms_log(pMac, LOGE,
5269 " **********csr_roam_complete fail to release command reason %d",
5270 pCommand->u.roamCmd.roamReason);
5271 }
5272 } else {
5273 sms_log(pMac, LOGE,
5274 " **********csr_roam_complete fail to release command reason %d",
5275 pCommand->u.roamCmd.roamReason);
5276 }
5277 } else {
5278 sms_log(pMac, LOGW,
5279 "CSR: Roam Completion called but ROAM command is not ACTIVE ...");
5280 }
5281 } else {
5282 sms_log(pMac, LOGW,
5283 "CSR: Roam Completion called but NO commands are ACTIVE ...");
5284 }
5285 if (fReleaseCommand) {
5286 sme_process_pending_queue(pMac);
5287 }
5288}
5289
5290void csr_reset_pmkid_candidate_list(tpAniSirGlobal pMac, uint32_t sessionId)
5291{
5292 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
5293 if (!pSession) {
5294 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
5295 return;
5296 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305297 qdf_mem_set(&(pSession->PmkidCandidateInfo[0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005298 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
5299 pSession->NumPmkidCandidate = 0;
5300}
5301
5302#ifdef FEATURE_WLAN_WAPI
5303void csr_reset_bkid_candidate_list(tpAniSirGlobal pMac, uint32_t sessionId)
5304{
5305 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
5306 if (!pSession) {
5307 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
5308 return;
5309 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305310 qdf_mem_set(&(pSession->BkidCandidateInfo[0]),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005311 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
5312 pSession->NumBkidCandidate = 0;
5313}
5314#endif /* FEATURE_WLAN_WAPI */
5315extern uint8_t csr_wpa_oui[][CSR_WPA_OUI_SIZE];
5316
5317/**
5318 * csr_roam_save_params() - Helper function to save params
5319 * @mac_ctx: pointer to mac context
5320 * @session_ptr: Session pointer
5321 * @auth_type: auth type
5322 * @ie_ptr: pointer to ie
5323 * @ie_local: pointr to local ie
5324 *
5325 * This function will save params to session
5326 *
5327 * Return: none.
5328 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305329static QDF_STATUS csr_roam_save_params(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005330 tCsrRoamSession *session_ptr,
5331 eCsrAuthType auth_type,
5332 tDot11fBeaconIEs *ie_ptr,
5333 tDot11fBeaconIEs *ie_local)
5334{
5335 uint32_t nIeLen;
5336 uint8_t *pIeBuf;
5337
5338 if ((eCSR_AUTH_TYPE_RSN == auth_type) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005339 (eCSR_AUTH_TYPE_FT_RSN == auth_type) ||
5340 (eCSR_AUTH_TYPE_FT_RSN_PSK == auth_type) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341#if defined WLAN_FEATURE_11W
5342 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == auth_type) ||
5343 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == auth_type) ||
5344#endif
5345 (eCSR_AUTH_TYPE_RSN_PSK == auth_type)) {
5346 if (ie_local->RSN.present) {
5347 tDot11fIERSN *rsnie = &ie_local->RSN;
5348 /*
5349 * Calculate the actual length
5350 * version + gp_cipher_suite + pwise_cipher_suite_count
5351 * + akm_suite_count + reserved + pwise_cipher_suites
5352 */
5353 nIeLen = 8 + 2 + 2
5354 + (rsnie->pwise_cipher_suite_count * 4)
5355 + (rsnie->akm_suite_count * 4);
5356 if (rsnie->pmkid_count)
5357 /* pmkid */
5358 nIeLen += 2 + rsnie->pmkid_count * 4;
5359
5360 /* nIeLen doesn't count EID and length fields */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305361 session_ptr->pWpaRsnRspIE = qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005362 if (NULL == session_ptr->pWpaRsnRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305363 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005364
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305365 qdf_mem_set(session_ptr->pWpaRsnRspIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005366 nIeLen + 2, 0);
5367 session_ptr->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5368 session_ptr->pWpaRsnRspIE[1] = (uint8_t) nIeLen;
5369 /* copy upto akm_suites */
5370 pIeBuf = session_ptr->pWpaRsnRspIE + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305371 qdf_mem_copy(pIeBuf, &rsnie->version,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005372 sizeof(rsnie->version));
5373 pIeBuf += sizeof(rsnie->version);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305374 qdf_mem_copy(pIeBuf, &rsnie->gp_cipher_suite,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005375 sizeof(rsnie->gp_cipher_suite));
5376 pIeBuf += sizeof(rsnie->gp_cipher_suite);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305377 qdf_mem_copy(pIeBuf, &rsnie->pwise_cipher_suite_count,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005378 sizeof(rsnie->pwise_cipher_suite_count));
5379 pIeBuf += sizeof(rsnie->pwise_cipher_suite_count);
5380 if (rsnie->pwise_cipher_suite_count) {
5381 /* copy pwise_cipher_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305382 qdf_mem_copy(pIeBuf, rsnie->pwise_cipher_suites,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005383 rsnie->pwise_cipher_suite_count * 4);
5384 pIeBuf += rsnie->pwise_cipher_suite_count * 4;
5385 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305386 qdf_mem_copy(pIeBuf, &rsnie->akm_suite_count, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005387 pIeBuf += 2;
5388 if (rsnie->akm_suite_count) {
5389 /* copy akm_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305390 qdf_mem_copy(pIeBuf, rsnie->akm_suites,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005391 rsnie->akm_suite_count * 4);
5392 pIeBuf += rsnie->akm_suite_count * 4;
5393 }
5394 /* copy the rest */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305395 qdf_mem_copy(pIeBuf, rsnie->akm_suites +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005396 rsnie->akm_suite_count * 4,
5397 2 + rsnie->pmkid_count * 4);
5398 session_ptr->nWpaRsnRspIeLength = nIeLen + 2;
5399 }
5400 } else if ((eCSR_AUTH_TYPE_WPA == auth_type) ||
5401 (eCSR_AUTH_TYPE_WPA_PSK == auth_type)) {
5402 if (ie_local->WPA.present) {
5403 tDot11fIEWPA *wpaie = &ie_local->WPA;
5404 /* Calculate the actual length wpaie */
5405 nIeLen = 12 + 2 /* auth_suite_count */
5406 + wpaie->unicast_cipher_count * 4
5407 + wpaie->auth_suite_count * 4;
5408
5409 /* The WPA capabilities follows the Auth Suite
5410 * (two octects)-- this field is optional, and
5411 * we always "send" zero, so just remove it. This is
5412 * consistent with our assumptions in the frames
5413 * compiler; nIeLen doesn't count EID & length fields */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305414 session_ptr->pWpaRsnRspIE = qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005415 if (NULL == session_ptr->pWpaRsnRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305416 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005417 session_ptr->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5418 session_ptr->pWpaRsnRspIE[1] = (uint8_t) nIeLen;
5419 pIeBuf = session_ptr->pWpaRsnRspIE + 2;
5420 /* Copy WPA OUI */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305421 qdf_mem_copy(pIeBuf, &csr_wpa_oui[1], 4);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005422 pIeBuf += 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305423 qdf_mem_copy(pIeBuf, &wpaie->version,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005424 8 + wpaie->unicast_cipher_count * 4);
5425 pIeBuf += 8 + wpaie->unicast_cipher_count * 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305426 qdf_mem_copy(pIeBuf, &wpaie->auth_suite_count,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005427 2 + wpaie->auth_suite_count * 4);
5428 pIeBuf += wpaie->auth_suite_count * 4;
5429 session_ptr->nWpaRsnRspIeLength = nIeLen + 2;
5430 }
5431 }
5432#ifdef FEATURE_WLAN_WAPI
5433 else if ((eCSR_AUTH_TYPE_WAPI_WAI_PSK == auth_type) ||
5434 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ==
5435 auth_type)) {
5436 if (ie_local->WAPI.present) {
5437 tDot11fIEWAPI *wapi_ie = &ie_local->WAPI;
5438 /* Calculate the actual length of wapi ie*/
5439 nIeLen = 4 + 2 /* pwise_cipher_suite_count */
5440 + wapi_ie->akm_suite_count * 4
5441 + wapi_ie->unicast_cipher_suite_count * 4
5442 + 6; /* gp_cipher_suite + preauth + reserved */
5443
5444 if (wapi_ie->bkid_count)
5445 nIeLen += 2 + wapi_ie->bkid_count * 4;
5446
5447 /* nIeLen doesn't count EID and length fields */
5448 session_ptr->pWapiRspIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305449 qdf_mem_malloc(nIeLen + 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005450 if (NULL == session_ptr->pWapiRspIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305451 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005452 session_ptr->pWapiRspIE[0] = DOT11F_EID_WAPI;
5453 session_ptr->pWapiRspIE[1] = (uint8_t) nIeLen;
5454 pIeBuf = session_ptr->pWapiRspIE + 2;
5455 /* copy upto akm_suite_count */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305456 qdf_mem_copy(pIeBuf, &wapi_ie->version, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005457 pIeBuf += 4;
5458 if (wapi_ie->akm_suite_count) {
5459 /* copy akm_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305460 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005461 wapi_ie->akm_suites,
5462 wapi_ie->akm_suite_count * 4);
5463 pIeBuf += wapi_ie->akm_suite_count * 4;
5464 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305465 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466 &wapi_ie->unicast_cipher_suite_count, 2);
5467 pIeBuf += 2;
5468 if (wapi_ie->unicast_cipher_suite_count) {
5469 uint16_t suite_size =
5470 wapi_ie->unicast_cipher_suite_count * 4;
5471 /* copy pwise_cipher_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305472 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005473 wapi_ie->unicast_cipher_suites,
5474 suite_size);
5475 pIeBuf += suite_size;
5476 }
5477 /* gp_cipher_suite */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305478 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005479 wapi_ie->multicast_cipher_suite, 4);
5480 pIeBuf += 4;
5481 /* preauth + reserved */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305482 qdf_mem_copy(pIeBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005483 wapi_ie->multicast_cipher_suite + 4, 2);
5484 pIeBuf += 2;
5485 if (wapi_ie->bkid_count) {
5486 /* bkid_count */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305487 qdf_mem_copy(pIeBuf, &wapi_ie->bkid_count, 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005488 pIeBuf += 2;
5489 /* copy akm_suites */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305490 qdf_mem_copy(pIeBuf, wapi_ie->bkid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491 wapi_ie->bkid_count * 4);
5492 pIeBuf += wapi_ie->bkid_count * 4;
5493 }
5494 session_ptr->nWapiRspIeLength = nIeLen + 2;
5495 }
5496 }
5497#endif /* FEATURE_WLAN_WAPI */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305498 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005499}
5500
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305501static QDF_STATUS csr_roam_save_security_rsp_ie(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005502 uint32_t sessionId,
5503 eCsrAuthType authType,
5504 tSirBssDescription *pSirBssDesc,
5505 tDot11fBeaconIEs *pIes)
5506{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305507 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005508 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
5509 tDot11fBeaconIEs *pIesLocal = pIes;
5510
5511 if (!pSession) {
5512 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305513 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005515
5516 if ((eCSR_AUTH_TYPE_WPA == authType) ||
5517 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
5518 (eCSR_AUTH_TYPE_RSN == authType) ||
5519 (eCSR_AUTH_TYPE_RSN_PSK == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005520 || (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5521 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522#ifdef FEATURE_WLAN_WAPI
5523 || (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5524 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
5525#endif /* FEATURE_WLAN_WAPI */
5526#ifdef WLAN_FEATURE_11W
5527 || (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
5528 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
5529#endif /* FEATURE_WLAN_WAPI */
5530 ) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305531 if (!pIesLocal && !QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005532 (csr_get_parsed_bss_description_ies(pMac,
5533 pSirBssDesc, &pIesLocal)))
5534 sms_log(pMac, LOGE, FL(" cannot parse IEs"));
5535 if (pIesLocal) {
5536 status = csr_roam_save_params(pMac, pSession, authType,
5537 pIes, pIesLocal);
5538 if (!pIes)
5539 /* locally allocated */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305540 qdf_mem_free(pIesLocal);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005541 }
5542 }
5543 return status;
5544}
5545
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005546/* Returns whether the current association is a 11r assoc or not */
5547bool csr_roam_is11r_assoc(tpAniSirGlobal pMac, uint8_t sessionId)
5548{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549 return csr_neighbor_roam_is11r_assoc(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005550}
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -08005551
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552#ifdef FEATURE_WLAN_ESE
5553/* Returns whether the current association is a ESE assoc or not */
5554bool csr_roam_is_ese_assoc(tpAniSirGlobal pMac, uint8_t sessionId)
5555{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005556 return csr_neighbor_roam_is_ese_assoc(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005557}
5558#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559/* Returns whether "Legacy Fast Roaming" is currently enabled...or not */
5560bool csr_roam_is_fast_roam_enabled(tpAniSirGlobal pMac, uint32_t sessionId)
5561{
5562 tCsrRoamSession *pSession = NULL;
5563
5564 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
5565 pSession = CSR_GET_SESSION(pMac, sessionId);
5566 if (NULL != pSession->pCurRoamProfile) {
5567 if (pSession->pCurRoamProfile->csrPersona !=
Anurag Chouhan6d760662016-02-20 16:05:43 +05305568 QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005569 return false;
5570 }
5571 }
5572 }
5573 if (true == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac)) {
5574 return pMac->roam.configParam.isFastRoamIniFeatureEnabled;
5575 } else {
5576 return pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
5577 (!csr_is_concurrent_session_running(pMac));
5578 }
5579}
5580
5581#ifdef FEATURE_WLAN_ESE
5582/**
5583 * csr_neighbor_roam_is_ese_assoc() - Check the Association type
5584 * @mac_ctx: Global MAC Context
5585 * @session_id: Session ID on which the check should be done
5586 *
5587 * This function returns whether the current association
5588 * is a ESE assoc or not
5589 *
5590 * Return: True if ESE association, false otherwise.
5591 **/
5592bool csr_neighbor_roam_is_ese_assoc(tpAniSirGlobal mac_ctx, uint8_t session_id)
5593{
5594 return mac_ctx->roam.neighborRoamInfo[session_id].isESEAssoc;
5595}
5596#endif /* FEATURE_WLAN_ESE */
5597
5598/* Returns whether "FW based BG scan" is currently enabled...or not */
5599bool csr_roam_is_roam_offload_scan_enabled(tpAniSirGlobal pMac)
5600{
5601 return pMac->roam.configParam.isRoamOffloadScanEnabled;
5602}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005603
5604#if defined(FEATURE_WLAN_ESE)
5605bool csr_roam_is_ese_ini_feature_enabled(tpAniSirGlobal pMac)
5606{
5607 return pMac->roam.configParam.isEseIniFeatureEnabled;
5608}
5609#endif /*FEATURE_WLAN_ESE */
5610
5611#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5612eCsrPhyMode csr_roamdot11mode_to_phymode(uint8_t dot11mode)
5613{
5614 eCsrPhyMode phymode = eCSR_DOT11_MODE_abg;
5615
5616 switch (dot11mode) {
5617 case WNI_CFG_DOT11_MODE_ALL:
5618 phymode = eCSR_DOT11_MODE_abg;
5619 break;
5620 case WNI_CFG_DOT11_MODE_11A:
5621 phymode = eCSR_DOT11_MODE_11a;
5622 break;
5623 case WNI_CFG_DOT11_MODE_11B:
5624 phymode = eCSR_DOT11_MODE_11b;
5625 break;
5626 case WNI_CFG_DOT11_MODE_11G:
5627 phymode = eCSR_DOT11_MODE_11g;
5628 break;
5629 case WNI_CFG_DOT11_MODE_11N:
5630 phymode = eCSR_DOT11_MODE_11n;
5631 break;
5632 case WNI_CFG_DOT11_MODE_11G_ONLY:
5633 phymode = eCSR_DOT11_MODE_11g_ONLY;
5634 break;
5635 case WNI_CFG_DOT11_MODE_11N_ONLY:
5636 phymode = eCSR_DOT11_MODE_11n_ONLY;
5637 break;
5638 case WNI_CFG_DOT11_MODE_11AC:
5639 phymode = eCSR_DOT11_MODE_11ac;
5640 break;
5641 case WNI_CFG_DOT11_MODE_11AC_ONLY:
5642 phymode = eCSR_DOT11_MODE_11ac_ONLY;
5643 break;
5644 default:
5645 break;
5646 }
5647
5648 return phymode;
5649}
5650#endif
5651
5652#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005653void csr_roam_synch_clean_up (tpAniSirGlobal mac, uint8_t session_id)
5654{
5655 cds_msg_t msg;
5656 struct roam_offload_synch_fail *roam_offload_failed = NULL;
5657 tCsrRoamSession *session = &mac->roam.roamSession[session_id];
5658
5659 /* Clean up the roam synch in progress for LFR3 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305660 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 "%s: Roam Synch Failed, Clean Up", __func__);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08005662 session->roam_synch_in_progress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305664 roam_offload_failed = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005665 sizeof(struct roam_offload_synch_fail));
5666 if (NULL == roam_offload_failed) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305667 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005668 "%s: unable to allocate memory for roam synch fail" ,
5669 __func__);
5670 return;
5671 }
5672
5673 roam_offload_failed->session_id = session_id;
5674 msg.type = WMA_ROAM_OFFLOAD_SYNCH_FAIL;
5675 msg.reserved = 0;
5676 msg.bodyptr = roam_offload_failed;
Anurag Chouhan6d760662016-02-20 16:05:43 +05305677 if (!QDF_IS_STATUS_SUCCESS(cds_mq_post_message(QDF_MODULE_ID_WMA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678 &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305679 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005680 "%s: Unable to post WMA_ROAM_OFFLOAD_SYNCH_FAIL to WMA",
5681 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305682 qdf_mem_free(roam_offload_failed);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005683 }
5684}
5685#endif
5686
5687#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5688/**
5689 * csr_roam_copy_ht_profile() - Copy from src to dst
5690 * @dst_profile: Destination HT profile
5691 * @src_profile: Source HT profile
5692 *
5693 * Copy the HT profile from the given source to destination
5694 *
5695 * Return: None
5696 */
5697static void csr_roam_copy_ht_profile(tCsrRoamHTProfile *dst_profile,
5698 tSirSmeHTProfile *src_profile)
5699{
5700 dst_profile->phymode =
5701 csr_roamdot11mode_to_phymode(src_profile->dot11mode);
5702 dst_profile->htCapability = src_profile->htCapability;
5703 dst_profile->htSupportedChannelWidthSet =
5704 src_profile->htSupportedChannelWidthSet;
5705 dst_profile->htRecommendedTxWidthSet =
5706 src_profile->htRecommendedTxWidthSet;
5707 dst_profile->htSecondaryChannelOffset =
5708 src_profile->htSecondaryChannelOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005709 dst_profile->vhtCapability = src_profile->vhtCapability;
5710 dst_profile->vhtTxChannelWidthSet = src_profile->vhtTxChannelWidthSet;
5711 dst_profile->apCenterChan = src_profile->apCenterChan;
5712 dst_profile->apChanWidth = src_profile->apChanWidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005713}
5714#endif
5715
5716/**
5717 * csr_roam_process_results_default() - Process the result for start bss
5718 * @mac_ctx: Global MAC Context
5719 * @cmd: Command to be processed
5720 * @context: Additional data in context of the cmd
5721 *
5722 * Return: None
5723 */
5724static void csr_roam_process_results_default(tpAniSirGlobal mac_ctx,
5725 tSmeCmd *cmd, void *context, eCsrRoamCompleteResult res)
5726{
5727 uint32_t session_id = cmd->sessionId;
5728 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
5729 tCsrRoamInfo roam_info;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305730 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005731
5732 sms_log(mac_ctx, LOGW, FL("receives no association indication"));
5733 sms_log(mac_ctx, LOG1, FL("Assoc ref count %d"),
5734 session->bRefAssocStartCnt);
5735 if (CSR_IS_INFRASTRUCTURE(&session->connectedProfile)
5736 || CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ(mac_ctx, session_id)) {
5737 /*
5738 * do not free for the other profiles as we need
5739 * to send down stop BSS later
5740 */
5741 csr_free_connect_bss_desc(mac_ctx, session_id);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08005742 csr_roam_free_connect_profile(&session->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005743 csr_roam_free_connected_info(mac_ctx, &session->connectedInfo);
5744 csr_set_default_dot11_mode(mac_ctx);
5745 }
5746
5747 switch (cmd->u.roamCmd.roamReason) {
5748 /*
5749 * If this transition is because of an 802.11 OID, then we
5750 * transition back to INIT state so we sit waiting for more
5751 * OIDs to be issued and we don't start the IDLE timer.
5752 */
5753 case eCsrSmeIssuedFTReassoc:
5754 case eCsrSmeIssuedAssocToSimilarAP:
5755 case eCsrHddIssued:
5756 case eCsrSmeIssuedDisassocForHandoff:
5757 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
5758 session_id);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305759 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005760 roam_info.pBssDesc = cmd->u.roamCmd.pLastRoamBss;
5761 roam_info.pProfile = &cmd->u.roamCmd.roamProfile;
5762 roam_info.statusCode = session->joinFailStatusCode.statusCode;
5763 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305764 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005765 &session->joinFailStatusCode.bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305766 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005767
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768 /*
5769 * If Join fails while Handoff is in progress, indicate
5770 * disassociated event to supplicant to reconnect
5771 */
5772 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)) {
5773 csr_neighbor_roam_indicate_connect(mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305774 (uint8_t)session_id, QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005775 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005776 if (session->bRefAssocStartCnt > 0) {
5777 session->bRefAssocStartCnt--;
5778 if (eCsrJoinFailureDueToConcurrency == res)
5779 csr_roam_call_callback(mac_ctx, session_id,
5780 &roam_info, cmd->u.roamCmd.roamId,
5781 eCSR_ROAM_ASSOCIATION_COMPLETION,
5782 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5783 else
5784 csr_roam_call_callback(mac_ctx, session_id,
5785 &roam_info, cmd->u.roamCmd.roamId,
5786 eCSR_ROAM_ASSOCIATION_COMPLETION,
5787 eCSR_ROAM_RESULT_FAILURE);
5788 } else {
5789 /*
5790 * bRefAssocStartCnt is not incremented when
5791 * eRoamState == eCsrStopRoamingDueToConcurrency
5792 * in csr_roam_join_next_bss API. so handle this in
5793 * else case by sending assoc failure
5794 */
5795 csr_roam_call_callback(mac_ctx, session_id,
5796 &roam_info, cmd->u.scanCmd.roamId,
5797 eCSR_ROAM_ASSOCIATION_FAILURE,
5798 eCSR_ROAM_RESULT_FAILURE);
5799 }
5800 sms_log(mac_ctx, LOG1, FL("roam(reason %d) failed"),
5801 cmd->u.roamCmd.roamReason);
5802#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5803 sme_qos_update_hand_off((uint8_t) session_id, false);
5804 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
5805 SME_QOS_CSR_DISCONNECT_IND, NULL);
5806#endif
5807 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
5808 eCSR_ROAM_RESULT_FAILURE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005809 break;
5810 case eCsrHddIssuedReassocToSameAP:
5811 case eCsrSmeIssuedReassocToSameAP:
5812 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
5813 session_id);
5814
5815 csr_roam_call_callback(mac_ctx, session_id, NULL,
5816 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
5817 eCSR_ROAM_RESULT_FORCED);
5818#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5819 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
5820 SME_QOS_CSR_DISCONNECT_IND, NULL);
5821#endif
5822 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
5823 eCSR_ROAM_RESULT_FAILURE, false);
5824 break;
5825 case eCsrForcedDisassoc:
5826 case eCsrForcedDeauth:
5827 case eCsrSmeIssuedIbssJoinFailure:
5828 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
5829 session_id);
5830
5831 if (eCsrSmeIssuedIbssJoinFailure == cmd->u.roamCmd.roamReason)
5832 /* notify HDD that IBSS join failed */
5833 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
5834 eCSR_ROAM_IBSS_IND,
5835 eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5836 else
5837 csr_roam_call_callback(mac_ctx, session_id, NULL,
5838 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
5839 eCSR_ROAM_RESULT_FORCED);
5840#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5841 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
5842 SME_QOS_CSR_DISCONNECT_IND,
5843 NULL);
5844#endif
5845 csr_roam_link_down(mac_ctx, session_id);
5846
5847 if (mac_ctx->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS) {
5848 sms_log(mac_ctx, LOGW,
5849 FL("FW still in connected state"));
5850 break;
5851 }
5852 break;
5853 case eCsrForcedIbssLeave:
5854 csr_roam_call_callback(mac_ctx, session_id, NULL,
5855 cmd->u.roamCmd.roamId, eCSR_ROAM_IBSS_LEAVE,
5856 eCSR_ROAM_RESULT_IBSS_STOP);
Krunal Soni2c68f232015-10-26 20:52:51 -07005857 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005858 break;
5859 case eCsrForcedDisassocMICFailure:
5860 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_IDLE,
5861 session_id);
5862
5863 csr_roam_call_callback(mac_ctx, session_id, NULL,
5864 cmd->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED,
5865 eCSR_ROAM_RESULT_MIC_FAILURE);
5866#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5867 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
5868 SME_QOS_CSR_DISCONNECT_REQ, NULL);
5869#endif
5870 break;
5871 case eCsrStopBss:
5872 csr_roam_call_callback(mac_ctx, session_id, NULL,
5873 cmd->u.roamCmd.roamId, eCSR_ROAM_INFRA_IND,
5874 eCSR_ROAM_RESULT_INFRA_STOPPED);
5875 break;
5876 case eCsrForcedDisassocSta:
5877 case eCsrForcedDeauthSta:
5878 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
5879 session_id);
5880 session = CSR_GET_SESSION(mac_ctx, session_id);
5881 if (CSR_IS_SESSION_VALID(mac_ctx, session_id) &&
5882 CSR_IS_INFRA_AP(&session->connectedProfile)) {
5883 roam_info.u.pConnectedProfile =
5884 &session->connectedProfile;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305885 qdf_mem_copy(roam_info.peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005886 cmd->u.roamCmd.peerMac,
5887 sizeof(tSirMacAddr));
5888 roam_info.reasonCode = eCSR_ROAM_RESULT_FORCED;
5889 roam_info.statusCode = eSIR_SME_SUCCESS;
5890 status = csr_roam_call_callback(mac_ctx, session_id,
5891 &roam_info, cmd->u.roamCmd.roamId,
5892 eCSR_ROAM_LOSTLINK,
5893 eCSR_ROAM_RESULT_FORCED);
5894 }
5895 break;
5896 case eCsrLostLink1:
5897 /* if lost link roam1 failed, then issue lost link Scan2 ... */
5898 csr_scan_request_lost_link2(mac_ctx, session_id);
5899 break;
5900 case eCsrLostLink2:
5901 /* if lost link roam2 failed, then issue lost link scan3 ... */
5902 csr_scan_request_lost_link3(mac_ctx, session_id);
5903 break;
5904 case eCsrLostLink3:
5905 default:
5906 csr_roam_state_change(mac_ctx,
5907 eCSR_ROAMING_STATE_IDLE, session_id);
5908
5909 /* We are done with one round of lostlink roaming here */
5910 csr_scan_handle_failed_lostlink3(mac_ctx, session_id);
5911 break;
5912 }
5913}
5914
5915/**
5916 * csr_roam_process_start_bss_success() - Process the result for start bss
5917 * @mac_ctx: Global MAC Context
5918 * @cmd: Command to be processed
5919 * @context: Additional data in context of the cmd
5920 *
5921 * Return: None
5922 */
5923static void csr_roam_process_start_bss_success(tpAniSirGlobal mac_ctx,
5924 tSmeCmd *cmd, void *context)
5925{
5926 uint32_t session_id = cmd->sessionId;
5927 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
5928 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
5929 tSirBssDescription *bss_desc = NULL;
5930 tCsrRoamInfo roam_info;
5931 tSirSmeStartBssRsp *start_bss_rsp = NULL;
5932 tCsrScanResult *scan_res = NULL;
5933 eRoamCmdStatus roam_status;
5934 eCsrRoamResult roam_result;
5935 tDot11fBeaconIEs *ies_ptr = NULL;
5936 tSirMacAddr bcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305937 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005938 host_log_ibss_pkt_type *ibss_log;
5939 uint32_t bi;
5940#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
5941 tSirSmeHTProfile *src_profile = NULL;
5942 tCsrRoamHTProfile *dst_profile = NULL;
5943#endif
5944
5945 /*
5946 * on the StartBss Response, LIM is returning the Bss Description that
5947 * we are beaconing. Add this Bss Description to our scan results and
5948 * chain the Profile to this Bss Description. On a Start BSS, there was
5949 * no detected Bss description (no partner) so we issued the Start Bss
5950 * to start the Ibss without any Bss description. Lim was kind enough
5951 * to return the Bss Description that we start beaconing for the newly
5952 * started Ibss.
5953 */
5954 sms_log(mac_ctx, LOG2, FL("receives start BSS ok indication"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305955 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005956 start_bss_rsp = (tSirSmeStartBssRsp *) context;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305957 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005958 if (CSR_IS_IBSS(profile))
5959 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5960 else if (CSR_IS_INFRA_AP(profile))
5961 session->connectState =
5962 eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5963 else
5964 session->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07005965 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005966 session_id);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07005967 bss_desc = &start_bss_rsp->bssDescription;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305968 if (!QDF_IS_STATUS_SUCCESS
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07005969 (csr_get_parsed_bss_description_ies(mac_ctx, bss_desc,
5970 &ies_ptr))) {
5971 sms_log(mac_ctx, LOGW, FL("cannot parse IBSS IEs"));
5972 roam_info.pBssDesc = bss_desc;
5973 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
5974 cmd->u.roamCmd.roamId, eCSR_ROAM_IBSS_IND,
5975 eCSR_ROAM_RESULT_IBSS_START_FAILED);
5976 return;
5977 }
5978 if (!CSR_IS_INFRA_AP(profile)) {
5979 scan_res =
5980 csr_scan_append_bss_description(mac_ctx,
5981 bss_desc, ies_ptr, false,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982 session_id);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07005983 }
5984 csr_roam_save_connected_bss_desc(mac_ctx, session_id, bss_desc);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08005985 csr_roam_free_connect_profile(&session->connectedProfile);
5986 csr_roam_free_connected_info(mac_ctx, &session->connectedInfo);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07005987 if (bss_desc) {
5988 csr_roam_save_connected_infomation(mac_ctx, session_id,
5989 profile, bss_desc, ies_ptr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305990 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305991 sizeof(struct qdf_mac_addr));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07005992 }
5993 /* We are done with the IEs so free it */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305994 qdf_mem_free(ies_ptr);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07005995#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5996 WLAN_HOST_DIAG_LOG_ALLOC(ibss_log,
5997 host_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5998 if (ibss_log) {
5999 if (CSR_INVALID_SCANRESULT_HANDLE ==
6000 cmd->u.roamCmd.hBSSList) {
6001 /*
6002 * We start the IBSS (didn't find any
6003 * matched IBSS out there)
6004 */
6005 ibss_log->eventId =
6006 WLAN_IBSS_EVENT_START_IBSS_RSP;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007 } else {
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006008 ibss_log->eventId =
6009 WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
6010 }
6011 if (bss_desc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306012 qdf_mem_copy(ibss_log->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306013 bss_desc->bssId, QDF_MAC_ADDR_SIZE);
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006014 ibss_log->operatingChannel =
6015 bss_desc->channelId;
6016 }
6017 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(
6018 mac_ctx,
6019 WNI_CFG_BEACON_INTERVAL,
6020 &bi)))
6021 /* U8 is not enough for BI */
6022 ibss_log->beaconInterval = (uint8_t) bi;
6023 WLAN_HOST_DIAG_LOG_REPORT(ibss_log);
6024 }
6025#endif
6026 /*
6027 * Only set context for non-WDS_STA. We don't even need it for
6028 * WDS_AP. But since the encryption.
6029 * is WPA2-PSK so it won't matter.
6030 */
6031 if (CSR_IS_ENC_TYPE_STATIC(profile->negotiatedUCEncryptionType)
6032 && session->pCurRoamProfile
6033 && !CSR_IS_INFRA_AP(session->pCurRoamProfile)) {
6034 /*
6035 * Issue the set Context request to LIM to establish
6036 * the Broadcast STA context for the Ibss. In Rome IBSS
6037 * case, dummy key installation will break proper BSS
6038 * key installation, so skip it.
6039 */
6040 if (!CSR_IS_IBSS(session->pCurRoamProfile)) {
6041 /* NO keys. these key parameters don't matter */
6042 csr_roam_issue_set_context_req(mac_ctx,
6043 session_id,
6044 profile->negotiatedMCEncryptionType,
6045 bss_desc, &bcast_mac, false,
6046 false, eSIR_TX_RX, 0, 0, NULL, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006047 }
6048 }
6049 /*
6050 * Only tell upper layer is we start the BSS because Vista doesn't like
6051 * multiple connection indications. If we don't start the BSS ourself,
6052 * handler of eSIR_SME_JOINED_NEW_BSS will trigger the connection start
6053 * indication in Vista
6054 */
6055 if (!CSR_IS_JOIN_TO_IBSS(profile)) {
6056 roam_status = eCSR_ROAM_IBSS_IND;
6057 roam_result = eCSR_ROAM_RESULT_IBSS_STARTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006058 if (CSR_IS_INFRA_AP(profile)) {
6059 roam_status = eCSR_ROAM_INFRA_IND;
6060 roam_result = eCSR_ROAM_RESULT_INFRA_STARTED;
6061 }
6062 /*
6063 * Only tell upper layer is we start the BSS because Vista
6064 * doesn't like multiple connection indications. If we don't
6065 * start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS
6066 * will trigger the connection start indication in Vista
6067 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306068 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006069 roam_info.statusCode = session->joinFailStatusCode.statusCode;
6070 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
6071 /* We start the IBSS (didn't find any matched IBSS out there) */
6072 roam_info.pBssDesc = bss_desc;
6073 roam_info.staId = (uint8_t) start_bss_rsp->staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306074 qdf_mem_copy(roam_info.bssid.bytes, bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306075 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006076 if (!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
6077 (csr_is_concurrent_session_running(mac_ctx))) {
6078 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
6079 }
6080#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6081 dst_profile = &session->connectedProfile.HTProfile;
6082 src_profile = &start_bss_rsp->HTProfile;
6083 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306084 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006085 csr_roam_copy_ht_profile(dst_profile, src_profile);
6086#endif
6087 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
6088 cmd->u.roamCmd.roamId,
6089 roam_status, roam_result);
6090 }
6091
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006092}
6093
6094/**
6095 * csr_roam_process_join_res() - Process the Join results
6096 * @mac_ctx: Global MAC Context
6097 * @result: Result after the command was processed
6098 * @cmd: Command to be processed
6099 * @context: Additional data in context of the cmd
6100 *
6101 * Process the join results which are obtained in a succesful join
6102 *
6103 * Return: None
6104 */
6105static void csr_roam_process_join_res(tpAniSirGlobal mac_ctx,
6106 eCsrRoamCompleteResult res, tSmeCmd *cmd, void *context)
6107{
6108 tSirMacAddr bcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
6109 sme_QosAssocInfo assoc_info;
6110 uint32_t key_timeout_interval = 0;
6111 uint8_t acm_mask = 0; /* HDD needs ACM mask in assoc rsp callback */
6112 uint32_t session_id = cmd->sessionId;
6113 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
6114 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
6115 tSirBssDescription *bss_desc = NULL;
6116 tCsrScanResult *scan_res = NULL;
6117 sme_qos_csr_event_indType ind_qos;
6118 csr_roam_offload_synch_params *roam_offload_params = NULL;
6119#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6120 tSirSmeHTProfile *src_profile = NULL;
6121 tCsrRoamHTProfile *dst_profile = NULL;
6122#endif
6123 tCsrRoamConnectedProfile *conn_profile = NULL;
6124 tDot11fBeaconIEs *ies_ptr = NULL;
6125 tCsrRoamInfo roam_info;
6126 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
6127 tSirSmeJoinRsp *join_rsp = (tSirSmeJoinRsp *) context;
6128 uint32_t len;
6129
6130 roam_offload_params = &session->roamOffloadSynchParams;
6131 conn_profile = &session->connectedProfile;
6132 if (eCsrReassocSuccess == res)
6133 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
6134 else
6135 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
6136 sms_log(mac_ctx, LOGW, FL("receives association indication"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306137 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006138 /* always free the memory here */
6139 if (session->pWpaRsnRspIE) {
6140 session->nWpaRsnRspIeLength = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306141 qdf_mem_free(session->pWpaRsnRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006142 session->pWpaRsnRspIE = NULL;
6143 }
6144#ifdef FEATURE_WLAN_WAPI
6145 if (session->pWapiRspIE) {
6146 session->nWapiRspIeLength = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306147 qdf_mem_free(session->pWapiRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006148 session->pWapiRspIE = NULL;
6149 }
6150#endif /* FEATURE_WLAN_WAPI */
6151#ifdef FEATURE_WLAN_BTAMP_UT_RF
6152 session->maxRetryCount = 0;
6153 csr_roam_stop_join_retry_timer(mac_ctx, session_id);
6154#endif
6155 /*
6156 * Reset remain_in_power_active_till_dhcp as
6157 * it might have been set by last failed secured connection.
6158 * It should be set only for secured connection.
6159 */
6160 ps_global_info->remain_in_power_active_till_dhcp = false;
6161 if (CSR_IS_INFRASTRUCTURE(profile))
6162 session->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
6163 else
6164 session->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
6165 /*
6166 * Use the last connected bssdesc for reassoc-ing to the same AP.
6167 * NOTE: What to do when reassoc to a different AP???
6168 */
6169 if ((eCsrHddIssuedReassocToSameAP == cmd->u.roamCmd.roamReason)
6170 || (eCsrSmeIssuedReassocToSameAP ==
6171 cmd->u.roamCmd.roamReason)) {
6172 bss_desc = session->pConnectBssDesc;
6173 if (bss_desc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306174 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306175 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006176 } else {
6177 if (cmd->u.roamCmd.pRoamBssEntry) {
6178 scan_res = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
6179 tCsrScanResult, Link);
6180 if (scan_res != NULL) {
6181 bss_desc = &scan_res->Result.BssDescriptor;
6182 ies_ptr = (tDot11fBeaconIEs *)
6183 (scan_res->Result.pvIes);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306184 qdf_mem_copy(&roam_info.bssid, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306185 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006186 }
6187 }
6188 }
6189 if (bss_desc) {
6190 roam_info.staId = STA_INVALID_IDX;
6191 csr_roam_save_connected_infomation(mac_ctx, session_id,
6192 profile, bss_desc, ies_ptr);
6193 /* Save WPA/RSN IE */
6194 csr_roam_save_security_rsp_ie(mac_ctx, session_id,
6195 profile->negotiatedAuthType, bss_desc, ies_ptr);
6196#ifdef FEATURE_WLAN_ESE
6197 roam_info.isESEAssoc = conn_profile->isESEAssoc;
6198#endif
6199
6200 /*
6201 * csr_roam_state_change also affects sub-state.
6202 * Hence, csr_roam_state_change happens first and then
6203 * substate change.
6204 * Moving even save profile above so that below
6205 * mentioned conditon is also met.
6206 * JEZ100225: Moved to after saving the profile.
6207 * Fix needed in main/latest
6208 */
6209 csr_roam_state_change(mac_ctx,
6210 eCSR_ROAMING_STATE_JOINED, session_id);
6211
6212 /*
6213 * Make sure the Set Context is issued before link
6214 * indication to NDIS. After link indication is
6215 * made to NDIS, frames could start flowing.
6216 * If we have not set context with LIM, the frames
6217 * will be dropped for the security context may not
6218 * be set properly.
6219 *
6220 * this was causing issues in the 2c_wlan_wep WHQL test
6221 * when the SetContext was issued after the link
6222 * indication. (Link Indication happens in the
6223 * profFSMSetConnectedInfra call).
6224 *
6225 * this reordering was done on titan_prod_usb branch
6226 * and is being replicated here.
6227 */
6228
6229 if (CSR_IS_ENC_TYPE_STATIC
6230 (profile->negotiatedUCEncryptionType) &&
6231 !profile->bWPSAssociation) {
6232 /*
6233 * Issue the set Context request to LIM to establish
6234 * the Unicast STA context
6235 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306236 if (!QDF_IS_STATUS_SUCCESS(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006237 csr_roam_issue_set_context_req(mac_ctx,
6238 session_id,
6239 profile->negotiatedUCEncryptionType,
6240 bss_desc, &(bss_desc->bssId),
6241 false, true,
6242 eSIR_TX_RX, 0, 0, NULL, 0))) {
6243 /* NO keys. these key parameters don't matter */
6244 sms_log(mac_ctx, LOGE,
6245 FL("Set context for unicast fail"));
6246 csr_roam_substate_change(mac_ctx,
6247 eCSR_ROAM_SUBSTATE_NONE, session_id);
6248 }
6249 /*
6250 * Issue the set Context request to LIM
6251 * to establish the Broadcast STA context
6252 * NO keys. these key parameters don't matter
6253 */
6254 csr_roam_issue_set_context_req(mac_ctx, session_id,
6255 profile->negotiatedMCEncryptionType,
6256 bss_desc, &bcast_mac, false, false,
6257 eSIR_TX_RX, 0, 0, NULL, 0);
6258 } else {
6259#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08006260 if (session->roam_synch_in_progress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006261 && (roam_offload_params->authStatus
6262 == CSR_ROAM_AUTH_STATUS_AUTHENTICATED)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306263 QDF_TRACE(QDF_MODULE_ID_SME,
6264 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006265 FL("LFR3:Don't start waitforkey timer"));
6266 csr_roam_substate_change(mac_ctx,
6267 eCSR_ROAM_SUBSTATE_NONE, session_id);
6268 } else {
6269#endif
6270 /* Need to wait for supplicant authtication */
6271 roam_info.fAuthRequired = true;
6272 /*
6273 * Set the substate to WaitForKey in case
6274 * authentiation is needed
6275 */
6276 csr_roam_substate_change(mac_ctx,
6277 eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY,
6278 session_id);
6279
6280 /*
6281 * Set remain_in_power_active_till_dhcp to make
6282 * sure we wait for until keys are set before
6283 * going into BMPS.
6284 */
6285 ps_global_info->remain_in_power_active_till_dhcp
6286 = true;
6287
6288 if (profile->bWPSAssociation)
6289 key_timeout_interval =
6290 CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
6291 else
6292 key_timeout_interval =
6293 CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
6294
6295 /* Save session_id in case of timeout */
6296 mac_ctx->roam.WaitForKeyTimerInfo.sessionId =
6297 (uint8_t) session_id;
6298 /*
6299 * This time should be long enough for the rest
6300 * of the process plus setting key
6301 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306302 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006303 (csr_roam_start_wait_for_key_timer(
6304 mac_ctx, key_timeout_interval))
6305 ) {
6306 /* Reset state so nothing is blocked. */
6307 sms_log(mac_ctx, LOGE, FL
6308 ("Failed preauth timer start"));
6309 csr_roam_substate_change(mac_ctx,
6310 eCSR_ROAM_SUBSTATE_NONE,
6311 session_id);
6312 }
6313#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6314 }
6315#endif
6316 }
6317
6318 assoc_info.pBssDesc = bss_desc; /* could be NULL */
6319 assoc_info.pProfile = profile;
6320 if (context) {
6321#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08006322 if (session->roam_synch_in_progress)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306323 QDF_TRACE(QDF_MODULE_ID_SME,
6324 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006325 FL("LFR3:Clear Connected info"));
6326#endif
6327 csr_roam_free_connected_info(mac_ctx,
6328 &session->connectedInfo);
6329 len = join_rsp->assocReqLength +
6330 join_rsp->assocRspLength +
6331 join_rsp->beaconLength;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006332 len += join_rsp->parsedRicRspLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006333#ifdef FEATURE_WLAN_ESE
6334 len += join_rsp->tspecIeLen;
6335#endif
6336 if (len) {
6337 session->connectedInfo.pbFrames =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306338 qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006339 if (session->connectedInfo.pbFrames !=
6340 NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306341 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006342 session->connectedInfo.pbFrames,
6343 join_rsp->frames, len);
6344 session->connectedInfo.nAssocReqLength =
6345 join_rsp->assocReqLength;
6346 session->connectedInfo.nAssocRspLength =
6347 join_rsp->assocRspLength;
6348 session->connectedInfo.nBeaconLength =
6349 join_rsp->beaconLength;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006350 session->connectedInfo.nRICRspLength =
6351 join_rsp->parsedRicRspLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006352#ifdef FEATURE_WLAN_ESE
6353 session->connectedInfo.nTspecIeLength =
6354 join_rsp->tspecIeLen;
6355#endif
6356 roam_info.nAssocReqLength =
6357 join_rsp->assocReqLength;
6358 roam_info.nAssocRspLength =
6359 join_rsp->assocRspLength;
6360 roam_info.nBeaconLength =
6361 join_rsp->beaconLength;
6362 roam_info.pbFrames =
6363 session->connectedInfo.pbFrames;
6364 }
6365 }
6366 if (cmd->u.roamCmd.fReassoc)
6367 roam_info.fReassocReq =
6368 roam_info.fReassocRsp = true;
6369 conn_profile->vht_channel_width =
6370 join_rsp->vht_channel_width;
6371 session->connectedInfo.staId =
6372 (uint8_t) join_rsp->staId;
6373 roam_info.staId = (uint8_t) join_rsp->staId;
6374 roam_info.ucastSig = (uint8_t) join_rsp->ucastSig;
6375 roam_info.bcastSig = (uint8_t) join_rsp->bcastSig;
6376 roam_info.timingMeasCap = join_rsp->timingMeasCap;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05306377 roam_info.chan_info.nss = join_rsp->nss;
6378 roam_info.chan_info.rate_flags =
6379 join_rsp->max_rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006380#ifdef FEATURE_WLAN_TDLS
6381 roam_info.tdls_prohibited = join_rsp->tdls_prohibited;
6382 roam_info.tdls_chan_swit_prohibited =
6383 join_rsp->tdls_chan_swit_prohibited;
6384 sms_log(mac_ctx, LOG1,
6385 FL("tdls:prohibit: %d, chan_swit_prohibit: %d"),
6386 roam_info.tdls_prohibited,
6387 roam_info.tdls_chan_swit_prohibited);
6388#endif
6389#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
6390 src_profile = &join_rsp->HTProfile;
6391 dst_profile = &conn_profile->HTProfile;
6392 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05306393 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006394 csr_roam_copy_ht_profile(dst_profile,
6395 src_profile);
6396#endif
6397 } else {
6398 if (cmd->u.roamCmd.fReassoc) {
6399 roam_info.fReassocReq =
6400 roam_info.fReassocRsp = true;
6401 roam_info.nAssocReqLength =
6402 session->connectedInfo.nAssocReqLength;
6403 roam_info.nAssocRspLength =
6404 session->connectedInfo.nAssocRspLength;
6405 roam_info.nBeaconLength =
6406 session->connectedInfo.nBeaconLength;
6407 roam_info.pbFrames =
6408 session->connectedInfo.pbFrames;
6409 }
6410 }
6411
6412 /*
6413 * Update the staId from the previous connected profile info
6414 * as the reassociation is triggred at SME/HDD
6415 */
6416
6417 if ((eCsrHddIssuedReassocToSameAP ==
6418 cmd->u.roamCmd.roamReason) ||
6419 (eCsrSmeIssuedReassocToSameAP ==
6420 cmd->u.roamCmd.roamReason))
6421 roam_info.staId = session->connectedInfo.staId;
6422
6423#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6424 /*
6425 * Indicate SME-QOS with reassoc success event,
6426 * only after copying the frames
6427 */
6428 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id, ind_qos,
6429 &assoc_info);
6430#endif
6431 roam_info.pBssDesc = bss_desc;
6432 roam_info.statusCode =
6433 session->joinFailStatusCode.statusCode;
6434 roam_info.reasonCode =
6435 session->joinFailStatusCode.reasonCode;
6436#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6437 acm_mask = sme_qos_get_acm_mask(mac_ctx, bss_desc, NULL);
6438#endif
6439 conn_profile->acm_mask = acm_mask;
6440 /*
6441 * start UAPSD if uapsd_mask is not 0 because HDD will
6442 * configure for trigger frame It may be better to let QoS do
6443 * this????
6444 */
6445 if (conn_profile->modifyProfileFields.uapsd_mask) {
6446 sms_log(mac_ctx, LOGE,
6447 " uapsd_mask (0x%X) set, request UAPSD now",
6448 conn_profile->modifyProfileFields.uapsd_mask);
6449 sme_ps_start_uapsd(mac_ctx, session_id,
6450 NULL, NULL);
6451 }
6452 conn_profile->dot11Mode = session->bssParams.uCfgDot11Mode;
6453 roam_info.u.pConnectedProfile = conn_profile;
6454
6455 if (session->bRefAssocStartCnt > 0) {
6456 session->bRefAssocStartCnt--;
6457 if (!IS_FEATURE_SUPPORTED_BY_FW
6458 (SLM_SESSIONIZATION) &&
6459 (csr_is_concurrent_session_running(mac_ctx))) {
6460 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
6461 }
6462#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08006463 if (session->roam_synch_in_progress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006464 roam_info.roamSynchInProgress = 1;
6465 roam_info.synchAuthStatus =
6466 roam_offload_params->authStatus;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306467 qdf_mem_copy(roam_info.kck,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006468 roam_offload_params->kck,
6469 SIR_KCK_KEY_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306470 qdf_mem_copy(roam_info.kek,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006471 roam_offload_params->kek,
6472 SIR_KEK_KEY_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306473 qdf_mem_copy(roam_info.replay_ctr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006474 roam_offload_params->replay_ctr,
6475 SIR_REPLAY_CTR_LEN);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306476 QDF_TRACE(QDF_MODULE_ID_SME,
6477 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006478 FL
6479 ("LFR3: Copy KCK, KEK and Replay Ctr"));
6480 }
Ravi Joshi277ae9b2015-11-13 11:30:43 -08006481
6482 roam_info.subnet_change_status =
6483 CSR_GET_SUBNET_STATUS(roam_offload_params->roamReason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006484#endif
6485 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
6486 cmd->u.roamCmd.roamId,
6487 eCSR_ROAM_ASSOCIATION_COMPLETION,
6488 eCSR_ROAM_RESULT_ASSOCIATED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006489 }
6490
6491 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
6492 eCSR_ROAM_RESULT_NONE, true);
6493 csr_reset_pmkid_candidate_list(mac_ctx, session_id);
6494#ifdef FEATURE_WLAN_WAPI
6495 csr_reset_bkid_candidate_list(mac_ctx, session_id);
6496#endif
6497 } else {
6498 sms_log(mac_ctx, LOGW,
6499 "Roam command doesn't have a BSS desc");
6500 }
6501 /* Not to signal link up because keys are yet to be set.
6502 * The linkup function will overwrite the sub-state that
6503 * we need to keep at this point.
6504 */
6505 if (!CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id)) {
6506#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08006507 if (session->roam_synch_in_progress) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306508 QDF_TRACE(QDF_MODULE_ID_SME,
6509 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006510 FL
6511 ("NO CSR_IS_WAIT_FOR_KEY -> csr_roam_link_up"));
6512 }
6513#endif
6514 csr_roam_link_up(mac_ctx, conn_profile->bssid);
6515 }
6516}
6517
6518/**
6519 * csr_roam_process_results() - Process the Roam Results
6520 * @mac_ctx: Global MAC Context
6521 * @cmd: Command that has been processed
6522 * @res: Results available after processing the command
6523 * @context: Context
6524 *
6525 * Process the available results and make an appropriate decision
6526 *
6527 * Return: true if the command can be released, else not.
6528 */
6529static bool csr_roam_process_results(tpAniSirGlobal mac_ctx, tSmeCmd *cmd,
6530 eCsrRoamCompleteResult res, void *context)
6531{
6532 bool release_cmd = true;
6533 tSirBssDescription *bss_desc = NULL;
6534 tCsrRoamInfo roam_info;
6535 uint32_t session_id = cmd->sessionId;
6536 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
6537 tCsrRoamProfile *profile = &cmd->u.roamCmd.roamProfile;
6538 eRoamCmdStatus roam_status;
6539 eCsrRoamResult roam_result;
6540 host_log_ibss_pkt_type *ibss_log;
6541
6542 if (!session) {
6543 sms_log(mac_ctx, LOGE, FL("session %d not found "), session_id);
6544 return false;
6545 }
6546 sms_log(mac_ctx, LOG1, FL("Processing ROAM results..."));
6547 switch (res) {
6548 case eCsrJoinSuccess:
6549 case eCsrReassocSuccess:
6550 csr_roam_process_join_res(mac_ctx, res, cmd, context);
6551 break;
6552 case eCsrStartBssSuccess:
6553 csr_roam_process_start_bss_success(mac_ctx, cmd, context);
6554 break;
6555 case eCsrStartBssFailure:
6556#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6557 WLAN_HOST_DIAG_LOG_ALLOC(ibss_log,
6558 host_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6559 if (ibss_log) {
6560 ibss_log->status = WLAN_IBSS_STATUS_FAILURE;
6561 WLAN_HOST_DIAG_LOG_REPORT(ibss_log);
6562 }
6563#endif
6564 roam_status = eCSR_ROAM_IBSS_IND;
6565 roam_result = eCSR_ROAM_RESULT_IBSS_STARTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006566 if (CSR_IS_INFRA_AP(profile)) {
6567 roam_status = eCSR_ROAM_INFRA_IND;
6568 roam_result = eCSR_ROAM_RESULT_INFRA_START_FAILED;
6569 }
6570 if (context) {
6571 bss_desc = (tSirBssDescription *) context;
6572 } else {
6573 bss_desc = NULL;
6574 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306575 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006576 roam_info.pBssDesc = bss_desc;
6577 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
6578 cmd->u.roamCmd.roamId, roam_status,
6579 roam_result);
6580 csr_set_default_dot11_mode(mac_ctx);
6581 break;
6582 case eCsrSilentlyStopRoaming:
6583 /*
6584 * We are here because we try to start the same IBSS.
6585 * No message to PE. return the roaming state to Joined.
6586 */
6587 sms_log(mac_ctx, LOGW, FL("receives silently stop roam ind"));
6588 csr_roam_state_change(mac_ctx, eCSR_ROAMING_STATE_JOINED,
6589 session_id);
6590 csr_roam_substate_change(mac_ctx, eCSR_ROAM_SUBSTATE_NONE,
6591 session_id);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306592 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006593 roam_info.pBssDesc = session->pConnectBssDesc;
6594 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306595 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006596 &roam_info.pBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306597 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006598 /*
6599 * Since there is no change in the current state, simply pass
6600 * back no result otherwise HDD may be mistakenly mark to
6601 * disconnected state.
6602 */
6603 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
6604 cmd->u.roamCmd.roamId,
6605 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE);
6606 break;
6607 case eCsrSilentlyStopRoamingSaveState:
6608 /* We are here because we try to connect to the same AP */
6609 /* No message to PE */
6610 sms_log(mac_ctx, LOGW,
6611 FL("receives silently stop roaming indication"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306612 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006613
6614 /* to aviod resetting the substate to NONE */
6615 mac_ctx->roam.curState[session_id] = eCSR_ROAMING_STATE_JOINED;
6616 /*
6617 * No need to change substate to wai_for_key because there
6618 * is no state change
6619 */
6620 roam_info.pBssDesc = session->pConnectBssDesc;
6621 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306622 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006623 &roam_info.pBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306624 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006625 roam_info.statusCode = session->joinFailStatusCode.statusCode;
6626 roam_info.reasonCode = session->joinFailStatusCode.reasonCode;
6627 roam_info.nBeaconLength = session->connectedInfo.nBeaconLength;
6628 roam_info.nAssocReqLength =
6629 session->connectedInfo.nAssocReqLength;
6630 roam_info.nAssocRspLength =
6631 session->connectedInfo.nAssocRspLength;
6632 roam_info.pbFrames = session->connectedInfo.pbFrames;
6633 roam_info.staId = session->connectedInfo.staId;
6634 roam_info.u.pConnectedProfile = &session->connectedProfile;
Abhishek Singhacfdc922015-12-30 17:31:21 +05306635 if (0 == roam_info.staId)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306636 QDF_ASSERT(0);
Abhishek Singhacfdc922015-12-30 17:31:21 +05306637
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006638 session->bRefAssocStartCnt--;
6639 csr_roam_call_callback(mac_ctx, session_id, &roam_info,
6640 cmd->u.roamCmd.roamId,
6641 eCSR_ROAM_ASSOCIATION_COMPLETION,
6642 eCSR_ROAM_RESULT_ASSOCIATED);
6643 csr_roam_completion(mac_ctx, session_id, NULL, cmd,
6644 eCSR_ROAM_RESULT_ASSOCIATED, true);
6645 break;
6646 case eCsrReassocFailure:
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07006647 /*
6648 * Currently Reassoc failure is handled through eCsrJoinFailure
6649 * Need to revisit for eCsrReassocFailure handling
6650 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006651#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6652 sme_qos_csr_event_ind(mac_ctx, (uint8_t) session_id,
6653 SME_QOS_CSR_REASSOC_FAILURE, NULL);
6654#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006655 break;
6656 case eCsrJoinFailure:
6657 case eCsrNothingToJoin:
6658 case eCsrJoinFailureDueToConcurrency:
6659 default:
6660 csr_roam_process_results_default(mac_ctx, cmd, context, res);
6661 break;
6662 }
6663 return release_cmd;
6664}
6665
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306666QDF_STATUS csr_roam_copy_profile(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006667 tCsrRoamProfile *pDstProfile,
6668 tCsrRoamProfile *pSrcProfile)
6669{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306670 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006671 uint32_t size = 0;
6672
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306673 qdf_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006674 if (pSrcProfile->BSSIDs.numOfBSSIDs) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05306675 size = sizeof(struct qdf_mac_addr) * pSrcProfile->BSSIDs.numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306676 pDstProfile->BSSIDs.bssid = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006677 if (NULL == pDstProfile->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306678 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006679 goto end;
6680 }
6681 pDstProfile->BSSIDs.numOfBSSIDs =
6682 pSrcProfile->BSSIDs.numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306683 qdf_mem_copy(pDstProfile->BSSIDs.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006684 pSrcProfile->BSSIDs.bssid, size);
6685 }
6686 if (pSrcProfile->SSIDs.numOfSSIDs) {
6687 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306688 pDstProfile->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006689 if (NULL == pDstProfile->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306690 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006691 goto end;
6692 }
6693 pDstProfile->SSIDs.numOfSSIDs =
6694 pSrcProfile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306695 qdf_mem_copy(pDstProfile->SSIDs.SSIDList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006696 pSrcProfile->SSIDs.SSIDList, size);
6697 }
6698 if (pSrcProfile->nWPAReqIELength) {
6699 pDstProfile->pWPAReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306700 qdf_mem_malloc(pSrcProfile->nWPAReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006701 if (NULL == pDstProfile->pWPAReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306702 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006703 goto end;
6704 }
6705 pDstProfile->nWPAReqIELength =
6706 pSrcProfile->nWPAReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306707 qdf_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006708 pSrcProfile->nWPAReqIELength);
6709 }
6710 if (pSrcProfile->nRSNReqIELength) {
6711 pDstProfile->pRSNReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306712 qdf_mem_malloc(pSrcProfile->nRSNReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006713 if (NULL == pDstProfile->pRSNReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306714 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006715 goto end;
6716 }
6717 pDstProfile->nRSNReqIELength =
6718 pSrcProfile->nRSNReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306719 qdf_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006720 pSrcProfile->nRSNReqIELength);
6721 }
6722#ifdef FEATURE_WLAN_WAPI
6723 if (pSrcProfile->nWAPIReqIELength) {
6724 pDstProfile->pWAPIReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306725 qdf_mem_malloc(pSrcProfile->nWAPIReqIELength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006726 if (NULL == pDstProfile->pWAPIReqIE) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306727 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006728 goto end;
6729 }
6730 pDstProfile->nWAPIReqIELength =
6731 pSrcProfile->nWAPIReqIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306732 qdf_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006733 pSrcProfile->nWAPIReqIELength);
6734 }
6735#endif /* FEATURE_WLAN_WAPI */
6736 if (pSrcProfile->nAddIEScanLength) {
6737 pDstProfile->pAddIEScan =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306738 qdf_mem_malloc(pSrcProfile->nAddIEScanLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006739 if (NULL == pDstProfile->pAddIEScan) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306740 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006741 goto end;
6742 }
6743 pDstProfile->nAddIEScanLength =
6744 pSrcProfile->nAddIEScanLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306745 qdf_mem_copy(pDstProfile->pAddIEScan, pSrcProfile->pAddIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006746 pSrcProfile->nAddIEScanLength);
6747 }
6748 if (pSrcProfile->nAddIEAssocLength) {
6749 pDstProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306750 qdf_mem_malloc(pSrcProfile->nAddIEAssocLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006751 if (NULL == pDstProfile->pAddIEAssoc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306752 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006753 goto end;
6754 }
6755 pDstProfile->nAddIEAssocLength =
6756 pSrcProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306757 qdf_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006758 pSrcProfile->nAddIEAssocLength);
6759 }
6760 if (pSrcProfile->ChannelInfo.ChannelList) {
6761 pDstProfile->ChannelInfo.ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306762 qdf_mem_malloc(pSrcProfile->ChannelInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006763 numOfChannels);
6764 if (NULL == pDstProfile->ChannelInfo.ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306765 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006766 goto end;
6767 }
6768 pDstProfile->ChannelInfo.numOfChannels =
6769 pSrcProfile->ChannelInfo.numOfChannels;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306770 qdf_mem_copy(pDstProfile->ChannelInfo.ChannelList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006771 pSrcProfile->ChannelInfo.ChannelList,
6772 pSrcProfile->ChannelInfo.numOfChannels);
6773 }
6774 pDstProfile->AuthType = pSrcProfile->AuthType;
6775 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6776 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6777 pDstProfile->negotiatedUCEncryptionType =
6778 pSrcProfile->negotiatedUCEncryptionType;
6779 pDstProfile->negotiatedMCEncryptionType =
6780 pSrcProfile->negotiatedMCEncryptionType;
6781 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
6782#ifdef WLAN_FEATURE_11W
6783 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6784 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6785 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6786#endif
6787 pDstProfile->BSSType = pSrcProfile->BSSType;
6788 pDstProfile->phyMode = pSrcProfile->phyMode;
6789 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6790
6791#ifdef FEATURE_WLAN_WAPI
6792 if (csr_is_profile_wapi(pSrcProfile))
6793 if (pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6794 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6795#endif /* FEATURE_WLAN_WAPI */
6796 pDstProfile->CBMode = pSrcProfile->CBMode;
6797 pDstProfile->ch_params.ch_width = pSrcProfile->ch_params.ch_width;
6798 pDstProfile->ch_params.center_freq_seg0 =
6799 pSrcProfile->ch_params.center_freq_seg0;
6800 pDstProfile->ch_params.center_freq_seg1 =
6801 pSrcProfile->ch_params.center_freq_seg1;
6802 pDstProfile->ch_params.sec_ch_offset =
6803 pSrcProfile->ch_params.sec_ch_offset;
6804 /*Save the WPS info */
6805 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
6806 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
6807 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
6808 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
6809 pDstProfile->privacy = pSrcProfile->privacy;
6810 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6811 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6812 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6813 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6814 pDstProfile->SSIDs.SSIDList[0].ssidHidden =
6815 pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6816 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6817 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6818 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6819 pDstProfile->wps_state = pSrcProfile->wps_state;
6820 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
6821 pDstProfile->sap_dot11mc = pSrcProfile->sap_dot11mc;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306822 qdf_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006823 sizeof(pDstProfile->Keys));
6824#ifdef WLAN_FEATURE_11W
6825 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6826 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6827 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6828#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006829 if (pSrcProfile->MDID.mdiePresent) {
6830 pDstProfile->MDID.mdiePresent = 1;
6831 pDstProfile->MDID.mobilityDomain =
6832 pSrcProfile->MDID.mobilityDomain;
6833 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306834 qdf_mem_copy(&pDstProfile->addIeParams, &pSrcProfile->addIeParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006835 sizeof(tSirAddIeParams));
6836end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306837 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006838 csr_release_profile(pMac, pDstProfile);
6839 pDstProfile = NULL;
6840 }
6841
6842 return status;
6843}
6844
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306845QDF_STATUS csr_roam_copy_connected_profile(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006846 uint32_t sessionId, tCsrRoamProfile *pDstProfile)
6847{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306848 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006849 tCsrRoamConnectedProfile *pSrcProfile =
6850 &pMac->roam.roamSession[sessionId].connectedProfile;
6851
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306852 qdf_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006853
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306854 pDstProfile->BSSIDs.bssid = qdf_mem_malloc(sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006855 if (NULL == pDstProfile->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306856 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006857 sms_log(pMac, LOGE,
6858 FL("failed to allocate memory for BSSID "
6859 MAC_ADDRESS_STR),
6860 MAC_ADDR_ARRAY(pSrcProfile->bssid.bytes));
6861 goto end;
6862 }
6863 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Anurag Chouhanc5548422016-02-24 18:33:27 +05306864 qdf_copy_macaddr(pDstProfile->BSSIDs.bssid, &pSrcProfile->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006865
6866 if (pSrcProfile->SSID.ssId) {
6867 pDstProfile->SSIDs.SSIDList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306868 qdf_mem_malloc(sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006869 if (NULL == pDstProfile->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306870 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006871 sms_log(pMac, LOGE,
6872 FL("failed to allocate memory for SSID "
6873 MAC_ADDRESS_STR),
6874 MAC_ADDR_ARRAY(pSrcProfile->bssid.bytes));
6875 goto end;
6876 }
6877 pDstProfile->SSIDs.numOfSSIDs = 1;
6878 pDstProfile->SSIDs.SSIDList[0].handoffPermitted =
6879 pSrcProfile->handoffPermitted;
6880 pDstProfile->SSIDs.SSIDList[0].ssidHidden =
6881 pSrcProfile->ssidHidden;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306882 qdf_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006883 &pSrcProfile->SSID, sizeof(tSirMacSSid));
6884 }
6885 if (pSrcProfile->nAddIEAssocLength) {
6886 pDstProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306887 qdf_mem_malloc(pSrcProfile->nAddIEAssocLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006888 if (NULL == pDstProfile->pAddIEAssoc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306889 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006890 sms_log(pMac, LOGE,
6891 FL("failed to allocate mem for additional ie"));
6892 goto end;
6893 }
6894 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306895 qdf_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006896 pSrcProfile->nAddIEAssocLength);
6897 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306898 pDstProfile->ChannelInfo.ChannelList = qdf_mem_malloc(1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006899 if (NULL == pDstProfile->ChannelInfo.ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306900 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006901 goto end;
6902 }
6903 pDstProfile->ChannelInfo.numOfChannels = 1;
6904 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
6905 pDstProfile->AuthType.numEntries = 1;
6906 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6907 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6908 pDstProfile->EncryptionType.numEntries = 1;
6909 pDstProfile->EncryptionType.encryptionType[0] =
6910 pSrcProfile->EncryptionType;
6911 pDstProfile->negotiatedUCEncryptionType =
6912 pSrcProfile->EncryptionType;
6913 pDstProfile->mcEncryptionType.numEntries = 1;
6914 pDstProfile->mcEncryptionType.encryptionType[0] =
6915 pSrcProfile->mcEncryptionType;
6916 pDstProfile->negotiatedMCEncryptionType =
6917 pSrcProfile->mcEncryptionType;
6918 pDstProfile->BSSType = pSrcProfile->BSSType;
6919 pDstProfile->CBMode = pSrcProfile->CBMode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306920 qdf_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006921 sizeof(pDstProfile->Keys));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006922 if (pSrcProfile->MDID.mdiePresent) {
6923 pDstProfile->MDID.mdiePresent = 1;
6924 pDstProfile->MDID.mobilityDomain =
6925 pSrcProfile->MDID.mobilityDomain;
6926 }
Krunal Sonib2f13042015-11-02 18:41:08 -08006927#ifdef WLAN_FEATURE_11W
6928 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6929 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6930 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6931#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006932
6933end:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306934 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006935 csr_release_profile(pMac, pDstProfile);
6936 pDstProfile = NULL;
6937 }
6938
6939 return status;
6940}
6941
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306942QDF_STATUS csr_roam_issue_connect(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006943 tCsrRoamProfile *pProfile,
6944 tScanResultHandle hBSSList,
6945 eCsrRoamReason reason, uint32_t roamId,
6946 bool fImediate, bool fClearScan)
6947{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306948 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006949 tSmeCmd *pCommand;
6950
6951 pCommand = csr_get_command_buffer(pMac);
6952 if (NULL == pCommand) {
6953 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306954 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006955 } else {
6956 if (fClearScan) {
6957 csr_scan_abort_mac_scan_not_for_connect(pMac, sessionId);
6958 }
6959 pCommand->u.roamCmd.fReleaseProfile = false;
6960 if (NULL == pProfile) {
6961 /* We can roam now */
6962 /* Since pProfile is NULL, we need to build our own profile, set everything to default */
6963 /* We can only support open and no encryption */
6964 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6965 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] =
6966 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6967 pCommand->u.roamCmd.roamProfile.EncryptionType.
6968 numEntries = 1;
6969 pCommand->u.roamCmd.roamProfile.EncryptionType.
6970 encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6971 pCommand->u.roamCmd.roamProfile.csrPersona =
Anurag Chouhan6d760662016-02-20 16:05:43 +05306972 QDF_STA_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006973 } else {
6974 /* make a copy of the profile */
6975 status =
6976 csr_roam_copy_profile(pMac,
6977 &pCommand->u.roamCmd.roamProfile,
6978 pProfile);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306979 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006980 pCommand->u.roamCmd.fReleaseProfile = true;
6981 }
6982 }
6983
6984 pCommand->command = eSmeCommandRoam;
6985 pCommand->sessionId = (uint8_t) sessionId;
6986 pCommand->u.roamCmd.hBSSList = hBSSList;
6987 pCommand->u.roamCmd.roamId = roamId;
6988 pCommand->u.roamCmd.roamReason = reason;
6989 /* We need to free the BssList when the command is done */
6990 pCommand->u.roamCmd.fReleaseBssList = true;
6991 pCommand->u.roamCmd.fUpdateCurRoamProfile = true;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05306992 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006993 FL("CSR PERSONA=%d"),
6994 pCommand->u.roamCmd.roamProfile.csrPersona);
6995 status = csr_queue_sme_command(pMac, pCommand, fImediate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306996 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006997 sms_log(pMac, LOGE,
6998 FL(" fail to send message status = %d"), status);
6999 csr_release_command_roam(pMac, pCommand);
7000 }
7001 }
7002
7003 return status;
7004}
7005
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307006QDF_STATUS csr_roam_issue_reassoc(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007007 tCsrRoamProfile *pProfile,
7008 tCsrRoamModifyProfileFields *pMmodProfileFields,
7009 eCsrRoamReason reason, uint32_t roamId,
7010 bool fImediate)
7011{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307012 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007013 tSmeCmd *pCommand;
7014
7015 pCommand = csr_get_command_buffer(pMac);
7016 if (NULL == pCommand) {
7017 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307018 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007019 } else {
7020 csr_scan_abort_mac_scan_not_for_connect(pMac, sessionId);
7021 if (pProfile) {
7022 /* This is likely trying to reassoc to different profile */
7023 pCommand->u.roamCmd.fReleaseProfile = false;
7024 /* make a copy of the profile */
7025 status =
7026 csr_roam_copy_profile(pMac,
7027 &pCommand->u.roamCmd.roamProfile,
7028 pProfile);
7029 pCommand->u.roamCmd.fUpdateCurRoamProfile = true;
7030 } else {
7031 status =
7032 csr_roam_copy_connected_profile(pMac, sessionId,
7033 &pCommand->u.roamCmd.
7034 roamProfile);
7035 /* how to update WPA/WPA2 info in roamProfile?? */
7036 pCommand->u.roamCmd.roamProfile.uapsd_mask =
7037 pMmodProfileFields->uapsd_mask;
7038 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307039 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007040 pCommand->u.roamCmd.fReleaseProfile = true;
7041 }
7042 pCommand->command = eSmeCommandRoam;
7043 pCommand->sessionId = (uint8_t) sessionId;
7044 pCommand->u.roamCmd.roamId = roamId;
7045 pCommand->u.roamCmd.roamReason = reason;
7046 /* We need to free the BssList when the command is done */
7047 /* For reassoc there is no BSS list, so the bool set to false */
7048 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
7049 pCommand->u.roamCmd.fReleaseBssList = false;
7050 pCommand->u.roamCmd.fReassoc = true;
7051 csr_roam_remove_duplicate_command(pMac, sessionId, pCommand,
7052 reason);
7053 status = csr_queue_sme_command(pMac, pCommand, fImediate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307054 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007055 sms_log(pMac, LOGE,
7056 FL(" fail to send message status = %d"), status);
7057 csr_roam_completion(pMac, sessionId, NULL, pCommand,
7058 eCSR_ROAM_RESULT_FAILURE, false);
7059 csr_release_command_roam(pMac, pCommand);
7060 }
7061 }
7062 return status;
7063}
7064
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307065QDF_STATUS csr_roam_enqueue_preauth(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007066 tpSirBssDescription pBssDescription,
7067 eCsrRoamReason reason, bool fImmediate)
7068{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307069 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007070 tSmeCmd *pCommand;
7071
7072 pCommand = csr_get_command_buffer(pMac);
7073 if (NULL == pCommand) {
7074 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307075 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007076 } else {
7077 if (pBssDescription) {
7078 /* copy over the parameters we need later */
7079 pCommand->command = eSmeCommandRoam;
7080 pCommand->sessionId = (uint8_t) sessionId;
7081 pCommand->u.roamCmd.roamReason = reason;
7082 /* this is the important parameter */
7083 /* in this case we are using this field for the "next" BSS */
7084 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
7085 status = csr_queue_sme_command(pMac, pCommand, fImmediate);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307086 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007087 sms_log(pMac, LOGE,
7088 FL
7089 (" fail to enqueue preauth command, status = %d"),
7090 status);
7091 csr_release_command_preauth(pMac, pCommand);
7092 }
7093 } else {
7094 /* Return failure */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307095 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007096 }
7097 }
7098 return status;
7099}
7100
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307101QDF_STATUS csr_dequeue_roam_command(tpAniSirGlobal pMac, eCsrRoamReason reason)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007102{
7103 tListElem *pEntry;
7104 tSmeCmd *pCommand;
7105 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7106 if (pEntry) {
7107 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7108 if ((eSmeCommandRoam == pCommand->command) &&
7109 (eCsrPerformPreauth == reason)) {
7110 sms_log(pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
7111 pCommand->command,
7112 pCommand->u.roamCmd.roamReason);
7113 if (csr_ll_remove_entry
7114 (&pMac->sme.smeCmdActiveList, pEntry,
7115 LL_ACCESS_LOCK)) {
7116 csr_release_command_preauth(pMac, pCommand);
7117 }
7118 } else if ((eSmeCommandRoam == pCommand->command) &&
7119 (eCsrSmeIssuedFTReassoc == reason)) {
7120 sms_log(pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
7121 pCommand->command,
7122 pCommand->u.roamCmd.roamReason);
7123 if (csr_ll_remove_entry
7124 (&pMac->sme.smeCmdActiveList, pEntry,
7125 LL_ACCESS_LOCK)) {
7126 csr_release_command_roam(pMac, pCommand);
7127 }
7128 } else {
7129 sms_log(pMac, LOGE, FL("Command = %d, Reason = %d "),
7130 pCommand->command,
7131 pCommand->u.roamCmd.roamReason);
7132 }
7133 } else {
7134 sms_log(pMac, LOGE,
7135 FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
7136 }
7137 sme_process_pending_queue(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307138 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007139}
7140
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307141QDF_STATUS csr_roam_connect(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007142 tCsrRoamProfile *pProfile,
7143 uint32_t *pRoamId)
7144{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307145 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007146 tScanResultHandle hBSSList;
7147 tCsrScanResultFilter *pScanFilter;
7148 uint32_t roamId = 0;
7149 bool fCallCallback = false;
7150 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
7151 tSirBssDescription first_ap_profile;
7152
7153 if (NULL == pSession) {
7154 sms_log(pMac, LOGE,
7155 FL("session does not exist for given sessionId:%d"),
7156 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307157 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007158 }
7159
7160 if (NULL == pProfile) {
7161 sms_log(pMac, LOGP, FL("No profile specified"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307162 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007163 }
7164 /* Initialize the count before proceeding with the Join requests */
7165 pSession->join_bssid_count = 0;
7166 sms_log(pMac, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05307167 FL("called BSSType = %s (%d) authtype = %d encryType = %d"),
7168 lim_bss_type_to_string(pProfile->BSSType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007169 pProfile->BSSType, pProfile->AuthType.authType[0],
7170 pProfile->EncryptionType.encryptionType[0]);
7171 csr_roam_cancel_roaming(pMac, sessionId);
7172 csr_scan_remove_fresh_scan_command(pMac, sessionId);
7173 /* Only abort the scan if its not used for other roam/connect purpose */
7174 csr_scan_abort_mac_scan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
7175 csr_roam_remove_duplicate_command(pMac, sessionId, NULL, eCsrHddIssued);
7176 /* Check whether ssid changes */
7177 if (csr_is_conn_state_connected(pMac, sessionId) &&
7178 pProfile->SSIDs.numOfSSIDs && !csr_is_ssid_in_list(pMac,
7179 &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7180 csr_roam_issue_disassociate_cmd(pMac, sessionId,
7181 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Abhishek Singhacfdc922015-12-30 17:31:21 +05307182 /*
7183 * If roamSession.connectState is disconnecting that mean
7184 * disconnect was received with scan for ssid in progress
7185 * and dropped. This state will ensure that connect will
7186 * not be issued from scan for ssid completion. Thus
7187 * if this fresh connect also issue scan for ssid the connect
7188 * command will be dropped assuming disconnect is in progress.
7189 * Thus reset connectState here
7190 */
7191 if (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING ==
7192 pMac->roam.roamSession[sessionId].connectState)
7193 pMac->roam.roamSession[sessionId].connectState =
7194 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007195#ifdef FEATURE_WLAN_BTAMP_UT_RF
7196 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
7197#endif
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307198 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007199 if (NULL == pScanFilter) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307200 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007201 goto end;
7202 }
7203
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307204 qdf_mem_set(pScanFilter, sizeof(tCsrScanResultFilter),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007205 0);
7206 /* Try to connect to any BSS */
7207 if (NULL == pProfile) {
7208 /* No encryption */
7209 pScanFilter->EncryptionType.numEntries = 1;
7210 pScanFilter->EncryptionType.encryptionType[0] =
7211 eCSR_ENCRYPT_TYPE_NONE;
7212 } else {
7213 /* Here is the profile we need to connect to */
7214 status = csr_roam_prepare_filter_from_profile(pMac,
7215 pProfile, pScanFilter);
7216 }
7217 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7218 if (pRoamId)
7219 *pRoamId = roamId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307220 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307221 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007222 goto end;
7223 }
7224
7225 /*Save the WPS info */
7226 if (NULL != pProfile) {
7227 pScanFilter->bWPSAssociation =
7228 pProfile->bWPSAssociation;
7229 pScanFilter->bOSENAssociation =
7230 pProfile->bOSENAssociation;
7231 } else {
7232 pScanFilter->bWPSAssociation = 0;
7233 pScanFilter->bOSENAssociation = 0;
7234 }
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07007235 if (pProfile && CSR_IS_INFRA_AP(pProfile)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007236 /* This can be started right away */
7237 status = csr_roam_issue_connect(pMac, sessionId, pProfile, NULL,
7238 eCsrHddIssued, roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307239 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007240 sms_log(pMac, LOGE,
7241 FL("CSR failed to issue start BSS cmd with status = 0x%08X"),
7242 status);
7243 fCallCallback = true;
7244 } else {
7245 sms_log(pMac, LOG1,
7246 FL("Connect request to proceed for sap mode"));
7247 }
7248
7249 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307250 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007251 goto end;
7252 }
7253 status = csr_scan_get_result(pMac, pScanFilter, &hBSSList);
7254 sms_log(pMac, LOG1,
7255 FL("******* csr_scan_get_result Status ****** %d"), status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307256 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007257 /* check if set hw mode needs to be done */
7258 if ((pMac->policy_manager_enabled) &&
Anurag Chouhan6d760662016-02-20 16:05:43 +05307259 ((pScanFilter->csrPersona == QDF_STA_MODE) ||
7260 (pScanFilter->csrPersona == QDF_P2P_CLIENT_MODE))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007261 csr_get_bssdescr_from_scan_handle(hBSSList,
7262 &first_ap_profile);
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05307263 status = cds_handle_conc_multiport(sessionId,
7264 first_ap_profile.channelId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307265 if ((QDF_IS_STATUS_SUCCESS(status)) &&
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05307266 (!csr_wait_for_connection_update(pMac, true))) {
7267 sms_log(pMac, LOG1,
7268 FL("conn update error"));
7269 csr_scan_result_purge(pMac, hBSSList);
7270 fCallCallback = true;
7271 goto error;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307272 } else if (status == QDF_STATUS_E_FAILURE) {
Chandrasekaran, Manishekar430ee2e2015-11-16 16:28:30 +05307273 sms_log(pMac, LOG1, FL("conn update error"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007274 csr_scan_result_purge(pMac, hBSSList);
7275 fCallCallback = true;
7276 goto error;
7277 }
7278 }
7279
7280 status = csr_roam_issue_connect(pMac, sessionId, pProfile,
7281 hBSSList, eCsrHddIssued, roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307282 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007283 sms_log(pMac, LOGE,
7284 FL("CSR failed to issue connect cmd with status = 0x%08X"),
7285 status);
7286 csr_scan_result_purge(pMac, hBSSList);
7287 fCallCallback = true;
7288 }
7289 } else if (NULL != pProfile) {
7290 /* Check whether it is for start ibss */
7291 if (CSR_IS_START_IBSS(pProfile)) {
7292 status = csr_roam_issue_connect(pMac, sessionId,
7293 pProfile, NULL, eCsrHddIssued,
7294 roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307295 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007296 sms_log(pMac, LOGE,
7297 FL("CSR failed to issue startIBSS cmd with status = 0x%08X"),
7298 status);
7299 fCallCallback = true;
7300 }
7301 } else {
7302 /* scan for this SSID */
7303 status = csr_scan_for_ssid(pMac, sessionId, pProfile,
7304 roamId, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307305 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007306 sms_log(pMac, LOGE,
7307 FL("CSR failed to issue SSID scan cmd with status = 0x%08X"),
7308 status);
7309 fCallCallback = true;
7310 } else {
7311 sms_log(pMac, LOG1,
7312 FL("SSID scan requested"));
7313 }
7314 }
7315 } else {
7316 fCallCallback = true;
7317 }
7318
7319error:
7320 if (NULL != pProfile)
7321 /*
7322 * we need to free memory for filter
7323 * if profile exists
7324 */
7325 csr_free_scan_filter(pMac, pScanFilter);
7326
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307327 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007328end:
7329 /* tell the caller if we fail to trigger a join request */
7330 if (fCallCallback) {
7331 csr_roam_call_callback(pMac, sessionId, NULL, roamId,
7332 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7333 }
7334 return status;
7335}
7336
7337/**
7338 * csr_roam_reassoc() - process reassoc command
7339 * @mac_ctx: mac global context
7340 * @session_id: session id
7341 * @profile: roam profile
7342 * @mod_fields: AC info being modified in reassoc
7343 * @roam_id: roam id to be populated
7344 *
7345 * Return: status of operation
7346 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307347QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007348csr_roam_reassoc(tpAniSirGlobal mac_ctx, uint32_t session_id,
7349 tCsrRoamProfile *profile,
7350 tCsrRoamModifyProfileFields mod_fields,
7351 uint32_t *roam_id)
7352{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307353 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007354 bool fCallCallback = true;
7355 uint32_t roamId = 0;
7356
7357 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
7358 if (NULL == profile) {
7359 sms_log(mac_ctx, LOGP, FL("No profile specified"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307360 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007361 }
7362 sms_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05307363 FL("called BSSType = %s (%d) authtype = %d encryType = %d"),
7364 lim_bss_type_to_string(profile->BSSType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007365 profile->BSSType, profile->AuthType.authType[0],
7366 profile->EncryptionType.encryptionType[0]);
7367 csr_roam_cancel_roaming(mac_ctx, session_id);
7368 csr_scan_remove_fresh_scan_command(mac_ctx, session_id);
7369 csr_scan_abort_mac_scan_not_for_connect(mac_ctx, session_id);
7370 csr_roam_remove_duplicate_command(mac_ctx, session_id, NULL,
7371 eCsrHddIssuedReassocToSameAP);
7372 if (csr_is_conn_state_connected(mac_ctx, session_id)) {
7373 if (profile) {
7374 if (profile->SSIDs.numOfSSIDs &&
7375 csr_is_ssid_in_list(mac_ctx,
7376 &session->connectedProfile.SSID,
7377 &profile->SSIDs)) {
7378 fCallCallback = false;
7379 } else {
7380 /*
7381 * Connected SSID did not match with what is
7382 * asked in profile
7383 */
7384 sms_log(mac_ctx, LOG1, FL("SSID mismatch"));
7385 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307386 } else if (qdf_mem_cmp(&mod_fields,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007387 &session->connectedProfile.modifyProfileFields,
7388 sizeof(tCsrRoamModifyProfileFields))) {
7389 fCallCallback = false;
7390 } else {
7391 sms_log(mac_ctx, LOG1,
7392 /*
7393 * Either the profile is NULL or none of the
7394 * fields in tCsrRoamModifyProfileFields got
7395 * modified
7396 */
7397 FL("Profile NULL or nothing to modify."));
7398 }
7399 } else {
7400 sms_log(mac_ctx, LOG1, FL("Not connected! No need to reassoc"));
7401 }
7402 if (!fCallCallback) {
7403 roamId = GET_NEXT_ROAM_ID(&mac_ctx->roam);
7404 if (roam_id)
7405 *roam_id = roamId;
7406 status = csr_roam_issue_reassoc(mac_ctx, session_id, profile,
7407 &mod_fields, eCsrHddIssuedReassocToSameAP,
7408 roamId, false);
7409 } else {
7410 status = csr_roam_call_callback(mac_ctx, session_id, NULL,
7411 roamId, eCSR_ROAM_FAILED,
7412 eCSR_ROAM_RESULT_FAILURE);
7413 }
7414 return status;
7415}
7416
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307417QDF_STATUS csr_roam_join_last_profile(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007418{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307419 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007420 tScanResultHandle hBSSList = NULL;
7421 tCsrScanResultFilter *pScanFilter = NULL;
7422 uint32_t roamId;
7423 tCsrRoamProfile *pProfile = NULL;
7424 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
7425
7426 if (!pSession) {
7427 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307428 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007429 }
7430
7431 if (pSession->pCurRoamProfile) {
7432 csr_scan_abort_mac_scan_not_for_connect(pMac, sessionId);
7433 /* We have to make a copy of pCurRoamProfile because it
7434 * will be free inside csr_roam_issue_connect */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307435 pProfile = qdf_mem_malloc(sizeof(tCsrRoamProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007436 if (NULL == pProfile) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307437 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007438 goto end;
7439 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307440 qdf_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007441 status = csr_roam_copy_profile(pMac, pProfile,
7442 pSession->pCurRoamProfile);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307443 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007444 goto end;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307445 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007446 if (NULL == pScanFilter) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307447 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007448 goto end;
7449 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307450 qdf_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007451 status = csr_roam_prepare_filter_from_profile(pMac, pProfile,
7452 pScanFilter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307453 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007454 goto end;
7455 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7456 status = csr_scan_get_result(pMac, pScanFilter, &hBSSList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307457 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007458 /* we want to put the last connected BSS to the
7459 * very beginning, if possible */
7460 csr_move_bss_to_head_from_bssid(pMac,
7461 &pSession->connectedProfile.bssid, hBSSList);
7462 status = csr_roam_issue_connect(pMac, sessionId,
7463 pProfile, hBSSList, eCsrHddIssued,
7464 roamId, false, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307465 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007466 csr_scan_result_purge(pMac, hBSSList);
7467 goto end;
7468 }
7469 } else {
7470 /* scan for this SSID only incase AP suppresses SSID */
7471 status = csr_scan_for_ssid(pMac, sessionId, pProfile,
7472 roamId, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307473 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007474 goto end;
7475 }
7476 } /* We have a profile */
7477 else {
7478 sms_log(pMac, LOGW, FL("cannot find a roaming profile"));
7479 goto end;
7480 }
7481end:
7482 if (pScanFilter) {
7483 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307484 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007485 }
7486 if (NULL != pProfile) {
7487 csr_release_profile(pMac, pProfile);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307488 qdf_mem_free(pProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007489 }
7490 return status;
7491}
7492
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307493QDF_STATUS csr_roam_reconnect(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007494{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307495 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007496 if (csr_is_conn_state_connected(pMac, sessionId)) {
7497 status =
7498 csr_roam_issue_disassociate_cmd(pMac, sessionId,
7499 eCSR_DISCONNECT_REASON_UNSPECIFIED);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307500 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007501 status = csr_roam_join_last_profile(pMac, sessionId);
7502 }
7503 }
7504 return status;
7505}
7506
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307507QDF_STATUS csr_roam_connect_to_last_profile(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007508{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307509 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007510 sms_log(pMac, LOGW, FL("is called"));
7511 csr_roam_cancel_roaming(pMac, sessionId);
7512 csr_roam_remove_duplicate_command(pMac, sessionId, NULL, eCsrHddIssued);
7513 if (csr_is_conn_state_disconnected(pMac, sessionId)) {
7514 status = csr_roam_join_last_profile(pMac, sessionId);
7515 }
7516 return status;
7517}
7518
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307519QDF_STATUS csr_roam_process_disassoc_deauth(tpAniSirGlobal pMac, tSmeCmd *pCommand,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007520 bool fDisassoc, bool fMICFailure)
7521{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307522 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007523 bool fComplete = false;
7524 eCsrRoamSubState NewSubstate;
7525 uint32_t sessionId = pCommand->sessionId;
7526
7527 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
7528 sms_log(pMac, LOG1,
7529 FL(" Stop Wait for key timer and change substate to"
7530 " eCSR_ROAM_SUBSTATE_NONE"));
7531 csr_roam_stop_wait_for_key_timer(pMac);
7532 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7533 }
7534 /* change state to 'Roaming'... */
7535 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
7536
7537 if (csr_is_conn_state_ibss(pMac, sessionId)) {
7538 /* If we are in an IBSS, then stop the IBSS... */
7539 status =
7540 csr_roam_issue_stop_bss(pMac, sessionId,
7541 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307542 fComplete = (!QDF_IS_STATUS_SUCCESS(status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007543 } else if (csr_is_conn_state_infra(pMac, sessionId)) {
7544 /*
7545 * in Infrastructure, we need to disassociate from the
7546 * Infrastructure network...
7547 */
7548 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7549 if (eCsrSmeIssuedDisassocForHandoff ==
7550 pCommand->u.roamCmd.roamReason) {
7551 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7552 } else
7553 if ((eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason)
7554 && (eSIR_MAC_DISASSOC_LEAVING_BSS_REASON ==
7555 pCommand->u.roamCmd.reason)) {
7556 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307557 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007558 FL
7559 ("set to substate eCSR_ROAM_SUBSTATE_DISASSOC_STA_HAS_LEFT"));
7560 }
Abhishek Singhe0680852015-12-16 14:28:48 +05307561 if (eCsrSmeIssuedDisassocForHandoff !=
7562 pCommand->u.roamCmd.roamReason) {
7563 /*
7564 * If we are in neighbor preauth done state then
7565 * on receiving disassoc or deauth we dont roam
7566 * instead we just disassoc from current ap and
7567 * then go to disconnected state.
7568 * This happens for ESE and 11r FT connections ONLY.
7569 */
Abhishek Singhe0680852015-12-16 14:28:48 +05307570 if (csr_roam_is11r_assoc(pMac, sessionId) &&
7571 (csr_neighbor_roam_state_preauth_done(pMac,
7572 sessionId))) {
7573 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
7574 pMac, sessionId);
7575 }
Abhishek Singhe0680852015-12-16 14:28:48 +05307576#ifdef FEATURE_WLAN_ESE
7577 if (csr_roam_is_ese_assoc(pMac, sessionId) &&
7578 (csr_neighbor_roam_state_preauth_done(pMac,
7579 sessionId))) {
7580 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
7581 pMac, sessionId);
7582 }
7583#endif
Abhishek Singhe0680852015-12-16 14:28:48 +05307584 if (csr_roam_is_fast_roam_enabled(pMac, sessionId) &&
7585 (csr_neighbor_roam_state_preauth_done(pMac,
7586 sessionId))) {
7587 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
7588 pMac, sessionId);
7589 }
Abhishek Singhe0680852015-12-16 14:28:48 +05307590 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007591 if (fDisassoc) {
7592 status =
7593 csr_roam_issue_disassociate(pMac, sessionId,
7594 NewSubstate, fMICFailure);
7595 } else {
7596 status =
7597 csr_roam_issue_deauth(pMac, sessionId,
7598 eCSR_ROAM_SUBSTATE_DEAUTH_REQ);
7599 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307600 fComplete = (!QDF_IS_STATUS_SUCCESS(status));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007601 } else {
7602 /* we got a dis-assoc request while not connected to any peer */
7603 /* just complete the command */
7604 fComplete = true;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307605 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007606 }
7607 if (fComplete) {
7608 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
7609 }
7610
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307611 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007612 if (csr_is_conn_state_infra(pMac, sessionId)) {
7613 /* Set the state to disconnect here */
7614 pMac->roam.roamSession[sessionId].connectState =
7615 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7616 }
7617 } else {
7618 sms_log(pMac, LOGW, FL(" failed with status %d"), status);
7619 }
7620 return status;
7621}
7622
7623/**
7624 * csr_prepare_disconnect_command() - function to prepare disconnect command
7625 * @mac: pointer to global mac structure
7626 * @session_id: sme session index
7627 * @sme_cmd: pointer to sme command being prepared
7628 *
7629 * Function to prepare internal sme disconnect command
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307630 * Return: QDF_STATUS_SUCCESS on success else QDF_STATUS_E_RESOURCES on failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007631 */
7632
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307633QDF_STATUS csr_prepare_disconnect_command(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007634 uint32_t session_id, tSmeCmd **sme_cmd)
7635{
7636 tSmeCmd *command;
7637
7638 command = csr_get_command_buffer(mac);
7639 if (!command) {
7640 sms_log(mac, LOGE, FL("fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307641 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007642 }
7643
7644 command->command = eSmeCommandRoam;
7645 command->sessionId = (uint8_t)session_id;
7646 command->u.roamCmd.roamReason = eCsrForcedDisassoc;
7647
7648 *sme_cmd = command;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307649 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007650}
7651
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307652QDF_STATUS csr_roam_issue_disassociate_cmd(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007653 eCsrRoamDisconnectReason reason)
7654{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307655 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007656 tSmeCmd *pCommand;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007657 do {
7658 pCommand = csr_get_command_buffer(pMac);
7659 if (!pCommand) {
7660 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307661 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007662 break;
7663 }
7664 /* Change the substate in case it is wait-for-key */
7665 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
7666 csr_roam_stop_wait_for_key_timer(pMac);
7667 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
7668 sessionId);
7669 }
7670 pCommand->command = eSmeCommandRoam;
7671 pCommand->sessionId = (uint8_t) sessionId;
7672 sms_log(pMac, LOG1,
7673 FL("Disassociate reason: %d, sessionId: %d"),
7674 reason, sessionId);
7675 switch (reason) {
7676 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7677 pCommand->u.roamCmd.roamReason =
7678 eCsrForcedDisassocMICFailure;
7679 break;
7680 case eCSR_DISCONNECT_REASON_DEAUTH:
7681 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7682 break;
7683 case eCSR_DISCONNECT_REASON_HANDOFF:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007684 pCommand->u.roamCmd.roamReason =
7685 eCsrSmeIssuedDisassocForHandoff;
7686 break;
7687 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7688 case eCSR_DISCONNECT_REASON_DISASSOC:
7689 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7690 break;
7691 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7692 pCommand->u.roamCmd.roamReason =
7693 eCsrSmeIssuedIbssJoinFailure;
7694 break;
7695 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7696 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7697 break;
7698 case eCSR_DISCONNECT_REASON_STA_HAS_LEFT:
7699 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7700 pCommand->u.roamCmd.reason =
7701 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307702 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007703 FL
7704 ("SME convert to internal reason code eCsrStaHasLeft"));
7705 break;
7706 default:
7707 break;
7708 }
Abhishek Singhb7b2a3b2015-12-03 16:09:38 +05307709 status = csr_queue_sme_command(pMac, pCommand, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307710 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007711 sms_log(pMac, LOGE,
7712 FL(" fail to send message status = %d"), status);
7713 csr_release_command_roam(pMac, pCommand);
7714 }
7715 } while (0);
7716 return status;
7717}
7718
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307719QDF_STATUS csr_roam_issue_stop_bss_cmd(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007720 bool fHighPriority)
7721{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307722 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007723 tSmeCmd *pCommand;
7724 pCommand = csr_get_command_buffer(pMac);
7725 if (NULL != pCommand) {
7726 /* Change the substate in case it is wait-for-key */
7727 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
7728 csr_roam_stop_wait_for_key_timer(pMac);
7729 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
7730 sessionId);
7731 }
7732 pCommand->command = eSmeCommandRoam;
7733 pCommand->sessionId = (uint8_t) sessionId;
7734 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7735 status = csr_queue_sme_command(pMac, pCommand, fHighPriority);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307736 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007737 sms_log(pMac, LOGE,
7738 FL(" fail to send message status = %d"), status);
7739 csr_release_command_roam(pMac, pCommand);
7740 }
7741 } else {
7742 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307743 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007744 }
7745 return status;
7746}
7747
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307748QDF_STATUS csr_roam_disconnect_internal(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007749 eCsrRoamDisconnectReason reason)
7750{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307751 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007752 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
7753
7754 if (!pSession) {
7755 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307756 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007757 }
7758#ifdef FEATURE_WLAN_BTAMP_UT_RF
7759 /* Stop the retry */
7760 pSession->maxRetryCount = 0;
7761 csr_roam_stop_join_retry_timer(pMac, sessionId);
7762#endif
7763 /* Not to call cancel roaming here */
7764 /* Only issue disconnect when necessary */
7765 if (csr_is_conn_state_connected(pMac, sessionId)
7766 || csr_is_bss_type_ibss(pSession->connectedProfile.BSSType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007767 || csr_is_roam_command_waiting_for_session(pMac, sessionId)) {
7768 sms_log(pMac, LOG2, FL("called"));
7769 status = csr_roam_issue_disassociate_cmd(pMac, sessionId,
7770 reason);
7771 } else {
kaliu154d7892015-12-30 17:27:58 +05307772 pMac->roam.roamSession[sessionId].connectState =
7773 eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007774 csr_scan_abort_scan_for_ssid(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307775 status = QDF_STATUS_CMD_NOT_QUEUED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007776 sms_log(pMac, LOG1,
7777 FL
7778 (" Disconnect cmd not queued, Roam command is not present"
7779 " return with status %d"), status);
7780 }
7781 return status;
7782}
7783
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307784QDF_STATUS csr_roam_disconnect(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007785 eCsrRoamDisconnectReason reason)
7786{
7787 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
7788
7789 if (!pSession) {
7790 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307791 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007792 }
7793
7794 csr_roam_cancel_roaming(pMac, sessionId);
7795 csr_roam_remove_duplicate_command(pMac, sessionId, NULL,
7796 eCsrForcedDisassoc);
7797
7798 return csr_roam_disconnect_internal(pMac, sessionId, reason);
7799}
7800
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307801QDF_STATUS csr_roam_save_connected_infomation(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007802 uint32_t sessionId,
7803 tCsrRoamProfile *pProfile,
7804 tSirBssDescription *pSirBssDesc,
7805 tDot11fBeaconIEs *pIes)
7806{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307807 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007808 tDot11fBeaconIEs *pIesTemp = pIes;
7809 uint8_t index;
7810 tCsrRoamSession *pSession = NULL;
7811 tCsrRoamConnectedProfile *pConnectProfile = NULL;
7812
7813 pSession = CSR_GET_SESSION(pMac, sessionId);
7814 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307815 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007816 FL("session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307817 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007818 }
7819 pConnectProfile = &pSession->connectedProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007820 if (pConnectProfile->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307821 qdf_mem_free(pConnectProfile->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007822 pConnectProfile->pAddIEAssoc = NULL;
7823 }
Varun Reddy Yeturud5216002016-02-03 17:09:09 -08007824 /*
7825 * In case of LFR2.0, the connected profile is copied into a temporary
7826 * profile and cleared and then is copied back. This is not needed for
7827 * LFR3.0, since the profile is not cleared.
7828 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007829 if (!pSession->roam_synch_in_progress) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307830 qdf_mem_set(&pSession->connectedProfile,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007831 sizeof(tCsrRoamConnectedProfile), 0);
7832 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7833 pConnectProfile->AuthInfo = pProfile->AuthType;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007834 pConnectProfile->EncryptionType =
7835 pProfile->negotiatedUCEncryptionType;
7836 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7837 pConnectProfile->mcEncryptionType =
7838 pProfile->negotiatedMCEncryptionType;
7839 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7840 pConnectProfile->BSSType = pProfile->BSSType;
7841 pConnectProfile->modifyProfileFields.uapsd_mask =
7842 pProfile->uapsd_mask;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307843 qdf_mem_copy(&pConnectProfile->Keys, &pProfile->Keys,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007844 sizeof(tCsrKeys));
7845 if (pProfile->nAddIEAssocLength) {
7846 pConnectProfile->pAddIEAssoc =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307847 qdf_mem_malloc(pProfile->nAddIEAssocLength);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007848 if (NULL == pConnectProfile->pAddIEAssoc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307849 status = QDF_STATUS_E_NOMEM;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007850 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307851 status = QDF_STATUS_SUCCESS;
7852 if (!QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007853 sms_log(pMac, LOGE,
7854 FL("Failed to allocate memory for IE"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307855 return QDF_STATUS_E_FAILURE;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007856 }
7857 pConnectProfile->nAddIEAssocLength =
7858 pProfile->nAddIEAssocLength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307859 qdf_mem_copy(pConnectProfile->pAddIEAssoc,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007860 pProfile->pAddIEAssoc,
7861 pProfile->nAddIEAssocLength);
7862 }
7863#ifdef WLAN_FEATURE_11W
7864 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
7865 pConnectProfile->MFPRequired = pProfile->MFPRequired;
7866 pConnectProfile->MFPCapable = pProfile->MFPCapable;
7867#endif
7868 }
Varun Reddy Yeturud5216002016-02-03 17:09:09 -08007869 if (pIes)
7870 pConnectProfile->CBMode = csr_get_cb_mode_from_ies(pMac,
7871 pSirBssDesc->channelId, pIes);
7872 else
7873 sms_log(pMac, LOGE, FL("IE unavailable to derive CB mode"));
7874
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08007875 /* Save bssid */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007876 pConnectProfile->operationChannel = pSirBssDesc->channelId;
7877 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
7878 if (!pConnectProfile->beaconInterval) {
7879 sms_log(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7880 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007881 csr_get_bss_id_bss_desc(pMac, pSirBssDesc, &pConnectProfile->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007882 if (pSirBssDesc->mdiePresent) {
7883 pConnectProfile->MDID.mdiePresent = 1;
7884 pConnectProfile->MDID.mobilityDomain =
7885 (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7886 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007887 if (NULL == pIesTemp) {
7888 status =
7889 csr_get_parsed_bss_description_ies(pMac, pSirBssDesc,
7890 &pIesTemp);
7891 }
7892#ifdef FEATURE_WLAN_ESE
7893 if ((csr_is_profile_ese(pProfile) ||
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307894 (QDF_IS_STATUS_SUCCESS(status) && (pIesTemp->ESEVersion.present)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007895 && (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)))
7896 && (pMac->roam.configParam.isEseIniFeatureEnabled)) {
7897 pConnectProfile->isESEAssoc = 1;
7898 }
7899#endif
7900 /* save ssid */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307901 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007902 if (pIesTemp->SSID.present) {
7903 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307904 qdf_mem_copy(pConnectProfile->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007905 pIesTemp->SSID.ssid,
7906 pIesTemp->SSID.num_ssid);
7907 }
7908 /* Save the bss desc */
7909 status =
7910 csr_roam_save_connected_bss_desc(pMac, sessionId, pSirBssDesc);
7911
7912 if (CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present) {
7913 /* Some HT AP's dont send WMM IE so in that case we assume all HT Ap's are Qos Enabled AP's */
7914 pConnectProfile->qap = true;
7915 } else {
7916 pConnectProfile->qap = false;
7917 }
7918
7919 if (pIesTemp->ExtCap.present) {
7920 struct s_ext_cap *p_ext_cap = (struct s_ext_cap *)
7921 pIesTemp->ExtCap.bytes;
7922 pConnectProfile->proxyARPService = p_ext_cap->
7923 proxy_arp_service;
7924 }
7925
7926 if (NULL == pIes) {
7927 /* Free memory if it allocated locally */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307928 qdf_mem_free(pIesTemp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007929 }
7930 }
7931 /* Save Qos connection */
7932 pConnectProfile->qosConnection =
7933 pMac->roam.roamSession[sessionId].fWMMConnection;
7934
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05307935 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007936 csr_free_connect_bss_desc(pMac, sessionId);
7937 }
7938 for (index = 0; index < pProfile->SSIDs.numOfSSIDs; index++) {
7939 if ((pProfile->SSIDs.SSIDList[index].SSID.length ==
7940 pConnectProfile->SSID.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307941 && (!qdf_mem_cmp(pProfile->SSIDs.SSIDList[index].SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007942 ssId, pConnectProfile->SSID.ssId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +05307943 pConnectProfile->SSID.length))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007944 pConnectProfile->handoffPermitted =
7945 pProfile->SSIDs.SSIDList[index].handoffPermitted;
7946 break;
7947 }
7948 pConnectProfile->handoffPermitted = false;
7949 }
7950
7951 return status;
7952}
7953
7954
Abhishek Singhb1d73ab2015-12-03 16:14:00 +05307955bool is_disconnect_pending(tpAniSirGlobal pmac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007956 uint8_t sessionid)
7957{
7958 tListElem *entry = NULL;
7959 tListElem *next_entry = NULL;
7960 tSmeCmd *command = NULL;
7961 bool disconnect_cmd_exist = false;
7962
7963 csr_ll_lock(&pmac->sme.smeCmdPendingList);
7964 entry = csr_ll_peek_head(&pmac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7965 while (entry) {
7966 next_entry = csr_ll_next(&pmac->sme.smeCmdPendingList,
7967 entry, LL_ACCESS_NOLOCK);
7968
7969 command = GET_BASE_ADDR(entry, tSmeCmd, Link);
7970 if (command && CSR_IS_DISCONNECT_COMMAND(command) &&
7971 command->sessionId == sessionid){
7972 disconnect_cmd_exist = true;
7973 break;
7974 }
7975 entry = next_entry;
7976 }
7977 csr_ll_unlock(&pmac->sme.smeCmdPendingList);
7978 return disconnect_cmd_exist;
7979}
7980
7981static void csr_roam_join_rsp_processor(tpAniSirGlobal pMac,
7982 tSirSmeJoinRsp *pSmeJoinRsp)
7983{
7984 tListElem *pEntry = NULL;
7985 tSmeCmd *pCommand = NULL;
7986 tCsrRoamSession *session_ptr;
7987
7988 if (pSmeJoinRsp) {
7989 session_ptr = CSR_GET_SESSION(pMac, pSmeJoinRsp->sessionId);
7990 } else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307991 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007992 FL("Sme Join Response is NULL"));
7993 return;
7994 }
7995 if (!session_ptr) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05307996 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08007997 FL("session %d not found"), pSmeJoinRsp->sessionId);
7998 return;
7999 }
8000 /* The head of the active list is the request we sent */
8001 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8002 if (pEntry) {
8003 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8004 }
8005 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode) {
8006 if (pCommand
8007 && eCsrSmeIssuedAssocToSimilarAP ==
8008 pCommand->u.roamCmd.roamReason) {
8009#ifndef WLAN_MDM_CODE_REDUCTION_OPT
8010 sme_qos_csr_event_ind(pMac, pSmeJoinRsp->sessionId,
8011 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8012#endif
8013 }
8014 /* *
8015 * The join bssid count can be reset as soon as
8016 * we are done with the join requests and returning
8017 * the response to upper layers
8018 * */
8019 session_ptr->join_bssid_count = 0;
8020 csr_roam_complete(pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp);
8021 } else {
8022 uint32_t roamId = 0;
8023 bool is_dis_pending;
8024
8025 /* The head of the active list is the request we sent */
8026 /* Try to get back the same profile and roam again */
8027 if (pCommand) {
8028 roamId = pCommand->u.roamCmd.roamId;
8029 }
8030 session_ptr->joinFailStatusCode.statusCode =
8031 pSmeJoinRsp->statusCode;
8032 session_ptr->joinFailStatusCode.reasonCode =
8033 pSmeJoinRsp->protStatusCode;
8034 sms_log(pMac, LOGW,
8035 "SmeJoinReq failed with statusCode= 0x%08X [%d]",
8036 pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008037 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
8038 if (csr_roam_is_handoff_in_progress(pMac, pSmeJoinRsp->sessionId)) {
8039 csr_roam_call_callback(pMac, pSmeJoinRsp->sessionId, NULL,
8040 roamId, eCSR_ROAM_DISASSOCIATED,
8041 eCSR_ROAM_RESULT_FORCED);
8042 /* Should indicate neighbor roam algorithm about the connect failure here */
8043 csr_neighbor_roam_indicate_connect(pMac,
8044 pSmeJoinRsp->sessionId,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308045 QDF_STATUS_E_FAILURE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008046 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008047 /*
8048 * if userspace has issued disconnection,
8049 * driver should not continue connecting
8050 */
8051 is_dis_pending = is_disconnect_pending(pMac, session_ptr->sessionId);
8052 if (pCommand && (session_ptr->join_bssid_count <
8053 CSR_MAX_BSSID_COUNT) && !is_dis_pending) {
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07008054 csr_roam(pMac, pCommand);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008055 } else {
8056 /* ****************************************************
8057 * When the upper layers issue a connect command, there
8058 * is a roam command with reason eCsrHddIssued that
8059 * gets enqueued and an associated timer for the SME
8060 * command timeout is started which is currently 120
8061 * seconds. This command would be dequeued only upon
8062 * succesfull connections. In case of join failures, if
8063 * there are too many BSS in the cache, and if we fail
8064 * Join requests with all of them, there is a chance of
8065 * timing out the above timer.
8066 * ***************************************************/
8067 if (session_ptr->join_bssid_count >=
8068 CSR_MAX_BSSID_COUNT)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308069 QDF_TRACE(QDF_MODULE_ID_SME,
8070 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008071 FL("Excessive Join Req Failures"));
8072
8073 if (is_dis_pending)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308074 QDF_TRACE(QDF_MODULE_ID_SME,
8075 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008076 FL("disconnect is pending, complete roam"));
8077
8078 session_ptr->join_bssid_count = 0;
8079 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
8080 }
8081 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
8082}
8083
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308084QDF_STATUS csr_roam_issue_join(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008085 tSirBssDescription *pSirBssDesc,
8086 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile,
8087 uint32_t roamId)
8088{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308089 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008090 sms_log(pMac, LOG1, "Attempting to Join Bssid= " MAC_ADDRESS_STR,
8091 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
8092
8093 /* Set the roaming substate to 'join attempt'... */
8094 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
8095 /* attempt to Join this BSS... */
8096 status =
8097 csr_send_join_req_msg(pMac, sessionId, pSirBssDesc, pProfile, pIes,
8098 eWNI_SME_JOIN_REQ);
8099 return status;
8100}
8101
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308102static QDF_STATUS csr_roam_issue_reassociate(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008103 uint32_t sessionId,
8104 tSirBssDescription *pSirBssDesc,
8105 tDot11fBeaconIEs *pIes,
8106 tCsrRoamProfile *pProfile)
8107{
8108 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
8109 /* Set the roaming substate to 'join attempt'... */
8110 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308111 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008112 FL(" calling csr_send_join_req_msg (eWNI_SME_REASSOC_REQ)"));
8113 /* attempt to Join this BSS... */
8114 return csr_send_join_req_msg(pMac, sessionId, pSirBssDesc, pProfile, pIes,
8115 eWNI_SME_REASSOC_REQ);
8116}
8117
8118void csr_roam_reissue_roam_command(tpAniSirGlobal pMac)
8119{
8120 tListElem *pEntry;
8121 tSmeCmd *pCommand;
8122 tCsrRoamInfo roamInfo;
8123 uint32_t sessionId;
8124 tCsrRoamSession *pSession;
8125
8126 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8127 if (NULL == pEntry) {
8128 sms_log(pMac, LOGE,
8129 FL("Disassoc rsp can't continue, no active CMD"));
8130 return;
8131 }
8132 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8133 if (eSmeCommandRoam != pCommand->command) {
8134 sms_log(pMac, LOGW, FL("Active cmd, is not a roaming CMD"));
8135 return;
8136 }
8137 sessionId = pCommand->sessionId;
8138 pSession = CSR_GET_SESSION(pMac, sessionId);
8139
8140 if (!pSession) {
8141 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
8142 return;
8143 }
8144
8145 if (!pCommand->u.roamCmd.fStopWds) {
8146 if (pSession->bRefAssocStartCnt > 0) {
8147 /*
8148 * bRefAssocStartCnt was incremented in
8149 * csr_roam_join_next_bss when the roam command issued
8150 * previously. As part of reissuing the roam command
8151 * again csr_roam_join_next_bss is going increment
8152 * RefAssocStartCnt. So make sure to decrement the
8153 * bRefAssocStartCnt
8154 */
8155 pSession->bRefAssocStartCnt--;
8156 }
8157 if (eCsrStopRoaming == csr_roam_join_next_bss(pMac, pCommand,
8158 true)) {
8159 sms_log(pMac, LOGW,
8160 FL("Failed to reissue join command"));
8161 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
8162 }
8163 return;
8164 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308165 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008166 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
8167 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
8168 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07008169 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
8170 csr_roam_call_callback(pMac, sessionId, &roamInfo,
8171 pCommand->u.roamCmd.roamId,
8172 eCSR_ROAM_INFRA_IND,
8173 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008174
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308175 if (!QDF_IS_STATUS_SUCCESS(csr_roam_issue_stop_bss(pMac, sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008176 eCSR_ROAM_SUBSTATE_STOP_BSS_REQ))) {
8177 sms_log(pMac, LOGE,
8178 FL("Failed to reissue stop_bss command for WDS"));
8179 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
8180 }
8181}
8182
8183bool csr_is_roam_command_waiting_for_session(tpAniSirGlobal pMac, uint32_t sessionId)
8184{
8185 bool fRet = false;
8186 tListElem *pEntry;
8187 tSmeCmd *pCommand = NULL;
8188 /* alwasy lock active list before locking pending list */
8189 csr_ll_lock(&pMac->sme.smeCmdActiveList);
8190 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8191 if (pEntry) {
8192 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8193 if ((eSmeCommandRoam == pCommand->command)
8194 && (sessionId == pCommand->sessionId)) {
8195 fRet = true;
8196 }
8197 }
8198 if (false == fRet) {
8199 csr_ll_lock(&pMac->sme.smeCmdPendingList);
8200 pEntry =
8201 csr_ll_peek_head(&pMac->sme.smeCmdPendingList,
8202 LL_ACCESS_NOLOCK);
8203 while (pEntry) {
8204 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8205 if ((eSmeCommandRoam == pCommand->command)
8206 && (sessionId == pCommand->sessionId)) {
8207 fRet = true;
8208 break;
8209 }
8210 pEntry =
8211 csr_ll_next(&pMac->sme.smeCmdPendingList, pEntry,
8212 LL_ACCESS_NOLOCK);
8213 }
8214 csr_ll_unlock(&pMac->sme.smeCmdPendingList);
8215 }
8216 if (false == fRet) {
8217 csr_ll_lock(&pMac->roam.roamCmdPendingList);
8218 pEntry =
8219 csr_ll_peek_head(&pMac->roam.roamCmdPendingList,
8220 LL_ACCESS_NOLOCK);
8221 while (pEntry) {
8222 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8223 if ((eSmeCommandRoam == pCommand->command)
8224 && (sessionId == pCommand->sessionId)) {
8225 fRet = true;
8226 break;
8227 }
8228 pEntry =
8229 csr_ll_next(&pMac->roam.roamCmdPendingList, pEntry,
8230 LL_ACCESS_NOLOCK);
8231 }
8232 csr_ll_unlock(&pMac->roam.roamCmdPendingList);
8233 }
8234 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
8235 return fRet;
8236}
8237
8238bool csr_is_roam_command_waiting(tpAniSirGlobal pMac)
8239{
8240 bool fRet = false;
8241 uint32_t i;
8242 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
8243 fRet = csr_is_roam_command_waiting_for_session(pMac, i);
8244 if (CSR_IS_SESSION_VALID(pMac, i)
8245 && (fRet)) {
8246 break;
8247 }
8248 }
8249 return fRet;
8250}
8251
8252bool csr_is_command_waiting(tpAniSirGlobal pMac)
8253{
8254 bool fRet = false;
8255 /* alwasy lock active list before locking pending list */
8256 csr_ll_lock(&pMac->sme.smeCmdActiveList);
8257 fRet = csr_ll_is_list_empty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8258 if (false == fRet) {
8259 fRet =
8260 csr_ll_is_list_empty(&pMac->sme.smeCmdPendingList,
8261 LL_ACCESS_LOCK);
8262 }
8263 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
8264 return fRet;
8265}
8266
8267bool csr_is_scan_for_roam_command_active(tpAniSirGlobal pMac)
8268{
8269 bool fRet = false;
8270 tListElem *pEntry;
8271 tCsrCmd *pCommand;
8272 /* alwasy lock active list before locking pending list */
8273 csr_ll_lock(&pMac->sme.smeCmdActiveList);
8274 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8275 if (pEntry) {
8276 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
8277 if ((eCsrRoamCommandScan == pCommand->command) &&
8278 ((eCsrScanForSsid == pCommand->u.scanCmd.reason) ||
8279 (eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason))) {
8280 fRet = true;
8281 }
8282 }
8283 csr_ll_unlock(&pMac->sme.smeCmdActiveList);
8284 return fRet;
8285}
8286
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308287QDF_STATUS csr_roam_issue_reassociate_cmd(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008288{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308289 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008290 tSmeCmd *pCommand = NULL;
8291 bool fHighPriority = true;
8292 bool fRemoveCmd = false;
8293 tListElem *pEntry;
8294 /* Delete the old assoc command. All is setup for reassoc to be serialized */
8295 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8296 if (pEntry) {
8297 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8298 if (!pCommand) {
8299 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308300 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008301 }
8302 if (eSmeCommandRoam == pCommand->command) {
8303 if (pCommand->u.roamCmd.roamReason ==
8304 eCsrSmeIssuedAssocToSimilarAP) {
8305 fRemoveCmd =
8306 csr_ll_remove_entry(&pMac->sme.
8307 smeCmdActiveList, pEntry,
8308 LL_ACCESS_LOCK);
8309 } else {
8310 sms_log(pMac, LOGE,
8311 FL
8312 (" Unexpected active roam command present "));
8313 }
8314 if (fRemoveCmd == false) {
8315 /* Implies we did not get the serialized assoc command we */
8316 /* were expecting */
8317 pCommand = NULL;
8318 }
8319 }
8320 }
8321 if (NULL == pCommand) {
8322 sms_log(pMac, LOGE,
8323 FL
8324 (" fail to get command buffer as expected based on previous connect roam command"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308325 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008326 }
8327 do {
8328 /* Change the substate in case it is wait-for-key */
8329 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
8330 csr_roam_stop_wait_for_key_timer(pMac);
8331 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
8332 sessionId);
8333 }
8334 pCommand->command = eSmeCommandRoam;
8335 pCommand->sessionId = (uint8_t) sessionId;
8336 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
8337 status = csr_queue_sme_command(pMac, pCommand, fHighPriority);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308338 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008339 sms_log(pMac, LOGE,
8340 FL(" fail to send message status = %d"), status);
8341 csr_release_command_roam(pMac, pCommand);
8342 }
8343 } while (0);
8344
8345 return status;
8346}
8347
8348static void
8349csr_roaming_state_config_cnf_processor(tpAniSirGlobal mac_ctx,
8350 uint32_t result)
8351{
8352 tListElem *entry = csr_ll_peek_head(&mac_ctx->sme.smeCmdActiveList,
8353 LL_ACCESS_LOCK);
8354 tCsrScanResult *scan_result = NULL;
8355 tSirBssDescription *bss_desc = NULL;
8356 tSmeCmd *cmd = NULL;
8357 uint32_t session_id;
8358 tCsrRoamSession *session;
8359 tDot11fBeaconIEs *local_ies = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308360 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008361
8362 if (NULL == entry) {
8363 sms_log(mac_ctx, LOGE, FL("CFG_CNF with active list empty"));
8364 return;
8365 }
8366 cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
8367 session_id = cmd->sessionId;
8368 session = CSR_GET_SESSION(mac_ctx, session_id);
8369
8370 if (!session) {
8371 sms_log(mac_ctx, LOGE, FL("session %d not found"), session_id);
8372 return;
8373 }
8374
8375 if (CSR_IS_ROAMING(session) && session->fCancelRoaming) {
8376 /* the roaming is cancelled. Simply complete the command */
8377 sms_log(mac_ctx, LOGW, FL("Roam command canceled"));
8378 csr_roam_complete(mac_ctx, eCsrNothingToJoin, NULL);
8379 return;
8380 }
8381
8382 /* If the roaming has stopped, not to continue the roaming command */
8383 if (!CSR_IS_ROAMING(session) && CSR_IS_ROAMING_COMMAND(cmd)) {
8384 /* No need to complete roaming here as it already completes */
8385 sms_log(mac_ctx, LOGW,
8386 FL("Roam cmd (reason %d) aborted(roaming completed)"),
8387 cmd->u.roamCmd.roamReason);
8388 csr_set_abort_roaming_command(mac_ctx, cmd);
8389 csr_roam_complete(mac_ctx, eCsrNothingToJoin, NULL);
8390 return;
8391 }
8392
8393 if (!IS_SIR_STATUS_SUCCESS(result)) {
8394 /*
8395 * In the event the configuration failed, for infra let the roam
8396 * processor attempt to join something else...
8397 */
8398 if (cmd->u.roamCmd.pRoamBssEntry
8399 && CSR_IS_INFRASTRUCTURE(&cmd->u.roamCmd.roamProfile)) {
8400 csr_roam(mac_ctx, cmd);
8401 } else {
8402 /* We need to complete the command */
8403 if (csr_is_bss_type_ibss
8404 (cmd->u.roamCmd.roamProfile.BSSType)) {
8405 csr_roam_complete(mac_ctx, eCsrStartBssFailure,
8406 NULL);
8407 } else {
8408 csr_roam_complete(mac_ctx, eCsrNothingToJoin,
8409 NULL);
8410 }
8411 }
8412 return;
8413 }
8414
8415 /* we have active entry */
8416 sms_log(mac_ctx, LOG2, "Cfg sequence complete");
8417 /*
8418 * Successfully set the configuration parameters for the new Bss.
8419 * Attempt to join the roaming Bss
8420 */
8421 if (cmd->u.roamCmd.pRoamBssEntry) {
8422 scan_result = GET_BASE_ADDR(cmd->u.roamCmd.pRoamBssEntry,
8423 tCsrScanResult,
8424 Link);
8425 bss_desc = &scan_result->Result.BssDescriptor;
8426 }
8427 if (csr_is_bss_type_ibss(cmd->u.roamCmd.roamProfile.BSSType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008428 || CSR_IS_INFRA_AP(&cmd->u.roamCmd.roamProfile)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308429 if (!QDF_IS_STATUS_SUCCESS(csr_roam_issue_start_bss(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008430 session_id, &session->bssParams,
8431 &cmd->u.roamCmd.roamProfile,
8432 bss_desc,
8433 cmd->u.roamCmd.roamId))) {
8434 sms_log(mac_ctx, LOGE, FL("CSR start BSS failed"));
8435 /* We need to complete the command */
8436 csr_roam_complete(mac_ctx, eCsrStartBssFailure, NULL);
8437 }
8438 return;
8439 }
8440
8441 if (!cmd->u.roamCmd.pRoamBssEntry) {
8442 sms_log(mac_ctx, LOGE, FL("pRoamBssEntry is NULL"));
8443 /* We need to complete the command */
8444 csr_roam_complete(mac_ctx, eCsrJoinFailure, NULL);
8445 return;
8446 }
8447
8448 if (NULL == scan_result) {
8449 /* If we are roaming TO an Infrastructure BSS... */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308450 QDF_ASSERT(scan_result != NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008451 return;
8452 }
8453
8454 if (!csr_is_infra_bss_desc(bss_desc)) {
8455 sms_log(mac_ctx, LOGW,
8456 FL("found BSSType mismatching the one in BSS descp"));
8457 return;
8458 }
8459
8460 local_ies = (tDot11fBeaconIEs *) scan_result->Result.pvIes;
8461 if (!local_ies) {
8462 status = csr_get_parsed_bss_description_ies(mac_ctx, bss_desc,
8463 &local_ies);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308464 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008465 return;
8466 }
8467
8468 if (csr_is_conn_state_connected_infra(mac_ctx, session_id)) {
8469 if (csr_is_ssid_equal(mac_ctx, session->pConnectBssDesc,
8470 bss_desc, local_ies)) {
8471 cmd->u.roamCmd.fReassoc = true;
8472 csr_roam_issue_reassociate(mac_ctx, session_id,
8473 bss_desc, local_ies,
8474 &cmd->u.roamCmd.roamProfile);
8475 } else {
8476 /*
8477 * otherwise, we have to issue a new Join request to LIM
8478 * because we disassociated from the previously
8479 * associated AP.
8480 */
8481 status = csr_roam_issue_join(mac_ctx, session_id,
8482 bss_desc, local_ies,
8483 &cmd->u.roamCmd.roamProfile,
8484 cmd->u.roamCmd.roamId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308485 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008486 /* try something else */
8487 csr_roam(mac_ctx, cmd);
8488 }
8489 }
8490 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308491 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008492 /*
8493 * We need to come with other way to figure out that this is
8494 * because of HO in BMP The below API will be only available for
8495 * Android as it uses a different HO algorithm. Reassoc request
8496 * will be used only for ESE and 11r handoff whereas other
8497 * legacy roaming should use join request
8498 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008499 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
8500 && csr_roam_is11r_assoc(mac_ctx, session_id)) {
8501 status = csr_roam_issue_reassociate(mac_ctx,
8502 session_id, bss_desc,
8503 (tDot11fBeaconIEs *)
8504 (scan_result->Result.pvIes),
8505 &cmd->u.roamCmd.roamProfile);
8506 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008507#ifdef FEATURE_WLAN_ESE
8508 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
8509 && csr_roam_is_ese_assoc(mac_ctx, session_id)) {
8510 /* Now serialize the reassoc command. */
8511 status = csr_roam_issue_reassociate_cmd(mac_ctx,
8512 session_id);
8513 } else
8514#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008515 if (csr_roam_is_handoff_in_progress(mac_ctx, session_id)
8516 && csr_roam_is_fast_roam_enabled(mac_ctx, session_id)) {
8517 /* Now serialize the reassoc command. */
8518 status = csr_roam_issue_reassociate_cmd(mac_ctx,
8519 session_id);
Deepak Dhamdhereecce9742015-11-08 01:16:43 -08008520 } else {
8521 /*
8522 * else we are not connected and attempting to Join.
8523 * Issue the Join request.
8524 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008525 status = csr_roam_issue_join(mac_ctx, session_id,
8526 bss_desc,
8527 (tDot11fBeaconIEs *)
8528 (scan_result->Result.pvIes),
8529 &cmd->u.roamCmd.roamProfile,
8530 cmd->u.roamCmd.roamId);
8531 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308532 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008533 /* try something else */
8534 csr_roam(mac_ctx, cmd);
8535 }
8536 }
8537 if (!scan_result->Result.pvIes) {
8538 /* Locally allocated */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308539 qdf_mem_free(local_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008540 }
8541}
8542
8543static void csr_roam_roaming_state_reassoc_rsp_processor(tpAniSirGlobal pMac,
8544 tpSirSmeJoinRsp pSmeJoinRsp)
8545{
8546 eCsrRoamCompleteResult result;
8547 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
8548 &pMac->roam.neighborRoamInfo[pSmeJoinRsp->sessionId];
8549 tCsrRoamInfo roamInfo;
8550 uint32_t roamId = 0;
8551
8552 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308553 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008554 FL("CSR SmeReassocReq Successful"));
8555 result = eCsrReassocSuccess;
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -08008556 /*
8557 * Since the neighbor roam algorithm uses reassoc req for
8558 * handoff instead of join, we need the response contents while
8559 * processing the result in csr_roam_process_results()
8560 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008561 if (csr_roam_is_handoff_in_progress(pMac, pSmeJoinRsp->sessionId)) {
8562 /* Need to dig more on indicating events to SME QoS module */
8563 sme_qos_csr_event_ind(pMac, pSmeJoinRsp->sessionId,
8564 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8565 csr_roam_complete(pMac, result, pSmeJoinRsp);
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -08008566 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008567 csr_roam_complete(pMac, result, NULL);
8568 }
8569 }
8570 /* Should we handle this similar to handling the join failure? Is it ok
8571 * to call csr_roam_complete() with state as CsrJoinFailure */
8572 else {
8573 sms_log(pMac, LOGW,
8574 "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]",
8575 pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode);
8576 result = eCsrReassocFailure;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008577 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE ==
8578 pSmeJoinRsp->statusCode)
8579 || (eSIR_SME_FT_REASSOC_FAILURE ==
8580 pSmeJoinRsp->statusCode)
8581 || (eSIR_SME_INVALID_PARAMETERS ==
8582 pSmeJoinRsp->statusCode)) {
8583 /* Inform HDD to turn off FT flag in HDD */
8584 if (pNeighborRoamInfo) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308585 qdf_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008586 csr_roam_call_callback(pMac,
8587 pSmeJoinRsp->sessionId,
8588 &roamInfo, roamId,
8589 eCSR_ROAM_FT_REASSOC_FAILED,
8590 eSIR_SME_SUCCESS);
8591 /*
8592 * Since the above callback sends a disconnect
8593 * to HDD, we should clean-up our state
8594 * machine as well to be in sync with the upper
8595 * layers. There is no need to send a disassoc
8596 * since: 1) we will never reassoc to the current
8597 * AP in LFR, and 2) there is no need to issue a
8598 * disassoc to the AP with which we were trying
8599 * to reassoc.
8600 */
8601 csr_roam_complete(pMac, eCsrJoinFailure, NULL);
8602 return;
8603 }
8604 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008605 /* In the event that the Reassociation fails, then we need to Disassociate the current association and keep */
8606 /* roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a */
8607 /* 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc. */
8608 /* The disassoc rsp message will remove the command from active list */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308609 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008610 (csr_roam_issue_disassociate
8611 (pMac, pSmeJoinRsp->sessionId,
8612 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, false))) {
8613 csr_roam_complete(pMac, eCsrJoinFailure, NULL);
8614 }
8615 }
8616}
8617
8618static void csr_roam_roaming_state_stop_bss_rsp_processor(tpAniSirGlobal pMac,
8619 tSirSmeRsp *pSmeRsp)
8620{
8621#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8622 {
8623 host_log_ibss_pkt_type *pIbssLog;
8624 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
8625 LOG_WLAN_IBSS_C);
8626 if (pIbssLog) {
8627 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8628 if (eSIR_SME_SUCCESS != pSmeRsp->statusCode) {
8629 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8630 }
8631 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
8632 }
8633 }
8634#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
8635 pMac->roam.roamSession[pSmeRsp->sessionId].connectState =
8636 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8637 if (CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ(pMac, pSmeRsp->sessionId)) {
8638 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
8639 } else
8640 if (CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE
8641 (pMac, pSmeRsp->sessionId)) {
8642 csr_roam_reissue_roam_command(pMac);
8643 }
8644}
8645
8646/**
8647 * csr_dequeue_command() - removes a command from active cmd list
8648 * @pMac: mac global context
8649 *
8650 * Return: void
8651 */
8652static void
8653csr_dequeue_command(tpAniSirGlobal mac_ctx)
8654{
8655 bool fRemoveCmd;
8656 tSmeCmd *cmd = NULL;
8657 tListElem *entry = csr_ll_peek_head(&mac_ctx->sme.smeCmdActiveList,
8658 LL_ACCESS_LOCK);
8659 if (!entry) {
8660 sms_log(mac_ctx, LOGE, FL("NO commands are active"));
8661 return;
8662 }
8663
8664 cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
8665 /*
8666 * If the head of the queue is Active and it is a given cmd type, remove
8667 * and put this on the Free queue.
8668 */
8669 if (eSmeCommandRoam != cmd->command) {
8670 sms_log(mac_ctx, LOGE, FL("Roam command not active"));
8671 return;
8672 }
8673 /*
8674 * we need to process the result first before removing it from active
8675 * list because state changes still happening insides
8676 * roamQProcessRoamResults so no other roam command should be issued.
8677 */
8678 fRemoveCmd = csr_ll_remove_entry(&mac_ctx->sme.smeCmdActiveList, entry,
8679 LL_ACCESS_LOCK);
8680 if (cmd->u.roamCmd.fReleaseProfile) {
8681 csr_release_profile(mac_ctx, &cmd->u.roamCmd.roamProfile);
8682 cmd->u.roamCmd.fReleaseProfile = false;
8683 }
8684 if (fRemoveCmd)
8685 csr_release_command_roam(mac_ctx, cmd);
8686 else
8687 sms_log(mac_ctx, LOGE, FL("fail to remove cmd reason %d"),
8688 cmd->u.roamCmd.roamReason);
8689}
8690
8691/**
8692 * csr_post_roam_failure() - post roam failure back to csr and issues a disassoc
8693 * @pMac: mac global context
8694 * @session_id: session id
8695 * @roam_info: roam info struct
8696 * @scan_filter: scan filter to free
8697 * @cur_roam_profile: current csr roam profile
8698 *
8699 * Return: void
8700 */
8701static void
8702csr_post_roam_failure(tpAniSirGlobal mac_ctx,
8703 uint32_t session_id,
8704 tCsrRoamInfo *roam_info,
8705 tCsrScanResultFilter *scan_filter,
8706 tCsrRoamProfile *cur_roam_profile)
8707{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308708 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008709
8710 if (scan_filter) {
8711 csr_free_scan_filter(mac_ctx, scan_filter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308712 qdf_mem_free(scan_filter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008713 }
8714 if (cur_roam_profile)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308715 qdf_mem_free(cur_roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008716
8717#ifdef WLAN_FEATURE_ROAM_OFFLOAD
8718 csr_roam_synch_clean_up(mac_ctx, session_id);
8719#endif
8720 /* Inform the upper layers that the reassoc failed */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308721 qdf_mem_zero(roam_info, sizeof(tCsrRoamInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008722 csr_roam_call_callback(mac_ctx, session_id, roam_info, 0,
8723 eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8724 /*
8725 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT
8726 * session. Upon success, we would re-enter this routine after receiving
8727 * the disassoc response and will fall into the reassoc fail sub-state.
8728 * And, eventually call csr_roam_complete which would remove the roam
8729 * command from SME active queue.
8730 */
8731 status = csr_roam_issue_disassociate(mac_ctx, session_id,
8732 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308733 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008734 sms_log(mac_ctx, LOGE,
8735 FL("csr_roam_issue_disassociate failed, status %d"),
8736 status);
8737 csr_roam_complete(mac_ctx, eCsrJoinFailure, NULL);
8738 }
8739}
8740
8741/**
8742 * csr_check_profile_in_scan_cache() - finds if roam profile is present in scan
8743 * cache or not
8744 * @pMac: mac global context
8745 * @scan_filter: out param, scan filter
8746 * @neighbor_roam_info: roam info struct
8747 * @hBSSList: scan result
8748 *
8749 * Return: true if found else false.
8750 */
8751static bool
8752csr_check_profile_in_scan_cache(tpAniSirGlobal mac_ctx,
8753 tCsrScanResultFilter **scan_filter,
8754 tpCsrNeighborRoamControlInfo neighbor_roam_info,
8755 tScanResultHandle *hBSSList)
8756{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308757 QDF_STATUS status;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308758 *scan_filter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008759 if (NULL == *scan_filter) {
8760 sms_log(mac_ctx, LOGE, FL("alloc for ScanFilter failed."));
8761 return false;
8762 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308763 qdf_mem_set(*scan_filter, sizeof(tCsrScanResultFilter), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008764 (*scan_filter)->scan_filter_for_roam = 1;
8765 status = csr_roam_prepare_filter_from_profile(mac_ctx,
8766 &neighbor_roam_info->csrNeighborRoamProfile,
8767 *scan_filter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308768 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008769 sms_log(mac_ctx, LOGE,
8770 FL("failed to prepare scan filter, status %d"),
8771 status);
8772 return false;
8773 }
8774 status = csr_scan_get_result(mac_ctx, *scan_filter, hBSSList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308775 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008776 sms_log(mac_ctx, LOGE,
8777 FL("csr_scan_get_result failed, status %d"),
8778 status);
8779 return false;
8780 }
8781 return true;
8782}
8783
8784void csr_roam_roaming_state_disassoc_rsp_processor(tpAniSirGlobal pMac,
8785 tSirSmeDisassocRsp *pSmeRsp)
8786{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008787 tScanResultHandle hBSSList;
8788 tCsrRoamInfo roamInfo;
8789 tCsrScanResultFilter *pScanFilter = NULL;
8790 uint32_t roamId = 0;
8791 tCsrRoamProfile *pCurRoamProfile = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308792 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008793 uint32_t sessionId;
8794 tCsrRoamSession *pSession;
8795 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = NULL;
8796 tSirSmeDisassocRsp SmeDisassocRsp;
8797
8798 csr_ser_des_unpack_diassoc_rsp((uint8_t *) pSmeRsp, &SmeDisassocRsp);
8799 sessionId = SmeDisassocRsp.sessionId;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308800 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG, FL("sessionId %d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008801 sessionId);
8802
8803 if (csr_is_conn_state_infra(pMac, sessionId)) {
8804 pMac->roam.roamSession[sessionId].connectState =
8805 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8806 }
8807
8808 pSession = CSR_GET_SESSION(pMac, sessionId);
8809 if (!pSession) {
8810 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
8811 return;
8812 }
8813
8814 if (CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN(pMac, sessionId)) {
8815 sms_log(pMac, LOG2, "***eCsrNothingToJoin***");
8816 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
8817 } else if (CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED(pMac, sessionId) ||
8818 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ(pMac, sessionId)) {
8819 if (eSIR_SME_SUCCESS == SmeDisassocRsp.statusCode) {
8820 sms_log(pMac, LOG2,
8821 FL("CSR force disassociated successful"));
8822 /*
8823 * A callback to HDD will be issued from
8824 * csr_roam_complete so no need to do anything here
8825 */
8826 }
8827 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
8828 } else if (CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05308829 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008830 FL("CSR SmeDisassocReq due to HO on session %d"),
8831 sessionId);
8832 pNeighborRoamInfo = &pMac->roam.neighborRoamInfo[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008833 /*
8834 * First ensure if the roam profile is in the scan cache.
8835 * If not, post a reassoc failure and disconnect.
8836 */
8837 if (!csr_check_profile_in_scan_cache(pMac, &pScanFilter,
8838 pNeighborRoamInfo, &hBSSList))
8839 goto POST_ROAM_FAILURE;
8840
8841 /*
8842 * After ensuring that the roam profile is in the scan result
8843 * list, dequeue the command from the active list.
8844 */
8845 csr_dequeue_command(pMac);
8846
8847 /* notify HDD about handoff and provide the BSSID too */
8848 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8849
Anurag Chouhanc5548422016-02-24 18:33:27 +05308850 qdf_copy_macaddr(&roamInfo.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008851 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid);
8852
8853 csr_roam_call_callback(pMac, sessionId, &roamInfo, 0,
8854 eCSR_ROAM_ROAMING_START,
8855 eCSR_ROAM_RESULT_NONE);
8856
8857 /*
8858 * Copy the connected profile to apply the same for this
8859 * connection as well
8860 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308861 pCurRoamProfile = qdf_mem_malloc(sizeof(tCsrRoamProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008862 if (pCurRoamProfile != NULL) {
8863 /*
8864 * notify sub-modules like QoS etc. that handoff
8865 * happening
8866 */
8867 sme_qos_csr_event_ind(pMac, sessionId,
8868 SME_QOS_CSR_HANDOFF_ASSOC_REQ,
8869 NULL);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308870 qdf_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008871 0);
8872 csr_roam_copy_profile(pMac, pCurRoamProfile,
8873 pSession->pCurRoamProfile);
8874 /* make sure to put it at the head of the cmd queue */
8875 status = csr_roam_issue_connect(pMac, sessionId,
8876 pCurRoamProfile, hBSSList,
8877 eCsrSmeIssuedAssocToSimilarAP,
8878 roamId, true, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05308879 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008880 sms_log(pMac, LOGE,
8881 FL("issue_connect failed. status %d"),
8882 status);
8883
8884 csr_release_profile(pMac, pCurRoamProfile);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308885 qdf_mem_free(pCurRoamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008886 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05308887 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008888 return;
8889 }
8890
8891POST_ROAM_FAILURE:
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -08008892 csr_post_roam_failure(pMac, sessionId, &roamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008893 pScanFilter, pCurRoamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08008894 } /* else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) ) */
8895 else if (CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL(pMac, sessionId)) {
8896 /* Disassoc due to Reassoc failure falls into this codepath */
8897 csr_roam_complete(pMac, eCsrJoinFailure, NULL);
8898 } else {
8899 if (eSIR_SME_SUCCESS == SmeDisassocRsp.statusCode) {
8900 /*
8901 * Successfully disassociated from the 'old' Bss.
8902 * We get Disassociate response in three conditions.
8903 * 1) The case where we are disasociating from an Infra
8904 * Bss to start an IBSS.
8905 * 2) When we are disassociating from an Infra Bss to
8906 * join an IBSS or a new infra network.
8907 * 3) Where we are doing an Infra to Infra roam between
8908 * networks with different SSIDs.
8909 * In all cases, we set the new Bss configuration here
8910 * and attempt to join
8911 */
8912 sms_log(pMac, LOG2,
8913 FL("Disassociated successfully"));
8914 } else {
8915 sms_log(pMac, LOGE,
8916 FL("DisassocReq failed, statusCode= 0x%08X"),
8917 SmeDisassocRsp.statusCode);
8918 }
8919 /* We are not done yet. Get the data and continue roaming */
8920 csr_roam_reissue_roam_command(pMac);
8921 }
8922}
8923
8924static void csr_roam_roaming_state_deauth_rsp_processor(tpAniSirGlobal pMac,
8925 tSirSmeDeauthRsp *pSmeRsp)
8926{
8927 tSirResultCodes statusCode;
8928 /* No one is sending eWNI_SME_DEAUTH_REQ to PE. */
8929 sms_log(pMac, LOGW, FL("is no-op"));
8930 statusCode = csr_get_de_auth_rsp_status_code(pSmeRsp);
8931 pMac->roam.deauthRspStatus = statusCode;
8932 if (CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ(pMac, pSmeRsp->sessionId)) {
8933 csr_roam_complete(pMac, eCsrNothingToJoin, NULL);
8934 } else {
8935 if (eSIR_SME_SUCCESS == statusCode) {
8936 /* Successfully deauth from the 'old' Bss... */
8937 /* */
8938 sms_log(pMac, LOG2,
8939 "CSR SmeDeauthReq disassociated Successfully");
8940 } else {
8941 sms_log(pMac, LOGW,
8942 "SmeDeauthReq failed with statusCode= 0x%08X",
8943 statusCode);
8944 }
8945 /* We are not done yet. Get the data and continue roaming */
8946 csr_roam_reissue_roam_command(pMac);
8947 }
8948}
8949
8950static void csr_roam_roaming_state_start_bss_rsp_processor(tpAniSirGlobal pMac,
8951 tSirSmeStartBssRsp *
8952 pSmeStartBssRsp)
8953{
8954 eCsrRoamCompleteResult result;
8955
8956 if (eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode) {
8957 sms_log(pMac, LOGW, "SmeStartBssReq Successful");
8958 result = eCsrStartBssSuccess;
8959 } else {
8960 sms_log(pMac, LOGW,
8961 "SmeStartBssReq failed with statusCode= 0x%08X",
8962 pSmeStartBssRsp->statusCode);
8963 /* Let csr_roam_complete decide what to do */
8964 result = eCsrStartBssFailure;
8965 }
8966 csr_roam_complete(pMac, result, pSmeStartBssRsp);
8967}
8968
8969/**
8970 * csr_roaming_state_msg_processor() - process roaming messages
8971 * @pMac: mac global context
8972 * @pMsgBuf: message buffer
8973 *
8974 * We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of
8975 * strucutres. It depends on how the message is constructed. If the message is
8976 * sent by lim_send_sme_rsp, the pMsgBuf is only a generic response and can only
8977 * be used as pointer to tSirSmeRsp. For the messages where sender allocates
8978 * memory for specific structures, then it can be cast accordingly.
8979 *
8980 * Return: status of operation
8981 */
8982void csr_roaming_state_msg_processor(tpAniSirGlobal pMac, void *pMsgBuf)
8983{
8984 tSirSmeRsp *pSmeRsp;
8985 tSmeIbssPeerInd *pIbssPeerInd;
8986 tCsrRoamInfo roamInfo;
8987 pSmeRsp = (tSirSmeRsp *) pMsgBuf;
8988 sms_log(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8989 pSmeRsp->messageType, pSmeRsp->messageType,
8990 mac_trace_getcsr_roam_sub_state(
8991 pMac->roam.curSubState[pSmeRsp->sessionId]));
8992 pSmeRsp->messageType = pSmeRsp->messageType;
8993 pSmeRsp->length = pSmeRsp->length;
8994 pSmeRsp->statusCode = pSmeRsp->statusCode;
8995
8996 switch (pSmeRsp->messageType) {
8997
8998 case eWNI_SME_JOIN_RSP:
8999 /* in Roaming state, process the Join response message... */
9000 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
9001 /* We sent a JOIN_REQ */
9002 csr_roam_join_rsp_processor(pMac,
9003 (tSirSmeJoinRsp *) pSmeRsp);
9004 break;
9005 case eWNI_SME_REASSOC_RSP:
9006 /* or the Reassociation response message... */
9007 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ(pMac, pSmeRsp->sessionId))
9008 csr_roam_roaming_state_reassoc_rsp_processor(pMac,
9009 (tpSirSmeJoinRsp) pSmeRsp);
9010 break;
9011 case eWNI_SME_STOP_BSS_RSP:
9012 /* or the Stop Bss response message... */
9013 csr_roam_roaming_state_stop_bss_rsp_processor(pMac, pSmeRsp);
9014 break;
9015 case eWNI_SME_DISASSOC_RSP:
9016 /* or the Disassociate response message... */
9017 if (CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ(pMac, pSmeRsp->sessionId)
9018 || CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN(pMac,
9019 pSmeRsp->sessionId)
9020 || CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL(pMac,
9021 pSmeRsp->sessionId)
9022 || CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED(pMac,
9023 pSmeRsp->sessionId)
9024 || CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE(pMac,
9025 pSmeRsp->sessionId)
9026 || CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac,
9027 pSmeRsp->sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309028 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009029 FL("eWNI_SME_DISASSOC_RSP subState = %s"),
9030 mac_trace_getcsr_roam_sub_state(
9031 pMac->roam.curSubState[pSmeRsp->sessionId]));
9032 csr_roam_roaming_state_disassoc_rsp_processor(pMac,
9033 (tSirSmeDisassocRsp *) pSmeRsp);
9034 }
9035 break;
9036 case eWNI_SME_DEAUTH_RSP:
9037 /* or the Deauthentication response message... */
9038 if (CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ(pMac, pSmeRsp->sessionId))
9039 csr_roam_roaming_state_deauth_rsp_processor(pMac,
9040 (tSirSmeDeauthRsp *) pSmeRsp);
9041 break;
9042 case eWNI_SME_START_BSS_RSP:
9043 /* or the Start BSS response message... */
9044 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ(pMac,
9045 pSmeRsp->sessionId))
9046 csr_roam_roaming_state_start_bss_rsp_processor(pMac,
9047 (tSirSmeStartBssRsp *) pSmeRsp);
9048 break;
9049 /* In case CSR issues STOP_BSS, we need to tell HDD about peer departed
9050 * becasue PE is removing them
9051 */
9052 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9053 pIbssPeerInd = (tSmeIbssPeerInd *) pSmeRsp;
9054 sms_log(pMac, LOGE,
9055 FL("Peer departed ntf from LIM in joining state"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309056 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009057 roamInfo.staId = (uint8_t) pIbssPeerInd->staId;
9058 roamInfo.ucastSig = (uint8_t) pIbssPeerInd->ucastSig;
9059 roamInfo.bcastSig = (uint8_t) pIbssPeerInd->bcastSig;
Anurag Chouhanc5548422016-02-24 18:33:27 +05309060 qdf_copy_macaddr(&roamInfo.peerMac, &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009061 csr_roam_call_callback(pMac, pSmeRsp->sessionId, &roamInfo, 0,
9062 eCSR_ROAM_CONNECT_STATUS_UPDATE,
9063 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9064 break;
9065 case eWNI_SME_GET_RSSI_REQ:
9066 {
9067 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq *) pMsgBuf;
9068 if (NULL != pGetRssiReq->rssiCallback)
9069 ((tCsrRssiCallback) pGetRssiReq->rssiCallback)
9070 (pGetRssiReq->lastRSSI, pGetRssiReq->staId,
9071 pGetRssiReq->pDevContext);
9072 else
9073 sms_log(pMac, LOGE,
9074 FL("pGetRssiReq->rssiCallback is NULL"));
9075 }
9076 break;
9077 default:
9078 sms_log(pMac, LOG1,
9079 FL("Unexpected message type = %d[0x%X] received in substate %s"),
9080 pSmeRsp->messageType, pSmeRsp->messageType,
9081 mac_trace_getcsr_roam_sub_state(
9082 pMac->roam.curSubState[pSmeRsp->sessionId]));
9083 /* If we are connected, check the link status change */
9084 if (!csr_is_conn_state_disconnected(pMac, pSmeRsp->sessionId))
9085 csr_roam_check_for_link_status_change(pMac, pSmeRsp);
9086 break;
9087 }
9088}
9089
9090void csr_roam_joined_state_msg_processor(tpAniSirGlobal pMac, void *pMsgBuf)
9091{
9092 tSirSmeRsp *pSirMsg = (tSirSmeRsp *) pMsgBuf;
9093 switch (pSirMsg->messageType) {
9094 case eWNI_SME_GET_STATISTICS_RSP:
9095 sms_log(pMac, LOG2, FL("Stats rsp from PE"));
9096 csr_roam_stats_rsp_processor(pMac, pSirMsg);
9097 break;
9098 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
9099 {
9100 tCsrRoamSession *pSession;
9101 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
9102 tCsrRoamInfo roamInfo;
9103 tCsrRoamInfo *pRoamInfo = NULL;
9104 uint32_t sessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309105 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009106 sms_log(pMac, LOG1,
9107 FL
9108 ("ASSOCIATION confirmation can be given to upper layer "));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309109 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009110 pRoamInfo = &roamInfo;
9111 pUpperLayerAssocCnf =
9112 (tSirSmeAssocIndToUpperLayerCnf *) pMsgBuf;
9113 status =
9114 csr_roam_get_session_id_from_bssid(pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309115 (struct qdf_mac_addr *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009116 pUpperLayerAssocCnf->
9117 bssId, &sessionId);
9118 pSession = CSR_GET_SESSION(pMac, sessionId);
9119
9120 if (!pSession) {
9121 sms_log(pMac, LOGE,
9122 FL(" session %d not found "),
9123 sessionId);
9124 return;
9125 }
9126
9127 pRoamInfo->statusCode = eSIR_SME_SUCCESS; /* send the status code as Success */
9128 pRoamInfo->u.pConnectedProfile =
9129 &pSession->connectedProfile;
9130 pRoamInfo->staId = (uint8_t) pUpperLayerAssocCnf->aid;
9131 pRoamInfo->rsnIELen =
9132 (uint8_t) pUpperLayerAssocCnf->rsnIE.length;
9133 pRoamInfo->prsnIE =
9134 pUpperLayerAssocCnf->rsnIE.rsnIEdata;
9135#ifdef FEATURE_WLAN_WAPI
9136 pRoamInfo->wapiIELen =
9137 (uint8_t) pUpperLayerAssocCnf->wapiIE.length;
9138 pRoamInfo->pwapiIE =
9139 pUpperLayerAssocCnf->wapiIE.wapiIEdata;
9140#endif
9141 pRoamInfo->addIELen =
9142 (uint8_t) pUpperLayerAssocCnf->addIE.length;
9143 pRoamInfo->paddIE =
9144 pUpperLayerAssocCnf->addIE.addIEdata;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309145 qdf_mem_copy(pRoamInfo->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009146 pUpperLayerAssocCnf->peerMacAddr,
9147 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309148 qdf_mem_copy(&pRoamInfo->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009149 pUpperLayerAssocCnf->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309150 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009151 pRoamInfo->wmmEnabledSta =
9152 pUpperLayerAssocCnf->wmmEnabledSta;
9153 pRoamInfo->timingMeasCap =
9154 pUpperLayerAssocCnf->timingMeasCap;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309155 qdf_mem_copy(&pRoamInfo->chan_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009156 &pUpperLayerAssocCnf->chan_info,
9157 sizeof(tSirSmeChanInfo));
9158 if (CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile)) {
9159 pMac->roam.roamSession[sessionId].connectState =
9160 eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
9161 pRoamInfo->fReassocReq =
9162 pUpperLayerAssocCnf->reassocReq;
9163 status =
9164 csr_roam_call_callback(pMac, sessionId,
9165 pRoamInfo, 0,
9166 eCSR_ROAM_INFRA_IND,
9167 eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9168 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009169 }
9170 break;
9171 default:
9172 csr_roam_check_for_link_status_change(pMac, pSirMsg);
9173 break;
9174 }
9175}
9176
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309177QDF_STATUS csr_roam_issue_set_context_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009178 uint32_t sessionId,
9179 eCsrEncryptionType EncryptType,
9180 tSirBssDescription *pBssDescription,
9181 tSirMacAddr *bssId, bool addKey,
9182 bool fUnicast,
9183 tAniKeyDirection aniKeyDirection,
9184 uint8_t keyId, uint16_t keyLength,
9185 uint8_t *pKey, uint8_t paeRole)
9186{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309187 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009188 tAniEdType edType;
9189
9190 if (eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType) {
9191 EncryptType = eCSR_ENCRYPT_TYPE_NONE;
9192 }
9193
9194 edType = csr_translate_encrypt_type_to_ed_type(EncryptType);
9195
9196 /*
9197 * Allow 0 keys to be set for the non-WPA encrypt types. For WPA encrypt
9198 * types, the num keys must be non-zero or LIM will reject the set
9199 * context (assumes the SET_CONTEXT does not occur until the keys are
9200 * distrubuted).
9201 */
9202 if (CSR_IS_ENC_TYPE_STATIC(EncryptType) || addKey) {
9203 tCsrRoamSetKey setKey;
9204 setKey.encType = EncryptType;
9205 setKey.keyDirection = aniKeyDirection;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309206 qdf_mem_copy(&setKey.peerMac, bssId, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009207 /* 0 for supplicant */
9208 setKey.paeRole = paeRole;
9209 /* Key index */
9210 setKey.keyId = keyId;
9211 setKey.keyLength = keyLength;
9212 if (keyLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309213 qdf_mem_copy(setKey.Key, pKey, keyLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009214 }
9215 status = csr_roam_issue_set_key_command(pMac, sessionId,
9216 &setKey, 0);
9217 }
9218 return status;
9219}
9220
9221/**
9222 * csr_update_key_cmd() - update key info in set key command
9223 * @mac_ctx: mac global context
9224 * @session: roam session
9225 * @set_key: input set key command
9226 * @set_key_cmd: set key command to update
9227 * @enqueue_cmd: indicates if command need to be enqueued to sme
9228 *
9229 * This function will validate the key length, adjust if too long. Tt will
9230 * update bool enqueue_cmd, to false if some error has occured key are local.
9231 *
9232 * Return: status of operation
9233 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309234static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009235csr_update_key_cmd(tpAniSirGlobal mac_ctx, tCsrRoamSession *session,
9236 tCsrRoamSetKey *set_key, tSmeCmd *set_key_cmd,
9237 bool *enqueue_cmd)
9238{
9239 switch (set_key->encType) {
9240 case eCSR_ENCRYPT_TYPE_WEP40:
9241 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
9242 /* KeyLength maybe 0 for static WEP */
9243 if (set_key->keyLength) {
9244 if (set_key->keyLength < CSR_WEP40_KEY_LEN) {
9245 sms_log(mac_ctx, LOGW,
9246 FL("Invalid WEP40 keylength [= %d]"),
9247 set_key->keyLength);
9248 *enqueue_cmd = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309249 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009250 }
9251
9252 set_key_cmd->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309253 qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009254 CSR_WEP40_KEY_LEN);
9255 }
9256 *enqueue_cmd = true;
9257 break;
9258 case eCSR_ENCRYPT_TYPE_WEP104:
9259 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
9260 /* KeyLength maybe 0 for static WEP */
9261 if (set_key->keyLength) {
9262 if (set_key->keyLength < CSR_WEP104_KEY_LEN) {
9263 sms_log(mac_ctx, LOGW,
9264 FL("Invalid WEP104 keylength [= %d]"),
9265 set_key->keyLength);
9266 *enqueue_cmd = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309267 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009268 }
9269
9270 set_key_cmd->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309271 qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009272 CSR_WEP104_KEY_LEN);
9273 }
9274 *enqueue_cmd = true;
9275 break;
9276 case eCSR_ENCRYPT_TYPE_TKIP:
9277 if (set_key->keyLength < CSR_TKIP_KEY_LEN) {
9278 sms_log(mac_ctx, LOGW,
9279 FL("Invalid TKIP keylength [= %d]"),
9280 set_key->keyLength);
9281 *enqueue_cmd = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309282 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009283 }
9284 set_key_cmd->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309285 qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009286 CSR_TKIP_KEY_LEN);
9287 *enqueue_cmd = true;
9288 break;
9289 case eCSR_ENCRYPT_TYPE_AES:
9290 if (set_key->keyLength < CSR_AES_KEY_LEN) {
9291 sms_log(mac_ctx, LOGW,
9292 FL("Invalid AES/CCMP keylength [= %d]"),
9293 set_key->keyLength);
9294 *enqueue_cmd = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309295 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009296 }
9297 set_key_cmd->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309298 qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009299 CSR_AES_KEY_LEN);
9300 *enqueue_cmd = true;
9301 break;
9302#ifdef FEATURE_WLAN_WAPI
9303 case eCSR_ENCRYPT_TYPE_WPI:
9304 if (set_key->keyLength < CSR_WAPI_KEY_LEN) {
9305 sms_log(mac_ctx, LOGW,
9306 FL("Invalid WAPI keylength [= %d]"),
9307 set_key->keyLength);
9308 *enqueue_cmd = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309309 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009310 }
9311 set_key_cmd->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309312 qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009313 CSR_WAPI_KEY_LEN);
9314 if (session->pCurRoamProfile) {
9315 session->pCurRoamProfile->negotiatedUCEncryptionType =
9316 eCSR_ENCRYPT_TYPE_WPI;
9317 } else {
9318 sms_log(mac_ctx, LOGW,
9319 FL("pCurRoamProfile is NULL."));
9320 *enqueue_cmd = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309321 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009322 }
9323 *enqueue_cmd = true;
9324 break;
9325#endif /* FEATURE_WLAN_WAPI */
9326#ifdef FEATURE_WLAN_ESE
9327 case eCSR_ENCRYPT_TYPE_KRK:
9328 /* no need to enqueue KRK key request, since they are local */
9329 *enqueue_cmd = false;
9330 if (set_key->keyLength < CSR_KRK_KEY_LEN) {
9331 sms_log(mac_ctx, LOGW,
9332 FL("Invalid KRK keylength [= %d]"),
9333 set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309334 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009335 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309336 qdf_mem_copy(session->eseCckmInfo.krk, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009337 CSR_KRK_KEY_LEN);
9338 session->eseCckmInfo.reassoc_req_num = 1;
9339 session->eseCckmInfo.krk_plumbed = true;
9340 break;
9341#ifdef WLAN_FEATURE_ROAM_OFFLOAD
9342 case eCSR_ENCRYPT_TYPE_BTK:
9343 /* no need to enqueue KRK key request, since they are local */
9344 *enqueue_cmd = false;
9345 if (set_key->keyLength < SIR_BTK_KEY_LEN) {
9346 sms_log(mac_ctx, LOGW,
9347 FL("LFR3:Invalid BTK keylength [= %d]"),
9348 set_key->keyLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309349 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009350 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309351 qdf_mem_copy(session->eseCckmInfo.btk, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009352 SIR_BTK_KEY_LEN);
9353 break;
9354#endif
9355#endif /* FEATURE_WLAN_ESE */
9356#ifdef WLAN_FEATURE_11W
9357 /* Check for 11w BIP */
9358 case eCSR_ENCRYPT_TYPE_AES_CMAC:
9359 if (set_key->keyLength < CSR_AES_KEY_LEN) {
9360 sms_log(mac_ctx, LOGW,
9361 FL("Invalid AES/CCMP keylength [= %d]"),
9362 set_key->keyLength);
9363 *enqueue_cmd = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309364 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009365 }
9366 set_key_cmd->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309367 qdf_mem_copy(set_key_cmd->u.setKeyCmd.Key, set_key->Key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009368 CSR_AES_KEY_LEN);
9369 *enqueue_cmd = true;
9370 break;
9371#endif /* WLAN_FEATURE_11W */
9372 default:
9373 /* for open security also we want to enqueue command */
9374 *enqueue_cmd = true;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309375 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009376 } /* end of switch */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309377 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009378}
9379
9380
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309381static QDF_STATUS csr_roam_issue_set_key_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009382 uint32_t sessionId,
9383 tCsrRoamSetKey *pSetKey,
9384 uint32_t roamId)
9385{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309386 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009387 bool enqueue_cmd = true;
9388 tSmeCmd *pCommand = NULL;
9389#if defined(FEATURE_WLAN_ESE) || defined (FEATURE_WLAN_WAPI)
9390 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
9391 if (NULL == pSession) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309392 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009393 FL("session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309394 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009395 }
9396#endif /* FEATURE_WLAN_ESE */
9397
9398 pCommand = csr_get_command_buffer(pMac);
9399 if (NULL == pCommand) {
9400 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309401 return QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009402 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309403 qdf_mem_zero(pCommand, sizeof(tSmeCmd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009404 pCommand->command = eSmeCommandSetKey;
9405 pCommand->sessionId = (uint8_t) sessionId;
9406 /*
9407 * following function will validate the key length, Adjust if too long.
9408 * for static WEP the keys are not set thru' SetContextReq
9409 *
9410 * it will update bool enqueue_cmd, to false if some error has occured
9411 * key are local. enqueue sme command only if enqueue_cmd is true
9412 * status is indication of success or failure and will be returned to
9413 * called of current function if command is not enqueued due to key req
9414 * being local
9415 */
9416 status = csr_update_key_cmd(pMac, pSession, pSetKey,
9417 pCommand, &enqueue_cmd);
9418 if (enqueue_cmd) {
9419 pCommand->u.setKeyCmd.roamId = roamId;
9420 pCommand->u.setKeyCmd.encType = pSetKey->encType;
9421 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection;
Anurag Chouhanc5548422016-02-24 18:33:27 +05309422 qdf_copy_macaddr(&pCommand->u.setKeyCmd.peermac,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08009423 &pSetKey->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009424 /* 0 for supplicant */
9425 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole;
9426 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309427 qdf_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009428 CSR_MAX_RSC_LEN);
9429 /*
9430 * Always put set key to the head of the Q because it is the
9431 * only thing to get executed in case of WT_KEY state
9432 */
9433
9434 status = csr_queue_sme_command(pMac, pCommand, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309435 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009436 sms_log(pMac, LOGE,
9437 FL("fail to send message status = %d"), status);
9438 /* update to false so that command can be freed */
9439 enqueue_cmd = false;
9440 }
9441 }
9442
9443 /*
9444 * Free the command if enqueue_cmd == false:
9445 * this means that command was not enqueued because either there has
9446 * been a failure, or it is a "local" operation like the set ESE CCKM
9447 * KRK key.
9448 */
9449 if (false == enqueue_cmd)
9450 csr_release_command_set_key(pMac, pCommand);
9451
9452 return status;
9453}
9454
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309455QDF_STATUS csr_roam_process_set_key_command(tpAniSirGlobal pMac, tSmeCmd *pCommand)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009456{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309457 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009458 uint8_t numKeys = (pCommand->u.setKeyCmd.keyLength) ? 1 : 0;
9459 tAniEdType edType =
9460 csr_translate_encrypt_type_to_ed_type(pCommand->u.setKeyCmd.encType);
9461 bool fUnicast =
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08009462 (pCommand->u.setKeyCmd.peermac.bytes[0] == 0xFF) ? false : true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009463 uint32_t sessionId = pCommand->sessionId;
9464#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9465 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
9466 WLAN_HOST_DIAG_EVENT_DEF(setKeyEvent,
9467 host_event_wlan_security_payload_type);
9468
9469 if (NULL == pSession) {
9470 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309471 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009472 }
9473
9474 if (eSIR_ED_NONE != edType) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309475 qdf_mem_set(&setKeyEvent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009476 sizeof(host_event_wlan_security_payload_type), 0);
Anurag Chouhanc5548422016-02-24 18:33:27 +05309477 if (qdf_is_macaddr_group(&pCommand->u.setKeyCmd.peermac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009478 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
9479 setKeyEvent.encryptionModeMulticast =
9480 (uint8_t) diag_enc_type_from_csr_type(pCommand->u.
9481 setKeyCmd.encType);
9482 setKeyEvent.encryptionModeUnicast =
9483 (uint8_t) diag_enc_type_from_csr_type(pSession->
9484 connectedProfile.
9485 EncryptionType);
9486 } else {
9487 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
9488 setKeyEvent.encryptionModeUnicast =
9489 (uint8_t) diag_enc_type_from_csr_type(pCommand->u.
9490 setKeyCmd.encType);
9491 setKeyEvent.encryptionModeMulticast =
9492 (uint8_t) diag_enc_type_from_csr_type(pSession->
9493 connectedProfile.
9494 mcEncryptionType);
9495 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309496 qdf_mem_copy(setKeyEvent.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009497 pSession->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309498 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009499 if (CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType)) {
9500 uint32_t defKeyId;
9501 /* It has to be static WEP here */
9502 if (IS_SIR_STATUS_SUCCESS
9503 (wlan_cfg_get_int
9504 (pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId))) {
9505 setKeyEvent.keyId = (uint8_t) defKeyId;
9506 }
9507 } else {
9508 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
9509 }
9510 setKeyEvent.authMode =
9511 (uint8_t) diag_auth_type_from_csr_type(pSession->
9512 connectedProfile.
9513 AuthType);
9514 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9515 }
9516#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
9517 if (csr_is_set_key_allowed(pMac, sessionId)) {
9518 status = csr_send_mb_set_context_req_msg(pMac, sessionId,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08009519 pCommand->u.
9520 setKeyCmd.peermac,
9521 numKeys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009522 edType, fUnicast,
9523 pCommand->u.setKeyCmd.
9524 keyDirection,
9525 pCommand->u.setKeyCmd.keyId,
9526 pCommand->u.setKeyCmd.
9527 keyLength,
9528 pCommand->u.setKeyCmd.Key,
9529 pCommand->u.setKeyCmd.
9530 paeRole,
9531 pCommand->u.setKeyCmd.
9532 keyRsc);
9533 } else {
9534 sms_log(pMac, LOGW, FL(" cannot process not connected"));
9535 /* Set this status so the error handling take care of the case. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309536 status = QDF_STATUS_CSR_WRONG_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009537 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309538 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009539 sms_log(pMac, LOGE, FL(" error status %d"), status);
9540 csr_roam_call_callback(pMac, sessionId, NULL,
9541 pCommand->u.setKeyCmd.roamId,
9542 eCSR_ROAM_SET_KEY_COMPLETE,
9543 eCSR_ROAM_RESULT_FAILURE);
9544#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9545 if (eSIR_ED_NONE != edType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05309546 if (qdf_is_macaddr_group(
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08009547 &pCommand->u.setKeyCmd.peermac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009548 setKeyEvent.eventId =
9549 WLAN_SECURITY_EVENT_SET_GTK_RSP;
9550 } else {
9551 setKeyEvent.eventId =
9552 WLAN_SECURITY_EVENT_SET_PTK_RSP;
9553 }
9554 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9555 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent,
9556 EVENT_WLAN_SECURITY);
9557 }
9558#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
9559 }
9560 return status;
9561}
9562
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309563QDF_STATUS csr_roam_set_key(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009564 tCsrRoamSetKey *pSetKey, uint32_t roamId)
9565{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309566 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009567
9568 if (!csr_is_set_key_allowed(pMac, sessionId)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309569 status = QDF_STATUS_CSR_WRONG_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009570 } else {
9571 status =
9572 csr_roam_issue_set_key_command(pMac, sessionId, pSetKey, roamId);
9573 }
9574 return status;
9575}
9576
9577/*
9578 Prepare a filter base on a profile for parsing the scan results.
9579 Upon successful return, caller MUST call csr_free_scan_filter on
9580 pScanFilter when it is done with the filter.
9581 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309582QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009583csr_roam_prepare_filter_from_profile(tpAniSirGlobal mac_ctx,
9584 tCsrRoamProfile *profile,
9585 tCsrScanResultFilter *scan_fltr)
9586{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309587 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009588 uint32_t size = 0;
9589 uint8_t idx = 0;
9590 tCsrChannelInfo *fltr_ch_info = &scan_fltr->ChannelInfo;
9591 tCsrChannelInfo *profile_ch_info = &profile->ChannelInfo;
9592 struct roam_ext_params *roam_params;
9593 uint8_t i;
9594
9595 roam_params = &mac_ctx->roam.configParam.roam_params;
9596
9597 if (profile->BSSIDs.numOfBSSIDs) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05309598 size = sizeof(struct qdf_mac_addr) * profile->BSSIDs.numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309599 scan_fltr->BSSIDs.bssid = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009600 if (NULL == scan_fltr->BSSIDs.bssid) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309601 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009602 goto free_filter;
9603 }
9604 scan_fltr->BSSIDs.numOfBSSIDs = profile->BSSIDs.numOfBSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309605 qdf_mem_copy(scan_fltr->BSSIDs.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009606 profile->BSSIDs.bssid, size);
9607 }
9608
9609 if (profile->SSIDs.numOfSSIDs) {
Sandeep Puligillaee029ad2015-10-26 18:58:00 -07009610 scan_fltr->SSIDs.numOfSSIDs = profile->SSIDs.numOfSSIDs;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309611 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009612 FL("No of Allowed List:%d"),
9613 roam_params->num_ssid_allowed_list);
9614 if (scan_fltr->scan_filter_for_roam
9615 && roam_params->num_ssid_allowed_list) {
9616 scan_fltr->SSIDs.numOfSSIDs =
9617 roam_params->num_ssid_allowed_list;
9618 size = sizeof(tCsrSSIDInfo) *
9619 scan_fltr->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309620 scan_fltr->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009621 if (NULL == scan_fltr->SSIDs.SSIDList)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309622 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009623 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309624 status = QDF_STATUS_SUCCESS;
9625 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009626 goto free_filter;
9627 for (i = 0;
9628 i < roam_params->num_ssid_allowed_list;
9629 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309630 qdf_mem_copy((void *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009631 scan_fltr->SSIDs.SSIDList[i].SSID.ssId,
9632 roam_params->ssid_allowed_list[i].ssId,
9633 roam_params->ssid_allowed_list[i].length);
9634 scan_fltr->SSIDs.SSIDList[i].SSID.length =
9635 roam_params->ssid_allowed_list[i].length;
9636 scan_fltr->SSIDs.SSIDList[i].handoffPermitted =
9637 1;
9638 scan_fltr->SSIDs.SSIDList[i].ssidHidden = 0;
9639 }
9640 } else {
9641 size = sizeof(tCsrSSIDInfo) *
9642 profile->SSIDs.numOfSSIDs;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309643 scan_fltr->SSIDs.SSIDList = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009644 if (NULL == scan_fltr->SSIDs.SSIDList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309645 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009646 goto free_filter;
9647 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309648 qdf_mem_copy(scan_fltr->SSIDs.SSIDList,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009649 profile->SSIDs.SSIDList, size);
9650 }
9651 }
9652
9653 if (!profile_ch_info->ChannelList
9654 || (profile_ch_info->ChannelList[0] == 0)) {
9655 fltr_ch_info->numOfChannels = 0;
9656 fltr_ch_info->ChannelList = NULL;
9657 } else if (profile_ch_info->numOfChannels) {
9658 fltr_ch_info->numOfChannels = 0;
9659 fltr_ch_info->ChannelList =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309660 qdf_mem_malloc(sizeof(*(fltr_ch_info->ChannelList)) *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009661 profile_ch_info->numOfChannels);
9662 if (NULL == fltr_ch_info->ChannelList) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309663 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009664 goto free_filter;
9665 }
9666
9667 for (idx = 0; idx < profile_ch_info->numOfChannels; idx++) {
9668 if (csr_roam_is_channel_valid(mac_ctx,
9669 profile_ch_info->ChannelList[idx])) {
9670 fltr_ch_info->
9671 ChannelList[fltr_ch_info->numOfChannels]
9672 = profile_ch_info->ChannelList[idx];
9673 fltr_ch_info->numOfChannels++;
9674 } else {
9675 sms_log(mac_ctx, LOG1,
9676 FL("Channel (%d) is invalid"),
9677 profile_ch_info->ChannelList[idx]);
9678 }
9679 }
9680 } else {
9681 sms_log(mac_ctx, LOGE, FL("Channel list empty"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309682 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009683 goto free_filter;
9684 }
9685 scan_fltr->uapsd_mask = profile->uapsd_mask;
9686 scan_fltr->authType = profile->AuthType;
9687 scan_fltr->EncryptionType = profile->EncryptionType;
9688 scan_fltr->mcEncryptionType = profile->mcEncryptionType;
9689 scan_fltr->BSSType = profile->BSSType;
9690 scan_fltr->phyMode = profile->phyMode;
9691#ifdef FEATURE_WLAN_WAPI
9692 /*
9693 * check if user asked for WAPI with 11n or auto mode, in that
9694 * case modify the phymode to 11g
9695 */
9696 if (csr_is_profile_wapi(profile)) {
9697 if (scan_fltr->phyMode & eCSR_DOT11_MODE_11n)
9698 scan_fltr->phyMode &= ~eCSR_DOT11_MODE_11n;
9699 if (scan_fltr->phyMode & eCSR_DOT11_MODE_AUTO)
9700 scan_fltr->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9701 if (!scan_fltr->phyMode)
9702 scan_fltr->phyMode = eCSR_DOT11_MODE_11g;
9703 }
9704#endif /* FEATURE_WLAN_WAPI */
9705 /*Save the WPS info */
9706 scan_fltr->bWPSAssociation = profile->bWPSAssociation;
9707 scan_fltr->bOSENAssociation = profile->bOSENAssociation;
9708 if (profile->countryCode[0]) {
9709 /*
9710 * This causes the matching function to use countryCode as one
9711 * of the criteria.
9712 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309713 qdf_mem_copy(scan_fltr->countryCode, profile->countryCode,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009714 WNI_CFG_COUNTRY_CODE_LEN);
9715 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009716 if (profile->MDID.mdiePresent) {
9717 scan_fltr->MDID.mdiePresent = 1;
9718 scan_fltr->MDID.mobilityDomain = profile->MDID.mobilityDomain;
9719 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009720
9721#ifdef WLAN_FEATURE_11W
9722 /* Management Frame Protection */
9723 scan_fltr->MFPEnabled = profile->MFPEnabled;
9724 scan_fltr->MFPRequired = profile->MFPRequired;
9725 scan_fltr->MFPCapable = profile->MFPCapable;
9726#endif
9727 scan_fltr->csrPersona = profile->csrPersona;
9728
9729free_filter:
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309730 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009731 csr_free_scan_filter(mac_ctx, scan_fltr);
9732
9733 return status;
9734}
9735
9736bool csr_roam_issue_wm_status_change(tpAniSirGlobal pMac, uint32_t sessionId,
9737 eCsrRoamWmStatusChangeTypes Type,
9738 tSirSmeRsp *pSmeRsp)
9739{
9740 bool fCommandQueued = false;
9741 tSmeCmd *pCommand;
9742 do {
9743 /* Validate the type is ok... */
9744 if ((eCsrDisassociated != Type)
9745 && (eCsrDeauthenticated != Type))
9746 break;
9747 pCommand = csr_get_command_buffer(pMac);
9748 if (!pCommand) {
9749 sms_log(pMac, LOGE, FL(" fail to get command buffer"));
9750 break;
9751 }
9752 /* Change the substate in case it is waiting for key */
9753 if (CSR_IS_WAIT_FOR_KEY(pMac, sessionId)) {
9754 csr_roam_stop_wait_for_key_timer(pMac);
9755 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
9756 sessionId);
9757 }
9758 pCommand->command = eSmeCommandWmStatusChange;
9759 pCommand->sessionId = (uint8_t) sessionId;
9760 pCommand->u.wmStatusChangeCmd.Type = Type;
9761 if (eCsrDisassociated == Type) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309762 qdf_mem_copy(&pCommand->u.wmStatusChangeCmd.u.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009763 DisassocIndMsg, pSmeRsp,
9764 sizeof(pCommand->u.wmStatusChangeCmd.u.
9765 DisassocIndMsg));
9766 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309767 qdf_mem_copy(&pCommand->u.wmStatusChangeCmd.u.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009768 DeauthIndMsg, pSmeRsp,
9769 sizeof(pCommand->u.wmStatusChangeCmd.u.
9770 DeauthIndMsg));
9771 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309772 if (QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009773 (csr_queue_sme_command(pMac, pCommand, true))) {
9774 fCommandQueued = true;
9775 } else {
9776 sms_log(pMac, LOGE, FL(" fail to send message "));
9777 csr_release_command_wm_status_change(pMac, pCommand);
9778 }
9779
9780 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9781 csr_set_default_dot11_mode(pMac);
9782 } while (0);
9783 return fCommandQueued;
9784}
9785
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309786static QDF_STATUS csr_send_snr_request(void *pGetRssiReq)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009787{
9788 void *wma_handle;
9789
Anurag Chouhan6d760662016-02-20 16:05:43 +05309790 wma_handle = cds_get_context(QDF_MODULE_ID_WMA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009791 if (!wma_handle) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309792 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009793 "wma_handle is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309794 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009795 }
9796
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309797 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009798 wma_send_snr_request(wma_handle, pGetRssiReq)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05309799 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009800 "Failed to Trigger wma stats request");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309801 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009802 }
9803
9804 /* dont send success, otherwise call back
9805 * will released with out values */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309806 return QDF_STATUS_E_BUSY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009807}
9808
9809static void csr_update_rssi(tpAniSirGlobal pMac, void *pMsg)
9810{
9811 int8_t rssi = 0;
9812 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq *) pMsg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309813 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009814 if (pGetRssiReq) {
9815 if (NULL != pGetRssiReq->p_cds_context) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309816 qdf_status = csr_send_snr_request(pGetRssiReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009817 } else {
9818 sms_log(pMac, LOGE,
9819 FL("pGetRssiReq->p_cds_context is NULL"));
9820 return;
9821 }
9822
9823 if (NULL != pGetRssiReq->rssiCallback) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309824 if (qdf_status != QDF_STATUS_E_BUSY)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009825 ((tCsrRssiCallback) (pGetRssiReq->rssiCallback))
9826 (rssi, pGetRssiReq->staId,
9827 pGetRssiReq->pDevContext);
9828 else
9829 sms_log(pMac, LOG1,
9830 FL
9831 ("rssi request is posted. waiting for reply"));
9832 } else {
9833 sms_log(pMac, LOGE,
9834 FL("pGetRssiReq->rssiCallback is NULL"));
9835 return;
9836 }
9837 } else {
9838 sms_log(pMac, LOGE, FL("pGetRssiReq is NULL"));
9839 }
9840 return;
9841
9842}
9843
9844static void csr_update_snr(tpAniSirGlobal pMac, void *pMsg)
9845{
9846 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq *) pMsg;
9847
9848 if (pGetSnrReq) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309849 if (QDF_STATUS_SUCCESS != wma_get_snr(pGetSnrReq)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009850 sms_log(pMac, LOGE, FL("Error in wma_get_snr"));
9851 return;
9852 }
9853
9854 } else {
9855 sms_log(pMac, LOGE, FL("pGetSnrReq is NULL"));
9856 }
9857 return;
9858}
9859
9860#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
9861void csr_tsm_stats_rsp_processor(tpAniSirGlobal pMac, void *pMsg)
9862{
9863 tAniGetTsmStatsRsp *pTsmStatsRsp = (tAniGetTsmStatsRsp *) pMsg;
9864
9865 if (NULL != pTsmStatsRsp) {
9866 /* Get roam Rssi request is backed up and passed back to the response,
9867 Extract the request message to fetch callback */
9868 tpAniGetTsmStatsReq reqBkp
9869 = (tAniGetTsmStatsReq *) pTsmStatsRsp->tsmStatsReq;
9870
9871 if (NULL != reqBkp) {
9872 if (NULL != reqBkp->tsmStatsCallback) {
9873 ((tCsrTsmStatsCallback)
9874 (reqBkp->tsmStatsCallback))(pTsmStatsRsp->
9875 tsmMetrics,
9876 pTsmStatsRsp->
9877 staId,
9878 reqBkp->
9879 pDevContext);
9880 reqBkp->tsmStatsCallback = NULL;
9881 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309882 qdf_mem_free(reqBkp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009883 pTsmStatsRsp->tsmStatsReq = NULL;
9884 } else {
9885 sms_log(pMac, LOGE, FL("reqBkp is NULL"));
9886 if (NULL != reqBkp) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309887 qdf_mem_free(reqBkp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009888 pTsmStatsRsp->tsmStatsReq = NULL;
9889 }
9890 }
9891 } else {
9892 sms_log(pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9893 }
9894 return;
9895}
9896
9897void csr_send_ese_adjacent_ap_rep_ind(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
9898{
9899 uint32_t roamTS2 = 0;
9900 tCsrRoamInfo roamInfo;
9901 tpPESession pSessionEntry = NULL;
9902 uint8_t sessionId = CSR_SESSION_ID_INVALID;
9903
9904 if (NULL == pSession) {
9905 sms_log(pMac, LOGE, FL("pSession is NULL"));
9906 return;
9907 }
9908
Anurag Chouhan210db072016-02-22 18:42:15 +05309909 roamTS2 = qdf_mc_timer_get_system_time();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009910 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
9911 sms_log(pMac, LOG1, "Bssid(" MAC_ADDRESS_STR ") Roaming Delay(%u ms)",
9912 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid.bytes),
9913 roamInfo.tsmRoamDelay);
9914
9915 pSessionEntry = pe_find_session_by_bssid(pMac,
9916 pSession->connectedProfile.bssid.bytes,
9917 &sessionId);
9918 if (NULL == pSessionEntry) {
9919 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
9920 return;
9921 }
9922
9923 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly
9924 = roamInfo.tsmRoamDelay;
9925
9926 csr_roam_call_callback(pMac, pSession->sessionId, &roamInfo,
9927 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
9928}
9929#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
9930
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309931static QDF_STATUS csr_send_reset_ap_caps_changed(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309932 struct qdf_mac_addr *bssId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009933{
9934 tpSirResetAPCapsChange pMsg;
9935 uint16_t len;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309936 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009937
9938 /* Create the message and send to lim */
9939 len = sizeof(tSirResetAPCapsChange);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309940 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009941 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309942 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009943 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309944 status = QDF_STATUS_SUCCESS;
Srinivas Girigowda40567b92015-09-24 15:17:25 -07009945
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309946 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309947 qdf_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009948 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9949 pMsg->length = len;
Anurag Chouhanc5548422016-02-24 18:33:27 +05309950 qdf_copy_macaddr(&pMsg->bssId, bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009951 sms_log(pMac, LOG1,
9952 FL("CSR reset caps change for Bssid= " MAC_ADDRESS_STR),
Srinivas Girigowda40567b92015-09-24 15:17:25 -07009953 MAC_ADDR_ARRAY(pMsg->bssId.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009954 status = cds_send_mb_message_to_mac(pMsg);
9955 } else {
Srinivas Girigowda40567b92015-09-24 15:17:25 -07009956 sms_log(pMac, LOGE, FL("Memory allocation failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009957 }
9958 return status;
9959}
9960
9961static void
9962csr_roam_chk_lnk_assoc_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
9963{
9964 tCsrRoamSession *session;
9965 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309966 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009967 tCsrRoamInfo *roam_info_ptr = NULL;
9968 tSirSmeAssocInd *pAssocInd;
9969 tCsrRoamInfo roam_info;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05309970 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009971
9972 sms_log(mac_ctx, LOG1, FL("Receive WNI_SME_ASSOC_IND from SME"));
9973 pAssocInd = (tSirSmeAssocInd *) msg_ptr;
9974 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Anurag Chouhan6d760662016-02-20 16:05:43 +05309975 (struct qdf_mac_addr *) pAssocInd->bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05309976 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08009977 sms_log(mac_ctx, LOG1,
9978 FL("Couldn't find session_id for given BSSID"));
9979 return;
9980 }
9981 session = CSR_GET_SESSION(mac_ctx, sessionId);
9982 if (!session) {
9983 sms_log(mac_ctx, LOGE, FL("session %d not found"), sessionId);
9984 return;
9985 }
9986 roam_info_ptr = &roam_info;
9987 /* Required for indicating the frames to upper layer */
9988 roam_info_ptr->assocReqLength = pAssocInd->assocReqLength;
9989 roam_info_ptr->assocReqPtr = pAssocInd->assocReqPtr;
9990 roam_info_ptr->beaconPtr = pAssocInd->beaconPtr;
9991 roam_info_ptr->beaconLength = pAssocInd->beaconLength;
9992 roam_info_ptr->statusCode = eSIR_SME_SUCCESS;
9993 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
9994 roam_info_ptr->staId = (uint8_t) pAssocInd->staId;
9995 roam_info_ptr->rsnIELen = (uint8_t) pAssocInd->rsnIE.length;
9996 roam_info_ptr->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9997#ifdef FEATURE_WLAN_WAPI
9998 roam_info_ptr->wapiIELen = (uint8_t) pAssocInd->wapiIE.length;
9999 roam_info_ptr->pwapiIE = pAssocInd->wapiIE.wapiIEdata;
10000#endif
10001 roam_info_ptr->addIELen = (uint8_t) pAssocInd->addIE.length;
10002 roam_info_ptr->paddIE = pAssocInd->addIE.addIEdata;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010003 qdf_mem_copy(roam_info_ptr->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010004 pAssocInd->peerMacAddr,
10005 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010006 qdf_mem_copy(roam_info_ptr->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010007 pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010008 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010009 roam_info_ptr->wmmEnabledSta = pAssocInd->wmmEnabledSta;
10010 roam_info_ptr->timingMeasCap = pAssocInd->timingMeasCap;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010011 qdf_mem_copy(&roam_info_ptr->chan_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010012 &pAssocInd->chan_info,
10013 sizeof(tSirSmeChanInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010014 if (CSR_IS_INFRA_AP(roam_info_ptr->u.pConnectedProfile)) {
10015 if (session->pCurRoamProfile &&
10016 CSR_IS_ENC_TYPE_STATIC(
10017 session->pCurRoamProfile->negotiatedUCEncryptionType)) {
10018 /* NO keys... these key parameters don't matter. */
10019 csr_roam_issue_set_context_req(mac_ctx, sessionId,
10020 session->pCurRoamProfile->negotiatedUCEncryptionType,
10021 session->pConnectBssDesc,
10022 &(roam_info_ptr->peerMac.bytes),
10023 false, true, eSIR_TX_RX, 0, 0, NULL, 0);
10024 roam_info_ptr->fAuthRequired = false;
10025 } else {
10026 roam_info_ptr->fAuthRequired = true;
10027 }
10028 status = csr_roam_call_callback(mac_ctx, sessionId,
10029 roam_info_ptr, 0, eCSR_ROAM_INFRA_IND,
10030 eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010031 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010032 /* Refused due to Mac filtering */
10033 roam_info_ptr->statusCode = eSIR_SME_ASSOC_REFUSED;
10034 }
10035
10036 /* Send Association completion message to PE */
10037 status = csr_send_assoc_cnf_msg(mac_ctx, pAssocInd, status);
10038 /*
10039 * send a message to CSR itself just to avoid the EAPOL frames going
10040 * OTA before association response
10041 */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070010042 if (CSR_IS_INFRA_AP(roam_info_ptr->u.pConnectedProfile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010043 && (roam_info_ptr->statusCode != eSIR_SME_ASSOC_REFUSED)) {
10044 roam_info_ptr->fReassocReq = pAssocInd->reassocReq;
10045 status = csr_send_assoc_ind_to_upper_layer_cnf_msg(mac_ctx,
10046 pAssocInd, status, sessionId);
10047 }
10048}
10049
10050static void
10051csr_roam_chk_lnk_disassoc_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10052{
10053 tCsrRoamSession *session;
10054 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010055 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010056 tCsrRoamInfo *roam_info_ptr = NULL;
10057 tSirSmeDisassocInd *pDisassocInd;
10058 tSmeCmd cmd;
10059 tCsrRoamInfo roam_info;
10060
10061 /*
10062 * Check if AP dis-associated us because of MIC failure. If so,
10063 * then we need to take action immediately and not wait till the
10064 * the WmStatusChange requests is pushed and processed
10065 */
10066 pDisassocInd = (tSirSmeDisassocInd *) msg_ptr;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010067 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010068 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010069 &pDisassocInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010070 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010071 sms_log(mac_ctx, LOGE, FL("Session Id not found for BSSID "
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010072 MAC_ADDRESS_STR),
10073 MAC_ADDR_ARRAY(pDisassocInd->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010074 return;
10075 }
10076
10077 sms_log(mac_ctx, LOGE,
10078 FL("DISASSOCIATION Indication from MAC for session %d "),
10079 sessionId);
10080 sms_log(mac_ctx, LOGE,
10081 FL("DISASSOCIATION from peer =" MAC_ADDRESS_STR
10082 " " " reason = %d status = %d "),
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010083 MAC_ADDR_ARRAY(pDisassocInd->peer_macaddr.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010084 pDisassocInd->reasonCode,
10085 pDisassocInd->statusCode);
10086 /*
10087 * If we are in neighbor preauth done state then on receiving
10088 * disassoc or deauth we dont roam instead we just disassoc
10089 * from current ap and then go to disconnected state
10090 * This happens for ESE and 11r FT connections ONLY.
10091 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010092 if (csr_roam_is11r_assoc(mac_ctx, sessionId) &&
10093 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10094 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10095 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010096#ifdef FEATURE_WLAN_ESE
10097 if (csr_roam_is_ese_assoc(mac_ctx, sessionId) &&
10098 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10099 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10100 mac_ctx, sessionId);
10101#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010102 if (csr_roam_is_fast_roam_enabled(mac_ctx, sessionId) &&
10103 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10104 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10105 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010106 session = CSR_GET_SESSION(mac_ctx, sessionId);
10107 if (!session) {
10108 sms_log(mac_ctx, LOGE, FL("session %d not found"), sessionId);
10109 return;
10110 }
10111 if (csr_is_conn_state_infra(mac_ctx, sessionId))
10112 session->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10113#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10114 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
10115 SME_QOS_CSR_DISCONNECT_IND, NULL);
10116#endif
10117 csr_roam_link_down(mac_ctx, sessionId);
10118 csr_roam_issue_wm_status_change(mac_ctx, sessionId,
10119 eCsrDisassociated, msg_ptr);
10120 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
10121 roam_info_ptr = &roam_info;
10122 roam_info_ptr->statusCode = pDisassocInd->statusCode;
10123 roam_info_ptr->reasonCode = pDisassocInd->reasonCode;
10124 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
10125 roam_info_ptr->staId = (uint8_t) pDisassocInd->staId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010126 qdf_copy_macaddr(&roam_info_ptr->peerMac,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010127 &pDisassocInd->peer_macaddr);
Anurag Chouhanc5548422016-02-24 18:33:27 +053010128 qdf_copy_macaddr(&roam_info_ptr->bssid,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010129 &pDisassocInd->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010130 status = csr_roam_call_callback(mac_ctx, sessionId,
10131 roam_info_ptr, 0,
10132 eCSR_ROAM_INFRA_IND,
10133 eCSR_ROAM_RESULT_DISASSOC_IND);
10134 /*
10135 * STA/P2P client got disassociated so remove any pending
10136 * deauth commands in sme pending list
10137 */
10138 cmd.command = eSmeCommandRoam;
10139 cmd.sessionId = (uint8_t) sessionId;
10140 cmd.u.roamCmd.roamReason = eCsrForcedDeauthSta;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010141 qdf_mem_copy(cmd.u.roamCmd.peerMac,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080010142 pDisassocInd->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010143 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010144 csr_roam_remove_duplicate_command(mac_ctx, sessionId, &cmd,
10145 eCsrForcedDeauthSta);
10146 }
10147}
10148
10149static void
10150csr_roam_chk_lnk_deauth_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10151{
10152 tCsrRoamSession *session;
10153 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010154 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010155 tCsrRoamInfo *roam_info_ptr = NULL;
10156 tSirSmeDeauthInd *pDeauthInd;
10157 tCsrRoamInfo roam_info;
10158
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010159 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010160 sms_log(mac_ctx, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
10161 pDeauthInd = (tpSirSmeDeauthInd) msg_ptr;
10162 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080010163 &pDeauthInd->bssid,
10164 &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010165 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010166 return;
10167 /* If we are in neighbor preauth done state then on receiving
10168 * disassoc or deauth we dont roam instead we just disassoc
10169 * from current ap and then go to disconnected state
10170 * This happens for ESE and 11r FT connections ONLY.
10171 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010172 if (csr_roam_is11r_assoc(mac_ctx, sessionId) &&
10173 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10174 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10175 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010176#ifdef FEATURE_WLAN_ESE
10177 if (csr_roam_is_ese_assoc(mac_ctx, sessionId) &&
10178 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10179 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10180 mac_ctx, sessionId);
10181#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010182 if (csr_roam_is_fast_roam_enabled(mac_ctx, sessionId) &&
10183 (csr_neighbor_roam_state_preauth_done(mac_ctx, sessionId)))
10184 csr_neighbor_roam_tranistion_preauth_done_to_disconnected(
10185 mac_ctx, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010186 session = CSR_GET_SESSION(mac_ctx, sessionId);
10187 if (!session) {
10188 sms_log(mac_ctx, LOGE, FL("session %d not found"), sessionId);
10189 return;
10190 }
10191
10192 if (csr_is_conn_state_infra(mac_ctx, sessionId))
10193 session->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10194#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10195 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
10196 SME_QOS_CSR_DISCONNECT_IND, NULL);
10197#endif
10198 csr_roam_link_down(mac_ctx, sessionId);
10199 csr_roam_issue_wm_status_change(mac_ctx, sessionId,
10200 eCsrDeauthenticated,
10201 msg_ptr);
10202 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
10203 roam_info_ptr = &roam_info;
10204 roam_info_ptr->statusCode = pDeauthInd->statusCode;
10205 roam_info_ptr->reasonCode = pDeauthInd->reasonCode;
10206 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
10207 roam_info_ptr->staId = (uint8_t) pDeauthInd->staId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010208 qdf_copy_macaddr(&roam_info_ptr->peerMac,
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080010209 &pDeauthInd->peer_macaddr);
Anurag Chouhanc5548422016-02-24 18:33:27 +053010210 qdf_copy_macaddr(&roam_info_ptr->bssid,
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080010211 &pDeauthInd->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010212 status = csr_roam_call_callback(mac_ctx, sessionId,
10213 roam_info_ptr, 0,
10214 eCSR_ROAM_INFRA_IND,
10215 eCSR_ROAM_RESULT_DEAUTH_IND);
10216 }
10217}
10218
10219static void
10220csr_roam_chk_lnk_swt_ch_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10221{
10222 tCsrRoamSession *session;
10223 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010224 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010225 tpSirSmeSwitchChannelInd pSwitchChnInd;
10226
10227 /* in case of STA, the SWITCH_CHANNEL originates from its AP */
10228 sms_log(mac_ctx, LOGW, FL("eWNI_SME_SWITCH_CHL_IND from SME"));
10229 pSwitchChnInd = (tpSirSmeSwitchChannelInd) msg_ptr;
10230 /* Update with the new channel id. The channel id is hidden in the
10231 * statusCode.
10232 */
10233 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda591c5652015-12-30 17:39:50 -080010234 &pSwitchChnInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010235 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010236 session = CSR_GET_SESSION(mac_ctx, sessionId);
10237 if (!session) {
10238 sms_log(mac_ctx, LOGE,
10239 FL("session %d not found"), sessionId);
10240 return;
10241 }
10242 session->connectedProfile.operationChannel =
10243 (uint8_t) pSwitchChnInd->newChannelId;
10244 if (session->pConnectBssDesc) {
10245 session->pConnectBssDesc->channelId =
10246 (uint8_t) pSwitchChnInd->newChannelId;
10247 }
10248 }
10249}
10250
10251static void
10252csr_roam_chk_lnk_deauth_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10253{
10254 tCsrRoamSession *session;
10255 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010256 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010257 tCsrRoamInfo *roam_info_ptr = NULL;
10258 tSirSmeDeauthRsp *pDeauthRsp = (tSirSmeDeauthRsp *) msg_ptr;
10259 tCsrRoamInfo roam_info;
10260
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010261 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010262 sms_log(mac_ctx, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
10263 sessionId = pDeauthRsp->sessionId;
10264 if (!CSR_IS_SESSION_VALID(mac_ctx, sessionId))
10265 return;
10266 session = CSR_GET_SESSION(mac_ctx, sessionId);
10267 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
10268 roam_info_ptr = &roam_info;
10269 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010270 qdf_copy_macaddr(&roam_info_ptr->peerMac,
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -080010271 &pDeauthRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010272 roam_info_ptr->reasonCode = eCSR_ROAM_RESULT_FORCED;
10273 roam_info_ptr->statusCode = pDeauthRsp->statusCode;
10274 status = csr_roam_call_callback(mac_ctx, sessionId,
10275 roam_info_ptr, 0,
10276 eCSR_ROAM_LOSTLINK,
10277 eCSR_ROAM_RESULT_FORCED);
10278 }
10279}
10280
10281static void
10282csr_roam_chk_lnk_disassoc_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10283{
10284 tCsrRoamSession *session;
10285 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010286 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010287 tCsrRoamInfo *roam_info_ptr = NULL;
10288 tCsrRoamInfo roam_info;
10289 /*
10290 * session id is invalid here so cant use it to access the array
10291 * curSubstate as index
10292 */
10293 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *) msg_ptr;
10294
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010295 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010296 sms_log(mac_ctx, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
10297 sessionId = pDisassocRsp->sessionId;
10298 if (!CSR_IS_SESSION_VALID(mac_ctx, sessionId))
10299 return;
10300 session = CSR_GET_SESSION(mac_ctx, sessionId);
10301 if (CSR_IS_INFRA_AP(&session->connectedProfile)) {
10302 roam_info_ptr = &roam_info;
10303 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010304 qdf_copy_macaddr(&roam_info_ptr->peerMac,
Srinivas Girigowdadd3c5132016-01-05 19:41:27 -080010305 &pDisassocRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010306 roam_info_ptr->reasonCode = eCSR_ROAM_RESULT_FORCED;
10307 roam_info_ptr->statusCode = pDisassocRsp->statusCode;
10308 status = csr_roam_call_callback(mac_ctx, sessionId,
10309 roam_info_ptr, 0,
10310 eCSR_ROAM_LOSTLINK,
10311 eCSR_ROAM_RESULT_FORCED);
10312 }
10313}
10314
10315#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10316static void
10317csr_roam_diag_mic_fail(tpAniSirGlobal mac_ctx, uint32_t sessionId)
10318{
10319 WLAN_HOST_DIAG_EVENT_DEF(secEvent,
10320 host_event_wlan_security_payload_type);
10321 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, sessionId);
10322 if (!session) {
10323 sms_log(mac_ctx, LOGE, FL("session %d not found"), sessionId);
10324 return;
10325 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010326 qdf_mem_set(&secEvent, sizeof(host_event_wlan_security_payload_type),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010327 0);
10328 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
10329 secEvent.encryptionModeMulticast =
10330 (uint8_t) diag_enc_type_from_csr_type(
10331 session->connectedProfile.mcEncryptionType);
10332 secEvent.encryptionModeUnicast =
10333 (uint8_t) diag_enc_type_from_csr_type(
10334 session->connectedProfile.EncryptionType);
10335 secEvent.authMode =
10336 (uint8_t) diag_auth_type_from_csr_type(
10337 session->connectedProfile.AuthType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010338 qdf_mem_copy(secEvent.bssid, session->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010339 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010340 WLAN_HOST_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
10341}
10342#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10343
10344static void
10345csr_roam_chk_lnk_mic_fail_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10346{
10347 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010348 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010349 tCsrRoamInfo *roam_info_ptr = NULL;
10350 tCsrRoamInfo roam_info;
10351 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd) msg_ptr;
10352 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
10353
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010354 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010355 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda37c133b2015-09-24 16:14:15 -070010356 &pMicInd->bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010357 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010358 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010359 roam_info.u.pMICFailureInfo = &pMicInd->info;
10360 roam_info_ptr = &roam_info;
10361 if (pMicInd->info.multicast)
10362 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
10363 else
10364 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
10365 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
10366 eCSR_ROAM_MIC_ERROR_IND, result);
10367 }
10368#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10369 csr_roam_diag_mic_fail(mac_ctx, sessionId);
10370#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10371}
10372
10373static void
10374csr_roam_chk_lnk_pbs_probe_req_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10375{
10376 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010377 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010378 tCsrRoamInfo roam_info;
10379 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd) msg_ptr;
10380
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010381 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010382 sms_log(mac_ctx, LOG1, FL("WPS PBC Probe request Indication from SME"));
10383
10384 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowdad6673be2015-11-24 14:18:13 -080010385 &pProbeReqInd->bssid, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010386 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010387 qdf_mem_set(&roam_info, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010388 roam_info.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
10389 csr_roam_call_callback(mac_ctx, sessionId, &roam_info,
10390 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
10391 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
10392 }
10393}
10394
10395#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10396static void
10397csr_roam_diag_joined_new_bss(tpAniSirGlobal mac_ctx,
10398 tSirSmeNewBssInfo *pNewBss)
10399{
10400 host_log_ibss_pkt_type *pIbssLog;
10401 uint32_t bi;
10402 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
10403 LOG_WLAN_IBSS_C);
10404 if (!pIbssLog)
10405 return;
10406 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
10407 if (pNewBss) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053010408 qdf_copy_macaddr(&pIbssLog->bssid, &pNewBss->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010409 if (pNewBss->ssId.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010410 qdf_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010411 pNewBss->ssId.length);
10412 pIbssLog->operatingChannel = pNewBss->channelNumber;
10413 }
10414 if (IS_SIR_STATUS_SUCCESS(wlan_cfg_get_int(mac_ctx,
10415 WNI_CFG_BEACON_INTERVAL,
10416 &bi)))
10417 /* U8 is not enough for beacon interval */
10418 pIbssLog->beaconInterval = (uint8_t) bi;
10419 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
10420}
10421#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10422
10423static void
10424csr_roam_chk_lnk_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
10425 tSirSmeRsp *msg_ptr)
10426{
10427 tCsrRoamSession *session;
10428 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010429 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010430 tCsrRoamInfo *roam_info_ptr = NULL;
10431 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
10432 tCsrRoamInfo roam_info;
10433 tSirSmeApNewCaps *pApNewCaps;
10434 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10435 tSirMacAddr Broadcastaddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
10436 tSirSmeNewBssInfo *pNewBss;
10437 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
10438
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010439 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010440 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *) msg_ptr;
10441 switch (pStatusChangeMsg->statusChangeCode) {
10442 case eSIR_SME_IBSS_ACTIVE:
10443 sessionId = csr_find_ibss_session(mac_ctx);
10444 if (CSR_SESSION_ID_INVALID == sessionId)
10445 break;
10446 session = CSR_GET_SESSION(mac_ctx, sessionId);
10447 if (!session) {
10448 sms_log(mac_ctx, LOGE, FL("session %d not found"),
10449 sessionId);
10450 return;
10451 }
10452 session->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
10453 if (session->pConnectBssDesc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010454 qdf_mem_copy(&roam_info.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010455 session->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010456 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010457 roam_info.u.pConnectedProfile =
10458 &session->connectedProfile;
10459 roam_info_ptr = &roam_info;
10460 } else {
10461 sms_log(mac_ctx, LOGE,
10462 FL("CSR: connected BSS is empty"));
10463 }
10464 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
10465 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10466 break;
10467
10468 case eSIR_SME_IBSS_INACTIVE:
10469 sessionId = csr_find_ibss_session(mac_ctx);
10470 if (CSR_SESSION_ID_INVALID != sessionId) {
10471 session = CSR_GET_SESSION(mac_ctx, sessionId);
10472 if (!session) {
10473 sms_log(mac_ctx, LOGE,
10474 FL("session %d not found"), sessionId);
10475 return;
10476 }
10477 session->connectState =
10478 eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
10479 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
10480 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10481 }
10482 break;
10483
10484 case eSIR_SME_JOINED_NEW_BSS:
10485 /* IBSS coalescing. */
10486 sms_log(mac_ctx, LOGW,
10487 FL("CSR: eSIR_SME_JOINED_NEW_BSS received from PE"));
10488 sessionId = csr_find_ibss_session(mac_ctx);
10489 if (CSR_SESSION_ID_INVALID == sessionId)
10490 break;
10491 session = CSR_GET_SESSION(mac_ctx, sessionId);
10492 if (!session) {
10493 sms_log(mac_ctx, LOGE, FL("session %d not found"),
10494 sessionId);
10495 return;
10496 }
10497 /* update the connection state information */
10498 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
10499#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10500 csr_roam_diag_joined_new_bss(mac_ctx, pNewBss);
10501#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10502 csr_roam_update_connected_profile_from_new_bss(mac_ctx,
10503 sessionId,
10504 pNewBss);
10505
10506 if ((eCSR_ENCRYPT_TYPE_NONE ==
10507 session->connectedProfile.EncryptionType)) {
10508 csr_roam_issue_set_context_req(mac_ctx,
10509 sessionId,
10510 session->connectedProfile.EncryptionType,
10511 session->pConnectBssDesc,
10512 &Broadcastaddr, false, false,
10513 eSIR_TX_RX, 0, 0, NULL, 0);
10514 }
10515 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
10516 roamStatus = eCSR_ROAM_IBSS_IND;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010517 qdf_mem_copy(&roam_info.bssid, &pNewBss->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010518 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010519 roam_info_ptr = &roam_info;
10520 /* This BSSID is the real BSSID, save it */
10521 if (session->pConnectBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010522 qdf_mem_copy(session->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010523 &pNewBss->bssId, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010524 break;
10525
10526 /*
10527 * detection by LIM that the capabilities of the associated
10528 * AP have changed.
10529 */
10530 case eSIR_SME_AP_CAPS_CHANGED:
10531 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
10532 sms_log(mac_ctx, LOGW,
10533 FL("CSR handling eSIR_SME_AP_CAPS_CHANGED"));
10534 status = csr_roam_get_session_id_from_bssid(mac_ctx,
Srinivas Girigowda26ebb192015-09-24 15:12:09 -070010535 &pApNewCaps->bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010536 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010537 break;
10538 if (eCSR_ROAMING_STATE_JOINED ==
10539 mac_ctx->roam.curState[sessionId]
10540 && ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC
10541 == mac_ctx->roam.curSubState[sessionId])
10542 || (eCSR_ROAM_SUBSTATE_NONE ==
10543 mac_ctx->roam.curSubState[sessionId])
10544 || (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC
10545 == mac_ctx->roam.curSubState[sessionId])
10546 || (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC ==
10547 mac_ctx->roam.curSubState[sessionId]))) {
10548 sms_log(mac_ctx, LOGW,
10549 FL("Calling csr_roam_disconnect_internal"));
10550 csr_roam_disconnect_internal(mac_ctx, sessionId,
10551 eCSR_DISCONNECT_REASON_UNSPECIFIED);
10552 } else {
10553 sms_log(mac_ctx, LOGW,
10554 FL("Skipping the new scan as CSR is in state %s and sub-state %s"),
10555 mac_trace_getcsr_roam_state(
10556 mac_ctx->roam.curState[sessionId]),
10557 mac_trace_getcsr_roam_sub_state(
10558 mac_ctx->roam.curSubState[sessionId]));
10559 /* We ignore the caps change event if CSR is not in full
10560 * connected state. Send one event to PE to reset
10561 * limSentCapsChangeNtf Once limSentCapsChangeNtf set
10562 * 0, lim can send sub sequent CAPS change event
10563 * otherwise lim cannot send any CAPS change events to
10564 * SME
10565 */
10566 csr_send_reset_ap_caps_changed(mac_ctx,
10567 &pApNewCaps->bssId);
10568 }
10569 break;
10570
10571 default:
10572 roamStatus = eCSR_ROAM_FAILED;
10573 result = eCSR_ROAM_RESULT_NONE;
10574 break;
10575 } /* end switch on statusChangeCode */
10576 if (eCSR_ROAM_RESULT_NONE != result) {
10577 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
10578 roamStatus, result);
10579 }
10580}
10581
10582static void
10583csr_roam_chk_lnk_ibss_new_peer_ind(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10584{
10585 tCsrRoamSession *session;
10586 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010587 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010588 tCsrRoamInfo *roam_info_ptr = NULL;
10589 tSmeIbssPeerInd *pIbssPeerInd = (tSmeIbssPeerInd *) msg_ptr;
10590 tCsrRoamInfo roam_info;
10591#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10592 host_log_ibss_pkt_type *pIbssLog;
10593 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
10594 LOG_WLAN_IBSS_C);
10595 if (pIbssLog) {
10596 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010597 qdf_copy_macaddr(&pIbssLog->peer_macaddr,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080010598 &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010599 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
10600 }
10601#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10602
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010603 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010604 sessionId = csr_find_ibss_session(mac_ctx);
10605 if (CSR_SESSION_ID_INVALID == sessionId)
10606 return;
10607 session = CSR_GET_SESSION(mac_ctx, sessionId);
10608 if (!session) {
10609 sms_log(mac_ctx, LOGE, FL("session %d not found"), sessionId);
10610 return;
10611 }
10612 /*
10613 * Issue the set Context request to LIM to establish the Unicast STA
10614 * context for the new peer...
10615 */
10616 if (!session->pConnectBssDesc) {
10617 sms_log(mac_ctx, LOGW, FL("CSR: connected BSS is empty"));
10618 goto callback_and_free;
10619 }
Anurag Chouhanc5548422016-02-24 18:33:27 +053010620 qdf_copy_macaddr(&roam_info.peerMac, &pIbssPeerInd->peer_addr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010621 qdf_mem_copy(&roam_info.bssid, session->pConnectBssDesc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010622 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010623 if (pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010624 roam_info.pbFrames = qdf_mem_malloc((pIbssPeerInd->mesgLen -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010625 sizeof(tSmeIbssPeerInd)));
10626 if (NULL == roam_info.pbFrames) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010627 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010628 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010629 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010630 roam_info.nBeaconLength = pIbssPeerInd->mesgLen -
10631 sizeof(tSmeIbssPeerInd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010632 qdf_mem_copy(roam_info.pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010633 ((uint8_t *) pIbssPeerInd) +
10634 sizeof(tSmeIbssPeerInd),
10635 roam_info.nBeaconLength);
10636 }
10637 roam_info.staId = (uint8_t) pIbssPeerInd->staId;
10638 roam_info.ucastSig = (uint8_t) pIbssPeerInd->ucastSig;
10639 roam_info.bcastSig = (uint8_t) pIbssPeerInd->bcastSig;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010640 roam_info.pBssDesc = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010641 session->pConnectBssDesc->length);
10642 if (NULL == roam_info.pBssDesc) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010643 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010644 if (roam_info.pbFrames)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010645 qdf_mem_free(roam_info.pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010646 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010647 qdf_mem_free(roam_info.pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010648 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010649 status = QDF_STATUS_SUCCESS;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010650 qdf_mem_copy(roam_info.pBssDesc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010651 session->pConnectBssDesc,
10652 session->pConnectBssDesc->length);
10653 roam_info_ptr = &roam_info;
10654 }
10655 } else {
10656 roam_info_ptr = &roam_info;
10657 }
10658 if ((eCSR_ENCRYPT_TYPE_NONE ==
10659 session->connectedProfile.EncryptionType)) {
10660 /* NO keys. these key parameters don't matter */
10661 csr_roam_issue_set_context_req(mac_ctx, sessionId,
10662 session->connectedProfile.EncryptionType,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080010663 session->pConnectBssDesc,
10664 &pIbssPeerInd->peer_addr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010665 false, true, eSIR_TX_RX, 0, 0, NULL, 0);
10666 }
10667
10668callback_and_free:
10669 /* send up the sec type for the new peer */
10670 if (roam_info_ptr)
10671 roam_info_ptr->u.pConnectedProfile = &session->connectedProfile;
10672 csr_roam_call_callback(mac_ctx, sessionId, roam_info_ptr, 0,
10673 eCSR_ROAM_CONNECT_STATUS_UPDATE,
10674 eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10675 if (roam_info_ptr) {
10676 if (roam_info.pbFrames)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010677 qdf_mem_free(roam_info.pbFrames);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010678 if (roam_info.pBssDesc)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010679 qdf_mem_free(roam_info.pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010680 }
10681}
10682
10683static void
10684csr_roam_chk_lnk_ibss_peer_departed_ind(tpAniSirGlobal mac_ctx,
10685 tSirSmeRsp *msg_ptr)
10686{
10687 uint32_t sessionId = CSR_SESSION_ID_INVALID;
10688 tCsrRoamInfo roam_info;
10689 tSmeIbssPeerInd *pIbssPeerInd;
10690
10691 if (NULL == msg_ptr) {
10692 sms_log(mac_ctx, LOGE, FL("IBSS peer ind. message is NULL"));
10693 return;
10694 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010695 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010696 pIbssPeerInd = (tSmeIbssPeerInd *) msg_ptr;
10697 sessionId = csr_find_ibss_session(mac_ctx);
10698 if (CSR_SESSION_ID_INVALID != sessionId) {
10699#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10700 host_log_ibss_pkt_type *pIbssLog;
10701 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
10702 LOG_WLAN_IBSS_C);
10703 if (pIbssLog) {
10704 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10705 if (pIbssPeerInd) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053010706 qdf_copy_macaddr(&pIbssLog->peer_macaddr,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -080010707 &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010708 }
10709 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
10710 }
10711#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10712 sms_log(mac_ctx, LOGW,
10713 FL("CSR: Peer departed notification from LIM"));
10714 roam_info.staId = (uint8_t) pIbssPeerInd->staId;
10715 roam_info.ucastSig = (uint8_t) pIbssPeerInd->ucastSig;
10716 roam_info.bcastSig = (uint8_t) pIbssPeerInd->bcastSig;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010717 qdf_copy_macaddr(&roam_info.peerMac, &pIbssPeerInd->peer_addr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010718 csr_roam_call_callback(mac_ctx, sessionId, &roam_info, 0,
10719 eCSR_ROAM_CONNECT_STATUS_UPDATE,
10720 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10721 }
10722}
10723
10724#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10725static void
10726csr_roam_diag_set_ctx_rsp(tpAniSirGlobal mac_ctx,
10727 tCsrRoamSession *session,
10728 tSirSmeSetContextRsp *pRsp)
10729{
10730 WLAN_HOST_DIAG_EVENT_DEF(setKeyEvent,
10731 host_event_wlan_security_payload_type);
10732 if (eCSR_ENCRYPT_TYPE_NONE ==
10733 session->connectedProfile.EncryptionType)
10734 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010735 qdf_mem_set(&setKeyEvent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010736 sizeof(host_event_wlan_security_payload_type), 0);
Anurag Chouhanc5548422016-02-24 18:33:27 +053010737 if (qdf_is_macaddr_group(&pRsp->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010738 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
10739 else
10740 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
10741 setKeyEvent.encryptionModeMulticast =
10742 (uint8_t) diag_enc_type_from_csr_type(
10743 session->connectedProfile.mcEncryptionType);
10744 setKeyEvent.encryptionModeUnicast =
10745 (uint8_t) diag_enc_type_from_csr_type(
10746 session->connectedProfile.EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010747 qdf_mem_copy(setKeyEvent.bssid, session->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053010748 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010749 setKeyEvent.authMode =
10750 (uint8_t) diag_auth_type_from_csr_type(
10751 session->connectedProfile.AuthType);
10752 if (eSIR_SME_SUCCESS != pRsp->statusCode)
10753 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10754 WLAN_HOST_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10755}
10756#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10757
10758static void
10759csr_roam_chk_lnk_set_ctx_rsp(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10760{
10761 tCsrRoamSession *session;
10762 uint32_t sessionId = CSR_SESSION_ID_INVALID;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053010763 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010764 tCsrRoamInfo *roam_info_ptr = NULL;
10765 tSmeCmd *cmd;
10766 tCsrRoamInfo roam_info;
10767 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10768 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *) msg_ptr;
10769 tListElem *entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010770
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010771 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010772 entry = csr_ll_peek_head(&mac_ctx->sme.smeCmdActiveList,
10773 LL_ACCESS_LOCK);
10774 if (!entry) {
10775 sms_log(mac_ctx, LOGE, FL("CSR: NO commands are ACTIVE ..."));
10776 goto process_pending_n_exit;
10777 }
10778
10779 cmd = GET_BASE_ADDR(entry, tSmeCmd, Link);
10780 if (eSmeCommandSetKey != cmd->command) {
10781 sms_log(mac_ctx, LOGE, FL("CSR: setkey cmd is not ACTIVE ..."));
10782 goto process_pending_n_exit;
10783 }
10784 sessionId = cmd->sessionId;
10785 session = CSR_GET_SESSION(mac_ctx, sessionId);
10786 if (!session) {
10787 sms_log(mac_ctx, LOGE, FL("session %d not found"), sessionId);
10788 return;
10789 }
10790#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10791 csr_roam_diag_set_ctx_rsp(mac_ctx, session, pRsp);
10792#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
10793 if (CSR_IS_WAIT_FOR_KEY(mac_ctx, sessionId)) {
10794 csr_roam_stop_wait_for_key_timer(mac_ctx);
10795 /* We are done with authentication, whethere succeed or not */
10796 csr_roam_substate_change(mac_ctx, eCSR_ROAM_SUBSTATE_NONE,
10797 sessionId);
10798 /* We do it here because this linkup function is not called
10799 * after association when a key needs to be set.
10800 */
10801 if (csr_is_conn_state_connected_infra(mac_ctx, sessionId))
10802 csr_roam_link_up(mac_ctx,
10803 session->connectedProfile.bssid);
10804 }
10805 if (eSIR_SME_SUCCESS == pRsp->statusCode) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053010806 qdf_copy_macaddr(&roam_info.peerMac, &pRsp->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010807 /* Make sure we install the GTK before indicating to HDD as
10808 * authenticated. This is to prevent broadcast packets go out
10809 * after PTK and before GTK.
10810 */
Anurag Chouhanc5548422016-02-24 18:33:27 +053010811 if (qdf_is_macaddr_broadcast(&pRsp->peer_macaddr)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010812 tpSirSetActiveModeSetBncFilterReq pMsg;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010813 pMsg = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010814 sizeof(tSirSetActiveModeSetBncFilterReq));
10815 pMsg->messageType = eWNI_SME_SET_BCN_FILTER_REQ;
10816 pMsg->length = sizeof(uint8_t);
10817 pMsg->seesionId = sessionId;
10818 status = cds_send_mb_message_to_mac(pMsg);
10819 result = eCSR_ROAM_RESULT_AUTHENTICATED;
10820 } else {
10821 result = eCSR_ROAM_RESULT_NONE;
10822 }
Sandeep Puligillae0875662016-02-12 16:09:21 -080010823 /*
10824 * OBSS SCAN Indication will be sent to Firmware
10825 * to start OBSS Scan
10826 */
10827 if (CSR_IS_CHANNEL_24GHZ(
10828 session->connectedProfile.operationChannel)
10829 && (session->connectState ==
10830 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
10831 && session->pCurRoamProfile
10832 && ((QDF_P2P_CLIENT_MODE ==
10833 session->pCurRoamProfile->csrPersona)
10834 || (QDF_STA_MODE ==
10835 session->pCurRoamProfile->csrPersona))) {
10836 struct sme_obss_ht40_scanind_msg *msg;
10837 msg = qdf_mem_malloc(sizeof(
10838 struct sme_obss_ht40_scanind_msg));
10839 msg->msg_type = eWNI_SME_HT40_OBSS_SCAN_IND;
10840 msg->length = sizeof(struct sme_obss_ht40_scanind_msg);
10841 qdf_copy_macaddr(&msg->mac_addr,
10842 &session->connectedProfile.bssid);
10843 status = cds_send_mb_message_to_mac(msg);
10844 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010845 roam_info_ptr = &roam_info;
10846 } else {
10847 result = eCSR_ROAM_RESULT_FAILURE;
10848 sms_log(mac_ctx, LOGE,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080010849 FL("CSR: setkey command failed(err=%d) PeerMac "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010850 MAC_ADDRESS_STR),
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080010851 pRsp->statusCode,
10852 MAC_ADDR_ARRAY(pRsp->peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010853 }
10854 csr_roam_call_callback(mac_ctx, sessionId, &roam_info,
10855 cmd->u.setKeyCmd.roamId,
10856 eCSR_ROAM_SET_KEY_COMPLETE, result);
10857 /* Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10858 * can go ahead and initiate the TSPEC if any are pending
10859 */
10860 sme_qos_csr_event_ind(mac_ctx, (uint8_t) sessionId,
10861 SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
10862#ifdef FEATURE_WLAN_ESE
10863 /* Send Adjacent AP repot to new AP. */
10864 if (result == eCSR_ROAM_RESULT_AUTHENTICATED
10865 && session->isPrevApInfoValid
10866 && session->connectedProfile.isESEAssoc) {
10867#ifdef FEATURE_WLAN_ESE_UPLOAD
10868 csr_send_ese_adjacent_ap_rep_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010869#endif
10870 session->isPrevApInfoValid = false;
10871 }
10872#endif
10873 if (csr_ll_remove_entry(&mac_ctx->sme.smeCmdActiveList, entry,
10874 LL_ACCESS_LOCK))
10875 csr_release_command_set_key(mac_ctx, cmd);
10876
10877process_pending_n_exit:
10878 sme_process_pending_queue(mac_ctx);
10879}
10880
10881
10882static void
10883csr_roam_chk_lnk_max_assoc_exceeded(tpAniSirGlobal mac_ctx, tSirSmeRsp *msg_ptr)
10884{
10885 uint32_t sessionId = CSR_SESSION_ID_INVALID;
10886 tSmeMaxAssocInd *pSmeMaxAssocInd;
10887 tCsrRoamInfo roam_info;
10888
Anurag Chouhan600c3a02016-03-01 10:33:54 +053010889 qdf_mem_set(&roam_info, sizeof(roam_info), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010890 pSmeMaxAssocInd = (tSmeMaxAssocInd *) msg_ptr;
10891 sms_log(mac_ctx, LOG1,
10892 FL("max assoc have been reached, new peer cannot be accepted"));
10893 sessionId = pSmeMaxAssocInd->sessionId;
10894 roam_info.sessionId = sessionId;
Anurag Chouhanc5548422016-02-24 18:33:27 +053010895 qdf_copy_macaddr(&roam_info.peerMac, &pSmeMaxAssocInd->peer_mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010896 csr_roam_call_callback(mac_ctx, sessionId, &roam_info, 0,
10897 eCSR_ROAM_INFRA_IND,
10898 eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10899}
10900
10901void csr_roam_check_for_link_status_change(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
10902{
10903 if (NULL == pSirMsg) {
10904 sms_log(pMac, LOGE, FL("pSirMsg is NULL"));
10905 return;
10906 }
10907 switch (pSirMsg->messageType) {
10908 case eWNI_SME_ASSOC_IND:
10909 csr_roam_chk_lnk_assoc_ind(pMac, pSirMsg);
10910 break;
10911 case eWNI_SME_DISASSOC_IND:
10912 csr_roam_chk_lnk_disassoc_ind(pMac, pSirMsg);
10913 break;
10914 case eWNI_SME_DEAUTH_IND:
10915 csr_roam_chk_lnk_deauth_ind(pMac, pSirMsg);
10916 break;
10917 case eWNI_SME_SWITCH_CHL_IND:
10918 csr_roam_chk_lnk_swt_ch_ind(pMac, pSirMsg);
10919 break;
10920 case eWNI_SME_DEAUTH_RSP:
10921 csr_roam_chk_lnk_deauth_rsp(pMac, pSirMsg);
10922 break;
10923 case eWNI_SME_DISASSOC_RSP:
10924 csr_roam_chk_lnk_disassoc_rsp(pMac, pSirMsg);
10925 break;
10926 case eWNI_SME_MIC_FAILURE_IND:
10927 csr_roam_chk_lnk_mic_fail_ind(pMac, pSirMsg);
10928 break;
10929 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
10930 csr_roam_chk_lnk_pbs_probe_req_ind(pMac, pSirMsg);
10931 break;
10932 case eWNI_SME_WM_STATUS_CHANGE_NTF:
10933 csr_roam_chk_lnk_wm_status_change_ntf(pMac, pSirMsg);
10934 break;
10935 case eWNI_SME_IBSS_NEW_PEER_IND:
10936 csr_roam_chk_lnk_ibss_new_peer_ind(pMac, pSirMsg);
10937 break;
10938 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10939 csr_roam_chk_lnk_ibss_peer_departed_ind(pMac, pSirMsg);
10940 break;
10941 case eWNI_SME_SETCONTEXT_RSP:
10942 csr_roam_chk_lnk_set_ctx_rsp(pMac, pSirMsg);
10943 break;
10944 case eWNI_SME_GET_STATISTICS_RSP:
10945 sms_log(pMac, LOG2, FL("Stats rsp from PE"));
10946 csr_roam_stats_rsp_processor(pMac, pSirMsg);
10947 break;
10948#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
10949 case eWNI_SME_GET_TSM_STATS_RSP:
10950 sms_log(pMac, LOG2, FL("TSM Stats rsp from PE"));
10951 csr_tsm_stats_rsp_processor(pMac, pSirMsg);
10952 break;
10953#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
10954 case eWNI_SME_GET_RSSI_REQ:
10955 sms_log(pMac, LOG2, FL("GetRssiReq from self"));
10956 csr_update_rssi(pMac, pSirMsg);
10957 break;
10958 case eWNI_SME_GET_SNR_REQ:
10959 sms_log(pMac, LOG2, FL("GetSnrReq from self"));
10960 csr_update_snr(pMac, pSirMsg);
10961 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010962 case eWNI_SME_FT_PRE_AUTH_RSP:
10963 csr_roam_ft_pre_auth_rsp_processor(pMac, (tpSirFTPreAuthRsp) pSirMsg);
10964 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010965 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10966 csr_roam_chk_lnk_max_assoc_exceeded(pMac, pSirMsg);
10967 break;
10968 case eWNI_SME_CANDIDATE_FOUND_IND:
10969 sms_log(pMac, LOG2, FL("Candidate found indication from PE"));
10970 csr_neighbor_roam_candidate_found_ind_hdlr(pMac, pSirMsg);
10971 break;
10972 case eWNI_SME_HANDOFF_REQ:
10973 sms_log(pMac, LOG2, FL("Handoff Req from self"));
10974 csr_neighbor_roam_handoff_req_hdlr(pMac, pSirMsg);
10975 break;
10976 default:
10977 break;
10978 } /* end switch on message type */
10979}
10980
10981void csr_call_roaming_completion_callback(tpAniSirGlobal pMac,
10982 tCsrRoamSession *pSession,
10983 tCsrRoamInfo *pRoamInfo, uint32_t roamId,
10984 eCsrRoamResult roamResult)
10985{
10986 if (pSession) {
10987 if (pSession->bRefAssocStartCnt) {
10988 pSession->bRefAssocStartCnt--;
10989
10990 if (0 != pSession->bRefAssocStartCnt) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053010991 QDF_ASSERT(pSession->bRefAssocStartCnt == 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080010992 return;
10993 }
10994 /* Need to call association_completion because there is an assoc_start pending. */
10995 csr_roam_call_callback(pMac, pSession->sessionId, NULL,
10996 roamId,
10997 eCSR_ROAM_ASSOCIATION_COMPLETION,
10998 eCSR_ROAM_RESULT_FAILURE);
10999 }
11000 csr_roam_call_callback(pMac, pSession->sessionId, pRoamInfo,
11001 roamId, eCSR_ROAM_ROAMING_COMPLETION,
11002 roamResult);
11003 } else {
11004 sms_log(pMac, LOGW, FL(" pSession is NULL"));
11005 }
11006}
11007
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011008QDF_STATUS csr_roam_start_roaming(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011009 eCsrRoamingReason roamingReason)
11010{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011011 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011012 if (CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
11013 (false == pMac->roam.roamSession[sessionId].fCancelRoaming)) {
11014 status = csr_scan_request_lost_link1(pMac, sessionId);
11015 }
11016 return status;
11017}
11018
11019/* return a bool to indicate whether roaming completed or continue. */
11020bool csr_roam_complete_roaming(tpAniSirGlobal pMac, uint32_t sessionId,
11021 bool fForce, eCsrRoamResult roamResult)
11022{
11023 bool fCompleted = true;
11024 uint32_t roamTime =
11025 (uint32_t) (pMac->roam.configParam.nRoamingTime *
Anurag Chouhan6d760662016-02-20 16:05:43 +053011026 QDF_TICKS_PER_SECOND);
Anurag Chouhan210db072016-02-22 18:42:15 +053011027 uint32_t curTime = (uint32_t) qdf_mc_timer_get_system_ticks();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011028 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11029 if (!pSession) {
11030 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
11031 return false;
11032 }
11033 /* Check whether time is up */
11034 if (pSession->fCancelRoaming || fForce ||
11035 ((curTime - pSession->roamingStartTime) > roamTime) ||
11036 eCsrReassocRoaming == pSession->roamingReason ||
11037 eCsrDynamicRoaming == pSession->roamingReason) {
11038 sms_log(pMac, LOGW, FL(" indicates roaming completion"));
11039 if (pSession->fCancelRoaming
11040 && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason)) {
11041 /* roaming is cancelled, tell HDD to indicate disconnect */
11042 /* Because LIM overload deauth_ind for both deauth frame and missed beacon */
11043 /* we need to use this logic to detinguish it. For missed beacon, LIM set reason */
11044 /* to be eSIR_BEACON_MISSED */
11045 if (eSIR_BEACON_MISSED == pSession->roamingStatusCode) {
11046 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11047 } else if (eCsrLostlinkRoamingDisassoc ==
11048 pSession->roamingReason) {
11049 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
11050 } else if (eCsrLostlinkRoamingDeauth ==
11051 pSession->roamingReason) {
11052 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
11053 } else {
11054 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
11055 }
11056 }
11057 csr_call_roaming_completion_callback(pMac, pSession, NULL, 0,
11058 roamResult);
11059 pSession->roamingReason = eCsrNotRoaming;
11060 } else {
11061 pSession->roamResult = roamResult;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011062 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011063 (csr_roam_start_roaming_timer
Anurag Chouhan210db072016-02-22 18:42:15 +053011064 (pMac, sessionId, QDF_MC_TIMER_TO_SEC_UNIT))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011065 csr_call_roaming_completion_callback(pMac, pSession, NULL,
11066 0, roamResult);
11067 pSession->roamingReason = eCsrNotRoaming;
11068 } else {
11069 fCompleted = false;
11070 }
11071 }
11072 return fCompleted;
11073}
11074
11075void csr_roam_cancel_roaming(tpAniSirGlobal pMac, uint32_t sessionId)
11076{
11077 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11078
11079 if (!pSession) {
11080 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
11081 return;
11082 }
11083
11084 if (CSR_IS_ROAMING(pSession)) {
11085 sms_log(pMac, LOGW, "Cancel roaming");
11086 pSession->fCancelRoaming = true;
11087 if (CSR_IS_ROAM_JOINING(pMac, sessionId)
11088 && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId)) {
11089 /* No need to do anything in here because the handler takes care of it */
11090 } else {
11091 eCsrRoamResult roamResult =
11092 CSR_IS_LOSTLINK_ROAMING(pSession->
11093 roamingReason) ?
11094 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
11095 /* Roaming is stopped after here */
11096 csr_roam_complete_roaming(pMac, sessionId, true,
11097 roamResult);
11098 /* Since CSR may be in lostlink roaming situation, abort all roaming related activities */
11099 csr_scan_abort_mac_scan(pMac, sessionId,
11100 eCSR_SCAN_ABORT_DEFAULT);
11101 csr_roam_stop_roaming_timer(pMac, sessionId);
11102 }
11103 }
11104}
11105
11106void csr_roam_roaming_timer_handler(void *pv)
11107{
11108 tCsrTimerInfo *pInfo = (tCsrTimerInfo *) pv;
11109 tpAniSirGlobal pMac = pInfo->pMac;
11110 uint32_t sessionId = pInfo->sessionId;
11111 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11112
11113 if (!pSession) {
11114 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
11115 return;
11116 }
11117
11118 if (false == pSession->fCancelRoaming) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011119 if (!QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011120 (csr_roam_start_roaming
11121 (pMac, sessionId, pSession->roamingReason))) {
11122 csr_call_roaming_completion_callback(pMac, pSession, NULL,
11123 0,
11124 pSession->roamResult);
11125 pSession->roamingReason = eCsrNotRoaming;
11126 }
11127 }
11128}
11129
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011130QDF_STATUS csr_roam_start_roaming_timer(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011131 uint32_t interval)
11132{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011133 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011134 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11135
11136 if (!pSession) {
11137 sms_log(pMac, LOGE, FL(" session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011138 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011139 }
11140
11141 sms_log(pMac, LOG1, " csrScanStartRoamingTimer");
11142 pSession->roamingTimerInfo.sessionId = (uint8_t) sessionId;
Anurag Chouhan210db072016-02-22 18:42:15 +053011143 status = qdf_mc_timer_start(&pSession->hTimerRoaming,
11144 interval / QDF_MC_TIMER_TO_MS_UNIT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011145
11146 return status;
11147}
11148
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011149QDF_STATUS csr_roam_stop_roaming_timer(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011150{
Anurag Chouhan210db072016-02-22 18:42:15 +053011151 return qdf_mc_timer_stop
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011152 (&pMac->roam.roamSession[sessionId].hTimerRoaming);
11153}
11154
11155void csr_roam_wait_for_key_time_out_handler(void *pv)
11156{
11157 tCsrTimerInfo *pInfo = (tCsrTimerInfo *) pv;
11158 tpAniSirGlobal pMac = pInfo->pMac;
11159 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, pInfo->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011160 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011161
11162 if (pSession == NULL) {
11163 sms_log(pMac, LOGE, "%s: session not found", __func__);
11164 return;
11165 }
11166
11167 sms_log(pMac, LOGW,
11168 FL("WaitForKey timer expired in state=%s sub-state=%s"),
11169 mac_trace_get_neighbour_roam_state(pMac->roam.
11170 neighborRoamInfo[pInfo->sessionId].
11171 neighborRoamState),
11172 mac_trace_getcsr_roam_sub_state(pMac->roam.
11173 curSubState[pInfo->sessionId]));
11174
11175 if (CSR_IS_WAIT_FOR_KEY(pMac, pInfo->sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011176 if (csr_neighbor_roam_is_handoff_in_progress(pMac, pInfo->sessionId)) {
11177 /*
11178 * Enable heartbeat timer when hand-off is in progress
11179 * and Key Wait timer expired.
11180 */
11181 sms_log(pMac, LOG2,
11182 "Enabling HB timer after WaitKey expiry"
11183 " (nHBCount=%d)",
11184 pMac->roam.configParam.HeartbeatThresh24);
11185 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11186 pMac->roam.configParam.HeartbeatThresh24);
11187 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011188 sms_log(pMac, LOGE, " SME pre-auth state timeout. ");
11189
11190 /* Change the substate so command queue is unblocked. */
11191 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId) {
11192 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_NONE,
11193 pInfo->sessionId);
11194 }
11195
11196 if (csr_is_conn_state_connected_infra(pMac, pInfo->sessionId)) {
11197 csr_roam_link_up(pMac,
11198 pSession->connectedProfile.bssid);
11199 sme_process_pending_queue(pMac);
11200 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011201 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011202 csr_roam_disconnect(pMac, pInfo->sessionId,
11203 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11204 sme_release_global_lock(&pMac->sme);
11205 }
11206 } else {
11207 sms_log(pMac, LOGE, "%s: session not found", __func__);
11208 }
11209 }
11210
11211}
11212
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011213QDF_STATUS csr_roam_start_wait_for_key_timer(tpAniSirGlobal pMac, uint32_t interval)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011214{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011215 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011216 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
11217 &pMac->roam.neighborRoamInfo[pMac->roam.WaitForKeyTimerInfo.
11218 sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011219 if (csr_neighbor_roam_is_handoff_in_progress(pMac,
Deepak Dhamdhereecce9742015-11-08 01:16:43 -080011220 pMac->roam.WaitForKeyTimerInfo.
11221 sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011222 /* Disable heartbeat timer when hand-off is in progress */
11223 sms_log(pMac, LOG2,
11224 FL("disabling HB timer in state=%s sub-state=%s"),
Deepak Dhamdhereecce9742015-11-08 01:16:43 -080011225 mac_trace_get_neighbour_roam_state(
11226 pNeighborRoamInfo->neighborRoamState),
11227 mac_trace_getcsr_roam_sub_state(
11228 pMac->roam.curSubState[pMac->roam.
11229 WaitForKeyTimerInfo.sessionId]));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011230 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0);
11231 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011232 sms_log(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Anurag Chouhan210db072016-02-22 18:42:15 +053011233 status = qdf_mc_timer_start(&pMac->roam.hTimerWaitForKey,
11234 interval / QDF_MC_TIMER_TO_MS_UNIT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011235
11236 return status;
11237}
11238
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011239QDF_STATUS csr_roam_stop_wait_for_key_timer(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011240{
11241 tpCsrNeighborRoamControlInfo pNeighborRoamInfo =
11242 &pMac->roam.neighborRoamInfo[pMac->roam.WaitForKeyTimerInfo.
11243 sessionId];
11244
11245 sms_log(pMac, LOG2,
11246 FL("WaitForKey timer stopped in state=%s sub-state=%s"),
11247 mac_trace_get_neighbour_roam_state(pNeighborRoamInfo->
11248 neighborRoamState),
11249 mac_trace_getcsr_roam_sub_state(pMac->roam.
11250 curSubState[pMac->roam.
11251 WaitForKeyTimerInfo.
11252 sessionId]));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011253 if (csr_neighbor_roam_is_handoff_in_progress(pMac,
11254 pMac->roam.WaitForKeyTimerInfo.
11255 sessionId)) {
11256 /*
11257 * Enable heartbeat timer when hand-off is in progress
11258 * and Key Wait timer got stopped for some reason
11259 */
11260 sms_log(pMac, LOG2, "Enabling HB timer after WaitKey stop"
11261 " (nHBCount=%d)",
11262 pMac->roam.configParam.HeartbeatThresh24);
11263 cfg_set_int(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11264 pMac->roam.configParam.HeartbeatThresh24);
11265 }
Anurag Chouhan210db072016-02-22 18:42:15 +053011266 return qdf_mc_timer_stop(&pMac->roam.hTimerWaitForKey);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011267}
11268
11269void csr_roam_completion(tpAniSirGlobal pMac, uint32_t sessionId,
11270 tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
11271 eCsrRoamResult roamResult, bool fSuccess)
11272{
11273 eRoamCmdStatus roamStatus = csr_get_roam_complete_status(pMac, sessionId);
11274 uint32_t roamId = 0;
11275 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11276
11277 if (!pSession) {
11278 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
11279 return;
11280 }
11281
11282 if (pCommand) {
11283 roamId = pCommand->u.roamCmd.roamId;
11284 if (sessionId != pCommand->sessionId) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011285 QDF_ASSERT(sessionId == pCommand->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011286 return;
11287 }
11288 }
11289 if (eCSR_ROAM_ROAMING_COMPLETION == roamStatus) {
11290 /* if success, force roaming completion */
11291 csr_roam_complete_roaming(pMac, sessionId, fSuccess, roamResult);
11292 } else {
11293 if (pSession->bRefAssocStartCnt != 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011294 QDF_ASSERT(pSession->bRefAssocStartCnt == 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011295 return;
11296 }
11297 sms_log(pMac, LOGW,
11298 FL
11299 (" indicates association completion. roamResult = %d"),
11300 roamResult);
11301 csr_roam_call_callback(pMac, sessionId, pRoamInfo, roamId,
11302 roamStatus, roamResult);
11303 }
11304}
11305
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011306QDF_STATUS csr_roam_lost_link(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011307 uint32_t type, tSirSmeRsp *pSirMsg)
11308{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011309 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011310 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
11311 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
11312 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
11313 tCsrRoamInfo *pRoamInfo = NULL;
11314 tCsrRoamInfo roamInfo;
11315 bool fToRoam;
11316 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11317
11318 if (!pSession) {
11319 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011320 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011321 }
11322 /* Only need to roam for infra station. In this case P2P client will roam as well */
11323 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
11324 pSession->fCancelRoaming = false;
11325 if (eWNI_SME_DISASSOC_IND == type) {
11326 result = eCSR_ROAM_RESULT_DISASSOC_IND;
11327 pDisassocIndMsg = (tSirSmeDisassocInd *) pSirMsg;
11328 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
11329 pSession->joinFailStatusCode.reasonCode =
11330 pDisassocIndMsg->reasonCode;
11331 } else if (eWNI_SME_DEAUTH_IND == type) {
11332 result = eCSR_ROAM_RESULT_DEAUTH_IND;
11333 pDeauthIndMsg = (tSirSmeDeauthInd *) pSirMsg;
11334 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
11335 /* Convert into proper reason code */
11336 if ((pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ||
11337 (pDeauthIndMsg->reasonCode ==
11338 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON))
11339 pSession->joinFailStatusCode.reasonCode = 0;
11340 else
11341 pSession->joinFailStatusCode.reasonCode =
11342 pDeauthIndMsg->reasonCode;
11343 /*
11344 * cfg layer expects 0 as reason code if
11345 * the driver dosent know the reason code
11346 * eSIR_BEACON_MISSED is defined as locally
11347 */
11348 } else {
11349 sms_log(pMac, LOGW, FL("gets an unknown type (%d)"), type);
11350 result = eCSR_ROAM_RESULT_NONE;
11351 pSession->joinFailStatusCode.reasonCode = 1;
11352 }
11353
11354 /* call profile lost link routine here */
11355 if (!CSR_IS_INFRA_AP(&pSession->connectedProfile)) {
11356 csr_roam_call_callback(pMac, sessionId, NULL, 0,
11357 eCSR_ROAM_LOSTLINK_DETECTED, result);
11358 /*Move the state to Idle after disconnection */
11359 csr_roam_state_change(pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
11360
11361 }
11362
11363 if (eWNI_SME_DISASSOC_IND == type) {
11364 status = csr_send_mb_disassoc_cnf_msg(pMac, pDisassocIndMsg);
11365 } else if (eWNI_SME_DEAUTH_IND == type) {
11366 status = csr_send_mb_deauth_cnf_msg(pMac, pDeauthIndMsg);
11367 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011368 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011369 /* If fail to send confirmation to PE, not to trigger roaming */
11370 fToRoam = false;
11371 }
11372 /* prepare to tell HDD to disconnect */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011373 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011374 roamInfo.statusCode = (tSirResultCodes) pSession->roamingStatusCode;
11375 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
11376 if (eWNI_SME_DISASSOC_IND == type) {
11377 /* staMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053011378 qdf_copy_macaddr(&roamInfo.peerMac,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080011379 &pDisassocIndMsg->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011380 roamInfo.staId = (uint8_t) pDisassocIndMsg->staId;
11381 roamInfo.reasonCode = pDisassocIndMsg->reasonCode;
11382 } else if (eWNI_SME_DEAUTH_IND == type) {
11383 /* staMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053011384 qdf_copy_macaddr(&roamInfo.peerMac,
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080011385 &pDeauthIndMsg->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011386 roamInfo.staId = (uint8_t) pDeauthIndMsg->staId;
11387 roamInfo.reasonCode = pDeauthIndMsg->reasonCode;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -080011388 roamInfo.rxRssi = pDeauthIndMsg->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011389 }
Srinivas Girigowda9ee9a5c2016-01-04 15:51:05 -080011390 sms_log(pMac, LOGW, FL("roamInfo.staId: %d"), roamInfo.staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011391
11392 /* See if we can possibly roam. If so, start the roaming process and notify HDD
11393 that we are roaming. But if we cannot possibly roam, or if we are unable to
11394 currently roam, then notify HDD of the lost link */
11395 if (fToRoam) {
11396 /* Only remove the connected BSS in infrastructure mode */
11397 csr_roam_remove_connected_bss_from_scan_cache(pMac,
11398 &pSession->
11399 connectedProfile);
11400 /* Not to do anying for lostlink with WDS */
11401 status = csr_roam_start_roaming(pMac, sessionId,
11402 (eWNI_SME_DEAUTH_IND == type) ?
11403 eCsrLostlinkRoamingDeauth :
11404 eCsrLostlinkRoamingDisassoc);
11405 if (pMac->roam.configParam.nRoamingTime) {
11406 status = csr_roam_start_roaming(pMac, sessionId,
11407 (eWNI_SME_DEAUTH_IND == type) ?
11408 eCsrLostlinkRoamingDeauth :
11409 eCsrLostlinkRoamingDisassoc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011410 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011411 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011412 /* For IBSS, we need to give some more info to HDD */
11413 if (csr_is_bss_type_ibss
11414 (pSession->connectedProfile.BSSType)) {
11415 roamInfo.u.pConnectedProfile =
11416 &pSession->connectedProfile;
11417 roamInfo.statusCode =
11418 (tSirResultCodes) pSession->
11419 roamingStatusCode;
11420 roamInfo.reasonCode =
11421 pSession->joinFailStatusCode.
11422 reasonCode;
11423 } else {
11424 roamInfo.reasonCode =
11425 eCsrRoamReasonSmeIssuedForLostLink;
11426 }
11427 pRoamInfo = &roamInfo;
11428 pSession->roamingReason =
11429 (eWNI_SME_DEAUTH_IND ==
11430 type) ? eCsrLostlinkRoamingDeauth :
11431 eCsrLostlinkRoamingDisassoc;
11432 pSession->roamingStartTime =
Anurag Chouhan210db072016-02-22 18:42:15 +053011433 (uint32_t) qdf_mc_timer_get_system_ticks();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011434 csr_roam_call_callback(pMac, sessionId, pRoamInfo,
11435 0, eCSR_ROAM_ROAMING_START,
11436 eCSR_ROAM_RESULT_LOSTLINK);
11437 } else {
11438 sms_log(pMac, LOGW,
11439 " %s Fail to start roaming, status = %d",
11440 __func__, status);
11441 fToRoam = false;
11442 }
11443 } else {
11444 /* We are told not to roam, indicate lostlink */
11445 fToRoam = false;
11446 }
11447 }
11448 if (!fToRoam) {
11449 /* Tell HDD about the lost link */
11450 if (!CSR_IS_INFRA_AP(&pSession->connectedProfile)) {
11451 /* Don't call csr_roam_call_callback for GO/SoftAp case as this indication
11452 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
11453 * csr_roam_check_for_link_status_change API.
11454 */
11455 csr_roam_call_callback(pMac, sessionId, &roamInfo, 0,
11456 eCSR_ROAM_LOSTLINK, result);
11457 }
11458
11459 }
11460
11461 return status;
11462}
11463
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011464QDF_STATUS csr_roam_lost_link_afterhandoff_failure(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011465 uint32_t sessionId)
11466{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011467 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011468 tListElem *pEntry = NULL;
11469 tSmeCmd *pCommand = NULL;
11470 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11471
11472 if (!pSession) {
11473 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011474 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011475 }
11476
11477 pSession->fCancelRoaming = false;
11478 /* Only remove the connected BSS in infrastructure mode */
11479 csr_roam_remove_connected_bss_from_scan_cache(pMac,
11480 &pSession->connectedProfile);
11481 if (pMac->roam.configParam.nRoamingTime) {
11482 status = csr_roam_start_roaming(pMac, sessionId,
11483 pSession->roamingReason);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011484 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011485 /*
11486 * before starting the lost link logic release
11487 * the roam command for handoff
11488 */
11489 pEntry =
11490 csr_ll_peek_head(&pMac->sme.smeCmdActiveList,
11491 LL_ACCESS_LOCK);
11492 if (pEntry) {
11493 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11494 }
11495 if (pCommand) {
11496 if ((eSmeCommandRoam == pCommand->command) &&
11497 (eCsrSmeIssuedAssocToSimilarAP ==
11498 pCommand->u.roamCmd.roamReason)) {
11499 if (csr_ll_remove_entry
11500 (&pMac->sme.smeCmdActiveList,
11501 pEntry, LL_ACCESS_LOCK)) {
11502 csr_release_command_roam(pMac,
11503 pCommand);
11504 }
11505 }
11506 }
11507 sms_log(pMac, LOGW, "Lost link roaming started ...");
11508 }
11509 } else {
11510 /* We are told not to roam, indicate lostlink */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011511 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011512 }
11513
11514 return status;
11515}
11516
11517void csr_roam_wm_status_change_complete(tpAniSirGlobal pMac)
11518{
11519 tListElem *pEntry;
11520 tSmeCmd *pCommand;
11521 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
11522 if (pEntry) {
11523 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11524 if (eSmeCommandWmStatusChange == pCommand->command) {
11525 /* Nothing to process in a Lost Link completion.... It just kicks off a */
11526 /* roaming sequence. */
11527 if (csr_ll_remove_entry
11528 (&pMac->sme.smeCmdActiveList, pEntry,
11529 LL_ACCESS_LOCK)) {
11530 csr_release_command_wm_status_change(pMac, pCommand);
11531 } else {
11532 sms_log(pMac, LOGE,
11533 " ******csr_roam_wm_status_change_complete fail to release command");
11534 }
11535
11536 } else {
11537 sms_log(pMac, LOGW,
11538 "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ...");
11539 }
11540 } else {
11541 sms_log(pMac, LOGW,
11542 "CSR: WmStatusChange Completion called but NO commands are ACTIVE ...");
11543 }
11544 sme_process_pending_queue(pMac);
11545}
11546
11547void csr_roam_process_wm_status_change_command(tpAniSirGlobal pMac,
11548 tSmeCmd *pCommand)
11549{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011550 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011551 tSirSmeRsp *pSirSmeMsg;
11552 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, pCommand->sessionId);
11553
11554 if (!pSession) {
11555 sms_log(pMac, LOGE, FL(" session %d not found "),
11556 pCommand->sessionId);
11557 return;
11558 }
11559 sms_log(pMac, LOG1, FL("session:%d, CmdType : %d"),
11560 pCommand->sessionId, pCommand->u.wmStatusChangeCmd.Type);
11561
11562 switch (pCommand->u.wmStatusChangeCmd.Type) {
11563 case eCsrDisassociated:
11564 pSirSmeMsg =
11565 (tSirSmeRsp *) &pCommand->u.wmStatusChangeCmd.u.
11566 DisassocIndMsg;
11567 status =
11568 csr_roam_lost_link(pMac, pCommand->sessionId,
11569 eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11570 break;
11571 case eCsrDeauthenticated:
11572 pSirSmeMsg =
11573 (tSirSmeRsp *) &pCommand->u.wmStatusChangeCmd.u.
11574 DeauthIndMsg;
11575 status =
11576 csr_roam_lost_link(pMac, pCommand->sessionId,
11577 eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11578 break;
11579 default:
11580 sms_log(pMac, LOGW, FL("gets an unknown command %d"),
11581 pCommand->u.wmStatusChangeCmd.Type);
11582 break;
11583 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011584 /* Lost Link just triggers a roaming sequence. We can complte the Lost Link */
11585 /* command here since there is nothing else to do. */
11586 csr_roam_wm_status_change_complete(pMac);
11587}
11588
11589
11590/**
11591 * csr_compute_mode_and_band() - computes dot11mode
11592 * @pMac: mac global context
11593 * @dot11_mode: out param, do11 mode calculated
11594 * @band: out param, band caclculated
11595 * @opr_ch: operating channels
11596 *
11597 * This function finds dot11 mode based on current mode, operating channel and
11598 * fw supported modes.
11599 *
11600 * Return: void
11601 */
11602static void
11603csr_compute_mode_and_band(tpAniSirGlobal mac_ctx,
11604 eCsrCfgDot11Mode *dot11_mode,
11605 eCsrBand *band,
11606 uint8_t opr_ch)
11607{
11608 bool vht_24_ghz = mac_ctx->roam.configParam.enableVhtFor24GHz;
11609 switch (mac_ctx->roam.configParam.uCfgDot11Mode) {
11610 case eCSR_CFG_DOT11_MODE_11A:
11611 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
11612 *band = eCSR_BAND_5G;
11613 break;
11614 case eCSR_CFG_DOT11_MODE_11B:
11615 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
11616 *band = eCSR_BAND_24;
11617 break;
11618 case eCSR_CFG_DOT11_MODE_11G:
11619 *dot11_mode = eCSR_CFG_DOT11_MODE_11G;
11620 *band = eCSR_BAND_24;
11621 break;
11622 case eCSR_CFG_DOT11_MODE_11N:
11623 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
11624 *band = CSR_GET_BAND(opr_ch);
11625 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011626 case eCSR_CFG_DOT11_MODE_11AC:
11627 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
11628 /*
11629 * If the operating channel is in 2.4 GHz band, check
11630 * for INI item to disable VHT operation in 2.4 GHz band
11631 */
11632 if (CDS_IS_CHANNEL_24GHZ(opr_ch) && !vht_24_ghz)
11633 /* Disable 11AC operation */
11634 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
11635 else
11636 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC;
11637 } else {
11638 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
11639 }
11640 *band = CSR_GET_BAND(opr_ch);
11641 break;
11642 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11643 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
11644 /*
11645 * If the operating channel is in 2.4 GHz band, check
11646 * for INI item to disable VHT operation in 2.4 GHz band
11647 */
11648 if (CDS_IS_CHANNEL_24GHZ(opr_ch) && !vht_24_ghz)
11649 /* Disable 11AC operation */
11650 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
11651 else
11652 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11653 } else {
11654 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
11655 }
11656 *band = CSR_GET_BAND(opr_ch);
11657 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011658 case eCSR_CFG_DOT11_MODE_AUTO:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011659 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC)) {
11660 /*
11661 * If the operating channel is in 2.4 GHz band,
11662 * check for INI item to disable VHT operation
11663 * in 2.4 GHz band
11664 */
11665 if (CDS_IS_CHANNEL_24GHZ(opr_ch)
11666 && !vht_24_ghz)
11667 /* Disable 11AC operation */
11668 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
11669 else
11670 *dot11_mode = eCSR_CFG_DOT11_MODE_11AC;
11671 } else {
11672 *dot11_mode = eCSR_CFG_DOT11_MODE_11N;
11673 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011674 *band = CSR_GET_BAND(opr_ch);
11675 break;
11676 default:
11677 /*
11678 * Global dot11 Mode setting is 11a/b/g. use the channel number
11679 * to determine the Mode setting.
11680 */
11681 if (eCSR_OPERATING_CHANNEL_AUTO == opr_ch) {
11682 *band = mac_ctx->roam.configParam.eBand;
11683 if (eCSR_BAND_24 == *band) {
11684 /*
11685 * See reason in else if ( CDS_IS_CHANNEL_24GHZ
11686 * (opr_ch) ) to pick 11B
11687 */
11688 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
11689 } else {
11690 /* prefer 5GHz */
11691 *band = eCSR_BAND_5G;
11692 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
11693 }
11694 } else if (CDS_IS_CHANNEL_24GHZ(opr_ch)) {
11695 /*
11696 * WiFi tests require IBSS networks to start in 11b mode
11697 * without any change to the default parameter settings
11698 * on the adapter. We use ACU to start an IBSS through
11699 * creation of a startIBSS profile. This startIBSS
11700 * profile has Auto MACProtocol and the adapter property
11701 * setting for dot11Mode is also AUTO. So in this case,
11702 * let's start the IBSS network in 11b mode instead of
11703 * 11g mode. So this is for Auto=profile->MacProtocol &&
11704 * Auto=Global. dot11Mode && profile->channel is < 14,
11705 * then start the IBSS in b mode.
11706 *
11707 * Note: we used to have this start as an 11g IBSS for
11708 * best performance. now to specify that the user will
11709 * have to set the do11Mode in the property page to 11g
11710 * to force it.
11711 */
11712 *dot11_mode = eCSR_CFG_DOT11_MODE_11B;
11713 *band = eCSR_BAND_24;
11714 } else {
11715 /* else, it's a 5.0GHz channel. Set mode to 11a. */
11716 *dot11_mode = eCSR_CFG_DOT11_MODE_11A;
11717 *band = eCSR_BAND_5G;
11718 }
11719 break;
11720 } /* switch */
11721}
11722
11723/**
11724 * csr_roam_get_phy_mode_band_for_bss() - This function returns band and mode
11725 * information.
11726 * @mac_ctx: mac global context
11727 * @profile: bss profile
11728 * @band: out param, band caclculated
11729 * @opr_ch: operating channels
11730 *
11731 * This function finds dot11 mode based on current mode, operating channel and
11732 * fw supported modes. The only tricky part is that if phyMode is set to 11abg,
11733 * this function may return eCSR_CFG_DOT11_MODE_11B instead of
11734 * eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
11735 *
11736 * Return: dot11mode
11737 */
11738static eCsrCfgDot11Mode
11739csr_roam_get_phy_mode_band_for_bss(tpAniSirGlobal mac_ctx,
11740 tCsrRoamProfile *profile,
11741 uint8_t opr_chn,
11742 eCsrBand *p_band)
11743{
11744 eCsrBand band;
11745 eCsrCfgDot11Mode curr_mode = mac_ctx->roam.configParam.uCfgDot11Mode;
11746 eCsrCfgDot11Mode cfg_dot11_mode =
11747 csr_get_cfg_dot11_mode_from_csr_phy_mode(profile,
11748 (eCsrPhyMode) profile->phyMode,
11749 mac_ctx->roam.configParam.ProprietaryRatesEnabled);
11750
11751 /*
11752 * If the global setting for dot11Mode is set to auto/abg, we overwrite
11753 * the setting in the profile.
11754 */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070011755 if ((!CSR_IS_INFRA_AP(profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011756 && ((eCSR_CFG_DOT11_MODE_AUTO == curr_mode)
11757 || (eCSR_CFG_DOT11_MODE_ABG == curr_mode)))
11758 || (eCSR_CFG_DOT11_MODE_AUTO == cfg_dot11_mode)
11759 || (eCSR_CFG_DOT11_MODE_ABG == cfg_dot11_mode)) {
11760 csr_compute_mode_and_band(mac_ctx, &cfg_dot11_mode,
11761 &band, opr_chn);
11762 } /* if( eCSR_CFG_DOT11_MODE_ABG == cfg_dot11_mode ) */
11763 else {
11764 /* dot11 mode is set, lets pick the band */
11765 if (eCSR_OPERATING_CHANNEL_AUTO == opr_chn) {
11766 /* channel is Auto also. */
11767 band = mac_ctx->roam.configParam.eBand;
11768 if (eCSR_BAND_ALL == band) {
11769 /* prefer 5GHz */
11770 band = eCSR_BAND_5G;
11771 }
11772 } else{
11773 band = CSR_GET_BAND(opr_chn);
11774 }
11775 }
11776 if (p_band)
11777 *p_band = band;
11778
11779 if (opr_chn == 14) {
11780 sms_log(mac_ctx, LOGE, FL("Switching to Dot11B mode"));
11781 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11B;
11782 }
11783
11784 /*
11785 * Incase of WEP Security encryption type is coming as part of add key.
11786 * So while STart BSS dont have information
11787 */
11788 if ((!CSR_IS_11n_ALLOWED(profile->EncryptionType.encryptionType[0])
11789 || ((profile->privacy == 1)
11790 && (profile->EncryptionType.encryptionType[0] ==
11791 eCSR_ENCRYPT_TYPE_NONE)))
11792 && ((eCSR_CFG_DOT11_MODE_11N == cfg_dot11_mode) ||
Kiran Kumar Lokere9a733a72016-02-17 19:01:15 -080011793 (eCSR_CFG_DOT11_MODE_11AC == cfg_dot11_mode))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011794 /* We cannot do 11n here */
11795 if (CDS_IS_CHANNEL_24GHZ(opr_chn))
11796 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11G;
11797 else
11798 cfg_dot11_mode = eCSR_CFG_DOT11_MODE_11A;
11799 }
11800 return cfg_dot11_mode;
11801}
11802
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011803QDF_STATUS csr_roam_issue_stop_bss(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011804 eCsrRoamSubState NewSubstate)
11805{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011806 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011807 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
11808
11809 if (!pSession) {
11810 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011811 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011812 }
11813#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11814 {
11815 host_log_ibss_pkt_type *pIbssLog;
11816 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
11817 LOG_WLAN_IBSS_C);
11818 if (pIbssLog) {
11819 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11820 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
11821 }
11822 }
11823#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
11824 /* Set the roaming substate to 'stop Bss request'... */
11825 csr_roam_substate_change(pMac, NewSubstate, sessionId);
11826
11827 /* attempt to stop the Bss (reason code is ignored...) */
11828 status = csr_send_mb_stop_bss_req_msg(pMac, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011829 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011830 sms_log(pMac, LOGW,
11831 FL("csr_send_mb_stop_bss_req_msg failed with status %d"),
11832 status);
11833 }
11834 return status;
11835}
11836
11837/* pNumChan is a caller allocated space with the sizeof pChannels */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011838QDF_STATUS csr_get_cfg_valid_channels(tpAniSirGlobal pMac, uint8_t *pChannels,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011839 uint32_t *pNumChan)
11840{
Edhar, Mahesh Kumareb31abd2016-01-21 17:50:47 +053011841 uint8_t num_chan_temp = 0;
11842 int i;
11843
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011844 if (!IS_SIR_STATUS_SUCCESS(wlan_cfg_get_str(pMac,
11845 WNI_CFG_VALID_CHANNEL_LIST,
11846 (uint8_t *) pChannels, pNumChan)))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011847 return QDF_STATUS_E_FAILURE;
Edhar, Mahesh Kumareb31abd2016-01-21 17:50:47 +053011848
11849 for (i = 0; i < *pNumChan; i++) {
11850 if (!cds_is_dsrc_channel(cds_chan_to_freq(pChannels[i]))) {
11851 pChannels[num_chan_temp] = pChannels[i];
11852 num_chan_temp++;
11853 }
11854 }
11855
11856 *pNumChan = num_chan_temp;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011857 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011858}
11859
Amar Singhala297bfa2015-10-15 15:07:29 -070011860int8_t csr_get_cfg_max_tx_power(tpAniSirGlobal pMac, uint8_t channel)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011861{
11862 uint32_t cfgLength = 0;
11863 uint16_t cfgId = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -070011864 int8_t maxTxPwr = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011865 uint8_t *pCountryInfo = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011866 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011867 uint8_t count = 0;
11868 uint8_t firstChannel;
11869 uint8_t maxChannels;
11870
11871 if (CDS_IS_CHANNEL_5GHZ(channel)) {
11872 cfgId = WNI_CFG_MAX_TX_POWER_5;
11873 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11874 } else if (CDS_IS_CHANNEL_24GHZ(channel)) {
11875 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11876 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11877 } else
11878 return maxTxPwr;
11879
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011880 pCountryInfo = qdf_mem_malloc(cfgLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011881 if (NULL == pCountryInfo)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011882 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011883 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011884 status = QDF_STATUS_SUCCESS;
11885 if (status != QDF_STATUS_SUCCESS) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053011886 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011887 FL("%s: failed to allocate memory, status = %d"),
11888 __FUNCTION__, status);
11889 goto error;
11890 }
11891 if (wlan_cfg_get_str(pMac, cfgId, (uint8_t *)pCountryInfo,
11892 &cfgLength) != eSIR_SUCCESS) {
11893 goto error;
11894 }
11895 /* Identify the channel and maxtxpower */
11896 while (count <= (cfgLength - (sizeof(tSirMacChanInfo)))) {
11897 firstChannel = pCountryInfo[count++];
11898 maxChannels = pCountryInfo[count++];
11899 maxTxPwr = pCountryInfo[count++];
11900
11901 if ((channel >= firstChannel) &&
11902 (channel < (firstChannel + maxChannels))) {
11903 break;
11904 }
11905 }
11906
11907error:
11908 if (NULL != pCountryInfo)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053011909 qdf_mem_free(pCountryInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011910
11911 return maxTxPwr;
11912}
11913
11914bool csr_roam_is_channel_valid(tpAniSirGlobal pMac, uint8_t channel)
11915{
11916 bool fValid = false;
11917 uint32_t idxValidChannels;
11918 uint32_t len = sizeof(pMac->roam.validChannelList);
11919
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053011920 if (QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011921 (csr_get_cfg_valid_channels(pMac, pMac->roam.validChannelList, &len))) {
11922 for (idxValidChannels = 0; (idxValidChannels < len);
11923 idxValidChannels++) {
11924 if (channel ==
11925 pMac->roam.validChannelList[idxValidChannels]) {
11926 fValid = true;
11927 break;
11928 }
11929 }
11930 }
11931 pMac->roam.numValidChannels = len;
11932 return fValid;
11933}
11934
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011935/* This function check and validate whether the NIC can do CB (40MHz) */
11936static ePhyChanBondState csr_get_cb_mode_from_ies(tpAniSirGlobal pMac,
11937 uint8_t primaryChn,
11938 tDot11fBeaconIEs *pIes)
11939{
11940 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
11941 uint8_t centerChn;
11942 uint32_t ChannelBondingMode;
11943 if (CDS_IS_CHANNEL_24GHZ(primaryChn)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011944 ChannelBondingMode =
11945 pMac->roam.configParam.channelBondingMode24GHz;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011946 } else {
11947 ChannelBondingMode =
11948 pMac->roam.configParam.channelBondingMode5GHz;
11949 }
11950
11951 if (WNI_CFG_CHANNEL_BONDING_MODE_DISABLE == ChannelBondingMode)
11952 return PHY_SINGLE_CHANNEL_CENTERED;
11953
11954 /* Figure what the other side's CB mode */
11955 if (!(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ ==
11956 pIes->HTCaps.supportedChannelWidthSet))) {
11957 return PHY_SINGLE_CHANNEL_CENTERED;
11958 }
11959
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053011960 /* In Case WPA2 and TKIP is the only one cipher suite in Pairwise */
11961 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011962 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053011963 "\x00\x0f\xac\x02", 4))
Abhishek Singh1e39fc22015-12-18 11:23:44 +053011964 /* In Case only WPA1 is supported and TKIP is
11965 * the only one cipher suite in Unicast.
Konamki, Sreelakshmiec14e6a2015-07-15 12:43:29 +053011966 */
Abhishek Singh1e39fc22015-12-18 11:23:44 +053011967 || (!pIes->RSN.present && (pIes->WPA.present &&
11968 (pIes->WPA.unicast_cipher_count == 1) &&
11969 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
11970 "\x00\x50\xf2\x02", 4)))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080011971 sms_log(pMac, LOGW,
11972 " No channel bonding in TKIP mode ");
11973 return PHY_SINGLE_CHANNEL_CENTERED;
11974 }
11975
11976 if (!pIes->HTInfo.present)
11977 return PHY_SINGLE_CHANNEL_CENTERED;
11978
11979 /*
11980 * This is called during INFRA STA/CLIENT and should use the merged
11981 * value of supported channel width and recommended tx width as per
11982 * standard
11983 */
11984 sms_log(pMac, LOG1, "scws %u rtws %u sco %u",
11985 pIes->HTCaps.supportedChannelWidthSet,
11986 pIes->HTInfo.recommendedTxWidthSet,
11987 pIes->HTInfo.secondaryChannelOffset);
11988
11989 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11990 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
11991 else
11992 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11993
11994 switch (eRet) {
11995 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11996 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11997 break;
11998 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11999 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
12000 break;
12001 case PHY_SINGLE_CHANNEL_CENTERED:
12002 default:
12003 centerChn = primaryChn;
12004 break;
12005 }
12006
Amar Singhal7ccdc4f2015-10-30 15:10:05 -070012007 if ((PHY_SINGLE_CHANNEL_CENTERED != eRet) &&
12008 (QDF_STATUS_SUCCESS != sme_check_ch_in_band(pMac,
12009 centerChn - 2, 2))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012010 sms_log(pMac, LOGE,
12011 "Invalid center channel (%d), disable 40MHz mode",
12012 centerChn);
12013 eRet = PHY_SINGLE_CHANNEL_CENTERED;
12014 }
12015 return eRet;
12016}
12017
12018bool csr_is_encryption_in_list(tpAniSirGlobal pMac,
12019 tCsrEncryptionList *pCipherList,
12020 eCsrEncryptionType encryptionType)
12021{
12022 bool fFound = false;
12023 uint32_t idx;
12024 for (idx = 0; idx < pCipherList->numEntries; idx++) {
12025 if (pCipherList->encryptionType[idx] == encryptionType) {
12026 fFound = true;
12027 break;
12028 }
12029 }
12030 return fFound;
12031}
12032
12033bool csr_is_auth_in_list(tpAniSirGlobal pMac, tCsrAuthList *pAuthList,
12034 eCsrAuthType authType)
12035{
12036 bool fFound = false;
12037 uint32_t idx;
12038 for (idx = 0; idx < pAuthList->numEntries; idx++) {
12039 if (pAuthList->authType[idx] == authType) {
12040 fFound = true;
12041 break;
12042 }
12043 }
12044 return fFound;
12045}
12046
12047bool csr_is_same_profile(tpAniSirGlobal pMac,
12048 tCsrRoamConnectedProfile *pProfile1,
12049 tCsrRoamProfile *pProfile2)
12050{
12051 uint32_t i;
12052 bool fCheck = false;
12053 tCsrScanResultFilter *pScanFilter = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012054 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012055
12056 if (!(pProfile1 && pProfile2))
12057 return fCheck;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012058 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012059 if (NULL == pScanFilter)
12060 return fCheck;
12061
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012062 qdf_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012063 status = csr_roam_prepare_filter_from_profile(pMac, pProfile2,
12064 pScanFilter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012065 if (!(QDF_IS_STATUS_SUCCESS(status)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012066 goto free_scan_filter;
12067
12068 for (i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++) {
12069 fCheck = csr_is_ssid_match(pMac,
12070 pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
12071 pScanFilter->SSIDs.SSIDList[i].SSID.length,
12072 pProfile1->SSID.ssId,
12073 pProfile1->SSID.length,
12074 false);
12075 if (fCheck)
12076 break;
12077 }
12078 if (!fCheck)
12079 goto free_scan_filter;
12080
12081 if (!csr_is_auth_in_list(pMac, &pProfile2->AuthType,
12082 pProfile1->AuthType)
12083 || (pProfile2->BSSType != pProfile1->BSSType)
12084 || !csr_is_encryption_in_list(pMac, &pProfile2->EncryptionType,
12085 pProfile1->EncryptionType)) {
12086 fCheck = false;
12087 goto free_scan_filter;
12088 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012089 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent) {
12090 if (pProfile1->MDID.mobilityDomain
12091 != pProfile2->MDID.mobilityDomain) {
12092 fCheck = false;
12093 goto free_scan_filter;
12094 }
12095 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012096 /* Match found */
12097 fCheck = true;
12098free_scan_filter:
12099 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012100 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012101 return fCheck;
12102}
12103
12104bool csr_roam_is_same_profile_keys(tpAniSirGlobal pMac,
12105 tCsrRoamConnectedProfile *pConnProfile,
12106 tCsrRoamProfile *pProfile2)
12107{
12108 bool fCheck = false;
12109 int i;
12110 do {
12111 /* Only check for static WEP */
12112 if (!csr_is_encryption_in_list
12113 (pMac, &pProfile2->EncryptionType,
12114 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY)
12115 && !csr_is_encryption_in_list(pMac,
12116 &pProfile2->EncryptionType,
12117 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
12118 fCheck = true;
12119 break;
12120 }
12121 if (!csr_is_encryption_in_list
12122 (pMac, &pProfile2->EncryptionType,
12123 pConnProfile->EncryptionType))
12124 break;
12125 if (pConnProfile->Keys.defaultIndex !=
12126 pProfile2->Keys.defaultIndex)
12127 break;
12128 for (i = 0; i < CSR_MAX_NUM_KEY; i++) {
12129 if (pConnProfile->Keys.KeyLength[i] !=
12130 pProfile2->Keys.KeyLength[i])
12131 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012132 if (qdf_mem_cmp(&pConnProfile->Keys.KeyMaterial[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012133 &pProfile2->Keys.KeyMaterial[i],
12134 pProfile2->Keys.KeyLength[i])) {
12135 break;
12136 }
12137 }
12138 if (i == CSR_MAX_NUM_KEY) {
12139 fCheck = true;
12140 }
12141 } while (0);
12142 return fCheck;
12143}
12144
12145/* IBSS */
12146
12147uint8_t csr_roam_get_ibss_start_channel_number50(tpAniSirGlobal pMac)
12148{
12149 uint8_t channel = 0;
12150 uint32_t idx;
12151 uint32_t idxValidChannels;
12152 bool fFound = false;
12153 uint32_t len = sizeof(pMac->roam.validChannelList);
12154
12155 if (eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G) {
12156 channel = pMac->roam.configParam.AdHocChannel5G;
12157 if (!csr_roam_is_channel_valid(pMac, channel)) {
12158 channel = 0;
12159 }
12160 }
12161 if (0 == channel
12162 &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012163 QDF_IS_STATUS_SUCCESS(csr_get_cfg_valid_channels
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012164 (pMac,
12165 (uint8_t *) pMac->roam.validChannelList,
12166 &len))) {
12167 for (idx = 0; (idx < CSR_NUM_IBSS_START_CHANNELS_50) && !fFound;
12168 idx++) {
12169 for (idxValidChannels = 0;
12170 (idxValidChannels < len) && !fFound;
12171 idxValidChannels++) {
12172 if (csr_start_ibss_channels50[idx] ==
12173 pMac->roam.
12174 validChannelList[idxValidChannels]) {
12175 fFound = true;
12176 channel = csr_start_ibss_channels50[idx];
12177 }
12178 }
12179 }
12180 /*
12181 * this is rare, but if it does happen,
12182 * we find anyone in 11a bandwidth and
12183 * return the first 11a channel found!
12184 */
12185 if (!fFound) {
12186 for (idxValidChannels = 0; idxValidChannels < len;
12187 idxValidChannels++) {
12188 if (CDS_IS_CHANNEL_5GHZ(pMac->roam.
12189 validChannelList[idxValidChannels])) {
12190 /* the max channel# in 11g is 14 */
12191 if (idxValidChannels <
12192 CSR_NUM_IBSS_START_CHANNELS_50) {
12193 channel =
12194 pMac->roam.validChannelList
12195 [idxValidChannels];
12196 }
12197 break;
12198 }
12199 }
12200 }
12201 } /* if */
12202
12203 return channel;
12204}
12205
12206uint8_t csr_roam_get_ibss_start_channel_number24(tpAniSirGlobal pMac)
12207{
12208 uint8_t channel = 1;
12209 uint32_t idx;
12210 uint32_t idxValidChannels;
12211 bool fFound = false;
12212 uint32_t len = sizeof(pMac->roam.validChannelList);
12213
12214 if (eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24) {
12215 channel = pMac->roam.configParam.AdHocChannel24;
12216 if (!csr_roam_is_channel_valid(pMac, channel)) {
12217 channel = 0;
12218 }
12219 }
12220
12221 if (0 == channel
12222 &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012223 QDF_IS_STATUS_SUCCESS(csr_get_cfg_valid_channels
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012224 (pMac,
12225 (uint8_t *) pMac->roam.validChannelList,
12226 &len))) {
12227 for (idx = 0; (idx < CSR_NUM_IBSS_START_CHANNELS_24) && !fFound;
12228 idx++) {
12229 for (idxValidChannels = 0;
12230 (idxValidChannels < len) && !fFound;
12231 idxValidChannels++) {
12232 if (csr_start_ibss_channels24[idx] ==
12233 pMac->roam.
12234 validChannelList[idxValidChannels]) {
12235 fFound = true;
12236 channel = csr_start_ibss_channels24[idx];
12237 }
12238 }
12239 }
12240 }
12241
12242 return channel;
12243}
12244
12245/**
12246 * csr_populate_basic_rates() - populates OFDM or CCK rates
12247 * @rates: rate struct to populate
12248 * @type: true: ofdm rates, false: cck rates
12249 * @masked: indicates if rates are to be masked with
12250 * CSR_DOT11_BASIC_RATE_MASK
12251 *
12252 * This function will populate OFDM or CCK rates
12253 *
12254 * Return: void
12255 */
12256static void
12257csr_populate_basic_rates(tSirMacRateSet *rate_set, bool type, bool masked)
12258{
12259 uint8_t ofdm_rates[8] = {
12260 SIR_MAC_RATE_6,
12261 SIR_MAC_RATE_9,
12262 SIR_MAC_RATE_12,
12263 SIR_MAC_RATE_18,
12264 SIR_MAC_RATE_24,
12265 SIR_MAC_RATE_36,
12266 SIR_MAC_RATE_48,
12267 SIR_MAC_RATE_54
12268 };
12269 uint8_t cck_rates[4] = {
12270 SIR_MAC_RATE_1,
12271 SIR_MAC_RATE_2,
12272 SIR_MAC_RATE_5_5,
12273 SIR_MAC_RATE_11
12274 };
12275
12276 if (type == true) {
12277 rate_set->numRates = 8;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012278 qdf_mem_copy(rate_set->rate, ofdm_rates, sizeof(ofdm_rates));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012279 if (masked) {
12280 rate_set->rate[0] |= CSR_DOT11_BASIC_RATE_MASK;
12281 rate_set->rate[2] |= CSR_DOT11_BASIC_RATE_MASK;
12282 rate_set->rate[4] |= CSR_DOT11_BASIC_RATE_MASK;
12283 }
12284 } else {
12285 rate_set->numRates = 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012286 qdf_mem_copy(rate_set->rate, cck_rates, sizeof(cck_rates));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012287 if (masked) {
12288 rate_set->rate[0] |= CSR_DOT11_BASIC_RATE_MASK;
12289 rate_set->rate[1] |= CSR_DOT11_BASIC_RATE_MASK;
12290 rate_set->rate[2] |= CSR_DOT11_BASIC_RATE_MASK;
12291 rate_set->rate[3] |= CSR_DOT11_BASIC_RATE_MASK;
12292 }
12293 }
12294}
12295
12296/**
12297 * csr_convert_mode_to_nw_type() - convert mode into network type
12298 * @dot11_mode: dot11_mode
12299 * @band: 2.4 or 5 GHz
12300 *
12301 * Return: tSirNwType
12302 */
12303static tSirNwType
12304csr_convert_mode_to_nw_type(eCsrCfgDot11Mode dot11_mode, eCsrBand band)
12305{
12306 switch (dot11_mode) {
12307 case eCSR_CFG_DOT11_MODE_11G:
12308 return eSIR_11G_NW_TYPE;
12309 case eCSR_CFG_DOT11_MODE_11B:
12310 return eSIR_11B_NW_TYPE;
12311 case eCSR_CFG_DOT11_MODE_11A:
12312 return eSIR_11A_NW_TYPE;
12313 case eCSR_CFG_DOT11_MODE_11N:
12314 default:
12315 /*
12316 * Because LIM only verifies it against 11a, 11b or 11g, set
12317 * only 11g or 11a here
12318 */
12319 if (eCSR_BAND_24 == band)
12320 return eSIR_11G_NW_TYPE;
12321 else
12322 return eSIR_11A_NW_TYPE;
12323 }
12324 return eSIR_DONOT_USE_NW_TYPE;
12325}
12326
12327/**
12328 * csr_roam_get_bss_start_parms() - get bss start param from profile
12329 * @pMac: mac global context
12330 * @pProfile: roam profile
12331 * @pParam: out param, start bss params
12332 *
12333 * This function populates start bss param from roam profile
12334 *
12335 * Return: void
12336 */
12337static void
12338csr_roam_get_bss_start_parms(tpAniSirGlobal pMac,
12339 tCsrRoamProfile *pProfile,
12340 tCsrRoamStartBssParams *pParam)
12341{
12342 eCsrBand band;
12343 uint8_t opr_ch = 0;
12344 tSirNwType nw_type;
12345 uint8_t tmp_opr_ch = 0;
12346 tSirMacRateSet *opr_rates = &pParam->operationalRateSet;
12347 tSirMacRateSet *ext_rates = &pParam->extendedRateSet;
12348
12349 if (pProfile->ChannelInfo.numOfChannels
12350 && pProfile->ChannelInfo.ChannelList) {
12351 tmp_opr_ch = pProfile->ChannelInfo.ChannelList[0];
12352 }
12353
12354 pParam->uCfgDot11Mode = csr_roam_get_phy_mode_band_for_bss(pMac,
12355 pProfile, tmp_opr_ch, &band);
12356
Anurag Chouhan6d760662016-02-20 16:05:43 +053012357 if (((pProfile->csrPersona == QDF_P2P_CLIENT_MODE)
12358 || (pProfile->csrPersona == QDF_P2P_GO_MODE))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012359 && (pParam->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)) {
12360 /* This should never happen */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012361 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_FATAL,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012362 FL("For P2P (persona %d) dot11_mode is 11B"),
12363 pProfile->csrPersona);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053012364 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012365 }
12366
12367 nw_type = csr_convert_mode_to_nw_type(pParam->uCfgDot11Mode, band);
12368 ext_rates->numRates = 0;
12369
12370 switch (nw_type) {
12371 default:
12372 sms_log(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"),
12373 nw_type);
12374 case eSIR_11A_NW_TYPE:
12375 csr_populate_basic_rates(opr_rates, true, true);
12376 if (eCSR_OPERATING_CHANNEL_ANY != tmp_opr_ch) {
12377 opr_ch = tmp_opr_ch;
12378 break;
12379 }
12380 opr_ch = csr_roam_get_ibss_start_channel_number50(pMac);
12381 if (0 == opr_ch &&
12382 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
12383 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)) {
12384 /*
12385 * We could not find a 5G channel by auto pick, let's
12386 * try 2.4G channels. We only do this here because
12387 * csr_roam_get_phy_mode_band_for_bss always picks 11a
12388 * for AUTO
12389 */
12390 nw_type = eSIR_11B_NW_TYPE;
12391 opr_ch = csr_roam_get_ibss_start_channel_number24(pMac);
12392 csr_populate_basic_rates(opr_rates, false, true);
12393 }
12394 break;
12395 case eSIR_11B_NW_TYPE:
12396 csr_populate_basic_rates(opr_rates, false, true);
12397 if (eCSR_OPERATING_CHANNEL_ANY == tmp_opr_ch)
12398 opr_ch = csr_roam_get_ibss_start_channel_number24(pMac);
12399 else
12400 opr_ch = tmp_opr_ch;
12401 break;
12402 case eSIR_11G_NW_TYPE:
12403 /* For P2P Client and P2P GO, disable 11b rates */
Anurag Chouhan6d760662016-02-20 16:05:43 +053012404 if ((pProfile->csrPersona == QDF_P2P_CLIENT_MODE)
12405 || (pProfile->csrPersona == QDF_P2P_GO_MODE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012406 || (eCSR_CFG_DOT11_MODE_11G_ONLY ==
12407 pParam->uCfgDot11Mode)) {
12408 csr_populate_basic_rates(opr_rates, true, true);
12409 } else {
12410 csr_populate_basic_rates(opr_rates, false, true);
12411 csr_populate_basic_rates(ext_rates, true, false);
12412 }
12413
12414 if (eCSR_OPERATING_CHANNEL_ANY == tmp_opr_ch)
12415 opr_ch = csr_roam_get_ibss_start_channel_number24(pMac);
12416 else
12417 opr_ch = tmp_opr_ch;
12418 break;
12419 }
12420 pParam->operationChn = opr_ch;
12421 pParam->sirNwType = nw_type;
12422 pParam->ch_params.ch_width = pProfile->ch_params.ch_width;
12423 pParam->ch_params.center_freq_seg0 =
12424 pProfile->ch_params.center_freq_seg0;
12425 pParam->ch_params.center_freq_seg1 =
12426 pProfile->ch_params.center_freq_seg1;
12427 pParam->ch_params.sec_ch_offset =
12428 pProfile->ch_params.sec_ch_offset;
12429}
12430
12431static void
12432csr_roam_get_bss_start_parms_from_bss_desc(tpAniSirGlobal pMac,
12433 tSirBssDescription *pBssDesc,
12434 tDot11fBeaconIEs *pIes,
12435 tCsrRoamStartBssParams *pParam)
12436{
12437 if (!pParam) {
12438 sms_log(pMac, LOGE, FL("BSS param's pointer is NULL"));
12439 return;
12440 }
12441
12442 pParam->sirNwType = pBssDesc->nwType;
12443 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12444 pParam->operationChn = pBssDesc->channelId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012445 qdf_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012446
12447 if (!pIes) {
12448 pParam->ssId.length = 0;
12449 pParam->operationalRateSet.numRates = 0;
12450 sms_log(pMac, LOGE, FL("IEs struct pointer is NULL"));
12451 return;
12452 }
12453
12454 if (pIes->SuppRates.present) {
12455 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
12456 if (pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX) {
12457 sms_log(pMac, LOGE,
12458 FL("num_rates: %d > max val, resetting"),
12459 pIes->SuppRates.num_rates);
12460 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
12461 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012462 qdf_mem_copy(pParam->operationalRateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012463 pIes->SuppRates.rates,
12464 sizeof(*pIes->SuppRates.rates) *
12465 pIes->SuppRates.num_rates);
12466 }
12467 if (pIes->ExtSuppRates.present) {
12468 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
12469 if (pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX) {
12470 sms_log(pMac, LOGE,
12471 FL("num_rates: %d > max val, resetting"),
12472 pIes->ExtSuppRates.num_rates);
12473 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
12474 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012475 qdf_mem_copy(pParam->extendedRateSet.rate,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012476 pIes->ExtSuppRates.rates,
12477 sizeof(*pIes->ExtSuppRates.rates) *
12478 pIes->ExtSuppRates.num_rates);
12479 }
12480 if (pIes->SSID.present) {
12481 pParam->ssId.length = pIes->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012482 qdf_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012483 pParam->ssId.length);
12484 }
12485 pParam->cbMode = csr_get_cb_mode_from_ies(pMac, pParam->operationChn,
12486 pIes);
12487}
12488
12489static void csr_roam_determine_max_rate_for_ad_hoc(tpAniSirGlobal pMac,
12490 tSirMacRateSet *pSirRateSet)
12491{
12492 uint8_t MaxRate = 0;
12493 uint32_t i;
12494 uint8_t *pRate;
12495
12496 pRate = pSirRateSet->rate;
12497 for (i = 0; i < pSirRateSet->numRates; i++) {
12498 MaxRate =
12499 CSR_MAX(MaxRate, (pRate[i] & (~CSR_DOT11_BASIC_RATE_MASK)));
12500 }
12501
12502 /* Save the max rate in the connected state information... */
12503
12504 /* modify LastRates variable as well */
12505
12506 return;
12507}
12508
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012509QDF_STATUS csr_roam_issue_start_bss(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012510 tCsrRoamStartBssParams *pParam,
12511 tCsrRoamProfile *pProfile,
12512 tSirBssDescription *pBssDesc, uint32_t roamId)
12513{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012514 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012515 eCsrBand eBand;
12516 /* Set the roaming substate to 'Start BSS attempt'... */
12517 csr_roam_substate_change(pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ,
12518 sessionId);
12519#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12520 /* Need to figure out whether we need to log WDS??? */
12521 if (CSR_IS_IBSS(pProfile)) {
12522 host_log_ibss_pkt_type *pIbssLog;
12523 WLAN_HOST_DIAG_LOG_ALLOC(pIbssLog, host_log_ibss_pkt_type,
12524 LOG_WLAN_IBSS_C);
12525 if (pIbssLog) {
12526 if (pBssDesc) {
12527 pIbssLog->eventId =
12528 WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012529 qdf_mem_copy(pIbssLog->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012530 pBssDesc->bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012531 } else {
12532 pIbssLog->eventId =
12533 WLAN_IBSS_EVENT_START_IBSS_REQ;
12534 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012535 qdf_mem_copy(pIbssLog->ssid, pParam->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012536 pParam->ssId.length);
12537 if (pProfile->ChannelInfo.numOfChannels == 0) {
12538 pIbssLog->channelSetting = AUTO_PICK;
12539 } else {
12540 pIbssLog->channelSetting = SPECIFIED;
12541 }
12542 pIbssLog->operatingChannel = pParam->operationChn;
12543 WLAN_HOST_DIAG_LOG_REPORT(pIbssLog);
12544 }
12545 }
12546#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12547 /* Put RSN information in for Starting BSS */
12548 pParam->nRSNIELength = (uint16_t) pProfile->nRSNReqIELength;
12549 pParam->pRSNIE = pProfile->pRSNReqIE;
12550
12551 pParam->privacy = pProfile->privacy;
12552 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
12553 pParam->authType = pProfile->csr80211AuthType;
12554 pParam->beaconInterval = pProfile->beaconInterval;
12555 pParam->dtimPeriod = pProfile->dtimPeriod;
12556 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
12557 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
12558 if (CSR_IS_INFRA_AP(pProfile) && (pParam->operationChn != 0)) {
12559 if (csr_is_valid_channel(pMac, pParam->operationChn) !=
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012560 QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012561 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
12562 }
12563 }
12564 pParam->protEnabled = pProfile->protEnabled;
12565 pParam->obssProtEnabled = pProfile->obssProtEnabled;
12566 pParam->ht_protection = pProfile->cfg_protection;
12567 pParam->wps_state = pProfile->wps_state;
12568
12569 pParam->uCfgDot11Mode =
12570 csr_roam_get_phy_mode_band_for_bss(pMac, pProfile,
12571 pParam->
12572 operationChn,
12573 &eBand);
12574 pParam->bssPersona = pProfile->csrPersona;
12575
12576#ifdef WLAN_FEATURE_11W
12577 pParam->mfpCapable = (0 != pProfile->MFPCapable);
12578 pParam->mfpRequired = (0 != pProfile->MFPRequired);
12579#endif
12580
12581 pParam->addIeParams.probeRespDataLen =
12582 pProfile->addIeParams.probeRespDataLen;
12583 pParam->addIeParams.probeRespData_buff =
12584 pProfile->addIeParams.probeRespData_buff;
12585
12586 pParam->addIeParams.assocRespDataLen =
12587 pProfile->addIeParams.assocRespDataLen;
12588 pParam->addIeParams.assocRespData_buff =
12589 pProfile->addIeParams.assocRespData_buff;
12590
12591 if (CSR_IS_IBSS(pProfile)) {
12592 pParam->addIeParams.probeRespBCNDataLen =
12593 pProfile->nWPAReqIELength;
12594 pParam->addIeParams.probeRespBCNData_buff = pProfile->pWPAReqIE;
12595 } else {
12596 pParam->addIeParams.probeRespBCNDataLen =
12597 pProfile->addIeParams.probeRespBCNDataLen;
12598 pParam->addIeParams.probeRespBCNData_buff =
12599 pProfile->addIeParams.probeRespBCNData_buff;
12600 }
12601 pParam->sap_dot11mc = pProfile->sap_dot11mc;
12602
12603 /* When starting an IBSS, start on the channel from the Profile. */
12604 status =
12605 csr_send_mb_start_bss_req_msg(pMac, sessionId, pProfile->BSSType, pParam,
12606 pBssDesc);
12607 return status;
12608}
12609
12610static void csr_roam_prepare_bss_params(tpAniSirGlobal pMac, uint32_t sessionId,
12611 tCsrRoamProfile *pProfile,
12612 tSirBssDescription *pBssDesc,
12613 tBssConfigParam *pBssConfig,
12614 tDot11fBeaconIEs *pIes)
12615{
12616 uint8_t Channel;
12617 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12618 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
12619
12620 if (!pSession) {
12621 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
12622 return;
12623 }
12624
12625 if (pBssDesc) {
12626 csr_roam_get_bss_start_parms_from_bss_desc(pMac, pBssDesc, pIes,
12627 &pSession->bssParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012628 } else {
12629 csr_roam_get_bss_start_parms(pMac, pProfile, &pSession->bssParams);
12630 /* Use the first SSID */
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070012631 if (pProfile->SSIDs.numOfSSIDs)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012632 qdf_mem_copy(&pSession->bssParams.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012633 pProfile->SSIDs.SSIDList,
12634 sizeof(tSirMacSSid));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070012635 if (pProfile->BSSIDs.numOfBSSIDs)
12636 /* Use the first BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012637 qdf_mem_copy(&pSession->bssParams.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012638 pProfile->BSSIDs.bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012639 sizeof(struct qdf_mac_addr));
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070012640 else
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012641 qdf_mem_set(&pSession->bssParams.bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012642 sizeof(struct qdf_mac_addr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012643 }
12644 Channel = pSession->bssParams.operationChn;
12645 /* Set operating channel in pProfile which will be used */
12646 /* in csr_roam_set_bss_config_cfg() to determine channel bonding */
12647 /* mode and will be configured in CFG later */
12648 pProfile->operationChannel = Channel;
12649
12650 if (Channel == 0) {
12651 sms_log(pMac, LOGE,
12652 " CSR cannot find a channel to start IBSS");
12653 } else {
12654
12655 csr_roam_determine_max_rate_for_ad_hoc(pMac,
12656 &pSession->bssParams.
12657 operationalRateSet);
12658 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS(pProfile)) {
12659 if (CDS_IS_CHANNEL_24GHZ(Channel)) {
12660 cbMode =
12661 pMac->roam.configParam.
12662 channelBondingMode24GHz;
12663 } else {
12664 cbMode =
12665 pMac->roam.configParam.
12666 channelBondingMode5GHz;
12667 }
12668 sms_log(pMac, LOG1, "## cbMode %d", cbMode);
12669 pBssConfig->cbMode = cbMode;
12670 pSession->bssParams.cbMode = cbMode;
12671 }
12672 }
12673}
12674
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012675static QDF_STATUS csr_roam_start_ibss(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012676 tCsrRoamProfile *pProfile,
12677 bool *pfSameIbss)
12678{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012679 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012680 bool fSameIbss = false;
12681
12682 if (csr_is_conn_state_ibss(pMac, sessionId)) {
12683 /* Check if any profile parameter has changed ? If any profile parameter */
12684 /* has changed then stop old BSS and start a new one with new parameters */
12685 if (csr_is_same_profile
12686 (pMac, &pMac->roam.roamSession[sessionId].connectedProfile,
12687 pProfile)) {
12688 fSameIbss = true;
12689 } else {
12690 status =
12691 csr_roam_issue_stop_bss(pMac, sessionId,
12692 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING);
12693 }
12694 } else if (csr_is_conn_state_connected_infra(pMac, sessionId)) {
12695 /* Disassociate from the connected Infrastructure network... */
12696 status =
12697 csr_roam_issue_disassociate(pMac, sessionId,
12698 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
12699 false);
12700 } else {
12701 tBssConfigParam *pBssConfig;
12702
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012703 pBssConfig = qdf_mem_malloc(sizeof(tBssConfigParam));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012704 if (NULL == pBssConfig)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012705 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012706 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012707 status = QDF_STATUS_SUCCESS;
12708 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012709 qdf_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012710 /* there is no Bss description before we start an IBSS so we need to adopt */
12711 /* all Bss configuration parameters from the Profile. */
12712 status =
12713 csr_roam_prepare_bss_config_from_profile(pMac, pProfile,
12714 pBssConfig,
12715 NULL);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012716 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012717 /* save dotMode */
12718 pMac->roam.roamSession[sessionId].bssParams.
12719 uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12720 /* Prepare some more parameters for this IBSS */
12721 csr_roam_prepare_bss_params(pMac, sessionId,
12722 pProfile, NULL,
12723 pBssConfig, NULL);
12724 status =
12725 csr_roam_set_bss_config_cfg(pMac, sessionId,
12726 pProfile, NULL,
12727 pBssConfig, NULL,
12728 false);
12729 }
12730
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012731 qdf_mem_free(pBssConfig);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012732 } /* Allocate memory */
12733 }
12734
12735 if (pfSameIbss) {
12736 *pfSameIbss = fSameIbss;
12737 }
12738 return status;
12739}
12740
12741static void csr_roam_update_connected_profile_from_new_bss(tpAniSirGlobal pMac,
12742 uint32_t sessionId,
12743 tSirSmeNewBssInfo *pNewBss)
12744{
12745 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
12746
12747 if (!pSession) {
12748 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
12749 return;
12750 }
12751
12752 if (pNewBss) {
12753 /* Set the operating channel. */
12754 pSession->connectedProfile.operationChannel =
12755 pNewBss->channelNumber;
12756 /* move the BSSId from the BSS description into the connected state information. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012757 qdf_mem_copy(&pSession->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012758 &(pNewBss->bssId), sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012759 }
12760 return;
12761}
12762
12763#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012764QDF_STATUS csr_roam_set_psk_pmk(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012765 uint8_t *pPSK_PMK, size_t pmk_len)
12766{
12767 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
12768 if (!pSession) {
12769 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012770 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012771 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012772 qdf_mem_copy(pSession->psk_pmk, pPSK_PMK, sizeof(pSession->psk_pmk));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012773 pSession->pmk_len = pmk_len;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012774 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012775}
12776#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
12777
12778#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12779static void
12780csr_roam_diag_set_pmkid(tCsrRoamSession *pSession)
12781{
12782 WLAN_HOST_DIAG_EVENT_DEF(secEvent,
12783 host_event_wlan_security_payload_type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012784 qdf_mem_set(&secEvent,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012785 sizeof(host_event_wlan_security_payload_type), 0);
12786 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12787 secEvent.encryptionModeMulticast =
12788 (uint8_t) diag_enc_type_from_csr_type(
12789 pSession->connectedProfile.mcEncryptionType);
12790 secEvent.encryptionModeUnicast =
12791 (uint8_t) diag_enc_type_from_csr_type(
12792 pSession->connectedProfile.EncryptionType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012793 qdf_mem_copy(secEvent.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012794 pSession->connectedProfile.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012795 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012796 secEvent.authMode = (uint8_t) diag_auth_type_from_csr_type(
12797 pSession->connectedProfile.AuthType);
12798 WLAN_HOST_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12799}
12800#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12801
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012802QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012803csr_roam_set_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId,
12804 tPmkidCacheInfo *pPMKIDCache, uint32_t numItems,
12805 bool update_entire_cache)
12806{
12807 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
12808 uint32_t i = 0;
12809 tPmkidCacheInfo *pmksa;
12810
12811 if (!pSession) {
12812 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012813 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012814 }
12815
12816 sms_log(pMac, LOGW, FL("numItems = %d"), numItems);
12817
12818 if (numItems > CSR_MAX_PMKID_ALLOWED)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012819 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012820
12821#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12822 csr_roam_diag_set_pmkid(pSession);
12823#endif /* FEATURE_WLAN_DIAG_SUPPORT_CSR */
12824
12825 if (update_entire_cache) {
12826 if (numItems && pPMKIDCache) {
12827 pSession->NumPmkidCache = (uint16_t) numItems;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012828 qdf_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012829 sizeof(tPmkidCacheInfo) * numItems);
12830 pSession->curr_cache_idx = (uint16_t)numItems;
12831 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012832 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012833 }
12834
12835 for (i = 0; i < numItems; i++) {
12836 pmksa = &pPMKIDCache[i];
12837
12838 /* Delete the entry if present */
12839 csr_roam_del_pmkid_from_cache(pMac, sessionId,
12840 pmksa->BSSID.bytes, false);
12841
12842 /* Add entry to the cache */
Anurag Chouhanc5548422016-02-24 18:33:27 +053012843 qdf_copy_macaddr(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012844 &pSession->PmkidCacheInfo[pSession->curr_cache_idx].BSSID,
12845 &pmksa->BSSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012846 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012847 pSession->PmkidCacheInfo[pSession->curr_cache_idx].PMKID,
12848 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12849
12850 /* Increment the CSR local cache index */
12851 if (pSession->curr_cache_idx < (CSR_MAX_PMKID_ALLOWED - 1))
12852 pSession->curr_cache_idx++;
12853 else
12854 pSession->curr_cache_idx = 0;
12855
12856 pSession->NumPmkidCache++;
12857 if (pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12858 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12859 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012860 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012861}
12862
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012863QDF_STATUS csr_roam_del_pmkid_from_cache(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012864 uint32_t sessionId,
12865 const uint8_t *pBSSId,
12866 bool flush_cache)
12867{
12868 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
12869 bool fMatchFound = false;
12870 uint32_t Index;
12871 uint32_t curr_idx;
12872 uint32_t i;
12873
12874 if (!pSession) {
12875 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012876 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012877 }
12878
12879 /* Check if there are no entries to delete */
12880 if (0 == pSession->NumPmkidCache) {
12881 sms_log(pMac, LOG1, FL("No entries to delete/Flush"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012882 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012883 }
12884
12885 if (flush_cache) {
12886 /* Flush the entire cache */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012887 qdf_mem_zero(pSession->PmkidCacheInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012888 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12889 pSession->NumPmkidCache = 0;
12890 pSession->curr_cache_idx = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012891 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012892 }
12893
12894 /* !flush_cache - so look up in the cache */
12895 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012896 if (!qdf_mem_cmp(pSession->PmkidCacheInfo[Index].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053012897 pBSSId, QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012898 fMatchFound = 1;
12899
12900 /* Clear this - the matched entry */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012901 qdf_mem_zero(&pSession->PmkidCacheInfo[Index],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012902 sizeof(tPmkidCacheInfo));
12903 break;
12904 }
12905 }
12906
12907 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12908 sms_log(pMac, LOG1, FL("No such PMKSA entry exists"
12909 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pBSSId));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012910 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012911 }
12912
12913 /* Match Found, Readjust the other entries */
12914 curr_idx = pSession->curr_cache_idx;
12915 if (Index < curr_idx) {
12916 for (i = Index; i < (curr_idx - 1); i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012917 qdf_mem_copy(&pSession->PmkidCacheInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012918 &pSession->PmkidCacheInfo[i + 1],
12919 sizeof(tPmkidCacheInfo));
12920 }
12921
12922 pSession->curr_cache_idx--;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012923 qdf_mem_zero(&pSession->PmkidCacheInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012924 [pSession->curr_cache_idx],
12925 sizeof(tPmkidCacheInfo));
12926 } else if (Index > curr_idx) {
12927 for (i = Index; i > (curr_idx); i--) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012928 qdf_mem_copy(&pSession->PmkidCacheInfo[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012929 &pSession->PmkidCacheInfo[i - 1],
12930 sizeof(tPmkidCacheInfo));
12931 }
12932
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012933 qdf_mem_zero(&pSession->PmkidCacheInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012934 [pSession->curr_cache_idx],
12935 sizeof(tPmkidCacheInfo));
12936 }
12937
12938 /* Decrement the count since an entry has been deleted */
12939 pSession->NumPmkidCache--;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012940 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012941}
12942
12943uint32_t csr_roam_get_num_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId)
12944{
12945 return pMac->roam.roamSession[sessionId].NumPmkidCache;
12946}
12947
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012948QDF_STATUS csr_roam_get_pmkid_cache(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012949 uint32_t *pNum, tPmkidCacheInfo *pPmkidCache)
12950{
12951 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
12952 tPmkidCacheInfo *pmksa;
12953 uint16_t i, j;
12954
12955 if (!pSession) {
12956 sms_log(pMac, LOGE, FL("session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012957 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012958 }
12959
12960 if (!pNum || !pPmkidCache) {
12961 sms_log(pMac, LOGE, FL("Either pNum or pPmkidCache is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012962 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012963 }
12964
12965 if (pSession->NumPmkidCache == 0) {
12966 *pNum = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012967 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012968 }
12969
12970 if (*pNum < pSession->NumPmkidCache) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012971 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012972 }
12973
12974 if (pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED) {
12975 sms_log(pMac, LOGE,
12976 FL(
12977 "NumPmkidCache :%d is more than CSR_MAX_PMKID_ALLOWED, resetting to CSR_MAX_PMKID_ALLOWED"),
12978 pSession->NumPmkidCache);
12979 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12980 }
12981
12982 for (i = 0, j = 0; ((j < pSession->NumPmkidCache) &&
12983 (i < CSR_MAX_PMKID_ALLOWED)); i++) {
12984 /* Fill the valid entries */
12985 pmksa = &pSession->PmkidCacheInfo[i];
Anurag Chouhanc5548422016-02-24 18:33:27 +053012986 if (!qdf_is_macaddr_zero(&pmksa->BSSID)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053012987 qdf_mem_copy(pPmkidCache, pmksa,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012988 sizeof(tPmkidCacheInfo));
12989 pPmkidCache++;
12990 j++;
12991 }
12992 }
12993
12994 *pNum = pSession->NumPmkidCache;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012995 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012996}
12997
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053012998QDF_STATUS csr_roam_get_wpa_rsn_req_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080012999 uint32_t *pLen, uint8_t *pBuf)
13000{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013001 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013002 uint32_t len;
13003 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13004
13005 if (!pSession) {
13006 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013007 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013008 }
13009
13010 if (pLen) {
13011 len = *pLen;
13012 *pLen = pSession->nWpaRsnReqIeLength;
13013 if (pBuf) {
13014 if (len >= pSession->nWpaRsnReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013015 qdf_mem_copy(pBuf, pSession->pWpaRsnReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013016 pSession->nWpaRsnReqIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013017 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013018 }
13019 }
13020 }
13021 return status;
13022}
13023
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013024QDF_STATUS csr_roam_get_wpa_rsn_rsp_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013025 uint32_t *pLen, uint8_t *pBuf)
13026{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013027 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013028 uint32_t len;
13029 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13030
13031 if (!pSession) {
13032 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013033 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013034 }
13035
13036 if (pLen) {
13037 len = *pLen;
13038 *pLen = pSession->nWpaRsnRspIeLength;
13039 if (pBuf) {
13040 if (len >= pSession->nWpaRsnRspIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013041 qdf_mem_copy(pBuf, pSession->pWpaRsnRspIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013042 pSession->nWpaRsnRspIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013043 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013044 }
13045 }
13046 }
13047 return status;
13048}
13049
13050#ifdef FEATURE_WLAN_WAPI
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013051QDF_STATUS csr_roam_get_wapi_req_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013052 uint32_t *pLen, uint8_t *pBuf)
13053{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013054 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013055 uint32_t len;
13056 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13057
13058 if (!pSession) {
13059 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013060 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013061 }
13062
13063 if (pLen) {
13064 len = *pLen;
13065 *pLen = pSession->nWapiReqIeLength;
13066 if (pBuf) {
13067 if (len >= pSession->nWapiReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013068 qdf_mem_copy(pBuf, pSession->pWapiReqIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013069 pSession->nWapiReqIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013070 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013071 }
13072 }
13073 }
13074 return status;
13075}
13076
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013077QDF_STATUS csr_roam_get_wapi_rsp_ie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013078 uint32_t *pLen, uint8_t *pBuf)
13079{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013080 QDF_STATUS status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013081 uint32_t len;
13082 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13083
13084 if (!pSession) {
13085 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013086 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013087 }
13088
13089 if (pLen) {
13090 len = *pLen;
13091 *pLen = pSession->nWapiRspIeLength;
13092 if (pBuf) {
13093 if (len >= pSession->nWapiRspIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013094 qdf_mem_copy(pBuf, pSession->pWapiRspIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013095 pSession->nWapiRspIeLength);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013096 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013097 }
13098 }
13099 }
13100 return status;
13101}
13102#endif /* FEATURE_WLAN_WAPI */
13103eRoamCmdStatus csr_get_roam_complete_status(tpAniSirGlobal pMac, uint32_t sessionId)
13104{
13105 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
13106 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13107
13108 if (!pSession) {
13109 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
13110 return retStatus;
13111 }
13112
13113 if (CSR_IS_ROAMING(pSession)) {
13114 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
13115 pSession->fRoaming = false;
13116 }
13117 return retStatus;
13118}
13119
13120/* This function remove the connected BSS from te cached scan result */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013121QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013122csr_roam_remove_connected_bss_from_scan_cache(tpAniSirGlobal pMac,
13123 tCsrRoamConnectedProfile *pConnProfile)
13124{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013125 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013126 tCsrScanResultFilter *pScanFilter = NULL;
13127 tListElem *pEntry;
13128 tCsrScanResult *pResult;
13129 tDot11fBeaconIEs *pIes;
13130 bool fMatch;
13131
Anurag Chouhanc5548422016-02-24 18:33:27 +053013132 if ((qdf_is_macaddr_zero(&pConnProfile->bssid) ||
13133 qdf_is_macaddr_broadcast(&pConnProfile->bssid)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013134 return status;
13135 /*
13136 * Prepare the filter. Only fill in the necessary fields. Not all fields
13137 * are needed
13138 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013139 pScanFilter = qdf_mem_malloc(sizeof(tCsrScanResultFilter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013140 if (NULL == pScanFilter)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013141 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013142
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013143 qdf_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
13144 pScanFilter->BSSIDs.bssid = qdf_mem_malloc(sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013145 if (NULL == pScanFilter->BSSIDs.bssid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013146 qdf_mem_free(pScanFilter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013147 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013148 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013149 qdf_mem_copy(pScanFilter->BSSIDs.bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053013150 &pConnProfile->bssid, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013151 pScanFilter->BSSIDs.numOfBSSIDs = 1;
13152 if (!csr_is_nullssid(pConnProfile->SSID.ssId,
13153 pConnProfile->SSID.length)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013154 pScanFilter->SSIDs.SSIDList = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013155 sizeof(tCsrSSIDInfo));
13156 if (NULL == pScanFilter->SSIDs.SSIDList) {
13157 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013158 qdf_mem_free(pScanFilter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013159 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013160 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013161 qdf_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013162 &pConnProfile->SSID, sizeof(tSirMacSSid));
13163 }
13164 pScanFilter->authType.numEntries = 1;
13165 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
13166 pScanFilter->BSSType = pConnProfile->BSSType;
13167 pScanFilter->EncryptionType.numEntries = 1;
13168 pScanFilter->EncryptionType.encryptionType[0] =
13169 pConnProfile->EncryptionType;
13170 pScanFilter->mcEncryptionType.numEntries = 1;
13171 pScanFilter->mcEncryptionType.encryptionType[0] =
13172 pConnProfile->mcEncryptionType;
13173 /* We ignore the channel for now, BSSID should be enough */
13174 pScanFilter->ChannelInfo.numOfChannels = 0;
13175 /* Also ignore the following fields */
13176 pScanFilter->uapsd_mask = 0;
13177 pScanFilter->bWPSAssociation = false;
13178 pScanFilter->bOSENAssociation = false;
13179 pScanFilter->countryCode[0] = 0;
13180 pScanFilter->phyMode = eCSR_DOT11_MODE_AUTO;
Krunal Sonib2f13042015-11-02 18:41:08 -080013181#ifdef WLAN_FEATURE_11W
13182 pScanFilter->MFPEnabled = pConnProfile->MFPEnabled;
13183 pScanFilter->MFPRequired = pConnProfile->MFPRequired;
13184 pScanFilter->MFPCapable = pConnProfile->MFPCapable;
13185#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013186 csr_ll_lock(&pMac->scan.scanResultList);
13187 pEntry = csr_ll_peek_head(&pMac->scan.scanResultList, LL_ACCESS_NOLOCK);
13188 while (pEntry) {
13189 pResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
13190 pIes = (tDot11fBeaconIEs *) (pResult->Result.pvIes);
13191 fMatch = csr_match_bss(pMac, &pResult->Result.BssDescriptor,
13192 pScanFilter, NULL, NULL, NULL, &pIes);
13193 /* Release the IEs allocated by csr_match_bss is needed */
13194 if (!pResult->Result.pvIes) {
13195 /*
13196 * need to free the IEs since it is allocated
13197 * by csr_match_bss
13198 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013199 qdf_mem_free(pIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013200 }
13201 if (fMatch) {
13202 /* We found the one */
13203 if (csr_ll_remove_entry(&pMac->scan.scanResultList,
13204 pEntry, LL_ACCESS_NOLOCK))
13205 /* Free the memory */
13206 csr_free_scan_result_entry(pMac, pResult);
13207 break;
13208 }
13209 pEntry = csr_ll_next(&pMac->scan.scanResultList,
13210 pEntry, LL_ACCESS_NOLOCK);
13211 } /* while */
13212 csr_ll_unlock(&pMac->scan.scanResultList);
13213 csr_free_scan_filter(pMac, pScanFilter);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013214 qdf_mem_free(pScanFilter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013215 return status;
13216}
13217
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013218static QDF_STATUS csr_roam_start_wds(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013219 tCsrRoamProfile *pProfile,
13220 tSirBssDescription *pBssDesc)
13221{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013222 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013223 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13224 tBssConfigParam bssConfig;
13225
13226 if (!pSession) {
13227 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013228 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013229 }
13230
13231 if (csr_is_conn_state_ibss(pMac, sessionId)) {
13232 status =
13233 csr_roam_issue_stop_bss(pMac, sessionId,
13234 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING);
13235 } else if (csr_is_conn_state_connected_infra(pMac, sessionId)) {
13236 /* Disassociate from the connected Infrastructure network... */
13237 status =
13238 csr_roam_issue_disassociate(pMac, sessionId,
13239 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING,
13240 false);
13241 } else {
13242 /* We don't expect Bt-AMP HDD not to disconnect the last connection first at this time. */
13243 /* Otherwise we need to add code to handle the */
13244 /* situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then */
13245 /* send stop_bss to PE, before we can continue. */
13246
13247 if (csr_is_conn_state_wds(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013248 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013249 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013250 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013251 qdf_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013252 /* Assume HDD provide bssid in profile */
Anurag Chouhanc5548422016-02-24 18:33:27 +053013253 qdf_copy_macaddr(&pSession->bssParams.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013254 pProfile->BSSIDs.bssid);
13255 /* there is no Bss description before we start an WDS so we need */
13256 /* to adopt all Bss configuration parameters from the Profile. */
13257 status =
13258 csr_roam_prepare_bss_config_from_profile(pMac, pProfile,
13259 &bssConfig, pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013260 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013261 /* Save profile for late use */
13262 csr_free_roam_profile(pMac, sessionId);
13263 pSession->pCurRoamProfile =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013264 qdf_mem_malloc(sizeof(tCsrRoamProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013265 if (pSession->pCurRoamProfile != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013266 qdf_mem_set(pSession->pCurRoamProfile,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013267 sizeof(tCsrRoamProfile), 0);
13268 csr_roam_copy_profile(pMac,
13269 pSession->pCurRoamProfile,
13270 pProfile);
13271 }
13272 /* Prepare some more parameters for this WDS */
13273 csr_roam_prepare_bss_params(pMac, sessionId, pProfile, NULL,
13274 &bssConfig, NULL);
13275 status =
13276 csr_roam_set_bss_config_cfg(pMac, sessionId, pProfile,
13277 NULL, &bssConfig, NULL,
13278 false);
13279 }
13280 }
13281
13282 return status;
13283}
13284
13285/**
13286 * csr_add_supported_5Ghz_channels()- Add valid 5Ghz channels
13287 * in Join req.
13288 * @mac_ctx: pointer to global mac structure
13289 * @csr_join_req: join req sent to lim
13290 *
13291 * This function is called to update valid 5Ghz channels
13292 * in Join req.
13293 *
13294 * Return: void
13295 */
13296static void csr_add_supported_5Ghz_channels(tpAniSirGlobal mac_ctx,
13297 tSirSmeJoinReq *csr_join_req)
13298{
13299 uint16_t i, j;
13300 uint32_t size = 0;
13301
13302 if (!csr_join_req) {
13303 sms_log(mac_ctx, LOGE, FL(" csr_join_reqis NULL"));
13304 return;
13305 }
13306
13307 size = sizeof(mac_ctx->roam.validChannelList);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013308 if (QDF_IS_STATUS_SUCCESS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013309 (csr_get_cfg_valid_channels(mac_ctx,
13310 (uint8_t *) mac_ctx->roam.validChannelList,
13311 &size))) {
13312 for (i = 0, j = 0; i < size; i++) {
13313 /* Only add 5ghz channels.*/
13314 if (CDS_IS_CHANNEL_5GHZ
13315 (mac_ctx->roam.validChannelList[i])) {
13316 csr_join_req->supportedChannels.channelList[j] =
13317 mac_ctx->roam.validChannelList[i];
13318 j++;
13319 }
13320 }
13321 csr_join_req->supportedChannels.numChnl = j;
13322 } else {
13323 sms_log(mac_ctx, LOGE,
13324 FL("can not find any valid channel"));
13325 csr_join_req->supportedChannels.numChnl = 0;
13326 }
13327}
13328
13329/**
13330 * The communication between HDD and LIM is thru mailbox (MB).
13331 * Both sides will access the data structure "tSirSmeJoinReq".
13332 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the
13333 * regular way like tSirSmeJoinReq.assocType, this guideline stops at component
13334 * tSirRSNie;
13335 * any acces to the components after tSirRSNie is forbidden because the space
13336 * from tSirRSNie is squeezed with the component "tSirBssDescription" and since
13337 * the size of actual 'tSirBssDescription' varies, the receiving side should
13338 * keep in mind not to access the components DIRECTLY after tSirRSNie.
13339 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013340QDF_STATUS csr_send_join_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013341 tSirBssDescription *pBssDescription,
13342 tCsrRoamProfile *pProfile,
13343 tDot11fBeaconIEs *pIes, uint16_t messageType)
13344{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013345 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013346 uint8_t acm_mask = 0, uapsd_mask;
13347 uint16_t msgLen, ieLen;
13348 tSirMacRateSet OpRateSet;
13349 tSirMacRateSet ExRateSet;
13350 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
13351 uint32_t dwTmp, ucDot11Mode = 0;
13352 /* RSN MAX is bigger than WPA MAX */
13353 uint8_t wpaRsnIE[DOT11F_IE_RSN_MAX_LEN];
13354 uint8_t txBFCsnValue = 0;
13355 tSirSmeJoinReq *csr_join_req;
13356 tSirMacCapabilityInfo *pAP_capabilityInfo;
13357 tAniBool fTmp;
13358 int8_t pwrLimit = 0;
13359 struct ps_global_info *ps_global_info = &pMac->sme.ps_global_info;
13360 struct ps_params *ps_param = &ps_global_info->ps_params[sessionId];
13361 uint8_t ese_config = 0;
13362
13363
13364 if (!pSession) {
13365 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013366 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013367 }
13368 /* To satisfy klockworks */
13369 if (NULL == pBssDescription) {
13370 sms_log(pMac, LOGE, FL(" pBssDescription is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013371 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013372 }
13373
13374 do {
13375 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13376 pSession->joinFailStatusCode.reasonCode = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013377 qdf_mem_copy(&pSession->joinFailStatusCode.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013378 &pBssDescription->bssId, sizeof(tSirMacAddr));
13379 /*
13380 * the tSirSmeJoinReq which includes a single
13381 * bssDescription. it includes a single uint32_t for the
13382 * IE fields, but the length field in the bssDescription
13383 * needs to be interpreted to determine length of IE fields
13384 * So, take the size of the tSirSmeJoinReq, subtract size of
13385 * bssDescription, add the number of bytes indicated by the
13386 * length field of the bssDescription, add the size of length
13387 * field because it not included in the lenghth field.
13388 */
13389 msgLen = sizeof(tSirSmeJoinReq) - sizeof(*pBssDescription) +
13390 pBssDescription->length +
13391 sizeof(pBssDescription->length) +
13392 /*
13393 * add in the size of the WPA IE that
13394 * we may build.
13395 */
13396 sizeof(tCsrWpaIe) + sizeof(tCsrWpaAuthIe) +
13397 sizeof(uint16_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013398 csr_join_req = qdf_mem_malloc(msgLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013399 if (NULL == csr_join_req)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013400 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013401 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013402 status = QDF_STATUS_SUCCESS;
13403 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013404 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013405 qdf_mem_set(csr_join_req, msgLen, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013406 csr_join_req->messageType = messageType;
13407 csr_join_req->length = msgLen;
13408 csr_join_req->sessionId = (uint8_t) sessionId;
13409 csr_join_req->transactionId = 0;
13410 if (pIes->SSID.present && pIes->SSID.num_ssid) {
13411 csr_join_req->ssId.length = pIes->SSID.num_ssid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013412 qdf_mem_copy(&csr_join_req->ssId.ssId, pIes->SSID.ssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013413 pIes->SSID.num_ssid);
13414 } else
13415 csr_join_req->ssId.length = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013416 qdf_mem_copy(&csr_join_req->selfMacAddr, &pSession->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013417 sizeof(tSirMacAddr));
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -080013418 sms_log(pMac, LOGE,
13419 "Connecting to ssid:%.*s bssid: "
13420 MAC_ADDRESS_STR" rssi: %d channel: %d country_code: %c%c",
13421 pIes->SSID.num_ssid, pIes->SSID.ssid,
13422 MAC_ADDR_ARRAY(pBssDescription->bssId),
13423 pBssDescription->rssi, pBssDescription->channelId,
13424 pMac->scan.countryCodeCurrent[0],
13425 pMac->scan.countryCodeCurrent[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013426 /* bsstype */
13427 dwTmp = csr_translate_bsstype_to_mac_type
13428 (pProfile->BSSType);
13429 /* Override BssType for BTAMP */
13430 if (dwTmp == eSIR_BTAMP_STA_MODE)
13431 dwTmp = eSIR_BTAMP_AP_MODE;
13432 csr_join_req->bsstype = dwTmp;
13433 /* dot11mode */
13434 ucDot11Mode =
13435 csr_translate_to_wni_cfg_dot11_mode(pMac,
13436 pSession->bssParams.
13437 uCfgDot11Mode);
13438 if (pBssDescription->channelId <= 14
13439 && false == pMac->roam.configParam.enableVhtFor24GHz
13440 && WNI_CFG_DOT11_MODE_11AC == ucDot11Mode) {
13441 /* Need to disable VHT operation in 2.4 GHz band */
13442 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
13443 }
13444 csr_join_req->dot11mode = (uint8_t) ucDot11Mode;
13445#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
13446 csr_join_req->cc_switch_mode =
13447 pMac->roam.configParam.cc_switch_mode;
13448#endif
13449 csr_join_req->staPersona = (uint8_t) pProfile->csrPersona;
13450 csr_join_req->cbMode = (uint8_t) pSession->bssParams.cbMode;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013451 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013452 FL("CSR PERSONA=%d CSR CbMode %d"),
13453 pProfile->csrPersona, pSession->bssParams.cbMode);
13454 csr_join_req->uapsdPerAcBitmask = pProfile->uapsd_mask;
13455 status =
13456 csr_get_rate_set(pMac, pProfile,
13457 (eCsrPhyMode) pProfile->phyMode,
13458 pBssDescription, pIes, &OpRateSet,
13459 &ExRateSet);
13460 ps_param->uapsd_per_ac_bit_mask =
13461 pProfile->uapsd_mask;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013462 if (QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013463 /* OperationalRateSet */
13464 if (OpRateSet.numRates) {
13465 csr_join_req->operationalRateSet.numRates =
13466 OpRateSet.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013467 qdf_mem_copy(&csr_join_req->operationalRateSet.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013468 rate, OpRateSet.rate,
13469 OpRateSet.numRates);
13470 } else
13471 csr_join_req->operationalRateSet.numRates = 0;
13472
13473 /* ExtendedRateSet */
13474 if (ExRateSet.numRates) {
13475 csr_join_req->extendedRateSet.numRates =
13476 ExRateSet.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013477 qdf_mem_copy(&csr_join_req->extendedRateSet.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013478 rate, ExRateSet.rate,
13479 ExRateSet.numRates);
13480 } else
13481 csr_join_req->extendedRateSet.numRates = 0;
13482 } else {
13483 csr_join_req->operationalRateSet.numRates = 0;
13484 csr_join_req->extendedRateSet.numRates = 0;
13485 }
13486 /* rsnIE */
13487 if (csr_is_profile_wpa(pProfile)) {
13488 /* Insert the Wpa IE into the join request */
13489 ieLen =
13490 csr_retrieve_wpa_ie(pMac, pProfile,
13491 pBssDescription, pIes,
13492 (tCsrWpaIe *) (wpaRsnIE));
13493 } else if (csr_is_profile_rsn(pProfile)) {
13494 /* Insert the RSN IE into the join request */
13495 ieLen =
13496 csr_retrieve_rsn_ie(pMac, sessionId, pProfile,
13497 pBssDescription, pIes,
13498 (tCsrRSNIe *) (wpaRsnIE));
13499 }
13500#ifdef FEATURE_WLAN_WAPI
13501 else if (csr_is_profile_wapi(pProfile)) {
13502 /* Insert the WAPI IE into the join request */
13503 ieLen =
13504 csr_retrieve_wapi_ie(pMac, sessionId, pProfile,
13505 pBssDescription, pIes,
13506 (tCsrWapiIe *) (wpaRsnIE));
13507 }
13508#endif /* FEATURE_WLAN_WAPI */
13509 else {
13510 ieLen = 0;
13511 }
13512 /* remember the IE for future use */
13513 if (ieLen) {
13514 if (ieLen > DOT11F_IE_RSN_MAX_LEN) {
13515 sms_log(pMac, LOGE,
13516 FL
13517 (" WPA RSN IE length :%d is more than DOT11F_IE_RSN_MAX_LEN, resetting to %d"),
13518 ieLen, DOT11F_IE_RSN_MAX_LEN);
13519 ieLen = DOT11F_IE_RSN_MAX_LEN;
13520 }
13521#ifdef FEATURE_WLAN_WAPI
13522 if (csr_is_profile_wapi(pProfile)) {
13523 /* Check whether we need to allocate more mem */
13524 if (ieLen > pSession->nWapiReqIeLength) {
13525 if (pSession->pWapiReqIE
13526 && pSession->nWapiReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013527 qdf_mem_free(pSession->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013528 pWapiReqIE);
13529 }
13530 pSession->pWapiReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013531 qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013532 if (NULL == pSession->pWapiReqIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013533 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013534 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013535 status = QDF_STATUS_SUCCESS;
13536 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013537 break;
13538 }
13539 pSession->nWapiReqIeLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013540 qdf_mem_copy(pSession->pWapiReqIE, wpaRsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013541 ieLen);
13542 csr_join_req->rsnIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013543 qdf_mem_copy(&csr_join_req->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013544 wpaRsnIE, ieLen);
13545 } else /* should be WPA/WPA2 otherwise */
13546#endif /* FEATURE_WLAN_WAPI */
13547 {
13548 /* Check whether we need to allocate more mem */
13549 if (ieLen > pSession->nWpaRsnReqIeLength) {
13550 if (pSession->pWpaRsnReqIE
13551 && pSession->nWpaRsnReqIeLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013552 qdf_mem_free(pSession->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013553 pWpaRsnReqIE);
13554 }
13555 pSession->pWpaRsnReqIE =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013556 qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013557 if (NULL == pSession->pWpaRsnReqIE)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013558 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013559 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013560 status = QDF_STATUS_SUCCESS;
13561 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013562 break;
13563 }
13564 pSession->nWpaRsnReqIeLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013565 qdf_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013566 ieLen);
13567 csr_join_req->rsnIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013568 qdf_mem_copy(&csr_join_req->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013569 wpaRsnIE, ieLen);
13570 }
13571 } else {
13572 /* free whatever old info */
13573 pSession->nWpaRsnReqIeLength = 0;
13574 if (pSession->pWpaRsnReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013575 qdf_mem_free(pSession->pWpaRsnReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013576 pSession->pWpaRsnReqIE = NULL;
13577 }
13578#ifdef FEATURE_WLAN_WAPI
13579 pSession->nWapiReqIeLength = 0;
13580 if (pSession->pWapiReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013581 qdf_mem_free(pSession->pWapiReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013582 pSession->pWapiReqIE = NULL;
13583 }
13584#endif /* FEATURE_WLAN_WAPI */
13585 csr_join_req->rsnIE.length = 0;
13586 }
13587#ifdef FEATURE_WLAN_ESE
13588 if (eWNI_SME_JOIN_REQ == messageType)
13589 csr_join_req->cckmIE.length = 0;
13590 else if (eWNI_SME_REASSOC_REQ == messageType) {
13591 /* cckmIE */
13592 if (csr_is_profile_ese(pProfile)) {
13593 /* Insert the CCKM IE into the join request */
13594#ifdef FEATURE_WLAN_ESE_UPLOAD
13595 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013596 qdf_mem_copy((void *)(wpaRsnIE),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013597 pSession->suppCckmIeInfo.cckmIe,
13598 ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013599#endif /* FEATURE_WLAN_ESE_UPLOAD */
13600 } else
13601 ieLen = 0;
13602 /*
13603 * If present, copy the IE into the
13604 * eWNI_SME_REASSOC_REQ message buffer
13605 */
13606 if (ieLen) {
13607 /*
13608 * Copy the CCKM IE over from the temp
13609 * buffer (wpaRsnIE)
13610 */
13611 csr_join_req->cckmIE.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013612 qdf_mem_copy(&csr_join_req->cckmIE.cckmIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013613 wpaRsnIE, ieLen);
13614 } else
13615 csr_join_req->cckmIE.length = 0;
13616 }
13617#endif /* FEATURE_WLAN_ESE */
13618 /* addIEScan */
13619 if (pProfile->nAddIEScanLength && pProfile->pAddIEScan) {
13620 ieLen = pProfile->nAddIEScanLength;
13621 if (ieLen > pSession->nAddIEScanLength) {
13622 if (pSession->pAddIEScan
13623 && pSession->nAddIEScanLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013624 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013625 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013626 pSession->pAddIEScan = qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013627 if (NULL == pSession->pAddIEScan)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013628 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013629 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013630 status = QDF_STATUS_SUCCESS;
13631 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013632 break;
13633 }
13634 pSession->nAddIEScanLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013635 qdf_mem_copy(pSession->pAddIEScan, pProfile->pAddIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013636 ieLen);
13637 csr_join_req->addIEScan.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013638 qdf_mem_copy(&csr_join_req->addIEScan.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013639 pProfile->pAddIEScan, ieLen);
13640 } else {
13641 pSession->nAddIEScanLength = 0;
13642 if (pSession->pAddIEScan) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013643 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013644 pSession->pAddIEScan = NULL;
13645 }
13646 csr_join_req->addIEScan.length = 0;
13647 }
13648 /* addIEAssoc */
13649 if (pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc) {
13650 ieLen = pProfile->nAddIEAssocLength;
13651 if (ieLen > pSession->nAddIEAssocLength) {
13652 if (pSession->pAddIEAssoc
13653 && pSession->nAddIEAssocLength) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013654 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013655 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013656 pSession->pAddIEAssoc = qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013657 if (NULL == pSession->pAddIEAssoc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013658 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013659 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013660 status = QDF_STATUS_SUCCESS;
13661 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013662 break;
13663 }
13664 pSession->nAddIEAssocLength = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013665 qdf_mem_copy(pSession->pAddIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013666 pProfile->pAddIEAssoc, ieLen);
13667 csr_join_req->addIEAssoc.length = ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013668 qdf_mem_copy(&csr_join_req->addIEAssoc.addIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013669 pProfile->pAddIEAssoc, ieLen);
13670 } else {
13671 pSession->nAddIEAssocLength = 0;
13672 if (pSession->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013673 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013674 pSession->pAddIEAssoc = NULL;
13675 }
13676 csr_join_req->addIEAssoc.length = 0;
13677 }
13678
13679 if (eWNI_SME_REASSOC_REQ == messageType) {
13680 /* Unmask any AC in reassoc that is ACM-set */
13681 uapsd_mask = (uint8_t) pProfile->uapsd_mask;
13682 if (uapsd_mask && (NULL != pBssDescription)) {
13683 if (CSR_IS_QOS_BSS(pIes)
13684 && CSR_IS_UAPSD_BSS(pIes))
13685#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13686 acm_mask =
13687 sme_qos_get_acm_mask(pMac,
13688 pBssDescription,
13689 pIes);
13690#endif /* WLAN_MDM_CODE_REDUCTION_OPT */
13691 else
13692 uapsd_mask = 0;
13693 }
13694 }
13695
13696 csr_join_req->UCEncryptionType =
13697 csr_translate_encrypt_type_to_ed_type
13698 (pProfile->negotiatedUCEncryptionType);
13699
13700 csr_join_req->MCEncryptionType =
13701 csr_translate_encrypt_type_to_ed_type
13702 (pProfile->negotiatedMCEncryptionType);
13703#ifdef WLAN_FEATURE_11W
13704 if (pProfile->MFPEnabled)
13705 csr_join_req->MgmtEncryptionType = eSIR_ED_AES_128_CMAC;
13706 else
13707 csr_join_req->MgmtEncryptionType = eSIR_ED_NONE;
13708#endif
13709#ifdef FEATURE_WLAN_ESE
13710 ese_config = pMac->roam.configParam.isEseIniFeatureEnabled;
13711#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013712 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
13713 if (csr_is_profile11r(pProfile)
13714#ifdef FEATURE_WLAN_ESE
13715 &&
13716 !((pProfile->negotiatedAuthType ==
13717 eCSR_AUTH_TYPE_OPEN_SYSTEM) && (pIes->ESEVersion.present)
13718 && (ese_config))
13719#endif
13720 )
13721 csr_join_req->is11Rconnection = true;
13722 else
13723 csr_join_req->is11Rconnection = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013724#ifdef FEATURE_WLAN_ESE
13725 if (true == ese_config)
13726 csr_join_req->isESEFeatureIniEnabled = true;
13727 else
13728 csr_join_req->isESEFeatureIniEnabled = false;
13729
13730 /* A profile can not be both ESE and 11R. But an 802.11R AP
13731 * may be advertising support for ESE as well. So if we are
13732 * associating Open or explicitly ESE then we will get ESE.
13733 * If we are associating explictly 11R only then we will get
13734 * 11R.
13735 */
13736 if ((csr_is_profile_ese(pProfile) ||
13737 ((pIes->ESEVersion.present) &&
13738 (pProfile->negotiatedAuthType ==
13739 eCSR_AUTH_TYPE_OPEN_SYSTEM)))
13740 && (ese_config))
13741 csr_join_req->isESEconnection = true;
13742 else
13743 csr_join_req->isESEconnection = false;
13744
13745 if (eWNI_SME_JOIN_REQ == messageType) {
13746 tESETspecInfo eseTspec;
13747 /*
13748 * ESE-Tspec IEs in the ASSOC request is presently not
13749 * supported. so nullify the TSPEC parameters
13750 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013751 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13752 qdf_mem_copy(&csr_join_req->eseTspecInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013753 &eseTspec, sizeof(tESETspecInfo));
13754 } else if (eWNI_SME_REASSOC_REQ == messageType) {
13755 if ((csr_is_profile_ese(pProfile) ||
13756 ((pIes->ESEVersion.present)
13757 && (pProfile->negotiatedAuthType ==
13758 eCSR_AUTH_TYPE_OPEN_SYSTEM))) &&
13759 (ese_config)) {
13760 tESETspecInfo eseTspec;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013761 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013762 0);
13763 eseTspec.numTspecs =
13764 sme_qos_ese_retrieve_tspec_info(pMac,
13765 sessionId,
13766 (tTspecInfo *) &eseTspec.
13767 tspec[0]);
13768 csr_join_req->eseTspecInfo.numTspecs =
13769 eseTspec.numTspecs;
13770 if (eseTspec.numTspecs) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013771 qdf_mem_copy(&csr_join_req->eseTspecInfo
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013772 .tspec[0],
13773 &eseTspec.tspec[0],
13774 (eseTspec.numTspecs *
13775 sizeof(tTspecInfo)));
13776 }
13777 } else {
13778 tESETspecInfo eseTspec;
13779 /**
13780 * ESE-Tspec IEs in the ASSOC request is
13781 * presently not supported. so nullify the TSPEC
13782 * parameters
13783 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013784 qdf_mem_set(&eseTspec, sizeof(tESETspecInfo),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013785 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013786 qdf_mem_copy(&csr_join_req->eseTspecInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013787 &eseTspec,
13788 sizeof(tESETspecInfo));
13789 }
13790 }
13791#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013792 if (ese_config
Deepak Dhamdhereecce9742015-11-08 01:16:43 -080013793 || csr_roam_is_fast_roam_enabled(pMac, sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013794 csr_join_req->isFastTransitionEnabled = true;
13795 } else {
13796 csr_join_req->isFastTransitionEnabled = false;
13797 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013798 if (csr_roam_is_fast_roam_enabled(pMac, sessionId))
13799 csr_join_req->isFastRoamIniFeatureEnabled = true;
13800 else
13801 csr_join_req->isFastRoamIniFeatureEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013802
13803 csr_join_req->txLdpcIniFeatureEnabled =
13804 (uint8_t) pMac->roam.configParam.txLdpcEnable;
13805
13806 if ((csr_is11h_supported(pMac))
13807 && (CDS_IS_CHANNEL_5GHZ(pBssDescription->channelId))
13808 && (pIes->Country.present)
13809 && (!pMac->roam.configParam.
13810 fSupplicantCountryCodeHasPriority)) {
13811 csr_save_to_channel_power2_g_5_g(pMac,
13812 pIes->Country.num_triplets *
13813 sizeof(tSirMacChanInfo),
13814 (tSirMacChanInfo *)
13815 (&pIes->Country.triplets[0]));
13816 csr_apply_power2_current(pMac);
13817 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013818 qdf_mem_copy(&csr_join_req->htConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013819 &pSession->htConfig, sizeof(tSirHTConfig));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013820 csr_join_req->txBFIniFeatureEnabled =
13821 (uint8_t) pMac->roam.configParam.txBFEnable;
13822
13823 if (pMac->roam.configParam.txBFEnable) {
13824 txBFCsnValue =
13825 (uint8_t)pMac->roam.configParam.txBFCsnValue;
13826 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps) &&
13827 pIes->VHTCaps.numSoundingDim)
Anurag Chouhan6d760662016-02-20 16:05:43 +053013828 txBFCsnValue = QDF_MIN(txBFCsnValue,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013829 pIes->VHTCaps.numSoundingDim);
13830 else if (IS_BSS_VHT_CAPABLE(pIes->vendor2_ie.VHTCaps)
13831 && pIes->vendor2_ie.VHTCaps.numSoundingDim)
Anurag Chouhan6d760662016-02-20 16:05:43 +053013832 txBFCsnValue = QDF_MIN(txBFCsnValue,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013833 pIes->vendor2_ie.VHTCaps.numSoundingDim);
13834 }
13835 csr_join_req->txBFCsnValue = txBFCsnValue;
13836
13837 csr_join_req->txMuBformee =
13838 (uint8_t) pMac->roam.configParam.txMuBformee;
13839
13840 csr_join_req->enableVhtpAid =
13841 (uint8_t) pMac->roam.configParam.enableVhtpAid;
13842
13843 csr_join_req->enableVhtGid =
13844 (uint8_t) pMac->roam.configParam.enableVhtGid;
13845
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013846 csr_join_req->enableAmpduPs =
13847 (uint8_t) pMac->roam.configParam.enableAmpduPs;
13848
13849 csr_join_req->enableHtSmps =
13850 (uint8_t) pMac->roam.configParam.enableHtSmps;
13851
13852 csr_join_req->htSmps = (uint8_t) pMac->roam.configParam.htSmps;
13853
13854 csr_join_req->isAmsduSupportInAMPDU =
13855 (uint8_t) pMac->roam.configParam.isAmsduSupportInAMPDU;
13856
13857 if (pMac->roam.roamSession[sessionId].fWMMConnection)
13858 csr_join_req->isWMEenabled = true;
13859 else
13860 csr_join_req->isWMEenabled = false;
13861
13862 if (pMac->roam.roamSession[sessionId].fQOSConnection)
13863 csr_join_req->isQosEnabled = true;
13864 else
13865 csr_join_req->isQosEnabled = false;
13866
13867 if (pProfile->bOSENAssociation)
13868 csr_join_req->isOSENConnection = true;
13869 else
13870 csr_join_req->isOSENConnection = false;
13871
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080013872 /* Fill rrm config parameters */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013873 qdf_mem_copy(&csr_join_req->rrm_config,
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080013874 &pMac->rrm.rrmSmeContext.rrmConfig,
13875 sizeof(struct rrm_config_param));
13876
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013877 pAP_capabilityInfo =
13878 (tSirMacCapabilityInfo *)
13879 &pBssDescription->capabilityInfo;
13880 /*
13881 * tell the target AP my 11H capability only if both AP and STA
13882 * support
13883 * 11H and the channel being used is 11a
13884 */
13885 if (csr_is11h_supported(pMac) && pAP_capabilityInfo->spectrumMgt
13886 && eSIR_11A_NW_TYPE == pBssDescription->nwType) {
13887 fTmp = (tAniBool) 1;
13888 } else
13889 fTmp = (tAniBool) 0;
13890
13891 csr_join_req->spectrumMgtIndicator = fTmp;
13892 csr_join_req->powerCap.minTxPower = MIN_TX_PWR_CAP;
13893 /*
13894 * This is required for 11k test VoWiFi Ent: Test 2.
13895 * We need the power capabilities for Assoc Req.
13896 * This macro is provided by the halPhyCfg.h. We pick our
13897 * max and min capability by the halPhy provided macros
13898 */
13899 pwrLimit = csr_get_cfg_max_tx_power(pMac,
13900 pBssDescription->channelId);
13901 if (0 != pwrLimit)
13902 csr_join_req->powerCap.maxTxPower = pwrLimit;
13903 else
13904 csr_join_req->powerCap.maxTxPower = MAX_TX_PWR_CAP;
13905
13906 csr_add_supported_5Ghz_channels(pMac, csr_join_req);
13907
13908 csr_join_req->uapsdPerAcBitmask = (uint8_t)pProfile->uapsd_mask;
13909 /* Move the entire BssDescription into the join request. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013910 qdf_mem_copy(&csr_join_req->bssDescription, pBssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013911 pBssDescription->length +
13912 sizeof(pBssDescription->length));
13913
13914 /*
13915 * conc_custom_rule1:
13916 * If SAP comes up first and STA comes up later then SAP
13917 * need to follow STA's channel in 2.4Ghz. In following if
13918 * condition we are adding sanity check, just to make sure that
13919 * if this rule is enabled then don't allow STA to connect on
13920 * 5gz channel and also by this time SAP's channel should be the
13921 * same as STA's channel.
13922 */
13923 if (pMac->roam.configParam.conc_custom_rule1) {
13924 if ((0 ==
13925 pMac->
13926 roam.configParam.is_sta_connection_in_5gz_enabled)
13927 && CDS_IS_CHANNEL_5GHZ(pBssDescription->
13928 channelId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013929 QDF_TRACE(QDF_MODULE_ID_SME,
13930 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013931 FL("STA-conn on 5G isn't allowed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013932 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013933 break;
13934 }
13935 if (!CDS_IS_CHANNEL_5GHZ(pBssDescription->channelId) &&
13936 (false == csr_is_conn_allow_2g_band(pMac,
13937 pBssDescription->channelId))) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013938 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013939 break;
13940 }
13941 }
13942
13943 /*
13944 * conc_custom_rule2:
13945 * If P2PGO comes up first and STA comes up later then P2PGO
13946 * need to follow STA's channel in 5Ghz. In following if
13947 * condition we are just adding sanity check to make sure that
13948 * by this time P2PGO's channel is same as STA's channel.
13949 */
13950 if (pMac->roam.configParam.conc_custom_rule2) {
13951 if (!CDS_IS_CHANNEL_24GHZ(pBssDescription->channelId) &&
13952 (false == csr_is_conn_allow_5g_band(pMac,
13953 pBssDescription->channelId))) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013954 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013955 break;
13956 }
13957 }
13958 status = cds_send_mb_message_to_mac(csr_join_req);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013959 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013960 /*
13961 * cds_send_mb_message_to_mac would've released the mem
13962 * allocated by csr_join_req. Let's make it defensive by
13963 * assigning NULL to the pointer.
13964 */
13965 csr_join_req = NULL;
13966 break;
13967 } else {
13968#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13969 if (eWNI_SME_JOIN_REQ == messageType) {
13970 /* Notify QoS module that join happening */
13971 pSession->join_bssid_count++;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053013972 QDF_TRACE(QDF_MODULE_ID_SME,
13973 QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013974 "BSSID Count = %d",
13975 pSession->join_bssid_count);
13976 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
13977 SME_QOS_CSR_JOIN_REQ, NULL);
13978 } else if (eWNI_SME_REASSOC_REQ == messageType) {
13979 /* Notify QoS module that reassoc happening */
13980 sme_qos_csr_event_ind(pMac, (uint8_t) sessionId,
13981 SME_QOS_CSR_REASSOC_REQ,
13982 NULL);
13983 }
13984#endif
13985 }
13986 } while (0);
13987
13988 /* Clean up the memory in case of any failure */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013989 if (!QDF_IS_STATUS_SUCCESS(status) && (NULL != csr_join_req))
Anurag Chouhan600c3a02016-03-01 10:33:54 +053013990 qdf_mem_free(csr_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013991
13992 return status;
13993}
13994
13995/* */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053013996QDF_STATUS csr_send_mb_disassoc_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080013997 tSirMacAddr bssId, uint16_t reasonCode)
13998{
13999 tSirSmeDisassocReq *pMsg;
14000 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14001
14002 if (!CSR_IS_SESSION_VALID(pMac, sessionId))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014003 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014004
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014005 pMsg = qdf_mem_malloc(sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014006 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014007 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014008
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014009 qdf_mem_set(pMsg, sizeof(tSirSmeDisassocReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014010 pMsg->messageType = eWNI_SME_DISASSOC_REQ;
14011 pMsg->length = sizeof(tSirSmeDisassocReq);
14012 pMsg->sessionId = sessionId;
14013 pMsg->transactionId = 0;
14014 if ((pSession->pCurRoamProfile != NULL)
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070014015 && (CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014016 qdf_mem_copy(&pMsg->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014017 &pSession->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014018 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014019 qdf_mem_copy(&pMsg->peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014020 bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014021 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014022 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014023 qdf_mem_copy(&pMsg->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014024 bssId, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014025 qdf_mem_copy(&pMsg->peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014026 bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014027 }
14028 pMsg->reasonCode = reasonCode;
14029 /*
14030 * The state will be DISASSOC_HANDOFF only when we are doing
14031 * handoff. Here we should not send the disassoc over the air
14032 * to the AP
14033 */
14034 if (CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -080014035 && csr_roam_is11r_assoc(pMac, sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014036 /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
14037 pMsg->doNotSendOverTheAir = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR;
14038 }
14039 return cds_send_mb_message_to_mac(pMsg);
14040}
14041
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014042QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014043csr_send_mb_get_associated_stas_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014044 QDF_MODULE_ID modId,
14045 struct qdf_mac_addr bssid,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014046 void *pUsrContext,
14047 void *pfnSapEventCallback,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014048 uint8_t *pAssocStasBuf)
14049{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014050 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014051 tSirSmeGetAssocSTAsReq *pMsg;
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014052
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014053 pMsg = qdf_mem_malloc(sizeof(*pMsg));
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014054 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014055 return QDF_STATUS_E_NOMEM;
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014056
14057 pMsg->messageType = eWNI_SME_GET_ASSOC_STAS_REQ;
Anurag Chouhanc5548422016-02-24 18:33:27 +053014058 qdf_copy_macaddr(&pMsg->bssid, &bssid);
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014059 pMsg->modId = modId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014060 qdf_mem_copy(pMsg->pUsrContext, pUsrContext, sizeof(void *));
14061 qdf_mem_copy(pMsg->pSapEventCallback,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014062 pfnSapEventCallback, sizeof(void *));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014063 qdf_mem_copy(pMsg->pAssocStasArray, pAssocStasBuf, sizeof(void *));
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -080014064 pMsg->length = sizeof(*pMsg);
14065 status = cds_send_mb_message_to_mac(pMsg);
14066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014067 return status;
14068}
14069
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014070QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014071csr_send_mb_get_wpspbc_sessions(tpAniSirGlobal pMac, uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014072 struct qdf_mac_addr bssid, void *pUsrContext,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014073 void *pfnSapEventCallback,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014074 struct qdf_mac_addr remove_mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014075{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014076 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014077 tSirSmeGetWPSPBCSessionsReq *pMsg;
14078
14079 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014080 pMsg = qdf_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014081 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014082 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014083 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014084 status = QDF_STATUS_SUCCESS;
14085 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014086 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014087 qdf_mem_set(pMsg, sizeof(tSirSmeGetWPSPBCSessionsReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014088 pMsg->messageType = eWNI_SME_GET_WPSPBC_SESSION_REQ;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014089 qdf_mem_copy(pMsg->pUsrContext, pUsrContext, sizeof(void *));
14090 qdf_mem_copy(pMsg->pSapEventCallback, pfnSapEventCallback,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014091 sizeof(void *));
Anurag Chouhanc5548422016-02-24 18:33:27 +053014092 qdf_copy_macaddr(&pMsg->bssid, &bssid);
14093 qdf_copy_macaddr(&pMsg->remove_mac, &remove_mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014094 pMsg->length = sizeof(struct sSirSmeGetWPSPBCSessionsReq);
14095 status = cds_send_mb_message_to_mac(pMsg);
14096 } while (0);
14097 return status;
14098}
14099
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014100QDF_STATUS csr_send_chng_mcc_beacon_interval(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014101{
14102 tpSirChangeBIParams pMsg;
14103 uint16_t len = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014104 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014105 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14106
14107 if (!pSession) {
14108 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014109 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014110 }
14111 /* NO need to update the Beacon Params if update beacon parameter flag is not set */
14112 if (!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014113 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014114
14115 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval =
14116 false;
14117
14118 /* Create the message and send to lim */
14119 len = sizeof(tSirChangeBIParams);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014120 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014121 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014122 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014123 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014124 status = QDF_STATUS_SUCCESS;
14125 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014126 qdf_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014127 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
14128 pMsg->length = len;
14129
Anurag Chouhanc5548422016-02-24 18:33:27 +053014130 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014131 sms_log(pMac, LOG1,
14132 FL("CSR Attempting to change BI for Bssid= "
Srinivas Girigowda8e717d32015-11-24 15:54:33 -080014133 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pMsg->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014134 pMsg->sessionId = sessionId;
14135 sms_log(pMac, LOG1, FL(" session %d BeaconInterval %d"),
14136 sessionId,
14137 pMac->roam.roamSession[sessionId].bssParams.
14138 beaconInterval);
14139 pMsg->beaconInterval =
14140 pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
14141 status = cds_send_mb_message_to_mac(pMsg);
14142 }
14143 return status;
14144}
14145
14146#ifdef QCA_HT_2040_COEX
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014147QDF_STATUS csr_set_ht2040_mode(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014148 ePhyChanBondState cbMode, bool obssEnabled)
14149{
14150 tpSirSetHT2040Mode pMsg;
14151 uint16_t len = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014152 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014153 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14154
14155 if (!pSession) {
14156 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014157 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014158 }
14159
14160 /* Create the message and send to lim */
14161 len = sizeof(tSirSetHT2040Mode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014162 pMsg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014163 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014164 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014165 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014166 status = QDF_STATUS_SUCCESS;
14167 if (QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014168 qdf_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014169 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
14170 pMsg->length = len;
14171
Anurag Chouhanc5548422016-02-24 18:33:27 +053014172 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014173 sms_log(pMac, LOG1,
14174 FL("CSR Attempting to set HT20/40 mode for Bssid= "
Srinivas Girigowdac52474d2015-11-24 15:49:31 -080014175 MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pMsg->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014176 pMsg->sessionId = sessionId;
14177 sms_log(pMac, LOG1, FL(" session %d HT20/40 mode %d"),
14178 sessionId, cbMode);
14179 pMsg->cbMode = cbMode;
14180 pMsg->obssEnabled = obssEnabled;
14181 status = cds_send_mb_message_to_mac(pMsg);
14182 }
14183 return status;
14184}
14185#endif
14186
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014187QDF_STATUS csr_send_mb_deauth_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014188 tSirMacAddr bssId, uint16_t reasonCode)
14189{
14190 tSirSmeDeauthReq *pMsg;
14191 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14192
14193 if (!CSR_IS_SESSION_VALID(pMac, sessionId))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014194 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014195
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014196 pMsg = qdf_mem_malloc(sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014197 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014198 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014199
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014200 qdf_mem_set(pMsg, sizeof(tSirSmeDeauthReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014201 pMsg->messageType = eWNI_SME_DEAUTH_REQ;
14202 pMsg->length = sizeof(tSirSmeDeauthReq);
14203 pMsg->sessionId = sessionId;
14204 pMsg->transactionId = 0;
14205
14206 if ((pSession->pCurRoamProfile != NULL)
Sandeep Puligillaee029ad2015-10-26 18:58:00 -070014207 && (CSR_IS_INFRA_AP(pSession->pCurRoamProfile))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014208 qdf_mem_copy(&pMsg->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014209 &pSession->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014210 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014211 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014212 qdf_mem_copy(&pMsg->bssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014213 bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014214 }
14215
14216 /* Set the peer MAC address before sending the message to LIM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014217 qdf_mem_copy(&pMsg->peer_macaddr.bytes, bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014218 pMsg->reasonCode = reasonCode;
14219
14220 return cds_send_mb_message_to_mac(pMsg);
14221}
14222
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014223QDF_STATUS csr_send_mb_disassoc_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014224 tpSirSmeDisassocInd pDisassocInd)
14225{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014226 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014227 tSirSmeDisassocCnf *pMsg;
14228 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014229 pMsg = qdf_mem_malloc(sizeof(tSirSmeDisassocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014230 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014231 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014232 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014233 status = QDF_STATUS_SUCCESS;
14234 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014235 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014236 qdf_mem_set(pMsg, sizeof(tSirSmeDisassocCnf), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014237 pMsg->messageType = eWNI_SME_DISASSOC_CNF;
14238 pMsg->statusCode = eSIR_SME_SUCCESS;
14239 pMsg->length = sizeof(tSirSmeDisassocCnf);
Anurag Chouhanc5548422016-02-24 18:33:27 +053014240 qdf_copy_macaddr(&pMsg->peer_macaddr,
Srinivas Girigowdae13cc342016-01-05 17:07:53 -080014241 &pDisassocInd->peer_macaddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014242 status = QDF_STATUS_SUCCESS;
14243 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014244 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014245 break;
14246 }
14247
Anurag Chouhanc5548422016-02-24 18:33:27 +053014248 qdf_copy_macaddr(&pMsg->bssid, &pDisassocInd->bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014249 status = QDF_STATUS_SUCCESS;
14250 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014251 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014252 break;
14253 }
14254
14255 status = cds_send_mb_message_to_mac(pMsg);
14256 } while (0);
14257 return status;
14258}
14259
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014260QDF_STATUS csr_send_mb_deauth_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014261 tpSirSmeDeauthInd pDeauthInd)
14262{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014263 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014264 tSirSmeDeauthCnf *pMsg;
14265 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014266 pMsg = qdf_mem_malloc(sizeof(tSirSmeDeauthCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014267 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014268 status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014269 else
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014270 status = QDF_STATUS_SUCCESS;
14271 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014272 break;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014273 qdf_mem_set(pMsg, sizeof(tSirSmeDeauthCnf), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014274 pMsg->messageType = eWNI_SME_DEAUTH_CNF;
14275 pMsg->statusCode = eSIR_SME_SUCCESS;
14276 pMsg->length = sizeof(tSirSmeDeauthCnf);
Anurag Chouhanc5548422016-02-24 18:33:27 +053014277 qdf_copy_macaddr(&pMsg->bssid, &pDeauthInd->bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014278 status = QDF_STATUS_SUCCESS;
14279 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014280 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014281 break;
14282 }
Anurag Chouhanc5548422016-02-24 18:33:27 +053014283 qdf_copy_macaddr(&pMsg->peer_macaddr,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -080014284 &pDeauthInd->peer_macaddr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014285 status = QDF_STATUS_SUCCESS;
14286 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014287 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014288 break;
14289 }
14290 status = cds_send_mb_message_to_mac(pMsg);
14291 } while (0);
14292 return status;
14293}
14294
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014295QDF_STATUS csr_send_assoc_cnf_msg(tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd,
14296 QDF_STATUS Halstatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014297{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014298 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014299 tSirSmeAssocCnf *pMsg;
14300
14301 sms_log(pMac, LOG1,
14302 FL("Posting eWNI_SME_ASSOC_CNF to LIM.HalStatus :%d"),
14303 Halstatus);
14304 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014305 pMsg = qdf_mem_malloc(sizeof(tSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014306 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014307 return QDF_STATUS_E_NOMEM;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014308 qdf_mem_set(pMsg, sizeof(tSirSmeAssocCnf), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014309 pMsg->messageType = eWNI_SME_ASSOC_CNF;
14310 pMsg->length = sizeof(tSirSmeAssocCnf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014311 if (QDF_IS_STATUS_SUCCESS(Halstatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014312 pMsg->statusCode = eSIR_SME_SUCCESS;
14313 else
14314 pMsg->statusCode = eSIR_SME_ASSOC_REFUSED;
14315 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014316 qdf_mem_copy(pMsg->bssid.bytes, pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014317 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014318 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014319 qdf_mem_copy(pMsg->peer_macaddr.bytes, pAssocInd->peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014320 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014321 /* aid */
14322 pMsg->aid = pAssocInd->aid;
14323 /* alternateBssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014324 qdf_mem_copy(pMsg->alternate_bssid.bytes, pAssocInd->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014325 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014326 /* alternateChannelId */
14327 pMsg->alternateChannelId = 11;
14328 /* pMsg is freed by cds_send_mb_message_to_mac in anycase*/
14329 status = cds_send_mb_message_to_mac(pMsg);
14330 } while (0);
14331 return status;
14332}
14333
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014334QDF_STATUS csr_send_assoc_ind_to_upper_layer_cnf_msg(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014335 tpSirSmeAssocInd pAssocInd,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014336 QDF_STATUS Halstatus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014337 uint8_t sessionId)
14338{
14339 tSirMsgQ msgQ;
14340 tSirSmeAssocIndToUpperLayerCnf *pMsg;
14341 uint8_t *pBuf;
14342 tSirResultCodes statusCode;
14343 uint16_t wTmp;
14344 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014345 pMsg = qdf_mem_malloc(sizeof(tSirSmeAssocIndToUpperLayerCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014346 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014347 return QDF_STATUS_E_NOMEM;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014348 qdf_mem_set(pMsg, sizeof(tSirSmeAssocIndToUpperLayerCnf), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014349
14350 pMsg->messageType = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
14351 pMsg->length = sizeof(tSirSmeAssocIndToUpperLayerCnf);
14352
14353 pMsg->sessionId = sessionId;
14354
14355 pBuf = (uint8_t *) &pMsg->statusCode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014356 if (QDF_IS_STATUS_SUCCESS(Halstatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014357 statusCode = eSIR_SME_SUCCESS;
14358 else
14359 statusCode = eSIR_SME_ASSOC_REFUSED;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014360 qdf_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014361 pBuf += sizeof(tSirResultCodes);
14362 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014363 qdf_mem_copy((tSirMacAddr *) pBuf, pAssocInd->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014364 sizeof(tSirMacAddr));
14365 pBuf += sizeof(tSirMacAddr);
14366 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014367 qdf_mem_copy((tSirMacAddr *) pBuf, pAssocInd->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014368 sizeof(tSirMacAddr));
14369 pBuf += sizeof(tSirMacAddr);
14370 /* StaId */
14371 wTmp = pAssocInd->staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014372 qdf_mem_copy(pBuf, &wTmp, sizeof(uint16_t));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014373 pBuf += sizeof(uint16_t);
14374 /* alternateBssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014375 qdf_mem_copy((tSirMacAddr *) pBuf, pAssocInd->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014376 sizeof(tSirMacAddr));
14377 pBuf += sizeof(tSirMacAddr);
14378 /* alternateChannelId */
14379 *pBuf = 11;
14380 pBuf += sizeof(uint8_t);
14381 /* Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information */
14382 /* Wmm */
14383 *pBuf = pAssocInd->wmmEnabledSta;
14384 pBuf += sizeof(uint8_t);
14385 /* RSN IE */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014386 qdf_mem_copy((tSirRSNie *) pBuf, &pAssocInd->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014387 sizeof(tSirRSNie));
14388 pBuf += sizeof(tSirRSNie);
14389#ifdef FEATURE_WLAN_WAPI
14390 /* WAPI IE */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014391 qdf_mem_copy((tSirWAPIie *) pBuf, &pAssocInd->wapiIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014392 sizeof(tSirWAPIie));
14393 pBuf += sizeof(tSirWAPIie);
14394#endif
14395 /* Additional IE */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014396 qdf_mem_copy((void *)pBuf, &pAssocInd->addIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014397 sizeof(tSirAddie));
14398 pBuf += sizeof(tSirAddie);
14399 /* reassocReq */
14400 *pBuf = pAssocInd->reassocReq;
14401 pBuf += sizeof(uint8_t);
14402 /* timingMeasCap */
14403 *pBuf = pAssocInd->timingMeasCap;
14404 pBuf += sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014405 qdf_mem_copy((void *)pBuf, &pAssocInd->chan_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014406 sizeof(tSirSmeChanInfo));
14407 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
14408 msgQ.bodyptr = pMsg;
14409 msgQ.bodyval = 0;
14410 sys_process_mmh_msg(pMac, &msgQ);
14411 } while (0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014412 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014413}
14414
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014415QDF_STATUS csr_send_mb_set_context_req_msg(tpAniSirGlobal pMac,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080014416 uint32_t sessionId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014417 struct qdf_mac_addr peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080014418 uint8_t numKeys,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014419 tAniEdType edType, bool fUnicast,
14420 tAniKeyDirection aniKeyDirection,
14421 uint8_t keyId, uint8_t keyLength,
14422 uint8_t *pKey, uint8_t paeRole,
14423 uint8_t *pKeyRsc)
14424{
14425 tSirSmeSetContextReq *pMsg;
14426 uint16_t msgLen;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014427 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014428 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14429 sms_log(pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
14430 keyLength, edType);
14431 do {
14432 if ((1 != numKeys) && (0 != numKeys))
14433 break;
14434 /*
14435 * All of these fields appear in every SET_CONTEXT message.
14436 * Below we'll add in the size for each key set. Since we only support
14437 * up to one key, we always allocate memory for 1 key.
14438 */
14439 msgLen = sizeof(struct sSirSmeSetContextReq);
14440
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014441 pMsg = qdf_mem_malloc(msgLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014442 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014443 return QDF_STATUS_E_NOMEM;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014444 qdf_mem_set(pMsg, msgLen, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014445 pMsg->messageType = eWNI_SME_SETCONTEXT_REQ;
14446 pMsg->length = msgLen;
14447 pMsg->sessionId = (uint8_t) sessionId;
14448 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053014449 qdf_copy_macaddr(&pMsg->peer_macaddr, &peer_macaddr);
14450 qdf_copy_macaddr(&pMsg->bssid,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -080014451 &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014452
14453 /**
14454 * Set the pMsg->keyMaterial.length field
14455 * (this length is defined as all data that follows the
14456 * edType field in the tSirKeyMaterial keyMaterial; field).
14457 *
14458 * NOTE: This keyMaterial.length contains the length of a
14459 * MAX size key, though the keyLength can be shorter than this
14460 * max size. Is LIM interpreting this ok ?
14461 */
14462 pMsg->keyMaterial.length =
14463 sizeof(pMsg->keyMaterial.numKeys) +
14464 (numKeys * sizeof(pMsg->keyMaterial.key));
14465 pMsg->keyMaterial.edType = edType;
14466 pMsg->keyMaterial.numKeys = numKeys;
14467 pMsg->keyMaterial.key[0].keyId = keyId;
14468 pMsg->keyMaterial.key[0].unicast = fUnicast;
14469 pMsg->keyMaterial.key[0].keyDirection = aniKeyDirection;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014470 qdf_mem_copy(pMsg->keyMaterial.key[0].keyRsc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014471 pKeyRsc, CSR_MAX_RSC_LEN);
14472 /* 0 is Supplicant */
14473 pMsg->keyMaterial.key[0].paeRole = paeRole;
14474 pMsg->keyMaterial.key[0].keyLength = keyLength;
14475 if (keyLength && pKey) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014476 qdf_mem_copy(pMsg->keyMaterial.key[0].key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014477 pKey, keyLength);
14478 sms_log(pMac, LOG1,
14479 FL("SME set keyIndx (%d) encType (%d) key"),
14480 keyId, edType);
14481 sir_dump_buf(pMac, SIR_SMS_MODULE_ID, LOG1, pKey,
14482 keyLength);
14483 }
14484 status = cds_send_mb_message_to_mac(pMsg);
14485 } while (0);
14486 return status;
14487}
14488
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014489QDF_STATUS csr_send_mb_start_bss_req_msg(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014490 eCsrRoamBssType bssType,
14491 tCsrRoamStartBssParams *pParam,
14492 tSirBssDescription *pBssDesc)
14493{
14494 tSirSmeStartBssReq *pMsg;
14495 uint16_t wTmp;
14496 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14497
14498 if (!pSession) {
14499 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014500 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014501 }
14502
14503 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
14504 pSession->joinFailStatusCode.reasonCode = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014505 pMsg = qdf_mem_malloc(sizeof(tSirSmeStartBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014506 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014507 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014508
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014509 qdf_mem_set(pMsg, sizeof(tSirSmeStartBssReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014510 pMsg->messageType = eWNI_SME_START_BSS_REQ;
14511 pMsg->sessionId = sessionId;
14512 pMsg->length = sizeof(tSirSmeStartBssReq);
14513 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053014514 qdf_copy_macaddr(&pMsg->bssid, &pParam->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014515 /* selfMacAddr */
Anurag Chouhanc5548422016-02-24 18:33:27 +053014516 qdf_copy_macaddr(&pMsg->self_macaddr, &pSession->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014517 /* beaconInterval */
14518 if (pBssDesc && pBssDesc->beaconInterval)
14519 wTmp = pBssDesc->beaconInterval;
14520 else if (pParam->beaconInterval)
14521 wTmp = pParam->beaconInterval;
14522 else
14523 wTmp = WNI_CFG_BEACON_INTERVAL_STADEF;
14524
14525 if (csr_isconcurrentsession_valid(pMac, sessionId, pParam->bssPersona)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014526 == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014527 csr_validate_mcc_beacon_interval(pMac,
14528 pParam->operationChn,
14529 &wTmp,
14530 sessionId,
14531 pParam->bssPersona);
14532 /* Update the beacon Interval */
14533 pParam->beaconInterval = wTmp;
14534 } else {
14535 sms_log(pMac, LOGE,
14536 FL("****Start BSS failed persona already exists***"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014537 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014538 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014539 }
14540 pMsg->beaconInterval = wTmp;
14541 pMsg->dot11mode =
14542 csr_translate_to_wni_cfg_dot11_mode(pMac,
14543 pParam->uCfgDot11Mode);
14544#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
14545 pMsg->cc_switch_mode = pMac->roam.configParam.cc_switch_mode;
14546#endif
14547 pMsg->bssType = csr_translate_bsstype_to_mac_type(bssType);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014548 qdf_mem_copy(&pMsg->ssId, &pParam->ssId, sizeof(pParam->ssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014549 pMsg->channelId = pParam->operationChn;
14550 /* What should we really do for the cbmode. */
14551 pMsg->cbMode = (ePhyChanBondState) pParam->cbMode;
14552 pMsg->vht_channel_width = pParam->ch_params.ch_width;
14553 pMsg->center_freq_seg0 = pParam->ch_params.center_freq_seg0;
14554 pMsg->center_freq_seg1 = pParam->ch_params.center_freq_seg1;
14555 pMsg->sec_ch_offset = pParam->ch_params.sec_ch_offset;
14556 pMsg->privacy = pParam->privacy;
14557 pMsg->apUapsdEnable = pParam->ApUapsdEnable;
14558 pMsg->ssidHidden = pParam->ssidHidden;
14559 pMsg->fwdWPSPBCProbeReq = (uint8_t) pParam->fwdWPSPBCProbeReq;
14560 pMsg->protEnabled = (uint8_t) pParam->protEnabled;
14561 pMsg->obssProtEnabled = (uint8_t) pParam->obssProtEnabled;
14562 /* set cfg related to protection */
14563 pMsg->ht_capab = pParam->ht_protection;
14564 pMsg->authType = pParam->authType;
14565 pMsg->dtimPeriod = pParam->dtimPeriod;
14566 pMsg->wps_state = pParam->wps_state;
14567 pMsg->isCoalesingInIBSSAllowed = pMac->isCoalesingInIBSSAllowed;
14568 pMsg->bssPersona = pParam->bssPersona;
14569 pMsg->txLdpcIniFeatureEnabled = pMac->roam.configParam.txLdpcEnable;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -080014570 pMsg->txbf_ini_enabled =
14571 (uint8_t)pMac->roam.configParam.txBFEnable &&
14572 (uint8_t)pMac->roam.configParam.enable_txbf_sap_mode;
14573 pMsg->txbf_csn_val = (uint8_t)pMac->roam.configParam.txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014574#ifdef WLAN_FEATURE_11W
14575 pMsg->pmfCapable = pParam->mfpCapable;
14576 pMsg->pmfRequired = pParam->mfpRequired;
14577#endif
14578
14579 if (pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014580 qdf_mem_free(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014581 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014582 }
14583 pMsg->rsnIE.length = pParam->nRSNIELength;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014584 qdf_mem_copy(pMsg->rsnIE.rsnIEdata,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014585 pParam->pRSNIE,
14586 pParam->nRSNIELength);
14587 pMsg->nwType = (tSirNwType)pParam->sirNwType;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014588 qdf_mem_copy(&pMsg->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014589 &pParam->operationalRateSet,
14590 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014591 qdf_mem_copy(&pMsg->extendedRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014592 &pParam->extendedRateSet,
14593 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014594 qdf_mem_copy(&pMsg->htConfig,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014595 &pSession->htConfig,
14596 sizeof(tSirHTConfig));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014597 qdf_mem_copy(&pMsg->addIeParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014598 &pParam->addIeParams,
14599 sizeof(pParam->addIeParams));
14600 pMsg->obssEnabled = pMac->roam.configParam.obssEnabled;
14601 pMsg->sap_dot11mc = pParam->sap_dot11mc;
14602
14603 return cds_send_mb_message_to_mac(pMsg);
14604}
14605
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014606QDF_STATUS csr_send_mb_stop_bss_req_msg(tpAniSirGlobal pMac, uint32_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014607{
14608 tSirSmeStopBssReq *pMsg;
14609 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14610
14611 if (!pSession) {
14612 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014613 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014614 }
14615
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014616 pMsg = qdf_mem_malloc(sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014617 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014618 return QDF_STATUS_E_NOMEM;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014619 qdf_mem_set(pMsg, sizeof(tSirSmeStopBssReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014620 pMsg->messageType = eWNI_SME_STOP_BSS_REQ;
14621 pMsg->sessionId = sessionId;
14622 pMsg->length = sizeof(tSirSmeStopBssReq);
14623 pMsg->transactionId = 0;
14624 pMsg->reasonCode = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053014625 qdf_copy_macaddr(&pMsg->bssid, &pSession->connectedProfile.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014626 return cds_send_mb_message_to_mac(pMsg);
14627}
14628
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014629QDF_STATUS csr_reassoc(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014630 tCsrRoamModifyProfileFields *pModProfileFields,
14631 uint32_t *pRoamId, bool fForce)
14632{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014633 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014634 uint32_t roamId = 0;
14635 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
14636 if ((csr_is_conn_state_connected(pMac, sessionId)) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014637 (fForce || (qdf_mem_cmp(&pModProfileFields,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014638 &pSession->connectedProfile.
14639 modifyProfileFields,
14640 sizeof(tCsrRoamModifyProfileFields))))) {
14641 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14642 if (pRoamId) {
14643 *pRoamId = roamId;
14644 }
14645
14646 status =
14647 csr_roam_issue_reassoc(pMac, sessionId, NULL,
14648 pModProfileFields,
14649 eCsrSmeIssuedReassocToSameAP,
14650 roamId, false);
14651 }
14652 return status;
14653}
14654
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014655static QDF_STATUS csr_roam_session_opened(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014656 uint32_t sessionId)
14657{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014658 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014659 tCsrRoamInfo roamInfo;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014660 qdf_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014661 status = csr_roam_call_callback(pMac, sessionId, &roamInfo, 0,
14662 eCSR_ROAM_SESSION_OPENED,
14663 eCSR_ROAM_RESULT_NONE);
14664 return status;
14665}
14666
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014667QDF_STATUS csr_process_add_sta_session_rsp(tpAniSirGlobal pMac, uint8_t *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014668{
14669 tListElem *pEntry = NULL;
14670 tSmeCmd *pCommand = NULL;
14671 struct add_sta_self_params *rsp;
14672 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014673 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014674
14675 if (pMsg == NULL) {
14676 sms_log(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014677 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014678 }
14679 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
14680 if (!pEntry) {
14681 sms_log(pMac, LOGE, "in %s NO commands are ACTIVE ...",
14682 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014683 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014684 }
14685 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
14686 if (eSmeCommandAddStaSession != pCommand->command) {
14687 sms_log(pMac, LOGE, "in %s Cmd not in active list ...",
14688 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014689 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014690 }
14691 rsp = (struct add_sta_self_params *) pMsg;
14692 sms_log(pMac, LOG1, "Add Sta self rsp status = %d", rsp->status);
14693
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014694 if (QDF_STATUS_SUCCESS == rsp->status &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014695 (WMI_VDEV_TYPE_STA == rsp->type ||
14696 (WMI_VDEV_TYPE_AP == rsp->type &&
14697 WMI_UNIFIED_VDEV_SUBTYPE_P2P_DEVICE == rsp->sub_type))) {
14698 sms_log(pMac, LOG1, FL("send SET IE msg to PE"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014699 msg = qdf_mem_malloc(sizeof(*msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014700 if (NULL == msg) {
14701 sms_log(pMac, LOGE, FL("Memory allocation failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014702 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014703 }
14704
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014705 qdf_mem_set(msg, sizeof(*msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014706 msg->msg_type = eWNI_SME_SET_IE_REQ;
14707 msg->session_id = rsp->session_id;
14708 msg->length = sizeof(*msg);
14709 status = cds_send_mb_message_to_mac(msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014710 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014711 sms_log(pMac, LOGE,
14712 FL("Failed to send down the set IE req "));
14713 }
14714
14715 csr_roam_session_opened(pMac, pCommand->sessionId);
14716 /* Remove this command out of the active list */
14717 if (csr_ll_remove_entry(&pMac->sme.smeCmdActiveList, pEntry,
14718 LL_ACCESS_LOCK)) {
14719 /* Now put this command back on the avilable command list */
14720 csr_release_command(pMac, pCommand);
14721 }
14722 sme_process_pending_queue(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014723 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014724}
14725
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014726QDF_STATUS csr_issue_add_sta_for_session_req(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014727 tSirMacAddr sessionMacAddr,
14728 uint32_t type, uint32_t subType)
14729{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014730 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014731 tSmeCmd *pCommand;
14732 pCommand = csr_get_command_buffer(pMac);
14733 if (NULL == pCommand) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014734 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014735 } else {
14736 pCommand->command = eSmeCommandAddStaSession;
14737 pCommand->sessionId = (uint8_t) sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014738 qdf_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014739 sessionMacAddr, sizeof(tSirMacAddr));
14740 pCommand->u.addStaSessionCmd.currDeviceMode =
14741 pMac->sme.currDeviceMode;
14742 pCommand->u.addStaSessionCmd.type = type;
14743 pCommand->u.addStaSessionCmd.subType = subType;
14744 status = csr_queue_sme_command(pMac, pCommand, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014745 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014746 /* Should be panic?? */
14747 sms_log(pMac, LOGE,
14748 FL(" fail to send message status = %d"), status);
14749 }
14750 }
14751 return status;
14752}
14753
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014754QDF_STATUS csr_process_add_sta_session_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014755 tSmeCmd *pCommand)
14756{
14757 tAddStaForSessionCmd *pAddStaReq =
14758 &pCommand->u.addStaSessionCmd;
14759 uint8_t sessionId = pCommand->sessionId;
14760 struct add_sta_self_params *add_sta_self_req;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014761 QDF_STATUS status = QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014762 tSirMsgQ msg;
14763
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014764 add_sta_self_req = qdf_mem_malloc(sizeof(struct add_sta_self_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014765 if (NULL == add_sta_self_req) {
14766 lim_log(pMac, LOGP,
14767 FL
14768 ("Unable to allocate memory for tAddSelfStaParams"));
14769 return status;
14770 }
14771
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014772 qdf_mem_copy(add_sta_self_req->self_mac_addr, pAddStaReq->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014773 sizeof(tSirMacAddr));
14774 add_sta_self_req->curr_device_mode = pAddStaReq->currDeviceMode;
14775 add_sta_self_req->session_id = sessionId;
14776 add_sta_self_req->type = pAddStaReq->type;
14777 add_sta_self_req->sub_type = pAddStaReq->subType;
14778
14779 msg.type = WMA_ADD_STA_SELF_REQ;
14780 msg.reserved = 0;
14781 msg.bodyptr = add_sta_self_req;
14782 msg.bodyval = 0;
14783
14784 lim_log(pMac, LOG1,
14785 FL
14786 ("Send WMA_ADD_STA_SELF_REQ for selfMac=" MAC_ADDRESS_STR),
14787 MAC_ADDR_ARRAY(add_sta_self_req->self_mac_addr));
14788 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
14789 status = wma_post_ctrl_msg(pMac, &msg);
14790
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014791 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014792 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014793 qdf_mem_free(add_sta_self_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014794 add_sta_self_req = NULL;
14795 }
14796 return status;
14797}
14798
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014799QDF_STATUS csr_roam_open_session(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014800 csr_roam_completeCallback callback,
14801 void *pContext,
14802 uint8_t *pSelfMacAddr, uint8_t *pbSessionId,
14803 uint32_t type, uint32_t subType)
14804{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014805 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014806 uint32_t i, value = 0;
14807 union {
14808 uint16_t nCfgValue16;
14809 tSirMacHTCapabilityInfo htCapInfo;
14810 } uHTCapabilityInfo;
14811 tCsrRoamSession *pSession;
14812 *pbSessionId = CSR_SESSION_ID_INVALID;
14813
14814 for (i = 0; i < pMac->sme.max_intf_count; i++) {
Peng Xu66162de2016-02-11 17:01:20 -080014815 sms_log(pMac, LOG1, FL("session:%d active:%d"), i,
14816 pMac->roam.roamSession[i].sessionActive);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014817 if (!CSR_IS_SESSION_VALID(pMac, i)) {
14818 pSession = CSR_GET_SESSION(pMac, i);
14819 if (!pSession) {
14820 sms_log(pMac, LOGE,
14821 FL
14822 ("Session does not exist for interface %d"),
14823 i);
14824 break;
14825 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014826 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014827 pSession->sessionActive = true;
14828 pSession->sessionId = (uint8_t) i;
14829
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014830 /* Initialize FT related data structures only in STA mode */
14831 sme_ft_open(pMac, pSession->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014832
14833 pSession->callback = callback;
14834 pSession->pContext = pContext;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014835 qdf_mem_copy(&pSession->selfMacAddr, pSelfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014836 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014837 *pbSessionId = (uint8_t) i;
14838 status =
Anurag Chouhan210db072016-02-22 18:42:15 +053014839 qdf_mc_timer_init(&pSession->hTimerRoaming,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014840 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014841 csr_roam_roaming_timer_handler,
14842 &pSession->roamingTimerInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014843 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014844 sms_log(pMac, LOGE,
14845 FL
14846 ("cannot allocate memory for Roaming timer"));
14847 break;
14848 }
14849 /* get the HT capability info */
14850 if (wlan_cfg_get_int(pMac, WNI_CFG_HT_CAP_INFO, &value)
14851 != eSIR_SUCCESS) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053014852 QDF_TRACE(QDF_MODULE_ID_QDF,
14853 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014854 "%s: could not get HT capability info",
14855 __func__);
14856 break;
14857 }
14858#ifdef FEATURE_WLAN_BTAMP_UT_RF
Anurag Chouhan210db072016-02-22 18:42:15 +053014859 status = qdf_mc_timer_init(&pSession->hTimerJoinRetry,
Anurag Chouhan6d760662016-02-20 16:05:43 +053014860 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014861 csr_roam_join_retry_timer_handler,
14862 &pSession->
14863 joinRetryTimerInfo);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014864 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014865 sms_log(pMac, LOGE,
14866 FL
14867 ("cannot allocate memory for join retry timer"));
14868 break;
14869 }
14870#endif
14871 uHTCapabilityInfo.nCfgValue16 = 0xFFFF & value;
14872 pSession->htConfig.ht_rx_ldpc =
14873 uHTCapabilityInfo.htCapInfo.advCodingCap;
14874 pSession->htConfig.ht_tx_stbc =
14875 uHTCapabilityInfo.htCapInfo.txSTBC;
14876 pSession->htConfig.ht_rx_stbc =
14877 uHTCapabilityInfo.htCapInfo.rxSTBC;
14878 pSession->htConfig.ht_sgi = true;
14879 status =
14880 csr_issue_add_sta_for_session_req(pMac, i, pSelfMacAddr,
14881 type, subType);
14882 break;
14883 }
14884 }
14885 if (pMac->sme.max_intf_count == i) {
14886 /* No session is available */
14887 sms_log(pMac, LOGE,
14888 "%s: Reached max interfaces: %d! Session creation will fail",
14889 __func__, pMac->sme.max_intf_count);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014890 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014891 }
14892 return status;
14893}
14894
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014895QDF_STATUS csr_process_del_sta_session_rsp(tpAniSirGlobal pMac, uint8_t *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014896{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014897 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014898 tListElem *pEntry = NULL;
14899 tSmeCmd *pCommand = NULL;
14900 struct del_sta_self_params *rsp;
14901 uint8_t sessionId;
14902
14903 if (pMsg == NULL) {
14904 sms_log(pMac, LOGE, FL("msg ptr is NULL"));
14905 return status;
14906 }
14907 pEntry = csr_ll_peek_head(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
14908 if (!pEntry) {
14909 sms_log(pMac, LOGE, FL("NO commands are ACTIVE ..."));
14910 return status;
14911 }
14912 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
14913 sessionId = pCommand->sessionId;
14914 if (eSmeCommandDelStaSession != pCommand->command) {
14915 sms_log(pMac, LOGE, FL("NO Del sta session command ACTIVE"));
14916 return status;
14917 }
14918 rsp = (struct del_sta_self_params *) pMsg;
14919 sms_log(pMac, LOG1, FL("Del Sta rsp status = %d"), rsp->status);
14920 /* This session is done. */
14921 csr_cleanup_session(pMac, sessionId);
14922 if (pCommand->u.delStaSessionCmd.callback) {
14923 status = sme_release_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014924 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014925 sms_log(pMac, LOG1, FL("Failed to Release Lock"));
14926 else {
14927 pCommand->u.delStaSessionCmd.
14928 callback(pCommand->u.delStaSessionCmd.pContext);
14929 status = sme_acquire_global_lock(&pMac->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014930 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014931 sms_log(pMac, LOG1, FL("Failed to get Lock"));
14932 return status;
14933 }
14934 }
14935 }
14936 /* Remove this command out of the active list */
14937 if (csr_ll_remove_entry(&pMac->sme.smeCmdActiveList, pEntry,
14938 LL_ACCESS_LOCK)) {
14939 /* Now put this command back on the avilable command list */
14940 csr_release_command(pMac, pCommand);
14941 }
14942 sme_process_pending_queue(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014943 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014944 return status;
14945}
14946
14947
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014948QDF_STATUS csr_issue_del_sta_for_session_req(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014949 tSirMacAddr sessionMacAddr,
14950 csr_roamSessionCloseCallback callback,
14951 void *pContext)
14952{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014953 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014954 tSmeCmd *pCommand;
14955 pCommand = csr_get_command_buffer(pMac);
14956 if (NULL == pCommand) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014957 status = QDF_STATUS_E_RESOURCES;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014958 } else {
14959 pCommand->command = eSmeCommandDelStaSession;
14960 pCommand->sessionId = (uint8_t) sessionId;
14961 pCommand->u.delStaSessionCmd.callback = callback;
14962 pCommand->u.delStaSessionCmd.pContext = pContext;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014963 qdf_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014964 sessionMacAddr, sizeof(tSirMacAddr));
14965 status = csr_queue_sme_command(pMac, pCommand, true);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014966 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014967 /* Should be panic?? */
14968 sms_log(pMac, LOGE,
14969 FL(" fail to send message status = %d"), status);
14970 }
14971 }
14972 return status;
14973}
14974
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014975QDF_STATUS csr_process_del_sta_session_command(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014976 tSmeCmd *pCommand)
14977{
14978 struct del_sta_self_params *del_sta_self_req;
14979 tSirMsgQ msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014980 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014981 del_sta_self_req = qdf_mem_malloc(sizeof(struct del_sta_self_params));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014982 if (NULL == del_sta_self_req) {
14983 lim_log(pMac, LOGP,
14984 FL(" mem alloc failed for tDelStaSelfParams"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053014985 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014986 }
14987
Anurag Chouhan600c3a02016-03-01 10:33:54 +053014988 qdf_mem_copy(del_sta_self_req->self_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080014989 pCommand->u.delStaSessionCmd.selfMacAddr,
14990 sizeof(tSirMacAddr));
14991
14992 del_sta_self_req->session_id = pCommand->sessionId;
14993 msg.type = WMA_DEL_STA_SELF_REQ;
14994 msg.reserved = 0;
14995 msg.bodyptr = del_sta_self_req;
14996 msg.bodyval = 0;
14997
14998 sms_log(pMac, LOG1,
14999 FL("sending WMA_DEL_STA_SELF_REQ"));
15000 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
15001 status = wma_post_ctrl_msg(pMac, &msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015002 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015003 sms_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015004 qdf_mem_free(del_sta_self_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015005 }
15006 return status;
15007}
15008
15009static void purge_csr_session_cmd_list(tpAniSirGlobal pMac, uint32_t sessionId)
15010{
15011 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
15012 tListElem *pEntry, *pNext;
15013 tSmeCmd *pCommand;
15014 tDblLinkList localList;
15015
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015016 qdf_mem_zero(&localList, sizeof(tDblLinkList));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015017 if (!QDF_IS_STATUS_SUCCESS(csr_ll_open(pMac->hHdd, &localList))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015018 sms_log(pMac, LOGE, FL(" failed to open list"));
15019 return;
15020 }
15021 csr_ll_lock(pList);
15022 pEntry = csr_ll_peek_head(pList, LL_ACCESS_NOLOCK);
15023 while (pEntry != NULL) {
15024 pNext = csr_ll_next(pList, pEntry, LL_ACCESS_NOLOCK);
15025 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
15026 if (pCommand->sessionId == sessionId) {
15027 if (csr_ll_remove_entry(pList, pEntry, LL_ACCESS_NOLOCK)) {
15028 csr_ll_insert_tail(&localList, pEntry,
15029 LL_ACCESS_NOLOCK);
15030 }
15031 }
15032 pEntry = pNext;
15033 }
15034 csr_ll_unlock(pList);
15035
15036 while ((pEntry = csr_ll_remove_head(&localList, LL_ACCESS_NOLOCK))) {
15037 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
15038 csr_abort_command(pMac, pCommand, true);
15039 }
15040 csr_ll_close(&localList);
15041}
15042
15043void csr_cleanup_session(tpAniSirGlobal pMac, uint32_t sessionId)
15044{
15045 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
15046 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15047
15048 csr_roam_stop(pMac, sessionId);
15049
15050 /* Clean up FT related data structures */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015051 sme_ft_close(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015052 csr_free_connect_bss_desc(pMac, sessionId);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -080015053 csr_roam_free_connect_profile(&pSession->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015054 csr_roam_free_connected_info(pMac, &pSession->connectedInfo);
Anurag Chouhan210db072016-02-22 18:42:15 +053015055 qdf_mc_timer_destroy(&pSession->hTimerRoaming);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015056#ifdef FEATURE_WLAN_BTAMP_UT_RF
Anurag Chouhan210db072016-02-22 18:42:15 +053015057 qdf_mc_timer_destroy(&pSession->hTimerJoinRetry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015058#endif
15059 purge_sme_session_cmd_list(pMac, sessionId,
15060 &pMac->sme.smeCmdPendingList);
15061 purge_sme_session_cmd_list(pMac, sessionId,
15062 &pMac->sme.
15063 smeScanCmdPendingList);
15064
15065 purge_csr_session_cmd_list(pMac, sessionId);
15066 csr_init_session(pMac, sessionId);
15067 }
15068}
15069
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015070QDF_STATUS csr_roam_close_session(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015071 bool fSync,
15072 csr_roamSessionCloseCallback callback,
15073 void *pContext)
15074{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015075 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015076 if (CSR_IS_SESSION_VALID(pMac, sessionId)) {
15077 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15078 if (fSync) {
15079 csr_cleanup_session(pMac, sessionId);
15080 } else {
15081 purge_sme_session_cmd_list(pMac, sessionId,
15082 &pMac->sme.smeCmdPendingList);
15083 purge_sme_session_cmd_list(pMac, sessionId,
15084 &pMac->sme.smeScanCmdPendingList);
15085
15086 purge_csr_session_cmd_list(pMac, sessionId);
15087 status = csr_issue_del_sta_for_session_req(pMac,
15088 sessionId,
15089 pSession->selfMacAddr.bytes,
15090 callback, pContext);
15091 }
15092 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015093 status = QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015094 }
15095 return status;
15096}
15097
15098static void csr_init_session(tpAniSirGlobal pMac, uint32_t sessionId)
15099{
15100 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15101
15102 if (!pSession) {
15103 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
15104 return;
15105 }
15106
15107 pSession->sessionActive = false;
15108 pSession->sessionId = CSR_SESSION_ID_INVALID;
15109 pSession->callback = NULL;
15110 pSession->pContext = NULL;
15111 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
15112 csr_free_roam_profile(pMac, sessionId);
Naveen Rawatdf0a7e72016-01-06 18:35:53 -080015113 csr_roam_free_connect_profile(&pSession->connectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015114 csr_roam_free_connected_info(pMac, &pSession->connectedInfo);
15115 csr_free_connect_bss_desc(pMac, sessionId);
15116 csr_scan_enable(pMac);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015117 qdf_mem_set(&pSession->selfMacAddr, sizeof(struct qdf_mac_addr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015118 if (pSession->pWpaRsnReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015119 qdf_mem_free(pSession->pWpaRsnReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015120 pSession->pWpaRsnReqIE = NULL;
15121 }
15122 pSession->nWpaRsnReqIeLength = 0;
15123 if (pSession->pWpaRsnRspIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015124 qdf_mem_free(pSession->pWpaRsnRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015125 pSession->pWpaRsnRspIE = NULL;
15126 }
15127 pSession->nWpaRsnRspIeLength = 0;
15128#ifdef FEATURE_WLAN_WAPI
15129 if (pSession->pWapiReqIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015130 qdf_mem_free(pSession->pWapiReqIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015131 pSession->pWapiReqIE = NULL;
15132 }
15133 pSession->nWapiReqIeLength = 0;
15134 if (pSession->pWapiRspIE) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015135 qdf_mem_free(pSession->pWapiRspIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015136 pSession->pWapiRspIE = NULL;
15137 }
15138 pSession->nWapiRspIeLength = 0;
15139#endif /* FEATURE_WLAN_WAPI */
15140 if (pSession->pAddIEScan) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015141 qdf_mem_free(pSession->pAddIEScan);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015142 pSession->pAddIEScan = NULL;
15143 }
15144 pSession->nAddIEScanLength = 0;
15145 if (pSession->pAddIEAssoc) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015146 qdf_mem_free(pSession->pAddIEAssoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015147 pSession->pAddIEAssoc = NULL;
15148 }
15149 pSession->nAddIEAssocLength = 0;
15150}
15151
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015152QDF_STATUS csr_roam_get_session_id_from_bssid(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015153 struct qdf_mac_addr *bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015154 uint32_t *pSessionId)
15155{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015156 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015157 uint32_t i;
15158 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
15159 if (CSR_IS_SESSION_VALID(pMac, i)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +053015160 if (qdf_is_macaddr_equal(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015161 &pMac->roam.roamSession[i].connectedProfile.
15162 bssid)) {
15163 /* Found it */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015164 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015165 *pSessionId = i;
15166 break;
15167 }
15168 }
15169 }
15170 return status;
15171}
15172
15173/* This function assumes that we only support one IBSS session. We cannot use BSSID to identify */
15174/* session because for IBSS, the bssid changes. */
15175static uint32_t csr_find_ibss_session(tpAniSirGlobal pMac)
15176{
15177 uint32_t i, nRet = CSR_SESSION_ID_INVALID;
15178 tCsrRoamSession *pSession;
15179 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
15180 if (CSR_IS_SESSION_VALID(pMac, i)) {
15181 pSession = CSR_GET_SESSION(pMac, i);
15182 if (pSession->pCurRoamProfile
15183 &&
15184 (csr_is_bss_type_ibss
15185 (pSession->connectedProfile.BSSType))) {
15186 /* Found it */
15187 nRet = i;
15188 break;
15189 }
15190 }
15191 }
15192 return nRet;
15193}
15194
Anurag Chouhan6d760662016-02-20 16:05:43 +053015195static void csr_roam_link_up(tpAniSirGlobal pMac, struct qdf_mac_addr bssid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015196{
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080015197 uint32_t sessionId = 0;
15198
15199 /*
15200 * Update the current BSS info in ho control block based on connected
15201 * profile info from pmac global structure
15202 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015203
15204 sms_log(pMac, LOGW,
15205 " csr_roam_link_up: WLAN link UP with AP= " MAC_ADDRESS_STR,
15206 MAC_ADDR_ARRAY(bssid.bytes));
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080015207 /* Check for user misconfig of RSSI trigger threshold */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015208 pMac->roam.configParam.vccRssiThreshold =
15209 (0 == pMac->roam.configParam.vccRssiThreshold) ?
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080015210 CSR_VCC_RSSI_THRESHOLD :
15211 pMac->roam.configParam.vccRssiThreshold;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015212 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080015213 /* Check for user misconfig of UL MAC Loss trigger threshold */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015214 pMac->roam.configParam.vccUlMacLossThreshold =
15215 (0 == pMac->roam.configParam.vccUlMacLossThreshold) ?
15216 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.
15217 vccUlMacLossThreshold;
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080015218 /* Indicate the neighbor roal algorithm about the connect indication */
15219 csr_roam_get_session_id_from_bssid(pMac, &bssid,
15220 &sessionId);
15221 csr_neighbor_roam_indicate_connect(pMac, sessionId,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015222 QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015223}
15224
15225static void csr_roam_link_down(tpAniSirGlobal pMac, uint32_t sessionId)
15226{
15227 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
15228
15229 if (!pSession) {
15230 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
15231 return;
15232 }
15233 /* Only to handle the case for Handover on infra link */
15234 if (eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType) {
15235 return;
15236 }
15237 /*
15238 * Incase of station mode, immediately stop data transmission whenever
15239 * link down is detected.
15240 */
15241 if (csr_roam_is_sta_mode(pMac, sessionId)
15242 && !CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -080015243 && !csr_roam_is11r_assoc(pMac, sessionId)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015244 sms_log(pMac, LOG1, FL("Inform Link lost for session %d"),
15245 sessionId);
15246 csr_roam_call_callback(pMac, sessionId, NULL, 0,
15247 eCSR_ROAM_LOSTLINK,
15248 eCSR_ROAM_RESULT_LOSTLINK);
15249 }
15250 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers */
15251 csr_roam_dereg_statistics_req(pMac);
15252 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015253 /* Indicate the neighbor roal algorithm about the disconnect indication */
15254 csr_neighbor_roam_indicate_disconnect(pMac, sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015255
15256 /* Remove this code once SLM_Sessionization is supported */
15257 /* BMPS_WORKAROUND_NOT_NEEDED */
15258 if (!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
15259 csr_is_infra_ap_started(pMac) &&
15260 pMac->roam.configParam.doBMPSWorkaround) {
15261 pMac->roam.configParam.doBMPSWorkaround = 0;
15262 }
15263
15264}
15265
15266void csr_roam_tl_stats_timer_handler(void *pv)
15267{
15268 tpAniSirGlobal pMac = PMAC_STRUCT(pv);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015269 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015270 pMac->roam.tlStatsReqInfo.timerRunning = false;
15271
15272 sms_log(pMac, LOG1,
15273 FL
15274 (" TL stat timer is no-op. It needs to support multiple stations"));
15275
15276 if (!pMac->roam.tlStatsReqInfo.timerRunning) {
15277 if (pMac->roam.tlStatsReqInfo.periodicity) {
15278 /* start timer */
15279 status =
Anurag Chouhan210db072016-02-22 18:42:15 +053015280 qdf_mc_timer_start(&pMac->roam.tlStatsReqInfo.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015281 hTlStatsTimer,
15282 pMac->roam.tlStatsReqInfo.
15283 periodicity);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015284 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015285 sms_log(pMac, LOGE,
15286 FL
15287 ("csr_roam_tl_stats_timer_handler:cannot start TlStatsTimer timer"));
15288 return;
15289 }
15290 pMac->roam.tlStatsReqInfo.timerRunning = true;
15291 }
15292 }
15293}
15294
15295void csr_roam_pe_stats_timer_handler(void *pv)
15296{
15297 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *) pv;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015298 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015299 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015300 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015301 pPeStatsReqListEntry->timerRunning = false;
15302 if (pPeStatsReqListEntry->timerStopFailed == true) {
15303 /* If we entered here, meaning the timer could not be successfully */
15304 /* stopped in csr_roam_remove_entry_from_pe_stats_req_list(). So do it here. */
15305
15306 /* Destroy the timer */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015307 qdf_status =
Anurag Chouhan210db072016-02-22 18:42:15 +053015308 qdf_mc_timer_destroy(&pPeStatsReqListEntry->hPeStatsTimer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015309 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015310 sms_log(pMac, LOGE,
15311 FL
15312 ("csr_roam_pe_stats_timer_handler:failed to destroy hPeStatsTimer timer"));
15313 }
15314 /* Free the entry */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015315 qdf_mem_free(pPeStatsReqListEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015316 pPeStatsReqListEntry = NULL;
15317 } else {
15318 if (!pPeStatsReqListEntry->rspPending) {
15319 status =
15320 csr_send_mb_stats_req_msg(pMac,
15321 pPeStatsReqListEntry->
15322 statsMask & ~(1 <<
15323 eCsrGlobalClassDStats),
15324 pPeStatsReqListEntry->staId,
15325 pPeStatsReqListEntry->
15326 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015327 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015328 sms_log(pMac, LOGE,
15329 FL
15330 ("csr_roam_pe_stats_timer_handler:failed to send down stats req to PE"));
15331 } else {
15332 pPeStatsReqListEntry->rspPending = true;
15333 }
15334 }
15335 /* send down a req */
15336 if (pPeStatsReqListEntry->periodicity &&
Anurag Chouhan210db072016-02-22 18:42:15 +053015337 (QDF_TIMER_STATE_STOPPED ==
15338 qdf_mc_timer_get_current_state(&pPeStatsReqListEntry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015339 hPeStatsTimer))) {
15340 if (pPeStatsReqListEntry->periodicity <
15341 pMac->roam.configParam.
15342 statsReqPeriodicityInPS) {
15343 pPeStatsReqListEntry->periodicity =
15344 pMac->roam.configParam.
15345 statsReqPeriodicityInPS;
15346 }
15347 /* start timer */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015348 qdf_status =
Anurag Chouhan210db072016-02-22 18:42:15 +053015349 qdf_mc_timer_start(&pPeStatsReqListEntry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015350 hPeStatsTimer,
15351 pPeStatsReqListEntry->
15352 periodicity);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015353 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015354 sms_log(pMac, LOGE,
15355 FL
15356 ("csr_roam_pe_stats_timer_handler:cannot start hPeStatsTimer timer"));
15357 return;
15358 }
15359 pPeStatsReqListEntry->timerRunning = true;
15360
15361 }
15362
15363 }
15364}
15365
15366void csr_roam_stats_client_timer_handler(void *pv)
15367{
15368 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *) pv;
Anurag Chouhan210db072016-02-22 18:42:15 +053015369 if (QDF_TIMER_STATE_STOPPED ==
15370 qdf_mc_timer_get_current_state(&pStaEntry->timer)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053015371 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015372 FL("roam stats client timer is stopped"));
15373 }
15374}
15375
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015376QDF_STATUS csr_send_mb_stats_req_msg(tpAniSirGlobal pMac, uint32_t statsMask,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015377 uint8_t staId, uint8_t sessionId)
15378{
15379 tAniGetPEStatsReq *pMsg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015380 QDF_STATUS status = QDF_STATUS_SUCCESS;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015381 pMsg = qdf_mem_malloc(sizeof(tAniGetPEStatsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015382 if (NULL == pMsg) {
15383 sms_log(pMac, LOGE, FL("Failed to allocate mem for stats req "));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015384 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015385 }
15386 /* need to initiate a stats request to PE */
15387 pMsg->msgType = eWNI_SME_GET_STATISTICS_REQ;
15388 pMsg->msgLen = (uint16_t) sizeof(tAniGetPEStatsReq);
15389 pMsg->staId = staId;
15390 pMsg->statsMask = statsMask;
15391 pMsg->sessionId = sessionId;
15392 status = cds_send_mb_message_to_mac(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015393 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015394 sms_log(pMac, LOG1, FL("Failed to send down the stats req "));
15395 }
15396 return status;
15397}
15398
15399/**
15400 * csr_update_stats() - updates correct stats struct in mac_ctx
15401 * @mac: mac global context
15402 * @stats_type: stats type
15403 * @sme_stats_rsp: stats rsp msg packet
15404 * @stats: input stats data buffer to fill in mac_ctx struct
15405 * @length: out param - stats length
15406 *
15407 * This function fills corresponding stats struct in mac_cts based on stats type
15408 * passed
15409 *
15410 * Return: void
15411 */
15412static void
15413csr_update_stats(tpAniSirGlobal mac, uint8_t stats_type,
15414 tAniGetPEStatsRsp *sme_stats_rsp,
15415 uint8_t **stats, uint32_t *length)
15416{
15417 switch (stats_type) {
15418 case eCsrSummaryStats:
15419 sms_log(mac, LOG2, FL("summary stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015420 qdf_mem_copy((uint8_t *) &mac->roam.summaryStatsInfo, *stats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015421 sizeof(tCsrSummaryStatsInfo));
15422 *stats += sizeof(tCsrSummaryStatsInfo);
15423 *length -= sizeof(tCsrSummaryStatsInfo);
15424 break;
15425 case eCsrGlobalClassAStats:
15426 sms_log(mac, LOG2, FL("ClassA stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015427 qdf_mem_copy((uint8_t *) &mac->roam.classAStatsInfo, *stats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015428 sizeof(tCsrGlobalClassAStatsInfo));
15429 *stats += sizeof(tCsrGlobalClassAStatsInfo);
15430 *length -= sizeof(tCsrGlobalClassAStatsInfo);
15431 break;
15432 case eCsrGlobalClassBStats:
15433 sms_log(mac, LOG2, FL("ClassB stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015434 qdf_mem_copy((uint8_t *) &mac->roam.classBStatsInfo, *stats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015435 sizeof(tCsrGlobalClassBStatsInfo));
15436 *stats += sizeof(tCsrGlobalClassBStatsInfo);
15437 *length -= sizeof(tCsrGlobalClassBStatsInfo);
15438 break;
15439 case eCsrGlobalClassCStats:
15440 sms_log(mac, LOG2, FL("ClassC stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015441 qdf_mem_copy((uint8_t *) &mac->roam.classCStatsInfo, *stats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015442 sizeof(tCsrGlobalClassCStatsInfo));
15443 *stats += sizeof(tCsrGlobalClassCStatsInfo);
15444 *length -= sizeof(tCsrGlobalClassCStatsInfo);
15445 break;
15446 case eCsrPerStaStats:
15447 sms_log(mac, LOG2, FL("PerSta stats"));
15448 if (CSR_MAX_STA > sme_stats_rsp->staId) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015449 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015450 &mac->roam.perStaStatsInfo[sme_stats_rsp->staId],
15451 *stats, sizeof(tCsrPerStaStatsInfo));
15452 } else {
15453 sms_log(mac, LOGE, FL("out bound staId:%d. failed to copy PerSta stats"),
15454 sme_stats_rsp->staId);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053015455 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015456 }
15457 *stats += sizeof(tCsrPerStaStatsInfo);
15458 *length -= sizeof(tCsrPerStaStatsInfo);
15459 break;
15460 default:
15461 sms_log(mac, LOGW, FL("unknown stats type"));
15462 break;
15463 }
15464}
15465
15466/**
15467 * csr_roam_stats_rsp_processor() - processes stats rsp msg
15468 * @pMac mac global context
15469 * @pSirMsg: incoming message
15470 *
15471 * Return: void
15472 */
15473void csr_roam_stats_rsp_processor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
15474{
15475 tAniGetPEStatsRsp *pSmeStatsRsp;
15476 tListElem *pEntry = NULL;
15477 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15478 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15479 uint32_t tempMask = 0;
15480 uint8_t counter = 0;
15481 uint8_t *pStats = NULL;
15482 uint32_t length = 0;
15483 void *p_cds_gctx;
15484 int8_t rssi = 0, snr = 0;
15485 uint32_t *pRssi = NULL, *pSnr = NULL;
15486 uint32_t linkCapacity;
15487 pSmeStatsRsp = (tAniGetPEStatsRsp *) pSirMsg;
15488
15489 if (pSmeStatsRsp->rc) {
15490 sms_log(pMac, LOGW, FL("stats rsp from PE shows failure"));
15491 goto post_update;
15492 }
15493 tempMask = pSmeStatsRsp->statsMask;
15494 pStats = ((uint8_t *) &pSmeStatsRsp->statsMask) +
15495 sizeof(pSmeStatsRsp->statsMask);
15496 /*
15497 * subtract all statistics from this length, and after processing the
15498 * entire 'stat' part of the message, if the length is not zero, then
15499 * rssi is piggy packed in this 'stats' message.
15500 */
15501 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
15502 /* new stats info from PE, fill up the stats strucutres in PMAC */
15503 while (tempMask) {
15504 if (tempMask & 1) {
15505 csr_update_stats(pMac, counter, pSmeStatsRsp,
15506 &pStats, &length);
15507 }
15508 tempMask >>= 1;
15509 counter++;
15510 }
15511 p_cds_gctx = cds_get_global_context();
15512 if (length != 0) {
15513 pRssi = (uint32_t *) pStats;
15514 rssi = (int8_t) *pRssi;
15515 pStats += sizeof(uint32_t);
15516 length -= sizeof(uint32_t);
15517 } else {
15518 /* If riva is not sending rssi, continue to use the hack */
15519 rssi = RSSI_HACK_BMPS;
15520 }
15521
15522 if (length != 0) {
15523 linkCapacity = *(uint32_t *) pStats;
15524 pStats += sizeof(uint32_t);
15525 length -= sizeof(uint32_t);
15526 } else {
15527 linkCapacity = 0;
15528 }
15529
15530 if (length != 0) {
15531 pSnr = (uint32_t *) pStats;
15532 snr = (int8_t) *pSnr;
15533 } else {
15534 snr = SNR_HACK_BMPS;
15535 }
15536
15537post_update:
15538 /* make sure to update the pe stats req list */
15539 pEntry = csr_roam_find_in_pe_stats_req_list(pMac, pSmeStatsRsp->statsMask);
15540 if (pEntry) {
15541 pPeStaEntry = GET_BASE_ADDR(pEntry, tCsrPeStatsReqInfo, link);
15542 pPeStaEntry->rspPending = false;
15543
15544 }
15545 /* check the one timer cases */
15546 pEntry = csr_roam_check_client_req_list(pMac, pSmeStatsRsp->statsMask);
15547 if (pEntry) {
15548 pTempStaEntry =
15549 GET_BASE_ADDR(pEntry, tCsrStatsClientReqInfo, link);
15550 if (pTempStaEntry->timerExpired) {
15551 /* send up the stats report */
15552 csr_roam_report_statistics(pMac, pTempStaEntry->statsMask,
15553 pTempStaEntry->callback,
15554 pTempStaEntry->staId,
15555 pTempStaEntry->pContext);
15556 /* also remove from the client list */
15557 csr_roam_remove_stat_list_entry(pMac, pEntry);
15558 pTempStaEntry = NULL;
15559 }
15560 }
15561}
15562
15563tListElem *csr_roam_find_in_pe_stats_req_list(tpAniSirGlobal pMac, uint32_t statsMask)
15564{
15565 tListElem *pEntry = NULL;
15566 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
15567 pEntry = csr_ll_peek_head(&pMac->roam.peStatsReqList, LL_ACCESS_LOCK);
15568 if (!pEntry) {
15569 /* list empty */
15570 sms_log(pMac, LOG2,
15571 "csr_roam_find_in_pe_stats_req_list: List empty, no request to PE");
15572 return NULL;
15573 }
15574 while (pEntry) {
15575 pTempStaEntry = GET_BASE_ADDR(pEntry, tCsrPeStatsReqInfo, link);
15576 if (pTempStaEntry->statsMask == statsMask) {
15577 sms_log(pMac, LOG3,
15578 "csr_roam_find_in_pe_stats_req_list: match found");
15579 break;
15580 }
15581 pEntry =
15582 csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
15583 LL_ACCESS_NOLOCK);
15584 }
15585 return pEntry;
15586}
15587
15588tListElem *csr_roam_checkn_update_client_req_list(tpAniSirGlobal pMac,
15589 tCsrStatsClientReqInfo *pStaEntry,
15590 bool update)
15591{
15592 tListElem *pEntry;
15593 tCsrStatsClientReqInfo *pTempStaEntry;
15594 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList, LL_ACCESS_LOCK);
15595 if (!pEntry) {
15596 /* list empty */
15597 sms_log(pMac, LOG2,
15598 "csr_roam_checkn_update_client_req_list: List empty, no request from "
15599 "upper layer client(s)");
15600 return NULL;
15601 }
15602 while (pEntry) {
15603 pTempStaEntry =
15604 GET_BASE_ADDR(pEntry, tCsrStatsClientReqInfo, link);
15605 if ((pTempStaEntry->requesterId == pStaEntry->requesterId)
15606 && (pTempStaEntry->statsMask == pStaEntry->statsMask)) {
15607 sms_log(pMac, LOG3,
15608 "csr_roam_checkn_update_client_req_list: match found");
15609 if (update) {
15610 pTempStaEntry->periodicity =
15611 pStaEntry->periodicity;
15612 pTempStaEntry->callback = pStaEntry->callback;
15613 pTempStaEntry->pContext = pStaEntry->pContext;
15614 }
15615 break;
15616 }
15617 pEntry =
15618 csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
15619 LL_ACCESS_NOLOCK);
15620 }
15621 return pEntry;
15622}
15623
15624tListElem *csr_roam_check_client_req_list(tpAniSirGlobal pMac, uint32_t statsMask)
15625{
15626 tListElem *pEntry;
15627 tCsrStatsClientReqInfo *pTempStaEntry;
15628 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList, LL_ACCESS_LOCK);
15629 if (!pEntry) {
15630 /* list empty */
15631 sms_log(pMac, LOG2,
15632 "csr_roam_check_client_req_list: List empty, no request from "
15633 "upper layer client(s)");
15634 return NULL;
15635 }
15636 while (pEntry) {
15637 pTempStaEntry =
15638 GET_BASE_ADDR(pEntry, tCsrStatsClientReqInfo, link);
15639 if ((pTempStaEntry->
15640 statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask) {
15641 sms_log(pMac, LOG3,
15642 "csr_roam_check_client_req_list: match found");
15643 break;
15644 }
15645 pEntry =
15646 csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
15647 LL_ACCESS_NOLOCK);
15648 }
15649 return pEntry;
15650}
15651
15652void csr_roam_vcc_trigger(tpAniSirGlobal pMac)
15653{
15654 eCsrRoamLinkQualityInd newVccLinkQuality;
15655 uint32_t ul_mac_loss = 0;
15656 uint32_t ul_mac_loss_trigger_threshold;
15657 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15658 /*-------------------------------------------------------------------------
15659 Link quality is currently binary based on OBIWAN recommended triggers
15660 Check for a change in link quality and notify client if necessary
15661 -------------------------------------------------------------------------*/
15662 ul_mac_loss_trigger_threshold =
15663 pMac->roam.configParam.vccUlMacLossThreshold;
15664 if (0 == ul_mac_loss_trigger_threshold) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053015665 QDF_ASSERT(ul_mac_loss_trigger_threshold != 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015666 return;
15667 }
15668 sms_log(pMac, LOGW, "csr_roam_vcc_trigger: UL_MAC_LOSS_THRESHOLD is %d",
15669 ul_mac_loss_trigger_threshold);
15670 if (ul_mac_loss_trigger_threshold < ul_mac_loss) {
15671 sms_log(pMac, LOGW, "csr_roam_vcc_trigger: link quality is POOR ");
15672 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15673 } else {
15674 sms_log(pMac, LOGW, "csr_roam_vcc_trigger: link quality is GOOD");
15675 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15676 }
15677 sms_log(pMac, LOGW,
15678 "csr_roam_vcc_trigger: link qual : *** UL_MAC_LOSS %d *** ",
15679 ul_mac_loss);
15680 if (newVccLinkQuality != pMac->roam.vccLinkQuality) {
15681 sms_log(pMac, LOGW,
15682 "csr_roam_vcc_trigger: link quality changed: trigger necessary");
15683 if (NULL != pMac->roam.linkQualityIndInfo.callback) {
15684 sms_log(pMac, LOGW,
15685 "csr_roam_vcc_trigger: link quality indication %d",
15686 newVccLinkQuality);
15687
15688 /* we now invoke the callback once to notify client of initial value */
15689 pMac->roam.linkQualityIndInfo.
15690 callback(newVccLinkQuality,
15691 pMac->roam.linkQualityIndInfo.context);
15692 /* event: EVENT_WLAN_VCC */
15693 }
15694 }
15695 pMac->roam.vccLinkQuality = newVccLinkQuality;
15696
15697}
15698
15699tCsrStatsClientReqInfo *csr_roam_insert_entry_into_list(tpAniSirGlobal pMac,
15700 tDblLinkList *pStaList,
15701 tCsrStatsClientReqInfo *
15702 pStaEntry)
15703{
15704 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
15705 /* if same entity requested for same set of stats with different periodicity & */
15706 /* callback update it */
15707 if (NULL == csr_roam_checkn_update_client_req_list(pMac, pStaEntry, true)) {
15708
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015709 pNewStaEntry = qdf_mem_malloc(sizeof(tCsrStatsClientReqInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015710 if (NULL == pNewStaEntry) {
15711 sms_log(pMac, LOGW,
15712 "csr_roam_insert_entry_into_list: couldn't allocate memory for the "
15713 "entry");
15714 return NULL;
15715 }
15716
15717 pNewStaEntry->callback = pStaEntry->callback;
15718 pNewStaEntry->pContext = pStaEntry->pContext;
15719 pNewStaEntry->periodicity = pStaEntry->periodicity;
15720 pNewStaEntry->requesterId = pStaEntry->requesterId;
15721 pNewStaEntry->statsMask = pStaEntry->statsMask;
15722 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15723 pNewStaEntry->pMac = pStaEntry->pMac;
15724 pNewStaEntry->staId = pStaEntry->staId;
15725 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15726
15727 csr_ll_insert_tail(pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK);
15728 }
15729 return pNewStaEntry;
15730}
15731
15732tCsrPeStatsReqInfo *csr_roam_insert_entry_into_pe_stats_req_list(tpAniSirGlobal pMac,
15733 tDblLinkList *
15734 pStaList,
15735 tCsrPeStatsReqInfo *
15736 pStaEntry)
15737{
15738 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015739 pNewStaEntry = qdf_mem_malloc(sizeof(tCsrPeStatsReqInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015740 if (NULL == pNewStaEntry) {
15741 sms_log(pMac, LOGW,
15742 "csr_roam_insert_entry_into_pe_stats_req_list: couldn't allocate memory for the "
15743 "entry");
15744 return NULL;
15745 }
15746
15747 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15748 pNewStaEntry->numClient = pStaEntry->numClient;
15749 pNewStaEntry->periodicity = pStaEntry->periodicity;
15750 pNewStaEntry->statsMask = pStaEntry->statsMask;
15751 pNewStaEntry->pMac = pStaEntry->pMac;
15752 pNewStaEntry->staId = pStaEntry->staId;
15753 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15754 pNewStaEntry->rspPending = pStaEntry->rspPending;
15755
15756 csr_ll_insert_tail(pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK);
15757 return pNewStaEntry;
15758}
15759
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015760QDF_STATUS csr_get_rssi(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015761 tCsrRssiCallback callback,
15762 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015763 struct qdf_mac_addr bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015764 int8_t lastRSSI, void *pContext, void *p_cds_context)
15765{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015766 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015767 cds_msg_t msg;
15768 uint32_t sessionId;
15769
15770 tAniGetRssiReq *pMsg;
15771 sms_log(pMac, LOG2, FL("called"));
15772
15773 status = csr_roam_get_session_id_from_bssid(pMac, &bssId, &sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015774 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015775 callback(lastRSSI, staId, pContext);
15776 sms_log(pMac, LOGE, FL("Failed to get SessionId"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015777 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015778 }
15779
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015780 pMsg = qdf_mem_malloc(sizeof(tAniGetRssiReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015781 if (NULL == pMsg) {
15782 sms_log(pMac, LOGE,
15783 " csr_get_rssi: failed to allocate mem for req ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015784 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015785 }
15786
15787 pMsg->msgType = eWNI_SME_GET_RSSI_REQ;
15788 pMsg->msgLen = (uint16_t) sizeof(tAniGetRssiReq);
15789 pMsg->sessionId = sessionId;
15790 pMsg->staId = staId;
15791 pMsg->rssiCallback = callback;
15792 pMsg->pDevContext = pContext;
15793 pMsg->p_cds_context = p_cds_context;
15794 /*
15795 * store RSSI at time of calling, so that if RSSI request cannot
15796 * be sent to firmware, this value can be used to return immediately
15797 */
15798 pMsg->lastRSSI = lastRSSI;
15799 msg.type = eWNI_SME_GET_RSSI_REQ;
15800 msg.bodyptr = pMsg;
15801 msg.reserved = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015802 if (QDF_STATUS_SUCCESS != cds_mq_post_message(CDS_MQ_ID_SME, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015803 sms_log(pMac, LOGE, " csr_get_rssi failed to post msg to self ");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015804 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015805 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015806 }
15807 sms_log(pMac, LOG2, FL("returned"));
15808 return status;
15809}
15810
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015811QDF_STATUS csr_get_snr(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015812 tCsrSnrCallback callback,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015813 uint8_t staId, struct qdf_mac_addr bssId, void *pContext)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015814{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015815 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015816 cds_msg_t msg;
15817 uint32_t sessionId;
15818
15819 tAniGetSnrReq *pMsg;
15820
15821 sms_log(pMac, LOG2, FL("called"));
15822
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015823 pMsg = (tAniGetSnrReq *) qdf_mem_malloc(sizeof(tAniGetSnrReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015824 if (NULL == pMsg) {
15825 sms_log(pMac, LOGE, "%s: failed to allocate mem for req",
15826 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015827 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015828 }
15829
15830 csr_roam_get_session_id_from_bssid(pMac, &bssId, &sessionId);
15831
15832 pMsg->msgType = eWNI_SME_GET_SNR_REQ;
15833 pMsg->msgLen = (uint16_t) sizeof(tAniGetSnrReq);
15834 pMsg->sessionId = sessionId;
15835 pMsg->staId = staId;
15836 pMsg->snrCallback = callback;
15837 pMsg->pDevContext = pContext;
15838 msg.type = eWNI_SME_GET_SNR_REQ;
15839 msg.bodyptr = pMsg;
15840 msg.reserved = 0;
15841
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015842 if (QDF_STATUS_SUCCESS != cds_mq_post_message(CDS_MQ_ID_SME, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015843 sms_log(pMac, LOGE, "%s failed to post msg to self", __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015844 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015845 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015846 }
15847
15848 sms_log(pMac, LOG2, FL("returned"));
15849 return status;
15850}
15851
15852#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015853QDF_STATUS csr_get_tsm_stats(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015854 tCsrTsmStatsCallback callback,
15855 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015856 struct qdf_mac_addr bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015857 void *pContext, void *p_cds_context, uint8_t tid)
15858{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015859 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015860 tAniGetTsmStatsReq *pMsg = NULL;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053015861 pMsg = qdf_mem_malloc(sizeof(tAniGetTsmStatsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015862 if (!pMsg) {
15863 sms_log(pMac, LOGE,
15864 "csr_get_tsm_stats: failed to allocate mem for req");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015865 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015866 }
15867 /* need to initiate a stats request to PE */
15868 pMsg->msgType = eWNI_SME_GET_TSM_STATS_REQ;
15869 pMsg->msgLen = (uint16_t) sizeof(tAniGetTsmStatsReq);
15870 pMsg->staId = staId;
15871 pMsg->tid = tid;
Anurag Chouhanc5548422016-02-24 18:33:27 +053015872 qdf_copy_macaddr(&pMsg->bssId, &bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015873 pMsg->tsmStatsCallback = callback;
15874 pMsg->pDevContext = pContext;
15875 pMsg->p_cds_context = p_cds_context;
15876 status = cds_send_mb_message_to_mac(pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015877 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015878 sms_log(pMac, LOG1,
15879 " csr_get_tsm_stats: failed to send down the rssi req");
15880 /* pMsg is freed by cds_send_mb_message_to_mac */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015881 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015882 }
15883 return status;
15884}
15885#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
15886
15887/**
15888 * csr_deregister_client_request() - deregisters a get stats request
15889 * @mac_ctx: mac global context
15890 * @sta_entry: stats request entry
15891 *
15892 * Return: status of operation
15893 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015894static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015895csr_deregister_client_request(tpAniSirGlobal mac_ctx,
15896 tCsrStatsClientReqInfo *sta_entry)
15897{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015898 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015899 tListElem *entry = NULL;
15900 tCsrStatsClientReqInfo *ptr_sta_entry = NULL;
15901
15902 entry = csr_roam_checkn_update_client_req_list(mac_ctx, sta_entry,
15903 false);
15904 if (!entry) {
15905 sms_log(mac_ctx, LOGW,
15906 FL("callback is empty in the request & couldn't find any existing request in statsClientReqList"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015907 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015908 }
15909 /* clean up & return */
15910 ptr_sta_entry = GET_BASE_ADDR(entry, tCsrStatsClientReqInfo, link);
15911 if (NULL != ptr_sta_entry->pPeStaEntry) {
15912 ptr_sta_entry->pPeStaEntry->numClient--;
15913 /* check if we need to delete the entry from peStatsReqList */
15914 if (!ptr_sta_entry->pPeStaEntry->numClient)
15915 csr_roam_remove_entry_from_pe_stats_req_list(mac_ctx,
15916 ptr_sta_entry->pPeStaEntry);
15917 }
15918 /* check if we need to stop the tl stats timer too */
15919 mac_ctx->roam.tlStatsReqInfo.numClient--;
15920 if (!mac_ctx->roam.tlStatsReqInfo.numClient) {
15921 if (mac_ctx->roam.tlStatsReqInfo.timerRunning) {
Anurag Chouhan210db072016-02-22 18:42:15 +053015922 status = qdf_mc_timer_stop(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015923 &mac_ctx->roam.tlStatsReqInfo.hTlStatsTimer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015924 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015925 sms_log(mac_ctx, LOGE,
15926 FL("cannot stop TlStatsTimer timer"));
15927 return status;
15928 }
15929 }
15930 mac_ctx->roam.tlStatsReqInfo.periodicity = 0;
15931 mac_ctx->roam.tlStatsReqInfo.timerRunning = false;
15932 }
Anurag Chouhan210db072016-02-22 18:42:15 +053015933 qdf_mc_timer_stop(&ptr_sta_entry->timer);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053015934 /* Destroy the qdf timer... */
Anurag Chouhan210db072016-02-22 18:42:15 +053015935 status = qdf_mc_timer_destroy(&ptr_sta_entry->timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015936 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015937 sms_log(mac_ctx, LOGE,
15938 FL("failed to destroy Client req timer"));
15939
15940 csr_roam_remove_stat_list_entry(mac_ctx, entry);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015941 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015942}
15943
15944/**
15945 * csr_insert_stats_request_to_list() - inserts request to existing list
15946 * @mac_ctx: mac global context
15947 * @sta_entry: stats request entry
15948 * @periodicity: periodicity of stats
15949 *
15950 * Return: status of operation
15951 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015952static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015953csr_insert_stats_request_to_list(tpAniSirGlobal mac_ctx,
15954 tCsrStatsClientReqInfo *sta_entry,
15955 uint32_t periodicity)
15956{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015957 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015958 tCsrStatsClientReqInfo *ptr_sta_entry = csr_roam_insert_entry_into_list(
15959 mac_ctx, &mac_ctx->roam.statsClientReqList,
15960 sta_entry);
15961 if (!ptr_sta_entry) {
15962 sms_log(mac_ctx, LOGW,
15963 FL("Failed to insert req in statsClientReqList"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015964 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015965 }
15966 /* Init & start timer if needed */
15967 ptr_sta_entry->periodicity = periodicity;
15968 if (ptr_sta_entry->periodicity) {
Anurag Chouhan210db072016-02-22 18:42:15 +053015969 status = qdf_mc_timer_init(&ptr_sta_entry->timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +053015970 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015971 csr_roam_stats_client_timer_handler,
15972 ptr_sta_entry);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015973 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015974 sms_log(mac_ctx, LOGE,
15975 FL("cannot init StatsClient timer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015976 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015977 }
Anurag Chouhan210db072016-02-22 18:42:15 +053015978 status = qdf_mc_timer_start(&ptr_sta_entry->timer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015979 ptr_sta_entry->periodicity);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015980 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015981 sms_log(mac_ctx, LOGE,
15982 FL("cannot start StatsClient timer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015983 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015984 }
15985 }
15986 return status;
15987}
15988
15989/**
15990 * csr_get_statistics_from_tl() - fetch stats from tl layer
15991 * @mac_ctx: mac global context
15992 * @cache: indicate if cached stats are required
15993 * @staId: station id
15994 * @periodicity: periodicity of stats
15995 *
15996 * Return: status of operation
15997 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053015998static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080015999csr_get_statistics_from_tl(tpAniSirGlobal mac_ctx,
16000 bool cache,
16001 uint8_t staId,
16002 uint32_t periodicity)
16003{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016004 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016005
16006 if (cache && mac_ctx->roam.tlStatsReqInfo.numClient) {
16007 sms_log(mac_ctx, LOGE, FL("Looking for cached stats from TL"));
16008 mac_ctx->roam.tlStatsReqInfo.numClient++;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016009 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016010 }
16011
16012 /* update periodicity */
16013 if (mac_ctx->roam.tlStatsReqInfo.periodicity)
16014 mac_ctx->roam.tlStatsReqInfo.periodicity =
Anurag Chouhan6d760662016-02-20 16:05:43 +053016015 QDF_MIN(periodicity,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016016 mac_ctx->roam.tlStatsReqInfo.periodicity);
16017 else
16018 mac_ctx->roam.tlStatsReqInfo.periodicity = periodicity;
16019
16020 if (mac_ctx->roam.tlStatsReqInfo.periodicity
16021 < CSR_MIN_TL_STAT_QUERY_PERIOD) {
16022 mac_ctx->roam.tlStatsReqInfo.periodicity =
16023 CSR_MIN_TL_STAT_QUERY_PERIOD;
16024 }
16025
16026 if (!mac_ctx->roam.tlStatsReqInfo.timerRunning) {
16027
16028 if (mac_ctx->roam.tlStatsReqInfo.periodicity) {
16029 /* start timer */
Anurag Chouhan210db072016-02-22 18:42:15 +053016030 status = qdf_mc_timer_start(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016031 &mac_ctx->roam.tlStatsReqInfo.hTlStatsTimer,
16032 mac_ctx->roam.tlStatsReqInfo.periodicity);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016033 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016034 sms_log(mac_ctx, LOGE,
16035 FL("cannot start TlStatsTimer timer"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016036 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016037 }
16038 mac_ctx->roam.tlStatsReqInfo.timerRunning = true;
16039 }
16040 }
16041 mac_ctx->roam.tlStatsReqInfo.numClient++;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016042 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016043}
16044
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016045QDF_STATUS csr_get_statistics(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016046 eCsrStatsRequesterType requesterId,
16047 uint32_t statsMask,
16048 tCsrStatsCallback callback,
16049 uint32_t periodicity,
16050 bool cache,
16051 uint8_t staId,
16052 void *pContext,
16053 uint8_t sessionId)
16054{
16055 tCsrStatsClientReqInfo staEntry;
16056 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
16057 bool found = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016058 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016059 bool insertInClientList = false;
16060 uint32_t temp_mask = 0;
16061
16062 if (csr_is_all_session_disconnected(pMac))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016063 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016064
16065 if (csr_neighbor_middle_of_roaming(pMac, sessionId)) {
16066 sms_log(pMac, LOG1, FL("in the middle of roaming states"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016067 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016068 }
16069
16070 if ((!statsMask) && (!callback)) {
16071 sms_log(pMac, LOGW,
16072 FL("statsMask & callback empty in the request"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016073 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016074 }
16075 /* for the search list method for deregister */
16076 staEntry.requesterId = requesterId;
16077 staEntry.statsMask = statsMask;
16078 /* requester wants to deregister or just an error */
16079 if ((statsMask) && (!callback))
16080 return csr_deregister_client_request(pMac, &staEntry);
16081
16082 if (cache && !periodicity) {
16083 /* return the cached stats */
16084 csr_roam_report_statistics(pMac, statsMask, callback, staId,
16085 pContext);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016086 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016087 }
16088 /* add the request in the client req list */
16089 staEntry.callback = callback;
16090 staEntry.pContext = pContext;
16091 staEntry.periodicity = periodicity;
16092 staEntry.pPeStaEntry = NULL;
16093 staEntry.staId = staId;
16094 staEntry.pMac = pMac;
16095 staEntry.timerExpired = false;
16096 staEntry.sessionId = sessionId;
16097
16098 /* if periodic report requested with non cached result from PE/TL */
16099 if (periodicity) {
16100 /* if looking for stats from PE */
16101 temp_mask = statsMask & ~(1 << eCsrGlobalClassDStats);
16102 if (temp_mask) {
16103 /* check if same req made already & waiting for rsp */
16104 pPeStaEntry = csr_roam_check_pe_stats_req_list(pMac,
16105 temp_mask, periodicity, &found,
16106 staId, sessionId);
16107 if (!pPeStaEntry)
16108 /* bail out, maxed out on num of req for PE */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016109 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016110 else
16111 staEntry.pPeStaEntry = pPeStaEntry;
16112 }
16113 /*
16114 * request stats from TL rightaway if requested by client,
16115 * update tlStatsReqInfo if needed
16116 */
16117 temp_mask = statsMask & (1 << eCsrGlobalClassDStats);
16118 if (temp_mask) {
16119 status = csr_get_statistics_from_tl(pMac, cache, staId,
16120 periodicity);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016121 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016122 return status;
16123 }
16124 insertInClientList = true;
16125 }
16126 /* if one time report requested with non cached result from PE/TL */
16127 else if (!cache && !periodicity) {
16128 temp_mask = statsMask & ~(1 << eCsrGlobalClassDStats);
16129 if (temp_mask) {
16130 /* send down a req */
16131 status = csr_send_mb_stats_req_msg(pMac,
16132 temp_mask, staId, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016133 if (!QDF_IS_STATUS_SUCCESS(status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016134 sms_log(pMac, LOGE,
16135 FL("failed to send down stats req"));
16136 /*
16137 * so that when the stats rsp comes back from PE we
16138 * respond to upper layer right away
16139 */
16140 staEntry.timerExpired = true;
16141 insertInClientList = true;
16142 }
16143 /* if looking for stats from TL only */
16144 if (!insertInClientList) {
16145 /* return the stats */
16146 csr_roam_report_statistics(pMac, statsMask, callback,
16147 staId, pContext);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016148 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016149 }
16150 }
16151 if (insertInClientList)
16152 return csr_insert_stats_request_to_list(pMac, &staEntry,
16153 periodicity);
16154
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016155 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016156}
16157
16158static tSirRetStatus
16159csr_roam_scan_offload_populate_mac_header(tpAniSirGlobal pMac,
16160 uint8_t *pBD,
16161 uint8_t type,
16162 uint8_t subType,
16163 tSirMacAddr peerAddr,
16164 tSirMacAddr selfMacAddr)
16165{
16166 tSirRetStatus statusCode = eSIR_SUCCESS;
16167 tpSirMacMgmtHdr pMacHdr;
16168
16169 /* Prepare MAC management header */
16170 pMacHdr = (tpSirMacMgmtHdr) (pBD);
16171
16172 /* Prepare FC */
16173 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
16174 pMacHdr->fc.type = type;
16175 pMacHdr->fc.subType = subType;
16176
16177 /* Prepare Address 1 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016178 qdf_mem_copy((uint8_t *) pMacHdr->da, (uint8_t *) peerAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016179 sizeof(tSirMacAddr));
16180
16181 sir_copy_mac_addr(pMacHdr->sa, selfMacAddr);
16182
16183 /* Prepare Address 3 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016184 qdf_mem_copy((uint8_t *) pMacHdr->bssId, (uint8_t *) peerAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016185 sizeof(tSirMacAddr));
16186 return statusCode;
16187} /*** csr_roam_scan_offload_populate_mac_header() ***/
16188
16189static tSirRetStatus
16190csr_roam_scan_offload_prepare_probe_req_template(tpAniSirGlobal pMac,
16191 uint8_t nChannelNum,
16192 uint32_t dot11mode,
16193 tSirMacAddr selfMacAddr,
16194 uint8_t *pFrame,
16195 uint16_t *pusLen,
16196 tCsrRoamSession *psession)
16197{
16198 tDot11fProbeRequest pr;
16199 uint32_t nStatus, nBytes, nPayload;
16200 tSirRetStatus nSirStatus;
16201 /*Bcast tx */
16202 tSirMacAddr bssId = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
16203 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16204
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016205 qdf_mem_set((uint8_t *) &pr, sizeof(pr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016206
16207 populate_dot11f_supp_rates(pMac, nChannelNum, &pr.SuppRates, NULL);
16208
16209 if (WNI_CFG_DOT11_MODE_11B != dot11mode) {
16210 populate_dot11f_ext_supp_rates1(pMac, nChannelNum,
16211 &pr.ExtSuppRates);
16212 }
16213
16214 if (IS_DOT11_MODE_HT(dot11mode)) {
16215 populate_dot11f_ht_caps(pMac, NULL, &pr.HTCaps);
16216 pr.HTCaps.advCodingCap = psession->htConfig.ht_rx_ldpc;
16217 pr.HTCaps.txSTBC = psession->htConfig.ht_tx_stbc;
16218 pr.HTCaps.rxSTBC = psession->htConfig.ht_rx_stbc;
16219 if (!psession->htConfig.ht_sgi) {
16220 pr.HTCaps.shortGI20MHz = pr.HTCaps.shortGI40MHz = 0;
16221 }
16222 }
16223
16224 nStatus = dot11f_get_packed_probe_request_size(pMac, &pr, &nPayload);
16225 if (DOT11F_FAILED(nStatus)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016226 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016227 "Failed to calculate the packed size f"
16228 "or a Probe Request (0x%08x).\n", nStatus);
16229
16230 nPayload = sizeof(tDot11fProbeRequest);
16231 } else if (DOT11F_WARNED(nStatus)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016232 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016233 "There were warnings while calculating"
16234 "the packed size for a Probe Request ("
16235 "0x%08x).\n", nStatus);
16236 }
16237
16238 nBytes = nPayload + sizeof(tSirMacMgmtHdr);
16239
16240 /* Prepare outgoing frame */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016241 qdf_mem_set(pFrame, nBytes, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016242
16243 nSirStatus =
16244 csr_roam_scan_offload_populate_mac_header(pMac, pFrame,
16245 SIR_MAC_MGMT_FRAME,
16246 SIR_MAC_MGMT_PROBE_REQ, bssId,
16247 selfMacAddr);
16248
16249 if (eSIR_SUCCESS != nSirStatus) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016250 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016251 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
16252 nSirStatus);
16253 return nSirStatus;
16254 }
16255
16256 nStatus = dot11f_pack_probe_request(pMac, &pr, pFrame +
16257 sizeof(tSirMacMgmtHdr),
16258 nPayload, &nPayload);
16259 if (DOT11F_FAILED(nStatus)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016260 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016261 "Failed to pack a Probe Request (0x%08x).\n",
16262 nStatus);
16263 return eSIR_FAILURE;
16264 } else if (DOT11F_WARNED(nStatus)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016265 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016266 "There were warnings while packing a Probe Request (0x%08x).\n",
16267 nStatus);
16268 }
16269
16270 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
16271 return eSIR_SUCCESS;
16272}
16273
16274#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016275QDF_STATUS csr_roam_set_key_mgmt_offload(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016276 uint32_t sessionId,
16277 bool nRoamKeyMgmtOffloadEnabled)
16278{
16279 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
16280 if (!pSession) {
16281 sms_log(pMac, LOGE, FL("session %d not found"), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016282 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016283 }
16284 pSession->RoamKeyMgmtOffloadEnabled = nRoamKeyMgmtOffloadEnabled;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016285 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016286}
16287
16288/**
16289 * csr_update_roam_scan_offload_request() - updates req msg with roam offload
16290 * paramters
16291 * @pMac: mac global context
16292 * @req_buf: out param, roam offload scan request packet
16293 * @session: roam session
16294 *
16295 * Return: void
16296 */
16297static void
16298csr_update_roam_scan_offload_request(tpAniSirGlobal mac_ctx,
16299 tSirRoamOffloadScanReq *req_buf,
16300 tCsrRoamSession *session)
16301{
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016302 qdf_mem_copy(req_buf->PSK_PMK, session->psk_pmk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016303 sizeof(req_buf->PSK_PMK));
16304 req_buf->pmk_len = session->pmk_len;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016305 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016306 "LFR3: PMK Length = %d", req_buf->pmk_len);
16307 req_buf->R0KH_ID_Length = session->ftSmeContext.r0kh_id_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016308 qdf_mem_copy(req_buf->R0KH_ID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016309 session->ftSmeContext.r0kh_id,
16310 req_buf->R0KH_ID_Length);
16311 req_buf->Prefer5GHz = mac_ctx->roam.configParam.nRoamPrefer5GHz;
16312 req_buf->RoamRssiCatGap = mac_ctx->roam.configParam.bCatRssiOffset;
16313 req_buf->Select5GHzMargin = mac_ctx->roam.configParam.nSelect5GHzMargin;
16314 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
16315 (uint32_t *) &req_buf->ReassocFailureTimeout)
16316 != eSIR_SUCCESS) {
16317 sms_log(mac_ctx, LOGE,
16318 FL("could not retrieve ReassocFailureTimeout value"));
16319 req_buf->ReassocFailureTimeout =
16320 DEFAULT_REASSOC_FAILURE_TIMEOUT;
16321 }
16322#ifdef FEATURE_WLAN_ESE
16323 if (csr_is_auth_type_ese(req_buf->ConnectedNetwork.authentication)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016324 qdf_mem_copy(req_buf->KRK, session->eseCckmInfo.krk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016325 SIR_KRK_KEY_LEN);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016326 qdf_mem_copy(req_buf->BTK, session->eseCckmInfo.btk,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016327 SIR_BTK_KEY_LEN);
16328 }
16329#endif
16330 req_buf->AcUapsd.acbe_uapsd =
16331 SIR_UAPSD_GET(ACBE, mac_ctx->lim.gUapsdPerAcBitmask);
16332 req_buf->AcUapsd.acbk_uapsd =
16333 SIR_UAPSD_GET(ACBK, mac_ctx->lim.gUapsdPerAcBitmask);
16334 req_buf->AcUapsd.acvi_uapsd =
16335 SIR_UAPSD_GET(ACVI, mac_ctx->lim.gUapsdPerAcBitmask);
16336 req_buf->AcUapsd.acvo_uapsd =
16337 SIR_UAPSD_GET(ACVO, mac_ctx->lim.gUapsdPerAcBitmask);
16338}
16339#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
16340
16341/**
16342 * csr_check_band_channel_match() - check if passed band and channel match
16343 * paramters
16344 * @band: band to match with channel
16345 * @channel: channel to match with band
16346 *
16347 * Return: bool if match else false
16348 */
16349static bool
16350csr_check_band_channel_match(eCsrBand band, uint8_t channel)
16351{
16352 if (eCSR_BAND_ALL == band)
16353 return true;
16354
16355 if (eCSR_BAND_24 == band && CDS_IS_CHANNEL_24GHZ(channel))
16356 return true;
16357
16358 if (eCSR_BAND_5G == band && CDS_IS_CHANNEL_5GHZ(channel))
16359 return true;
16360
16361 return false;
16362}
16363
16364/**
16365 * csr_fetch_ch_lst_from_ini() - fetch channel list from ini and update req msg
16366 * paramters
16367 * @mac_ctx: global mac ctx
16368 * @roam_info: roam info struct
16369 * @req_buf: out param, roam offload scan request packet
16370 *
16371 * Return: result of operation
16372 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016373static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016374csr_fetch_ch_lst_from_ini(tpAniSirGlobal mac_ctx,
16375 tpCsrNeighborRoamControlInfo roam_info,
16376 tSirRoamOffloadScanReq *req_buf)
16377{
16378 eCsrBand band;
16379 uint8_t i = 0;
16380 uint8_t num_channels = 0;
16381 uint8_t *ch_lst = roam_info->cfgParams.channelInfo.ChannelList;
16382 /*
16383 * The INI channels need to be filtered with respect to the current band
16384 * that is supported.
16385 */
16386 band = mac_ctx->roam.configParam.bandCapability;
16387 if ((eCSR_BAND_24 != band) && (eCSR_BAND_5G != band)
16388 && (eCSR_BAND_ALL != band)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016389 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016390 FL("Invalid band(%d), roam scan offload req aborted"),
16391 band);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016392 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016393 }
16394
16395 for (i = 0; i < roam_info->cfgParams.channelInfo.numOfChannels; i++) {
16396 if (!csr_check_band_channel_match(band, *ch_lst))
16397 continue;
16398 /* Allow DFS channels only if the DFS roaming is enabled */
16399 if (((mac_ctx->roam.configParam.allowDFSChannelRoam !=
16400 CSR_ROAMING_DFS_CHANNEL_DISABLED)
16401 || (!CDS_IS_DFS_CH(*ch_lst)))
16402 && csr_roam_is_channel_valid(mac_ctx, *ch_lst)
16403 && *ch_lst && (num_channels < SIR_ROAM_MAX_CHANNELS)) {
16404 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
16405 *ch_lst;
16406 }
16407 ch_lst++;
16408 }
16409 req_buf->ConnectedNetwork.ChannelCount = num_channels;
16410 req_buf->ChannelCacheType = CHANNEL_LIST_STATIC;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016411 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016412}
16413
16414/**
16415 * csr_fetch_ch_lst_from_occupied_lst() - fetch channel list from occupied list
16416 * and update req msg
16417 * paramters
16418 * @mac_ctx: global mac ctx
16419 * @session_id: session id
16420 * @reason: reason to roam
16421 * @req_buf: out param, roam offload scan request packet
16422 * @roam_info: roam info struct
16423 *
16424 * Return: void
16425 */
16426static void
16427csr_fetch_ch_lst_from_occupied_lst(tpAniSirGlobal mac_ctx,
16428 uint8_t session_id,
16429 uint8_t reason,
16430 tSirRoamOffloadScanReq *req_buf,
16431 tpCsrNeighborRoamControlInfo roam_info)
16432{
16433 uint8_t i = 0;
16434 uint8_t num_channels = 0;
16435 uint8_t *ch_lst =
16436 mac_ctx->scan.occupiedChannels[session_id].channelList;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016437 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016438 "Num of channels before filtering=%d",
16439 mac_ctx->scan.occupiedChannels[session_id].numChannels);
16440 for (i = 0; i < mac_ctx->scan.occupiedChannels[session_id].numChannels;
16441 i++) {
16442 if (((mac_ctx->roam.configParam.allowDFSChannelRoam !=
16443 CSR_ROAMING_DFS_CHANNEL_DISABLED)
16444 || (!CDS_IS_DFS_CH(*ch_lst)))
16445 && *ch_lst && (num_channels < SIR_ROAM_MAX_CHANNELS)) {
16446 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
16447 *ch_lst;
16448 }
16449 if (*ch_lst)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016450 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016451 "DFSRoam=%d, ChnlState=%d, Chnl=%d, num_ch=%d",
16452 mac_ctx->roam.configParam.allowDFSChannelRoam,
16453 cds_get_channel_state(*ch_lst), *ch_lst,
16454 num_channels);
16455 ch_lst++;
16456 }
16457 req_buf->ConnectedNetwork.ChannelCount = num_channels;
16458 /*
16459 * If the profile changes as to what it was earlier, inform the FW
16460 * through FLUSH as ChannelCacheType in which case, the FW will flush
16461 * the occupied channels for the earlier profile and try to learn them
16462 * afresh
16463 */
16464 if (reason == REASON_FLUSH_CHANNEL_LIST)
16465 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16466 else {
16467 if (csr_neighbor_roam_is_new_connected_profile(mac_ctx,
16468 session_id))
16469 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16470 else
16471 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16472 }
16473}
16474
16475#ifdef FEATURE_WLAN_ESE
16476/**
16477 * csr_fetch_ch_lst_from_received_list() - fetch channel list from received list
16478 * and update req msg
16479 * paramters
16480 * @mac_ctx: global mac ctx
16481 * @roam_info: roam info struct
16482 * @curr_ch_lst_info: current channel list info
16483 * @req_buf: out param, roam offload scan request packet
16484 *
16485 * Return: void
16486 */
16487static void
16488csr_fetch_ch_lst_from_received_list(tpAniSirGlobal mac_ctx,
16489 tpCsrNeighborRoamControlInfo roam_info,
16490 tpCsrChannelInfo curr_ch_lst_info,
16491 tSirRoamOffloadScanReq *req_buf)
16492{
16493 uint8_t i = 0;
16494 uint8_t num_channels = 0;
16495 uint8_t *ch_lst = NULL;
16496
16497 if (curr_ch_lst_info->numOfChannels == 0)
16498 return;
16499
16500 ch_lst = curr_ch_lst_info->ChannelList;
16501 for (i = 0; i < curr_ch_lst_info->numOfChannels; i++) {
16502 if (((mac_ctx->roam.configParam.allowDFSChannelRoam
16503 != CSR_ROAMING_DFS_CHANNEL_DISABLED) ||
16504 (!CDS_IS_DFS_CH(*ch_lst))) && *ch_lst) {
16505 req_buf->ConnectedNetwork.ChannelCache[num_channels++] =
16506 *ch_lst;
16507 }
16508 ch_lst++;
16509 }
16510 req_buf->ConnectedNetwork.ChannelCount = num_channels;
16511 req_buf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16512}
16513#endif
16514
16515/**
16516 * csr_fetch_valid_ch_lst() - fetch channel list from valid channel list and
16517 * update req msg
16518 * paramters
16519 * @mac_ctx: global mac ctx
16520 * @req_buf: out param, roam offload scan request packet
16521 *
16522 * Return: void
16523 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016524static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016525csr_fetch_valid_ch_lst(tpAniSirGlobal mac_ctx,
16526 tSirRoamOffloadScanReq *req_buf)
16527{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016528 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016529 uint32_t host_channels = 0;
16530 uint8_t *ch_lst = NULL;
16531 uint8_t i = 0, num_channels = 0;
16532
16533 host_channels = sizeof(mac_ctx->roam.validChannelList);
16534 status = csr_get_cfg_valid_channels(mac_ctx,
16535 mac_ctx->roam.validChannelList,
16536 &host_channels);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016537 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016538 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016539 FL("Failed to get the valid channel list"));
16540 return status;
16541 }
16542 ch_lst = mac_ctx->roam.validChannelList;
16543 mac_ctx->roam.numValidChannels = host_channels;
16544 for (i = 0; i < mac_ctx->roam.numValidChannels; i++) {
16545 if (((mac_ctx->roam.configParam.allowDFSChannelRoam
16546 != CSR_ROAMING_DFS_CHANNEL_DISABLED) ||
16547 (!CDS_IS_DFS_CH(*ch_lst))) && *ch_lst) {
16548 req_buf->ValidChannelList[num_channels++] = *ch_lst;
16549 }
16550 ch_lst++;
16551 }
16552 req_buf->ValidChannelCount = num_channels;
16553 return status;
16554}
16555
16556/**
16557 * csr_create_roam_scan_offload_request() - init roam offload scan request
16558 *
16559 * paramters
16560 * @mac_ctx: global mac ctx
16561 * @command: roam scan offload command input
16562 * @session_id: session id
16563 * @reason: reason to roam
16564 * @session: roam session
16565 * @roam_info: roam info struct
16566 *
16567 * Return: roam offload scan request packet buffer
16568 */
16569static tSirRoamOffloadScanReq *
16570csr_create_roam_scan_offload_request(tpAniSirGlobal mac_ctx,
16571 uint8_t command,
16572 uint8_t session_id,
16573 uint8_t reason,
16574 tCsrRoamSession *session,
16575 tpCsrNeighborRoamControlInfo roam_info)
16576{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016577 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016578 uint8_t i, j, dot11_mode;
16579 bool ese_neighbor_list_recvd = false;
16580 uint8_t ch_cache_str[128] = { 0 };
16581 tSirRoamOffloadScanReq *req_buf = NULL;
16582 tpCsrChannelInfo curr_ch_lst_info =
16583 &roam_info->roamChannelInfo.currentChannelListInfo;
16584#ifdef FEATURE_WLAN_ESE
16585 /*
16586 * this flag will be true if connection is ESE and no neighbor
16587 * list received or if the connection is not ESE
16588 */
16589 ese_neighbor_list_recvd = ((roam_info->isESEAssoc)
16590 && (roam_info->roamChannelInfo.IAPPNeighborListReceived
16591 == false))
16592 || (roam_info->isESEAssoc == false);
16593#endif /* FEATURE_WLAN_ESE */
16594
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016595 req_buf = qdf_mem_malloc(sizeof(tSirRoamOffloadScanReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016596 if (NULL == req_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016597 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016598 FL("Mem alloc for roam scan offload req failed."));
16599 return NULL;
16600 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016601 qdf_mem_zero(req_buf, sizeof(tSirRoamOffloadScanReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016602 req_buf->Command = command;
16603 /*
16604 * If command is STOP, then pass down ScanOffloadEnabled as Zero. This
16605 * will handle the case of host driver reloads, but Riva still up and
16606 * running
16607 */
16608 if (command == ROAM_SCAN_OFFLOAD_STOP) {
16609 /*
16610 * clear the roaming parameters that are per connection.
16611 * For a new connection, they have to be programmed again.
16612 */
16613 if (csr_neighbor_middle_of_roaming((tHalHandle)mac_ctx,
16614 session_id))
16615 req_buf->middle_of_roaming = 1;
16616 else
16617 csr_roam_reset_roam_params(mac_ctx);
16618 req_buf->RoamScanOffloadEnabled = 0;
16619 } else {
16620 req_buf->RoamScanOffloadEnabled =
16621 mac_ctx->roam.configParam.isRoamOffloadScanEnabled;
16622 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016623 qdf_mem_copy(req_buf->ConnectedNetwork.currAPbssid,
Anurag Chouhan6d760662016-02-20 16:05:43 +053016624 roam_info->currAPbssid.bytes, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016625 req_buf->ConnectedNetwork.ssId.length =
16626 mac_ctx->roam.roamSession[session_id].
16627 connectedProfile.SSID.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016628 qdf_mem_copy(req_buf->ConnectedNetwork.ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016629 mac_ctx->roam.roamSession[session_id].
16630 connectedProfile.SSID.ssId,
16631 req_buf->ConnectedNetwork.ssId.length);
16632 req_buf->ConnectedNetwork.authentication =
16633 mac_ctx->roam.roamSession[session_id].connectedProfile.AuthType;
16634 req_buf->ConnectedNetwork.encryption =
16635 mac_ctx->roam.roamSession[session_id].
16636 connectedProfile.EncryptionType;
16637 req_buf->ConnectedNetwork.mcencryption =
16638 mac_ctx->roam.roamSession[session_id].
16639 connectedProfile.mcEncryptionType;
16640#ifdef WLAN_FEATURE_11W
16641 req_buf->ConnectedNetwork.mfp_enabled =
16642 mac_ctx->roam.roamSession[session_id].connectedProfile.MFPEnabled;
16643#endif
16644 req_buf->delay_before_vdev_stop =
16645 roam_info->cfgParams.delay_before_vdev_stop;
16646 req_buf->OpportunisticScanThresholdDiff =
16647 roam_info->cfgParams.nOpportunisticThresholdDiff;
16648 req_buf->RoamRescanRssiDiff =
16649 roam_info->cfgParams.nRoamRescanRssiDiff;
16650 req_buf->RoamRssiDiff = mac_ctx->roam.configParam.RoamRssiDiff;
16651 req_buf->reason = reason;
16652 req_buf->NeighborScanTimerPeriod =
16653 roam_info->cfgParams.neighborScanPeriod;
16654 req_buf->NeighborRoamScanRefreshPeriod =
16655 roam_info->cfgParams.neighborResultsRefreshPeriod;
16656 req_buf->NeighborScanChannelMinTime =
16657 roam_info->cfgParams.minChannelScanTime;
16658 req_buf->NeighborScanChannelMaxTime =
16659 roam_info->cfgParams.maxChannelScanTime;
16660 req_buf->EmptyRefreshScanPeriod =
16661 roam_info->cfgParams.emptyScanRefreshPeriod;
16662 req_buf->RoamBmissFirstBcnt =
16663 roam_info->cfgParams.nRoamBmissFirstBcnt;
16664 req_buf->RoamBmissFinalBcnt =
16665 roam_info->cfgParams.nRoamBmissFinalBcnt;
16666 req_buf->RoamBeaconRssiWeight =
16667 roam_info->cfgParams.nRoamBeaconRssiWeight;
16668 /* MAWC feature */
16669 req_buf->MAWCEnabled = mac_ctx->roam.configParam.MAWCEnabled;
16670#ifdef FEATURE_WLAN_ESE
16671 req_buf->IsESEAssoc =
16672 csr_neighbor_roam_is_ese_assoc(mac_ctx, session_id) &&
16673 ((req_buf->ConnectedNetwork.authentication ==
16674 eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
16675 (csr_is_auth_type_ese(req_buf->
16676 ConnectedNetwork.authentication)));
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016677 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016678 FL("LFR3:IsEseAssoc=%d\n"), req_buf->IsESEAssoc);
16679#endif
16680 if (ese_neighbor_list_recvd || curr_ch_lst_info->numOfChannels == 0) {
16681 /*
16682 * Retrieve the Channel Cache either from ini or from the
16683 * occupied channels list. Give Preference to INI Channels
16684 */
16685 if (roam_info->cfgParams.channelInfo.numOfChannels) {
16686 status = csr_fetch_ch_lst_from_ini(mac_ctx, roam_info,
16687 req_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016688 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016689 qdf_mem_free(req_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016690 return NULL;
16691 }
16692 } else {
16693 csr_fetch_ch_lst_from_occupied_lst(mac_ctx, session_id,
16694 reason, req_buf, roam_info);
16695 }
16696 }
16697#ifdef FEATURE_WLAN_ESE
16698 else {
16699 /*
16700 * If ESE is enabled, and a neighbor Report is received,then
16701 * Ignore the INI Channels or the Occupied Channel List.
16702 * Consider the channels in the neighbor list sent by the ESE AP
16703 */
16704 csr_fetch_ch_lst_from_received_list(mac_ctx, roam_info,
16705 curr_ch_lst_info, req_buf);
16706 }
16707#endif
16708 for (i = 0, j = 0; i < req_buf->ConnectedNetwork.ChannelCount; i++) {
16709 if (j < sizeof(ch_cache_str)) {
16710 j += snprintf(ch_cache_str + j,
16711 sizeof(ch_cache_str) - j, " %d",
16712 req_buf->ConnectedNetwork.
16713 ChannelCache[i]);
16714 } else
16715 break;
16716 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016717 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016718 FL("ChnlCacheType:%d, No of Chnls:%d,Channels: %s"),
16719 req_buf->ChannelCacheType,
16720 req_buf->ConnectedNetwork.ChannelCount, ch_cache_str);
16721
16722 /* Maintain the Valid Channels List */
16723 status = csr_fetch_valid_ch_lst(mac_ctx, req_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016724 if (!QDF_IS_STATUS_SUCCESS(status)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016725 qdf_mem_free(req_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016726 return NULL;
16727 }
16728
16729 req_buf->MDID.mdiePresent =
16730 mac_ctx->roam.roamSession[session_id].
16731 connectedProfile.MDID.mdiePresent;
16732 req_buf->MDID.mobilityDomain =
16733 mac_ctx->roam.roamSession[session_id].
16734 connectedProfile.MDID.mobilityDomain;
16735 req_buf->sessionId = session_id;
16736 req_buf->nProbes = mac_ctx->roam.configParam.nProbes;
16737 req_buf->HomeAwayTime = mac_ctx->roam.configParam.nRoamScanHomeAwayTime;
16738
16739 /*
16740 * Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16741 * where RFS is the RF Switching time. It is twice RFS to consider the
16742 * time to go off channel and return to the home channel.
16743 */
16744 if (req_buf->HomeAwayTime < (req_buf->NeighborScanChannelMaxTime +
16745 (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016746 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016747 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)"),
16748 req_buf->HomeAwayTime,
16749 (req_buf->NeighborScanChannelMaxTime +
16750 (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16751 req_buf->HomeAwayTime = 0;
16752 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016753 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016754 FL("HomeAwayTime:%d"), req_buf->HomeAwayTime);
16755
16756 /*Prepare a probe request for 2.4GHz band and one for 5GHz band */
16757 dot11_mode = (uint8_t) csr_translate_to_wni_cfg_dot11_mode(mac_ctx,
16758 csr_find_best_phy_mode(mac_ctx,
16759 mac_ctx->roam.configParam.phyMode));
16760 csr_roam_scan_offload_prepare_probe_req_template(mac_ctx,
16761 SIR_ROAM_SCAN_24G_DEFAULT_CH, dot11_mode,
16762 session->selfMacAddr.bytes, req_buf->p24GProbeTemplate,
16763 &req_buf->us24GProbeTemplateLen, session);
16764
16765 csr_roam_scan_offload_prepare_probe_req_template(mac_ctx,
16766 SIR_ROAM_SCAN_5G_DEFAULT_CH, dot11_mode,
16767 session->selfMacAddr.bytes,
16768 req_buf->p5GProbeTemplate, &req_buf->us5GProbeTemplateLen,
16769 session);
16770 req_buf->allowDFSChannelRoam =
16771 mac_ctx->roam.configParam.allowDFSChannelRoam;
Varun Reddy Yeturu05186292015-09-28 17:12:33 -070016772 req_buf->early_stop_scan_enable =
16773 mac_ctx->roam.configParam.early_stop_scan_enable;
16774 req_buf->early_stop_scan_min_threshold =
16775 mac_ctx->roam.configParam.early_stop_scan_min_threshold;
16776 req_buf->early_stop_scan_max_threshold =
16777 mac_ctx->roam.configParam.early_stop_scan_max_threshold;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016778 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu05186292015-09-28 17:12:33 -070016779 FL("EarlyStopFeature Enable=%d, MinThresh=%d, MaxThresh=%d"),
16780 req_buf->early_stop_scan_enable,
16781 req_buf->early_stop_scan_min_threshold,
16782 req_buf->early_stop_scan_max_threshold);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016783#ifdef WLAN_FEATURE_ROAM_OFFLOAD
16784 req_buf->RoamOffloadEnabled = csr_roamIsRoamOffloadEnabled(mac_ctx);
16785 req_buf->RoamKeyMgmtOffloadEnabled = session->RoamKeyMgmtOffloadEnabled;
16786 /* Roam Offload piggybacks upon the Roam Scan offload command. */
16787 if (req_buf->RoamOffloadEnabled)
16788 csr_update_roam_scan_offload_request(mac_ctx, req_buf, session);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016789 qdf_mem_copy(&req_buf->roam_params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016790 &mac_ctx->roam.configParam.roam_params,
16791 sizeof(req_buf->roam_params));
16792#endif
16793 return req_buf;
16794}
16795/**
16796 * check_allowed_ssid_list() - Check the WhiteList
16797 * @req_buffer: Buffer which contains the connected profile SSID.
16798 * @roam_params: Buffer which contains the whitelist SSID's.
16799 *
16800 * Check if the connected profile SSID exists in the whitelist.
16801 * It is assumed that the framework provides this also in the whitelist.
16802 * If it exists there is no issue. Otherwise add it to the list.
16803 *
16804 * Return: None
16805 */
16806static void check_allowed_ssid_list(tSirRoamOffloadScanReq *req_buffer,
16807 struct roam_ext_params *roam_params)
16808{
16809 int i = 0;
16810 bool match = false;
16811 for (i = 0; i < roam_params->num_ssid_allowed_list; i++) {
16812 if ((roam_params->ssid_allowed_list[i].length ==
16813 req_buffer->ConnectedNetwork.ssId.length) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016814 (!qdf_mem_cmp(roam_params->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016815 req_buffer->ConnectedNetwork.ssId.ssId,
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016816 roam_params->ssid_allowed_list[i].length))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016817 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016818 "Whitelist contains connected profile SSID");
16819 match = true;
16820 break;
16821 }
16822 }
16823 if (!match) {
16824 if (roam_params->num_ssid_allowed_list >=
16825 MAX_SSID_ALLOWED_LIST) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016826 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016827 "Whitelist is FULL. Cannot Add another entry");
16828 return;
16829 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016830 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016831 "Adding Connected profile SSID to whitelist");
16832 /* i is the next available index to add the entry.*/
16833 i = roam_params->num_ssid_allowed_list;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053016834 qdf_mem_copy(roam_params->ssid_allowed_list[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016835 req_buffer->ConnectedNetwork.ssId.ssId,
16836 req_buffer->ConnectedNetwork.ssId.length);
16837 roam_params->ssid_allowed_list[i].length =
16838 req_buffer->ConnectedNetwork.ssId.length;
16839 roam_params->num_ssid_allowed_list++;
16840 }
16841}
16842
16843/*
16844 * Below Table describe whether RSO command can be send down to fimrware or not.
16845 * Host check it on the basis of previous RSO command sent down to firmware.
16846 *||==========================================================================||
16847 *|| New cmd | LAST SENT COMMAND ---> ||
16848 *||====|=====================================================================||
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080016849 *|| V | START | STOP | RESTART | UPDATE_CFG| ABORT_SCAN ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016850 *|| -------------------------------------------------------------------------||
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080016851 *|| RSO_START | NO | YES | NO | NO | NO ||
16852 *|| RSO_STOP | YES | YES | YES | YES | YES ||
16853 *|| RSO_RESTART | YES | YES | NO | YES | YES ||
16854 *|| RSO_UPDATE_CFG | YES | NO | YES | YES | YES ||
16855 *|| RSO_ABORT_SCAN | YES | NO | YES | YES | YES ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016856 *||==========================================================================||
16857 **/
16858#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
16859#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
16860#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
16861#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080016862#define RSO_ABORT_SCAN_BIT (1<<ROAM_SCAN_OFFLOAD_ABORT_SCAN)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016863#define RSO_START_ALLOW_MASK (RSO_STOP_BIT)
16864#define RSO_STOP_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080016865 RSO_STOP_BIT | RSO_START_BIT | RSO_ABORT_SCAN_BIT)
16866#define RSO_RESTART_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_START_BIT | \
16867 RSO_ABORT_SCAN_BIT | RSO_RESTART_BIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016868#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_STOP_BIT | \
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080016869 RSO_START_BIT | RSO_ABORT_SCAN_BIT)
16870#define RSO_ABORT_SCAN_ALLOW_MASK (RSO_START_BIT | RSO_RESTART_BIT | \
16871 RSO_UPDATE_CFG_BIT | RSO_ABORT_SCAN_BIT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016872
16873bool csr_is_RSO_cmd_allowed(tpAniSirGlobal mac_ctx, uint8_t command,
16874 uint8_t session_id)
16875{
16876 tpCsrNeighborRoamControlInfo neigh_roam_info =
16877 &mac_ctx->roam.neighborRoamInfo[session_id];
16878 uint8_t desiredMask = 0;
16879 bool ret_val;
16880
16881 switch (command) {
16882 case ROAM_SCAN_OFFLOAD_START:
16883 desiredMask = RSO_START_ALLOW_MASK;
16884 break;
16885 case ROAM_SCAN_OFFLOAD_STOP:
16886 desiredMask = RSO_STOP_ALLOW_MASK;
16887 break;
16888 case ROAM_SCAN_OFFLOAD_RESTART:
16889 desiredMask = RSO_RESTART_ALLOW_MASK;
16890 break;
16891 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
16892 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
16893 break;
Varun Reddy Yeturud8455812016-01-16 19:05:06 -080016894 case ROAM_SCAN_OFFLOAD_ABORT_SCAN:
16895 desiredMask = RSO_ABORT_SCAN_ALLOW_MASK;
16896 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016897 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016898 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016899 FL("Wrong RSO command %d, not allowed"), command);
16900 return 0;/*Cmd Not allowed*/
16901 }
16902 ret_val = desiredMask & (1 << neigh_roam_info->last_sent_cmd);
16903 return ret_val;
16904}
16905
16906/**
16907 * csr_roam_offload_scan() - populates roam offload scan request and sends to
16908 * WMA
16909 *
16910 * paramters
16911 * @mac_ctx: global mac ctx
16912 * @session_id: session id
16913 * @command: roam scan offload command input
16914 * @reason: reason to roam
16915 *
16916 * Return: result of operation
16917 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016918QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016919csr_roam_offload_scan(tpAniSirGlobal mac_ctx, uint8_t session_id,
16920 uint8_t command, uint8_t reason)
16921{
16922 uint8_t *state = NULL;
16923 cds_msg_t msg;
16924 tSirRoamOffloadScanReq *req_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016925 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016926 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
16927 tpCsrNeighborRoamControlInfo roam_info =
16928 &mac_ctx->roam.neighborRoamInfo[session_id];
16929 struct roam_ext_params *roam_params_dst;
16930 struct roam_ext_params *roam_params_src;
16931 uint8_t i;
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080016932 uint8_t op_channel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016933
16934 if (NULL == session) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016935 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016936 FL("session is null"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016937 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016938 }
16939#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080016940 if (session->roam_synch_in_progress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016941 && (ROAM_SCAN_OFFLOAD_STOP == command)) {
16942 /*
16943 * When roam synch is in progress for propagation, there is no
16944 * need to send down the STOP command since the firmware is not
16945 * expecting any WMI commands when the roam synch is in progress
16946 */
16947 b_roam_scan_offload_started = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016948 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016949 }
16950#endif
16951 if (0 == csr_roam_is_roam_offload_scan_enabled(mac_ctx)) {
16952 sms_log(mac_ctx, LOGE, "isRoamOffloadScanEnabled not set");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016953 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016954 }
16955 if (!csr_is_RSO_cmd_allowed(mac_ctx, command, session_id) &&
16956 reason != REASON_ROAM_SET_BLACKLIST_BSSID) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016957 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016958 FL("RSO out-of-sync command %d lastSentCmd %d"),
16959 command, roam_info->last_sent_cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016960 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016961 }
16962
16963 if ((true == b_roam_scan_offload_started)
16964 && (ROAM_SCAN_OFFLOAD_START == command)) {
16965 sms_log(mac_ctx, LOGE, "Roam Scan Offload is already started");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016966 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016967 }
16968 /*
16969 * The Dynamic Config Items Update may happen even if the state is in
16970 * INIT. It is important to ensure that the command is passed down to
16971 * the FW only if the Infra Station is in a connected state.A connected
16972 * station could also be in a PREAUTH or REASSOC states.So, consider not
16973 * sending the command down in INIT state. We also have to ensure that
16974 * if there is a STOP command we always have to inform Riva,
16975 * irrespective of whichever state we are in
16976 */
16977
16978 if ((roam_info->neighborRoamState ==
16979 eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
16980 (command != ROAM_SCAN_OFFLOAD_STOP) &&
16981 (reason != REASON_ROAM_SET_BLACKLIST_BSSID)) {
16982 state = mac_trace_get_neighbour_roam_state(
16983 roam_info->neighborRoamState);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016984 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016985 FL("Scan Command not sent to FW state=%s and cmd=%d"),
16986 state, command);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016987 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016988 }
16989
16990 req_buf = csr_create_roam_scan_offload_request(mac_ctx, command,
16991 session_id, reason,
16992 session, roam_info);
16993 if (!req_buf) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053016994 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016995 FL("Failed to create req packet"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053016996 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080016997 }
16998 roam_params_dst = &req_buf->roam_params;
16999 roam_params_src = &mac_ctx->roam.configParam.roam_params;
17000 if (reason == REASON_ROAM_SET_SSID_ALLOWED)
17001 check_allowed_ssid_list(req_buf, roam_params_src);
17002 /*
17003 * Configure the lookup threshold either from INI or from framework.
17004 * If both are present, give higher priority to the one from framework.
17005 */
17006 if (roam_params_src->alert_rssi_threshold)
17007 req_buf->LookupThreshold =
17008 roam_params_src->alert_rssi_threshold;
17009 else
17010 req_buf->LookupThreshold =
17011 (int8_t)roam_info->cfgParams.neighborLookupThreshold *
17012 (-1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017013 qdf_mem_copy(roam_params_dst, roam_params_src,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017014 sizeof(struct roam_ext_params));
17015 /*
17016 * rssi_diff which is updated via framework is equivalent to the
17017 * INI RoamRssiDiff parameter and hence should be updated.
17018 */
17019 if (roam_params_src->rssi_diff)
17020 req_buf->RoamRssiDiff = roam_params_src->rssi_diff;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017021 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017022 "num_bssid_avoid_list: %d, num_ssid_allowed_list: %d, "
17023 "num_bssid_favored: %d, raise_rssi_thresh_5g: %d, "
17024 "drop_rssi_thresh_5g: %d, raise_rssi_type_5g: %d, "
17025 "raise_factor_5g: %d, drop_rssi_type_5g: %d, "
17026 "drop_factor_5g: %d, max_raise_rssi_5g: %d, "
17027 "max_drop_rssi_5g: %d, rssi_diff: %d, alert_rssi_threshold:%d",
17028 roam_params_dst->num_bssid_avoid_list,
17029 roam_params_dst->num_ssid_allowed_list,
17030 roam_params_dst->num_bssid_favored,
17031 roam_params_dst->raise_rssi_thresh_5g,
17032 roam_params_dst->drop_rssi_thresh_5g,
17033 roam_params_dst->raise_rssi_type_5g,
17034 roam_params_dst->raise_factor_5g,
17035 roam_params_dst->drop_rssi_type_5g,
17036 roam_params_dst->drop_factor_5g,
17037 roam_params_dst->max_raise_rssi_5g,
17038 roam_params_dst->max_drop_rssi_5g,
17039 req_buf->RoamRssiDiff, roam_params_dst->alert_rssi_threshold);
17040
Gupta, Kapilc68ad462016-02-01 19:17:23 +053017041 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
17042 "dense_rssi_thresh_offset: %d, dense_min_aps_cnt:%d, traffic_threshold:%d",
17043 roam_params_dst->dense_rssi_thresh_offset,
17044 roam_params_dst->dense_min_aps_cnt,
17045 roam_params_dst->traffic_threshold);
17046
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017047 for (i = 0; i < roam_params_dst->num_bssid_avoid_list; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017048 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017049 "Blacklist Bssid: ("MAC_ADDRESS_STR")",
Srinivas Girigowdab0532392015-11-24 11:50:16 -080017050 MAC_ADDR_ARRAY(roam_params_dst->bssid_avoid_list[i].bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017051 }
17052 for (i = 0; i < roam_params_dst->num_ssid_allowed_list; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017053 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017054 "Whitelist: %.*s",
17055 roam_params_dst->ssid_allowed_list[i].length,
17056 roam_params_dst->ssid_allowed_list[i].ssId);
17057 }
17058 for (i = 0; i < roam_params_dst->num_bssid_favored; i++) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017059 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017060 "Preferred Bssid: ("MAC_ADDRESS_STR") score: %d",
Srinivas Girigowdab0532392015-11-24 11:50:16 -080017061 MAC_ADDR_ARRAY(roam_params_dst->bssid_favored[i].bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017062 roam_params_dst->bssid_favored_factor[i]);
17063 }
17064
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080017065 op_channel = session->connectedProfile.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017066 req_buf->hi_rssi_scan_max_count =
17067 roam_info->cfgParams.hi_rssi_scan_max_count;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017068 req_buf->hi_rssi_scan_delay =
17069 roam_info->cfgParams.hi_rssi_scan_delay;
17070 req_buf->hi_rssi_scan_rssi_ub =
17071 roam_info->cfgParams.hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080017072 /*
17073 * If the current operation channel is 5G frequency band, then
17074 * there is no need to enable the HI_RSSI feature. This feature
17075 * is useful only if we are connected to a 2.4 GHz AP and we wish
17076 * to connect to a better 5GHz AP is available.
17077 */
17078 if (CDS_IS_CHANNEL_5GHZ(op_channel)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017079 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080017080 "Disabling HI_RSSI feature as connected AP is 5GHz");
17081 req_buf->hi_rssi_scan_rssi_delta = 0;
17082 } else {
17083 req_buf->hi_rssi_scan_rssi_delta =
17084 roam_info->cfgParams.hi_rssi_scan_rssi_delta;
17085 }
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017086 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturu062dc742015-11-03 17:30:43 -080017087 "hi_rssi:delta=%d, max_count=%d, delay=%d, ub=%d",
17088 req_buf->hi_rssi_scan_rssi_delta,
17089 req_buf->hi_rssi_scan_max_count,
17090 req_buf->hi_rssi_scan_delay,
17091 req_buf->hi_rssi_scan_rssi_ub);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017092
17093 msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
17094 msg.reserved = 0;
17095 msg.bodyptr = req_buf;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017096 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +053017097 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017098 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017099 "%s: Not able to post message to WMA",
17100 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017101 qdf_mem_free(req_buf);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017102 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017103 } else {
17104 if (ROAM_SCAN_OFFLOAD_START == command)
17105 b_roam_scan_offload_started = true;
17106 else if (ROAM_SCAN_OFFLOAD_STOP == command)
17107 b_roam_scan_offload_started = false;
17108 }
17109 /* update the last sent cmd */
17110 roam_info->last_sent_cmd = command;
17111
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017112 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017113 "Roam Scan Offload Command %d, Reason %d", command, reason);
17114 return status;
17115}
17116
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017117QDF_STATUS csr_roam_offload_scan_rsp_hdlr(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017118 tpSirRoamOffloadScanRsp scanOffloadRsp)
17119{
17120 switch (scanOffloadRsp->reason) {
17121 case 0:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017122 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017123 "Rsp for Roam Scan Offload with failure status");
17124 break;
17125 case REASON_OS_REQUESTED_ROAMING_NOW:
17126 csr_neighbor_roam_proceed_with_handoff_req(pMac,
17127 scanOffloadRsp->sessionId);
17128 break;
17129
17130 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017131 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017132 "Rsp for Roam Scan Offload with reason %d",
17133 scanOffloadRsp->reason);
17134 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017135 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017136}
17137
17138tCsrPeStatsReqInfo *csr_roam_check_pe_stats_req_list(tpAniSirGlobal pMac,
17139 uint32_t statsMask,
17140 uint32_t periodicity,
17141 bool *pFound,
17142 uint8_t staId, uint8_t sessionId)
17143{
17144 bool found = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017145 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017146 tCsrPeStatsReqInfo staEntry;
17147 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
17148 tListElem *pStaEntry = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017149 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017150 *pFound = false;
17151
17152 pStaEntry = csr_roam_find_in_pe_stats_req_list(pMac, statsMask);
17153 if (pStaEntry) {
17154 pTempStaEntry =
17155 GET_BASE_ADDR(pStaEntry, tCsrPeStatsReqInfo, link);
17156 if (pTempStaEntry->periodicity) {
17157 pTempStaEntry->periodicity =
Anurag Chouhan6d760662016-02-20 16:05:43 +053017158 QDF_MIN(periodicity,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017159 pTempStaEntry->periodicity);
17160 } else {
17161 pTempStaEntry->periodicity = periodicity;
17162 }
17163 pTempStaEntry->numClient++;
17164 found = true;
17165 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017166 qdf_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017167 staEntry.numClient = 1;
17168 staEntry.periodicity = periodicity;
17169 staEntry.pMac = pMac;
17170 staEntry.rspPending = false;
17171 staEntry.staId = staId;
17172 staEntry.statsMask = statsMask;
17173 staEntry.timerRunning = false;
17174 staEntry.sessionId = sessionId;
17175 pTempStaEntry =
17176 csr_roam_insert_entry_into_pe_stats_req_list(pMac,
17177 &pMac->roam.
17178 peStatsReqList,
17179 &staEntry);
17180 if (!pTempStaEntry) {
17181 /* msg */
17182 sms_log(pMac, LOGW,
17183 "csr_roam_check_pe_stats_req_list: Failed to insert req in peStatsReqList");
17184 return NULL;
17185 }
17186 }
17187 pTempStaEntry->periodicity =
17188 pMac->roam.configParam.statsReqPeriodicityInPS;
17189
17190 if (!pTempStaEntry->timerRunning) {
17191 /* send down a req in case of one time req, for periodic ones wait for timer to expire */
17192 if (!pTempStaEntry->rspPending && !pTempStaEntry->periodicity) {
17193 status = csr_send_mb_stats_req_msg(pMac,
17194 statsMask & ~(1 <<
17195 eCsrGlobalClassDStats),
17196 staId, sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017197 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017198 sms_log(pMac, LOGE,
17199 FL
17200 ("csr_roam_check_pe_stats_req_list:failed to send down stats req to PE"));
17201 } else {
17202 pTempStaEntry->rspPending = true;
17203 }
17204 }
17205 if (pTempStaEntry->periodicity) {
17206 if (!found) {
17207
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017208 qdf_status =
Anurag Chouhan210db072016-02-22 18:42:15 +053017209 qdf_mc_timer_init(&pTempStaEntry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017210 hPeStatsTimer,
Anurag Chouhan6d760662016-02-20 16:05:43 +053017211 QDF_TIMER_TYPE_SW,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017212 csr_roam_pe_stats_timer_handler,
17213 pTempStaEntry);
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 init hPeStatsTimer timer"));
17218 return NULL;
17219 }
17220 }
17221 /* start timer */
17222 sms_log(pMac, LOG1,
17223 "csr_roam_check_pe_stats_req_list:peStatsTimer period %d",
17224 pTempStaEntry->periodicity);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017225 qdf_status =
Anurag Chouhan210db072016-02-22 18:42:15 +053017226 qdf_mc_timer_start(&pTempStaEntry->hPeStatsTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017227 pTempStaEntry->periodicity);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017228 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017229 sms_log(pMac, LOGE,
17230 FL
17231 ("csr_roam_check_pe_stats_req_list:cannot start hPeStatsTimer timer"));
17232 return NULL;
17233 }
17234 pTempStaEntry->timerRunning = true;
17235 }
17236 }
17237 *pFound = found;
17238 return pTempStaEntry;
17239}
17240
17241/*
17242 pStaEntry is no longer invalid upon the return of this function.
17243 */
17244static void csr_roam_remove_stat_list_entry(tpAniSirGlobal pMac, tListElem *pEntry)
17245{
17246 if (pEntry) {
17247 if (csr_ll_remove_entry
17248 (&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017249 qdf_mem_free(GET_BASE_ADDR
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017250 (pEntry, tCsrStatsClientReqInfo, link));
17251 }
17252 }
17253}
17254
17255void csr_roam_remove_entry_from_pe_stats_req_list(tpAniSirGlobal pMac,
17256 tCsrPeStatsReqInfo *pPeStaEntry)
17257{
17258 tListElem *pEntry;
17259 tCsrPeStatsReqInfo *pTempStaEntry;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017260 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017261 pEntry = csr_ll_peek_head(&pMac->roam.peStatsReqList, LL_ACCESS_LOCK);
17262 if (!pEntry) {
17263 sms_log(pMac, LOGE, FL(" List empty, no stats req for PE"));
17264 return;
17265 }
17266 while (pEntry) {
17267 pTempStaEntry = GET_BASE_ADDR(pEntry, tCsrPeStatsReqInfo, link);
17268 if (NULL == pTempStaEntry
17269 || (pTempStaEntry->statsMask !=
17270 pPeStaEntry->statsMask)) {
17271 pEntry = csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
17272 LL_ACCESS_NOLOCK);
17273 continue;
17274 }
17275 sms_log(pMac, LOGW, FL("Match found"));
17276 if (pTempStaEntry->timerRunning) {
Anurag Chouhan210db072016-02-22 18:42:15 +053017277 qdf_status = qdf_mc_timer_stop(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017278 &pTempStaEntry->hPeStatsTimer);
17279 /*
17280 * If we are not able to stop the timer here, just
17281 * remove the entry from the linked list. Destroy the
17282 * timer object and free the memory in the timer CB
17283 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017284 if (qdf_status == QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017285 /* the timer is successfully stopped */
17286 pTempStaEntry->timerRunning = false;
17287 /* Destroy the timer */
Anurag Chouhan210db072016-02-22 18:42:15 +053017288 qdf_status = qdf_mc_timer_destroy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017289 &pTempStaEntry->hPeStatsTimer);
17290 } else {
17291 /*
17292 * the timer could not be stopped. Hence destroy
17293 * and free the memory for the PE stat entry in
17294 * the timer CB.
17295 */
17296 pTempStaEntry->timerStopFailed = true;
17297 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017298 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017299 sms_log(pMac, LOGE,
17300 FL("failed to stop/destroy timer"));
17301 }
17302 }
17303
17304 if (csr_ll_remove_entry(&pMac->roam.peStatsReqList, pEntry,
17305 LL_ACCESS_LOCK)) {
17306 /*
17307 * Only free the memory if we could stop the timer
17308 * successfully
17309 */
17310 if (!pTempStaEntry->timerStopFailed) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017311 qdf_mem_free(pTempStaEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017312 pTempStaEntry = NULL;
17313 }
17314 break;
17315 }
17316 pEntry = csr_ll_next(&pMac->roam.peStatsReqList, pEntry,
17317 LL_ACCESS_NOLOCK);
17318 } /* end of while loop */
17319 return;
17320}
17321
17322void csr_roam_report_statistics(tpAniSirGlobal pMac, uint32_t statsMask,
17323 tCsrStatsCallback callback, uint8_t staId,
17324 void *pContext)
17325{
17326 uint8_t stats[500];
17327 uint8_t *pStats = NULL;
17328 uint32_t tempMask = 0;
17329 uint8_t counter = 0;
17330 if (!callback) {
17331 sms_log(pMac, LOGE, FL("Cannot report callback NULL"));
17332 return;
17333 }
17334 if (!statsMask) {
17335 sms_log(pMac, LOGE, FL("Cannot report statsMask is 0"));
17336 return;
17337 }
17338 pStats = stats;
17339 tempMask = statsMask;
17340 while (tempMask) {
17341 if (tempMask & 1) {
17342 /* new stats info from PE, fill up the stats strucutres in PMAC */
17343 switch (counter) {
17344 case eCsrSummaryStats:
17345 sms_log(pMac, LOG2, FL("Summary stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017346 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017347 (uint8_t *) &pMac->roam.
17348 summaryStatsInfo,
17349 sizeof(tCsrSummaryStatsInfo));
17350 pStats += sizeof(tCsrSummaryStatsInfo);
17351 break;
17352 case eCsrGlobalClassAStats:
17353 sms_log(pMac, LOG2, FL("ClassA stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017354 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017355 (uint8_t *) &pMac->roam.
17356 classAStatsInfo,
17357 sizeof(tCsrGlobalClassAStatsInfo));
17358 pStats += sizeof(tCsrGlobalClassAStatsInfo);
17359 break;
17360 case eCsrGlobalClassBStats:
17361 sms_log(pMac, LOG2, FL("ClassB stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017362 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017363 (uint8_t *) &pMac->roam.
17364 classBStatsInfo,
17365 sizeof(tCsrGlobalClassBStatsInfo));
17366 pStats += sizeof(tCsrGlobalClassBStatsInfo);
17367 break;
17368 case eCsrGlobalClassCStats:
17369 sms_log(pMac, LOG2, FL("ClassC stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017370 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017371 (uint8_t *) &pMac->roam.
17372 classCStatsInfo,
17373 sizeof(tCsrGlobalClassCStatsInfo));
17374 pStats += sizeof(tCsrGlobalClassCStatsInfo);
17375 break;
17376 case eCsrGlobalClassDStats:
17377 sms_log(pMac, LOG2, FL("ClassD stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017378 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017379 (uint8_t *) &pMac->roam.
17380 classDStatsInfo,
17381 sizeof(tCsrGlobalClassDStatsInfo));
17382 pStats += sizeof(tCsrGlobalClassDStatsInfo);
17383 break;
17384 case eCsrPerStaStats:
17385 sms_log(pMac, LOG2, FL("PerSta stats"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017386 qdf_mem_copy(pStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017387 (uint8_t *) &pMac->roam.
17388 perStaStatsInfo[staId],
17389 sizeof(tCsrPerStaStatsInfo));
17390 pStats += sizeof(tCsrPerStaStatsInfo);
17391 break;
17392 default:
17393 sms_log(pMac, LOGE,
17394 FL("Unknown stats type and counter %d"),
17395 counter);
17396 break;
17397 }
17398 }
17399 tempMask >>= 1;
17400 counter++;
17401 }
17402 callback(stats, pContext);
17403}
17404
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017405QDF_STATUS csr_roam_dereg_statistics_req(tpAniSirGlobal pMac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017406{
17407 tListElem *pEntry = NULL;
17408 tListElem *pPrevEntry = NULL;
17409 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017410 QDF_STATUS status = QDF_STATUS_SUCCESS;
17411 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017412 pEntry = csr_ll_peek_head(&pMac->roam.statsClientReqList, LL_ACCESS_LOCK);
17413 if (!pEntry) {
17414 /* list empty */
17415 sms_log(pMac, LOGW,
17416 "csr_roam_dereg_statistics_req: List empty, no request from "
17417 "upper layer client(s)");
17418 return status;
17419 }
17420 while (pEntry) {
17421 if (pPrevEntry) {
17422 pTempStaEntry =
17423 GET_BASE_ADDR(pPrevEntry, tCsrStatsClientReqInfo,
17424 link);
17425 /* send up the stats report */
17426 csr_roam_report_statistics(pMac, pTempStaEntry->statsMask,
17427 pTempStaEntry->callback,
17428 pTempStaEntry->staId,
17429 pTempStaEntry->pContext);
17430 csr_roam_remove_stat_list_entry(pMac, pPrevEntry);
17431 }
17432 pTempStaEntry =
17433 GET_BASE_ADDR(pEntry, tCsrStatsClientReqInfo, link);
17434 if (pTempStaEntry->pPeStaEntry) {
17435 /* pPeStaEntry can be NULL */
17436 pTempStaEntry->pPeStaEntry->numClient--;
17437 /* check if we need to delete the entry from peStatsReqList too */
17438 if (!pTempStaEntry->pPeStaEntry->numClient) {
17439 csr_roam_remove_entry_from_pe_stats_req_list(pMac,
17440 pTempStaEntry->
17441 pPeStaEntry);
17442 }
17443 }
17444 /* check if we need to stop the tl stats timer too */
17445 pMac->roam.tlStatsReqInfo.numClient--;
17446 if (!pMac->roam.tlStatsReqInfo.numClient) {
17447 if (pMac->roam.tlStatsReqInfo.timerRunning) {
17448 status =
Anurag Chouhan210db072016-02-22 18:42:15 +053017449 qdf_mc_timer_stop(&pMac->roam.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017450 tlStatsReqInfo.
17451 hTlStatsTimer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017452 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017453 sms_log(pMac, LOGE,
17454 FL
17455 ("csr_roam_dereg_statistics_req:cannot stop TlStatsTimer timer"));
17456 /* we will continue */
17457 }
17458 }
17459 pMac->roam.tlStatsReqInfo.periodicity = 0;
17460 pMac->roam.tlStatsReqInfo.timerRunning = false;
17461 }
17462 if (pTempStaEntry->periodicity) {
17463 /* While creating StaEntry in csr_get_statistics, */
17464 /* Initializing and starting timer only when periodicity is set. */
17465 /* So Stop and Destroy timer only when periodicity is set. */
17466
Anurag Chouhan210db072016-02-22 18:42:15 +053017467 qdf_mc_timer_stop(&pTempStaEntry->timer);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053017468 /* Destroy the qdf timer... */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017469 qdf_status =
Anurag Chouhan210db072016-02-22 18:42:15 +053017470 qdf_mc_timer_destroy(&pTempStaEntry->timer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017471 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017472 sms_log(pMac, LOGE,
17473 FL
17474 ("csr_roam_dereg_statistics_req:failed to destroy Client req timer"));
17475 }
17476 }
17477
17478 pPrevEntry = pEntry;
17479 pEntry =
17480 csr_ll_next(&pMac->roam.statsClientReqList, pEntry,
17481 LL_ACCESS_NOLOCK);
17482 }
17483 /* the last one */
17484 if (pPrevEntry) {
17485 pTempStaEntry =
17486 GET_BASE_ADDR(pPrevEntry, tCsrStatsClientReqInfo, link);
17487 /* send up the stats report */
17488 csr_roam_report_statistics(pMac, pTempStaEntry->statsMask,
17489 pTempStaEntry->callback,
17490 pTempStaEntry->staId,
17491 pTempStaEntry->pContext);
17492 csr_roam_remove_stat_list_entry(pMac, pPrevEntry);
17493 }
17494 return status;
17495
17496}
17497
17498tSmeCmd *csr_get_command_buffer(tpAniSirGlobal pMac)
17499{
17500 tSmeCmd *pCmd = sme_get_command_buffer(pMac);
17501 if (pCmd) {
17502 pMac->roam.sPendingCommands++;
17503 }
17504 return pCmd;
17505}
17506
17507void csr_release_command(tpAniSirGlobal pMac, tSmeCmd *pCommand)
17508{
17509 if (pMac->roam.sPendingCommands > 0) {
17510 /* All command allocated through csr_get_command_buffer need to */
17511 /* decrement the pending count when releasing. */
17512 pMac->roam.sPendingCommands--;
17513 sme_release_command(pMac, pCommand);
17514 } else {
17515 sms_log(pMac, LOGE, FL("no pending commands"));
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017516 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017517 }
17518}
17519
17520/* Return SUCCESS is the command is queued, failed */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017521QDF_STATUS csr_queue_sme_command(tpAniSirGlobal pMac, tSmeCmd *pCommand,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017522 bool fHighPriority)
17523{
17524 bool fNoCmdPending;
17525
17526 if (!SME_IS_START(pMac)) {
17527 sms_log(pMac, LOGE, FL("Sme in stop state"));
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053017528 QDF_ASSERT(0);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017529 return QDF_STATUS_E_PERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017530 }
17531
17532 if ((eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd) {
17533 sms_log(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
17534 pCommand->u.scanCmd.reason);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017535 return QDF_STATUS_CSR_WRONG_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017536 }
17537
17538 if ((pCommand->command == eSmeCommandScan)
17539 || (pCommand->command == eSmeCommandRemainOnChannel)) {
17540 sms_log(pMac, LOGW,
17541 FL("scan pending list count %d scan_id %d"),
17542 pMac->sme.smeScanCmdPendingList.Count,
17543 pCommand->u.scanCmd.scanID);
17544 csr_ll_insert_tail(&pMac->sme.smeScanCmdPendingList,
17545 &pCommand->Link, LL_ACCESS_LOCK);
17546 /* process the command queue... */
17547 sme_process_pending_queue(pMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017548 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017549 }
17550 /* Make sure roamCmdPendingList is not empty first */
17551 fNoCmdPending =
17552 csr_ll_is_list_empty(&pMac->roam.roamCmdPendingList, false);
17553 if (fNoCmdPending) {
17554 sme_push_command(pMac, pCommand, fHighPriority);
17555 } else {
17556 /* no list lock is needed since SME lock is held */
17557 if (!fHighPriority) {
17558 csr_ll_insert_tail(&pMac->roam.roamCmdPendingList,
17559 &pCommand->Link, false);
17560 } else {
17561 csr_ll_insert_head(&pMac->roam.roamCmdPendingList,
17562 &pCommand->Link, false);
17563 }
17564 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017565 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017566}
17567
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017568QDF_STATUS csr_roam_update_apwpsie(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017569 tSirAPWPSIEs *pAPWPSIES)
17570{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017571 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017572 tSirUpdateAPWPSIEsReq *pMsg;
17573
17574 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17575 if (NULL == pSession) {
17576 sms_log(pMac, LOGE,
Srinivas Girigowda5d486002015-11-25 12:18:44 -080017577 FL("Session does not exist for session id %d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017578 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017579 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017580 }
17581
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017582 pMsg = qdf_mem_malloc(sizeof(*pMsg));
Srinivas Girigowda5d486002015-11-25 12:18:44 -080017583 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017584 return QDF_STATUS_E_NOMEM;
Srinivas Girigowda5d486002015-11-25 12:18:44 -080017585
17586 pMsg->messageType = eWNI_SME_UPDATE_APWPSIE_REQ;
17587 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053017588 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Srinivas Girigowda5d486002015-11-25 12:18:44 -080017589 pMsg->sessionId = sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017590 qdf_mem_copy(&pMsg->APWPSIEs, pAPWPSIES, sizeof(tSirAPWPSIEs));
Srinivas Girigowda5d486002015-11-25 12:18:44 -080017591 pMsg->length = sizeof(*pMsg);
17592 status = cds_send_mb_message_to_mac(pMsg);
17593
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017594 return status;
17595}
17596
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017597QDF_STATUS csr_roam_update_wparsni_es(tpAniSirGlobal pMac, uint32_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017598 tSirRSNie *pAPSirRSNie)
17599{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017600 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017601 tSirUpdateAPWPARSNIEsReq *pMsg;
17602 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17603 if (NULL == pSession) {
17604 sms_log(pMac, LOGE,
17605 FL(" Session does not exist for session id %d"),
17606 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017607 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017608 }
17609 do {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017610 pMsg = qdf_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017611 if (NULL == pMsg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017612 return QDF_STATUS_E_NOMEM;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017613 qdf_mem_set(pMsg, sizeof(tSirUpdateAPWPARSNIEsReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017614 pMsg->messageType = eWNI_SME_SET_APWPARSNIEs_REQ;
17615 pMsg->transactionId = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +053017616 qdf_copy_macaddr(&pMsg->bssid, &pSession->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017617 pMsg->sessionId = sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017618 qdf_mem_copy(&pMsg->APWPARSNIEs, pAPSirRSNie,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017619 sizeof(tSirRSNie));
17620 pMsg->length = sizeof(struct sSirUpdateAPWPARSNIEsReq);
17621 status = cds_send_mb_message_to_mac(pMsg);
17622 } while (0);
17623 return status;
17624}
17625
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017626QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017627csr_roam_issue_ft_preauth_req(tHalHandle hHal, uint32_t sessionId,
17628 tpSirBssDescription pBssDescription)
17629{
17630 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
17631 tpSirFTPreAuthReq pftPreAuthReq;
17632 uint16_t auth_req_len = 0;
17633 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17634
17635 if (NULL == pSession) {
17636 sms_log(pMac, LOGE,
17637 FL("Session does not exist for session id(%d)"),
17638 sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017639 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017640 }
17641
17642 auth_req_len = sizeof(tSirFTPreAuthReq);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017643 pftPreAuthReq = (tpSirFTPreAuthReq) qdf_mem_malloc(auth_req_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017644 if (NULL == pftPreAuthReq) {
17645 sms_log(pMac, LOGE,
17646 FL("Memory allocation for FT Preauth request failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017647 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017648 }
17649 /* Save the SME Session ID here. We need it while processing the preauth response */
17650 pSession->ftSmeContext.smeSessionId = sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017651 qdf_mem_zero(pftPreAuthReq, auth_req_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017652
17653 pftPreAuthReq->pbssDescription =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017654 (tpSirBssDescription) qdf_mem_malloc(sizeof(pBssDescription->length)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017655 + pBssDescription->length);
17656 if (NULL == pftPreAuthReq->pbssDescription) {
17657 sms_log(pMac, LOGE,
17658 FL("Memory allocation for FT Preauth request failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017659 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017660 }
17661
17662 pftPreAuthReq->messageType = eWNI_SME_FT_PRE_AUTH_REQ;
17663
17664 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
17665
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017666 qdf_mem_copy((void *)&pftPreAuthReq->currbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017667 (void *)pSession->connectedProfile.bssid.bytes,
17668 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017669 qdf_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017670 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017671 qdf_mem_copy((void *)&pftPreAuthReq->self_mac_addr,
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -070017672 (void *)&pSession->selfMacAddr.bytes, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017673
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017674 if (csr_roam_is11r_assoc(pMac, sessionId) &&
17675 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType !=
17676 eCSR_AUTH_TYPE_OPEN_SYSTEM)) {
17677 pftPreAuthReq->ft_ies_length =
17678 (uint16_t) pSession->ftSmeContext.auth_ft_ies_length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017679 qdf_mem_copy(pftPreAuthReq->ft_ies,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017680 pSession->ftSmeContext.auth_ft_ies,
17681 pSession->ftSmeContext.auth_ft_ies_length);
Deepak Dhamdhereadd334b2016-01-09 23:40:33 -080017682 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017683 pftPreAuthReq->ft_ies_length = 0;
17684 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017685 qdf_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017686 sizeof(pBssDescription->length) + pBssDescription->length);
17687 pftPreAuthReq->length = auth_req_len;
17688 return cds_send_mb_message_to_mac(pftPreAuthReq);
17689}
17690
17691/*--------------------------------------------------------------------------
17692 * This will receive and process the FT Pre Auth Rsp from the current
17693 * associated ap.
17694 *
17695 * This will invoke the hdd call back. This is so that hdd can now
17696 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
17697 ------------------------------------------------------------------------*/
17698void csr_roam_ft_pre_auth_rsp_processor(tHalHandle hHal,
17699 tpSirFTPreAuthRsp pFTPreAuthRsp)
17700{
17701 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017702 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017703 tCsrRoamInfo roamInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017704 eCsrAuthType conn_Auth_type;
17705 uint32_t sessionId = pFTPreAuthRsp->smeSessionId;
17706 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17707
17708 if (NULL == pSession) {
17709 sms_log(pMac, LOGE, FL("pSession is NULL"));
17710 return;
17711 }
Deepak Dhamdhere42b5c112015-11-07 00:23:22 -080017712 status = csr_neighbor_roam_preauth_rsp_handler(pMac,
17713 pFTPreAuthRsp->smeSessionId,
17714 pFTPreAuthRsp->status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017715 if (status != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017716 /*
17717 * Bail out if pre-auth was not even processed.
17718 */
17719 sms_log(pMac, LOGE,
17720 FL("Preauth was not processed: %d SessionID: %d"),
17721 status, sessionId);
17722 return;
17723 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017724
17725 /* The below function calls/timers should be invoked only if the pre-auth is successful */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017726 if (QDF_STATUS_SUCCESS != (QDF_STATUS) pFTPreAuthRsp->status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017727 return;
17728 /* Implies a success */
17729 pSession->ftSmeContext.FTState = eFT_AUTH_COMPLETE;
17730 /* Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs */
17731 pSession->ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
17732 /* No need to notify qos module if this is a non 11r & ESE roam */
17733 if (csr_roam_is11r_assoc(pMac, pFTPreAuthRsp->smeSessionId)
17734#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
17735 || csr_roam_is_ese_assoc(pMac, pFTPreAuthRsp->smeSessionId)
17736#endif
17737 ) {
17738 sme_qos_csr_event_ind(pMac,
17739 pSession->ftSmeContext.smeSessionId,
17740 SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17741 }
17742 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17743 * actual transition from the current to handoff AP is triggered */
17744 status =
Anurag Chouhan210db072016-02-22 18:42:15 +053017745 qdf_mc_timer_start(&pSession->ftSmeContext.preAuthReassocIntvlTimer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017746 60);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017747 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017748 sms_log(pMac, LOGE,
17749 FL
17750 ("Preauth reassoc interval timer start failed to start with status %d"),
17751 status);
17752 return;
17753 }
17754 /* Save the received response */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017755 qdf_mem_copy((void *)&pSession->ftSmeContext.preAuthbssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053017756 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017757 if (csr_roam_is11r_assoc(pMac, pFTPreAuthRsp->smeSessionId))
17758 csr_roam_call_callback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17759 eCSR_ROAM_FT_RESPONSE,
17760 eCSR_ROAM_RESULT_NONE);
17761
17762#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17763 if (csr_roam_is_ese_assoc(pMac, pFTPreAuthRsp->smeSessionId)) {
17764 /* read TSF */
17765 csr_roam_read_tsf(pMac, (uint8_t *) roamInfo.timestamp,
17766 pFTPreAuthRsp->smeSessionId);
17767 /* Save the bssid from the received response */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017768 qdf_mem_copy((void *)&roamInfo.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017769 (void *)pFTPreAuthRsp->preAuthbssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053017770 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017771 csr_roam_call_callback(pMac, pFTPreAuthRsp->smeSessionId,
17772 &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY,
17773 0);
17774 }
17775#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
17776
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017777 /* If Legacy Fast Roaming is enabled, signal the supplicant */
17778 /* So he can send us a PMK-ID for this candidate AP. */
17779 if (csr_roam_is_fast_roam_enabled(pMac, pFTPreAuthRsp->smeSessionId)) {
17780 /* Save the bssid from the received response */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017781 qdf_mem_copy((void *)&roamInfo.bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017782 (void *)pFTPreAuthRsp->preAuthbssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053017783 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017784 csr_roam_call_callback(pMac, pFTPreAuthRsp->smeSessionId,
17785 &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17786 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017787
17788 /* If its an Open Auth, FT IEs are not provided by supplicant */
17789 /* Hence populate them here */
17790 conn_Auth_type =
17791 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
17792
17793 pSession->ftSmeContext.addMDIE = false;
Mukul Sharma156278d2015-10-23 14:03:14 +053017794
17795 /* Done with it, init it. */
17796 pSession->ftSmeContext.psavedFTPreAuthRsp = NULL;
17797
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017798 if (csr_roam_is11r_assoc(pMac, pFTPreAuthRsp->smeSessionId) &&
17799 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM)) {
17800 uint16_t ft_ies_length;
17801 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
17802
17803 if ((pSession->ftSmeContext.reassoc_ft_ies) &&
17804 (pSession->ftSmeContext.reassoc_ft_ies_length)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017805 qdf_mem_free(pSession->ftSmeContext.reassoc_ft_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017806 pSession->ftSmeContext.reassoc_ft_ies_length = 0;
17807 pSession->ftSmeContext.reassoc_ft_ies = NULL;
17808 }
17809
Edhar, Mahesh Kumar394c3542015-10-30 11:48:42 +053017810 if (!ft_ies_length)
17811 return;
17812
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017813 pSession->ftSmeContext.reassoc_ft_ies =
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017814 qdf_mem_malloc(ft_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017815 if (NULL == pSession->ftSmeContext.reassoc_ft_ies) {
17816 sms_log(pMac, LOGE,
17817 FL("Memory allocation failed for ft_ies"));
17818 return;
17819 } else {
17820 /* Copy the RIC IEs to reassoc IEs */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017821 qdf_mem_copy(((uint8_t *) pSession->ftSmeContext.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017822 reassoc_ft_ies),
17823 (uint8_t *) pFTPreAuthRsp->ric_ies,
17824 pFTPreAuthRsp->ric_ies_length);
17825 pSession->ftSmeContext.reassoc_ft_ies_length =
17826 ft_ies_length;
17827 pSession->ftSmeContext.addMDIE = true;
17828 }
17829 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017830}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017831
17832
17833/*
17834 pBuf points to the beginning of the message
17835 LIM packs disassoc rsp as below,
17836 messageType - 2 bytes
17837 messageLength - 2 bytes
17838 sessionId - 1 byte
17839 transactionId - 2 bytes (uint16_t)
17840 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17841 peerMacAddr - 6 bytes
17842 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17843 */
17844static void csr_ser_des_unpack_diassoc_rsp(uint8_t *pBuf, tSirSmeDisassocRsp *pRsp)
17845{
17846 if (pBuf && pRsp) {
17847 pBuf += 4; /* skip type and length */
17848 pRsp->sessionId = *pBuf++;
Anurag Chouhanc5548422016-02-24 18:33:27 +053017849 qdf_get_u16(pBuf, (uint16_t *) &pRsp->transactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017850 pBuf += 2;
Anurag Chouhanc5548422016-02-24 18:33:27 +053017851 qdf_get_u32(pBuf, (uint32_t *) &pRsp->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017852 pBuf += 4;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017853 qdf_mem_copy(pRsp->peer_macaddr.bytes, pBuf, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017854 }
17855}
17856
Anurag Chouhan6d760662016-02-20 16:05:43 +053017857/* Returns whether a session is in QDF_STA_MODE...or not */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017858bool csr_roam_is_sta_mode(tpAniSirGlobal pMac, uint32_t sessionId)
17859{
17860 tCsrRoamSession *pSession = NULL;
17861 pSession = CSR_GET_SESSION(pMac, sessionId);
17862 if (!pSession) {
17863 sms_log(pMac, LOGE, FL(" %s: session %d not found "), __func__,
17864 sessionId);
17865 return false;
17866 }
17867 if (!CSR_IS_SESSION_VALID(pMac, sessionId)) {
17868 sms_log(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17869 return false;
17870 }
17871 if (eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType) {
17872 return false;
17873 }
17874 /* There is a possibility that the above check may fail,because
17875 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17876 * when it is connected.So,we may sneak through the above check even
17877 * if we are not a STA mode INFRA station. So, if we sneak through
17878 * the above condition, we can use the following check if we are
17879 * really in STA Mode.*/
17880
17881 if (NULL != pSession->pCurRoamProfile) {
Anurag Chouhan6d760662016-02-20 16:05:43 +053017882 if (pSession->pCurRoamProfile->csrPersona == QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017883 return true;
17884 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017885 return false;
17886 }
17887 }
17888
17889 return false;
17890}
17891
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017892QDF_STATUS csr_handoff_request(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017893 uint8_t sessionId,
17894 tCsrHandoffRequest *pHandoffInfo)
17895{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017896 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017897 cds_msg_t msg;
17898
17899 tAniHandoffReq *pMsg;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017900 pMsg = qdf_mem_malloc(sizeof(tAniHandoffReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017901 if (NULL == pMsg) {
17902 sms_log(pMac, LOGE,
17903 " csr_handoff_request: failed to allocate mem for req ");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017904 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017905 }
17906 pMsg->msgType = eWNI_SME_HANDOFF_REQ;
17907 pMsg->msgLen = (uint16_t) sizeof(tAniHandoffReq);
17908 pMsg->sessionId = sessionId;
17909 pMsg->channel = pHandoffInfo->channel;
17910 pMsg->handoff_src = pHandoffInfo->src;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017911 qdf_mem_copy(pMsg->bssid, pHandoffInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017912 msg.type = eWNI_SME_HANDOFF_REQ;
17913 msg.bodyptr = pMsg;
17914 msg.reserved = 0;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017915 if (QDF_STATUS_SUCCESS != cds_mq_post_message(CDS_MQ_ID_SME, &msg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017916 sms_log(pMac, LOGE,
17917 " csr_handoff_request failed to post msg to self ");
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017918 qdf_mem_free((void *)pMsg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017919 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017920 }
17921 return status;
17922}
17923
17924#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17925/* ---------------------------------------------------------------------------
17926 \fn csr_set_cckm_ie
17927 \brief This function stores the CCKM IE passed by the supplicant
17928 in a place holder data structure and this IE will be packed inside
17929 reassociation request
17930 \param pMac - pMac global structure
17931 \param sessionId - Current session id
17932 \param pCckmIe - pointer to CCKM IE data
17933 \param ccKmIeLen - length of the CCKM IE
17934 \- return Success or failure
17935 -------------------------------------------------------------------------*/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017936QDF_STATUS csr_set_cckm_ie(tpAniSirGlobal pMac, const uint8_t sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017937 const uint8_t *pCckmIe, const uint8_t ccKmIeLen)
17938{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017939 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017940 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17941 if (!pSession) {
17942 sms_log(pMac, LOGE, FL(" session %d not found "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017943 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017944 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017945 qdf_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017946 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17947 return status;
17948}
17949
17950/* ---------------------------------------------------------------------------
17951 \fn csr_roam_read_tsf
17952 \brief This function reads the TSF; and also add the time elapsed since
17953 last beacon or probe response reception from the hand off AP to arrive at
17954 the latest TSF value.
17955 \param pMac - pMac global structure
17956 \param pTimestamp - output TSF timestamp
17957 \- return Success or failure
17958 -------------------------------------------------------------------------*/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017959QDF_STATUS csr_roam_read_tsf(tpAniSirGlobal pMac, uint8_t *pTimestamp,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017960 uint8_t sessionId)
17961{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017962 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017963 tCsrNeighborRoamBSSInfo handoffNode;
17964 uint32_t timer_diff = 0;
17965 uint32_t timeStamp[2];
17966 tpSirBssDescription pBssDescription = NULL;
17967 csr_neighbor_roam_get_handoff_ap_info(pMac, &handoffNode, sessionId);
17968 pBssDescription = handoffNode.pBssDescription;
17969 /* Get the time diff in milli seconds */
17970 timer_diff =
Anurag Chouhan210db072016-02-22 18:42:15 +053017971 qdf_mc_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017972 /* Convert msec to micro sec timer */
17973 timer_diff = (uint32_t) (timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17974 timeStamp[0] = pBssDescription->timeStamp[0];
17975 timeStamp[1] = pBssDescription->timeStamp[1];
17976 update_cckmtsf(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053017977 qdf_mem_copy(pTimestamp, (void *)&timeStamp[0], sizeof(uint32_t) * 2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017978 return status;
17979}
17980#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
17981
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080017982/**
17983 * csr_roam_channel_change_req() - Post channel change request to LIM
17984 * @pMac: mac context
17985 * @bssid: SAP bssid
17986 * @ch_params: channel information
17987 * @profile: CSR profile
17988 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017989 * This API is primarily used to post
17990 * Channel Change Req for SAP
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080017991 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017992 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017993 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017994QDF_STATUS csr_roam_channel_change_req(tpAniSirGlobal pMac,
Amar Singhale4f28ee2015-10-21 14:36:56 -070017995 struct qdf_mac_addr bssid,
17996 struct ch_params_s *ch_params,
17997 tCsrRoamProfile *profile)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080017998{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053017999 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018000 tSirChanChangeRequest *pMsg;
18001 tCsrRoamStartBssParams param;
18002
18003 csr_roam_get_bss_start_parms(pMac, profile, &param);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018004 pMsg = qdf_mem_malloc(sizeof(tSirChanChangeRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018005 if (!pMsg) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018006 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018007 }
18008
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018009 qdf_mem_set((void *)pMsg, sizeof(tSirChanChangeRequest), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018010
18011 pMsg->messageType = eWNI_SME_CHANNEL_CHANGE_REQ;
18012 pMsg->messageLen = sizeof(tSirChanChangeRequest);
18013 pMsg->targetChannel = profile->ChannelInfo.ChannelList[0];
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080018014 pMsg->sec_ch_offset = ch_params->sec_ch_offset;
18015 pMsg->ch_width = profile->ch_params.ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018016 pMsg->dot11mode = csr_translate_to_wni_cfg_dot11_mode(pMac,
18017 pMac->roam.configParam.uCfgDot11Mode);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080018018 pMsg->center_freq_seg_0 = ch_params->center_freq_seg0;
18019 pMsg->center_freq_seg_1 = ch_params->center_freq_seg1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018020 qdf_mem_copy(pMsg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
18021 qdf_mem_copy(&pMsg->operational_rateset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018022 &param.operationalRateSet, sizeof(pMsg->operational_rateset));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018023 qdf_mem_copy(&pMsg->extended_rateset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018024 &param.extendedRateSet, sizeof(pMsg->extended_rateset));
18025 status = cds_send_mb_message_to_mac(pMsg);
18026
18027 return status;
18028}
18029
18030/*
18031 * Post Beacon Tx Start request to LIM
18032 * immediately after SAP CAC WAIT is
18033 * completed without any RADAR indications.
18034 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018035QDF_STATUS csr_roam_start_beacon_req(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +053018036 struct qdf_mac_addr bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018037 uint8_t dfsCacWaitStatus)
18038{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018039 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018040 tSirStartBeaconIndication *pMsg;
18041
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018042 pMsg = qdf_mem_malloc(sizeof(tSirStartBeaconIndication));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018043
18044 if (!pMsg) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018045 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018046 }
18047
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018048 qdf_mem_set((void *)pMsg, sizeof(tSirStartBeaconIndication), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018049 pMsg->messageType = eWNI_SME_START_BEACON_REQ;
18050 pMsg->messageLen = sizeof(tSirStartBeaconIndication);
18051 pMsg->beaconStartStatus = dfsCacWaitStatus;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018052 qdf_mem_copy(pMsg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018053
18054 status = cds_send_mb_message_to_mac(pMsg);
18055
18056 return status;
18057}
18058
18059/*----------------------------------------------------------------------------
18060 \fn csr_roam_modify_add_ies
18061 \brief This function sends msg to modify the additional IE buffers in PE
18062 \param pMac - pMac global structure
18063 \param pModifyIE - pointer to tSirModifyIE structure
18064 \param updateType - Type of buffer
18065 \- return Success or failure
18066 -----------------------------------------------------------------------------*/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018067QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018068csr_roam_modify_add_ies(tpAniSirGlobal pMac,
18069 tSirModifyIE *pModifyIE, eUpdateIEsType updateType)
18070{
18071 tpSirModifyIEsInd pModifyAddIEInd = NULL;
18072 uint8_t *pLocalBuffer = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018073 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018074
18075 /* following buffer will be freed by consumer (PE) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018076 pLocalBuffer = qdf_mem_malloc(pModifyIE->ieBufferlength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018077
18078 if (NULL == pLocalBuffer) {
18079 sms_log(pMac, LOGE, FL("Memory Allocation Failure!!!"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018080 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018081 }
18082
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018083 pModifyAddIEInd = qdf_mem_malloc(sizeof(tSirModifyIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018084 if (NULL == pModifyAddIEInd) {
18085 sms_log(pMac, LOGE, FL("Memory Allocation Failure!!!"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018086 qdf_mem_free(pLocalBuffer);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018087 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018088 }
18089
18090 /*copy the IE buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018091 qdf_mem_copy(pLocalBuffer, pModifyIE->pIEBuffer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018092 pModifyIE->ieBufferlength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018093 qdf_mem_zero(pModifyAddIEInd, sizeof(tSirModifyIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018094
18095 pModifyAddIEInd->msgType = eWNI_SME_MODIFY_ADDITIONAL_IES;
18096 pModifyAddIEInd->msgLen = sizeof(tSirModifyIEsInd);
18097
Anurag Chouhanc5548422016-02-24 18:33:27 +053018098 qdf_copy_macaddr(&pModifyAddIEInd->modifyIE.bssid, &pModifyIE->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018099
18100 pModifyAddIEInd->modifyIE.smeSessionId = pModifyIE->smeSessionId;
18101 pModifyAddIEInd->modifyIE.notify = pModifyIE->notify;
18102 pModifyAddIEInd->modifyIE.ieID = pModifyIE->ieID;
18103 pModifyAddIEInd->modifyIE.ieIDLen = pModifyIE->ieIDLen;
18104 pModifyAddIEInd->modifyIE.pIEBuffer = pLocalBuffer;
18105 pModifyAddIEInd->modifyIE.ieBufferlength = pModifyIE->ieBufferlength;
Rajeev Kumar8e3e2832015-11-06 16:02:54 -080018106 pModifyAddIEInd->modifyIE.oui_length = pModifyIE->oui_length;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018107
18108 pModifyAddIEInd->updateType = updateType;
18109
18110 status = cds_send_mb_message_to_mac(pModifyAddIEInd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018111 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018112 sms_log(pMac, LOGE,
18113 FL("Failed to send eWNI_SME_UPDATE_ADDTIONAL_IES msg"
18114 "!!! status %d"), status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018115 qdf_mem_free(pLocalBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018116 }
18117 return status;
18118}
18119
18120/*----------------------------------------------------------------------------
18121 \fn csr_roam_update_add_ies
18122 \brief This function sends msg to updates the additional IE buffers in PE
18123 \param pMac - pMac global structure
18124 \param sessionId - SME session id
18125 \param bssid - BSSID
18126 \param additionIEBuffer - buffer containing addition IE from hostapd
18127 \param length - length of buffer
18128 \param updateType - Type of buffer
18129 \param append - append or replace completely
18130 \- return Success or failure
18131 -----------------------------------------------------------------------------*/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018132QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018133csr_roam_update_add_ies(tpAniSirGlobal pMac,
18134 tSirUpdateIE *pUpdateIE, eUpdateIEsType updateType)
18135{
18136 tpSirUpdateIEsInd pUpdateAddIEs = NULL;
18137 uint8_t *pLocalBuffer = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018138 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018139
18140 if (pUpdateIE->ieBufferlength != 0) {
18141 /* Following buffer will be freed by consumer (PE) */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018142 pLocalBuffer = qdf_mem_malloc(pUpdateIE->ieBufferlength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018143 if (NULL == pLocalBuffer) {
18144 sms_log(pMac, LOGE, FL("Memory Allocation Failure!!!"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018145 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018146 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018147 qdf_mem_copy(pLocalBuffer, pUpdateIE->pAdditionIEBuffer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018148 pUpdateIE->ieBufferlength);
18149 }
18150
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018151 pUpdateAddIEs = qdf_mem_malloc(sizeof(tSirUpdateIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018152 if (NULL == pUpdateAddIEs) {
18153 sms_log(pMac, LOGE, FL("Memory Allocation Failure!!!"));
18154 if (pLocalBuffer != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018155 qdf_mem_free(pLocalBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018156 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018157 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018158 }
18159
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018160 qdf_mem_zero(pUpdateAddIEs, sizeof(tSirUpdateIEsInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018161
18162 pUpdateAddIEs->msgType = eWNI_SME_UPDATE_ADDITIONAL_IES;
18163 pUpdateAddIEs->msgLen = sizeof(tSirUpdateIEsInd);
18164
Anurag Chouhanc5548422016-02-24 18:33:27 +053018165 qdf_copy_macaddr(&pUpdateAddIEs->updateIE.bssid, &pUpdateIE->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018166
18167 pUpdateAddIEs->updateIE.smeSessionId = pUpdateIE->smeSessionId;
18168 pUpdateAddIEs->updateIE.append = pUpdateIE->append;
18169 pUpdateAddIEs->updateIE.notify = pUpdateIE->notify;
18170 pUpdateAddIEs->updateIE.ieBufferlength = pUpdateIE->ieBufferlength;
18171 pUpdateAddIEs->updateIE.pAdditionIEBuffer = pLocalBuffer;
18172
18173 pUpdateAddIEs->updateType = updateType;
18174
18175 status = cds_send_mb_message_to_mac(pUpdateAddIEs);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018176 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018177 sms_log(pMac, LOGE,
18178 FL("Failed to send eWNI_SME_UPDATE_ADDTIONAL_IES msg"
18179 "!!! status %d"), status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018180 qdf_mem_free(pLocalBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018181 }
18182 return status;
18183}
18184
18185/**
Abhishek Singh518323d2015-10-19 17:42:01 +053018186 * csr_send_ext_change_channel()- function to post send ECSA
18187 * action frame to lim.
18188 * @mac_ctx: pointer to global mac structure
18189 * @channel: new channel to switch
18190 * @session_id: senssion it should be sent on.
18191 *
18192 * This function is called to post ECSA frame to lim.
18193 *
18194 * Return: success if msg posted to LIM else return failure
18195 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018196QDF_STATUS csr_send_ext_change_channel(tpAniSirGlobal mac_ctx, uint32_t channel,
Abhishek Singh518323d2015-10-19 17:42:01 +053018197 uint8_t session_id)
18198{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018199 QDF_STATUS status = QDF_STATUS_SUCCESS;
Abhishek Singh518323d2015-10-19 17:42:01 +053018200 struct sir_sme_ext_cng_chan_req *msg;
18201
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018202 msg = qdf_mem_malloc(sizeof(*msg));
Abhishek Singh518323d2015-10-19 17:42:01 +053018203 if (NULL == msg)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018204 return QDF_STATUS_E_NOMEM;
Abhishek Singh518323d2015-10-19 17:42:01 +053018205
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018206 qdf_mem_zero(msg, sizeof(*msg));
Abhishek Singh518323d2015-10-19 17:42:01 +053018207 msg->message_type = eWNI_SME_EXT_CHANGE_CHANNEL;
18208 msg->length = sizeof(*msg);
18209 msg->new_channel = channel;
18210 msg->session_id = session_id;
18211 status = cds_send_mb_message_to_mac(msg);
18212 return status;
18213}
18214
18215/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018216 * csr_roam_send_chan_sw_ie_request() - Request to transmit CSA IE
18217 * @mac_ctx: Global MAC context
18218 * @bssid: BSSID
18219 * @target_channel: Channel on which to send the IE
18220 * @csa_ie_reqd: Include/Exclude CSA IE.
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -080018221 * @ch_params: operating Channel related information
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018222 *
18223 * This function sends request to transmit channel switch announcement
18224 * IE to lower layers
18225 *
18226 * Return: success or failure
18227 **/
Amar Singhale4f28ee2015-10-21 14:36:56 -070018228QDF_STATUS csr_roam_send_chan_sw_ie_request(tpAniSirGlobal mac_ctx,
18229 struct qdf_mac_addr bssid,
18230 uint8_t target_channel,
18231 uint8_t csa_ie_reqd,
18232 struct ch_params_s *ch_params)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018233{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018234 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018235 tSirDfsCsaIeRequest *msg;
18236
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018237 msg = qdf_mem_malloc(sizeof(tSirDfsCsaIeRequest));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018238 if (!msg) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018239 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018240 }
18241
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018242 qdf_mem_set((void *)msg, sizeof(tSirDfsCsaIeRequest), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018243 msg->msgType = eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ;
18244 msg->msgLen = sizeof(tSirDfsCsaIeRequest);
18245
18246 msg->targetChannel = target_channel;
18247 msg->csaIeRequired = csa_ie_reqd;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018248 qdf_mem_copy(msg->bssid, bssid.bytes, QDF_MAC_ADDR_SIZE);
Amar Singhale4f28ee2015-10-21 14:36:56 -070018249 qdf_mem_copy(&msg->ch_params, ch_params, sizeof(struct ch_params_s));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018250
18251 status = cds_send_mb_message_to_mac(msg);
18252
18253 return status;
18254}
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080018255#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
18256/**
18257 * csr_roaming_report_diag_event() - Diag events for LFR3
18258 * @mac_ctx: MAC context
18259 * @roam_synch_ind_ptr: Roam Synch Indication Pointer
18260 * @reason: Reason for this event to happen
18261 *
18262 * The major events in the host for LFR3 roaming such as
18263 * roam synch indication, roam synch completion and
18264 * roam synch handoff fail will be indicated to the
18265 * diag framework using this API.
18266 *
18267 * Return: None
18268 */
18269void csr_roaming_report_diag_event(tpAniSirGlobal mac_ctx,
18270 roam_offload_synch_ind *roam_synch_ind_ptr,
18271 eCsrDiagWlanStatusEventReason reason)
18272{
18273 WLAN_HOST_DIAG_EVENT_DEF(roam_connection,
18274 host_event_wlan_status_payload_type);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018275 qdf_mem_set(&roam_connection,
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080018276 sizeof(host_event_wlan_status_payload_type), 0);
18277 switch (reason) {
18278 case eCSR_REASON_ROAM_SYNCH_IND:
18279 roam_connection.eventId = eCSR_WLAN_STATUS_CONNECT;
18280 if (roam_synch_ind_ptr) {
18281 roam_connection.rssi = roam_synch_ind_ptr->rssi;
18282 roam_connection.channel =
18283 cds_freq_to_chan(roam_synch_ind_ptr->chan_freq);
18284 }
18285 break;
18286 case eCSR_REASON_ROAM_SYNCH_CNF:
18287 roam_connection.eventId = eCSR_WLAN_STATUS_CONNECT;
18288 break;
18289 case eCSR_REASON_ROAM_HO_FAIL:
18290 roam_connection.eventId = eCSR_WLAN_STATUS_DISCONNECT;
18291 break;
18292 default:
18293 sms_log(mac_ctx, LOGE,
18294 FL("LFR3: Unsupported reason %d"), reason);
18295 return;
18296 }
18297 roam_connection.reason = reason;
18298 WLAN_HOST_DIAG_EVENT_REPORT(&roam_connection, EVENT_WLAN_STATUS);
18299}
18300#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018301
18302#ifdef WLAN_FEATURE_ROAM_OFFLOAD
18303/*----------------------------------------------------------------------------
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018304* fn csr_process_ho_fail_ind
18305* brief This function will process the Hand Off Failure indication
18306* received from the firmware. It will trigger a disconnect on
18307* the session which the firmware reported a hand off failure
18308* param pMac global structure
18309* param pMsgBuf - Contains the session ID for which the handler should apply
18310* --------------------------------------------------------------------------*/
18311void csr_process_ho_fail_ind(tpAniSirGlobal pMac, void *pMsgBuf)
18312{
18313 tSirSmeHOFailureInd *pSmeHOFailInd = (tSirSmeHOFailureInd *) pMsgBuf;
18314 uint32_t sessionId;
18315
18316 if (pSmeHOFailInd)
18317 sessionId = pSmeHOFailInd->sessionId;
18318 else {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018319 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018320 "LFR3: Hand-Off Failure Ind is NULL");
18321 return;
18322 }
18323 /* Roaming is supported only on Infra STA Mode. */
18324 if (!csr_roam_is_sta_mode(pMac, sessionId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018325 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018326 "LFR3:HO Fail cannot be handled for session %d",
18327 sessionId);
18328 return;
18329 }
18330 csr_roam_synch_clean_up(pMac, sessionId);
Varun Reddy Yeturubee4f782015-11-02 10:16:05 -080018331 csr_roaming_report_diag_event(pMac, NULL,
18332 eCSR_REASON_ROAM_HO_FAIL);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018333 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018334 "LFR3:Issue Disconnect on session %d", sessionId);
18335 csr_roam_disconnect(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
18336}
18337#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
18338
18339/**
18340 * csr_update_op_class_array() - update op class for each band
18341 * @mac_ctx: mac global context
18342 * @op_classes: out param, operating class array to update
18343 * @channel_info: channel info
18344 * @ch_name: channel band name to display in debug messages
18345 * @i: out param, stores number of operating classes
18346 *
18347 * Return: void
18348 */
18349static void
18350csr_update_op_class_array(tpAniSirGlobal mac_ctx,
18351 uint8_t *op_classes,
18352 tCsrChannel *channel_info,
18353 char *ch_name,
18354 uint8_t *i)
18355{
18356 uint8_t j = 0, idx = 0, class = 0;
18357 bool found = false;
18358 uint8_t num_channels = channel_info->numChannels;
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053018359 uint8_t ch_bandwidth;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018360
18361 sms_log(mac_ctx, LOG1,
18362 FL("Num of %s channels, %d"),
18363 ch_name, num_channels);
18364
18365 for (idx = 0; idx < num_channels
18366 && *i < (SIR_MAC_MAX_SUPP_OPER_CLASSES - 1); idx++) {
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053018367 for (ch_bandwidth = BW20; ch_bandwidth < BWALL;
18368 ch_bandwidth++) {
18369 class = cds_regdm_get_opclass_from_channel(
18370 mac_ctx->scan.countryCodeCurrent,
18371 channel_info->channelList[idx],
18372 ch_bandwidth);
18373 sms_log(mac_ctx, LOG4, FL("for chan %d, op class: %d"),
18374 channel_info->channelList[idx], class);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018375
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053018376 found = false;
18377 for (j = 0; j < SIR_MAC_MAX_SUPP_OPER_CLASSES - 1;
18378 j++) {
18379 if (op_classes[j] == class) {
18380 found = true;
18381 break;
18382 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018383 }
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +053018384
18385 if (!found) {
18386 op_classes[*i] = class;
18387 *i = *i + 1;
18388 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018389 }
18390 }
18391}
18392
18393/**
18394 * csr_update_op_class_array() - update op class for all bands
18395 * @hHal: global hal context
18396 *
18397 * Return: void
18398 */
18399void csr_init_operating_classes(tHalHandle hHal)
18400{
18401 uint8_t i = 0;
18402 uint8_t j = 0;
18403 uint8_t swap = 0;
18404 uint8_t numClasses = 0;
18405 uint8_t opClasses[SIR_MAC_MAX_SUPP_OPER_CLASSES] = {0,};
18406 tpAniSirGlobal pMac = PMAC_STRUCT(hHal);
18407
18408 sms_log(pMac, LOG1, FL("Current Country = %c%c"),
18409 pMac->scan.countryCodeCurrent[0],
18410 pMac->scan.countryCodeCurrent[1]);
18411
18412 csr_update_op_class_array(pMac, opClasses,
18413 &pMac->scan.base_channels, "20MHz", &i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018414 numClasses = i;
18415
18416 /* As per spec the operating classes should be in ascending order.
18417 * Bubble sort is fine since we don't have many classes
18418 */
18419 for (i = 0; i < (numClasses - 1); i++) {
18420 for (j = 0; j < (numClasses - i - 1); j++) {
18421 /* For decreasing order use < */
18422 if (opClasses[j] > opClasses[j + 1]) {
18423 swap = opClasses[j];
18424 opClasses[j] = opClasses[j + 1];
18425 opClasses[j + 1] = swap;
18426 }
18427 }
18428 }
18429
18430 sms_log(pMac, LOG1, FL("Number of unique supported op classes %d"),
18431 numClasses);
18432 for (i = 0; i < numClasses; i++) {
18433 sms_log(pMac, LOG1, FL("supported opClasses[%d] = %d"), i,
18434 opClasses[i]);
18435 }
18436
18437 /* Set the ordered list of op classes in regdomain
18438 * for use by other modules
18439 */
18440 cds_regdm_set_curr_opclasses(numClasses, &opClasses[0]);
18441}
18442
18443/**
18444 * csr_find_session_by_type() - This function will find given session type from
18445 * all sessions.
18446 * @mac_ctx: pointer to mac context.
18447 * @type: session type
18448 *
18449 * Return: session id for give session type.
18450 **/
18451static uint32_t
Anurag Chouhan6d760662016-02-20 16:05:43 +053018452csr_find_session_by_type(tpAniSirGlobal mac_ctx, enum tQDF_ADAPTER_MODE type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018453{
18454 uint32_t i, session_id = CSR_SESSION_ID_INVALID;
18455 tCsrRoamSession *session_ptr;
18456 for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) {
18457 if (!CSR_IS_SESSION_VALID(mac_ctx, i))
18458 continue;
18459
18460 session_ptr = CSR_GET_SESSION(mac_ctx, i);
18461 if (type == session_ptr->bssParams.bssPersona) {
18462 session_id = i;
18463 break;
18464 }
18465 }
18466 return session_id;
18467}
18468/**
18469 * csr_is_conn_allow_2g_band() - This function will check if station's conn
18470 * is allowed in 2.4Ghz band.
18471 * @mac_ctx: pointer to mac context.
18472 * @chnl: station's channel.
18473 *
18474 * This function will check if station's connection is allowed in 5Ghz band
18475 * after comparing it with SAP's operating channel. If SAP's operating
18476 * channel and Station's channel is different than this function will return
18477 * false else true.
18478 *
18479 * Return: true or false.
18480 **/
18481static bool csr_is_conn_allow_2g_band(tpAniSirGlobal mac_ctx, uint32_t chnl)
18482{
18483 uint32_t sap_session_id;
18484 tCsrRoamSession *sap_session;
18485
18486 if (0 == chnl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018487 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018488 FL("channel is zero, connection not allowed"));
18489
18490 return false;
18491 }
18492
Anurag Chouhan6d760662016-02-20 16:05:43 +053018493 sap_session_id = csr_find_session_by_type(mac_ctx, QDF_SAP_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018494 if (CSR_SESSION_ID_INVALID != sap_session_id) {
18495 sap_session = CSR_GET_SESSION(mac_ctx, sap_session_id);
18496 if ((0 != sap_session->bssParams.operationChn) &&
18497 (sap_session->bssParams.operationChn != chnl)) {
18498
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018499 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018500 FL
18501 ("Can't allow STA to connect, chnls not same"));
18502 return false;
18503 }
18504 }
18505 return true;
18506}
18507
18508/**
18509 * csr_is_conn_allow_5g_band() - This function will check if station's conn
18510 * is allowed in 5Ghz band.
18511 * @mac_ctx: pointer to mac context.
18512 * @chnl: station's channel.
18513 *
18514 * This function will check if station's connection is allowed in 5Ghz band
18515 * after comparing it with P2PGO's operating channel. If P2PGO's operating
18516 * channel and Station's channel is different than this function will return
18517 * false else true.
18518 *
18519 * Return: true or false.
18520 **/
18521static bool csr_is_conn_allow_5g_band(tpAniSirGlobal mac_ctx, uint32_t chnl)
18522{
18523 uint32_t p2pgo_session_id;
18524 tCsrRoamSession *p2pgo_session;
18525
18526 if (0 == chnl) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018527 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018528 FL
18529 ("channel is zero, connection not allowed"));
18530 return false;
18531 }
18532
Anurag Chouhan6d760662016-02-20 16:05:43 +053018533 p2pgo_session_id = csr_find_session_by_type(mac_ctx, QDF_P2P_GO_MODE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018534 if (CSR_SESSION_ID_INVALID != p2pgo_session_id) {
18535 p2pgo_session = CSR_GET_SESSION(mac_ctx, p2pgo_session_id);
18536 if ((0 != p2pgo_session->bssParams.operationChn) &&
18537 (eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED !=
18538 p2pgo_session->connectState) &&
18539 (p2pgo_session->bssParams.operationChn !=
18540 chnl)) {
18541
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018542 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018543 FL
18544 ("Can't allow STA to connect, chnls not same"));
18545 return false;
18546 }
18547 }
18548 return true;
18549}
18550
18551/**
18552 * csr_clear_joinreq_param() - This function will clear station's params
18553 * for stored join request to csr.
18554 * @hal_handle: pointer to hal context.
18555 * @session_id: station's session id.
18556 *
18557 * This function will clear station's allocated memory for cached join
18558 * request.
18559 *
18560 * Return: true or false based on function's overall success.
18561 **/
18562bool csr_clear_joinreq_param(tpAniSirGlobal mac_ctx,
18563 uint32_t session_id)
18564{
18565 tCsrRoamSession *sta_session;
18566 tScanResultList *bss_list;
18567
18568 if (NULL == mac_ctx)
18569 return false;
18570
18571 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
18572 if (NULL == sta_session)
18573 return false;
18574
18575 /* Release the memory allocated by previous join request */
18576 bss_list =
18577 (tScanResultList *)&sta_session->stored_roam_profile.
18578 bsslist_handle;
18579 if (NULL != bss_list) {
18580 csr_scan_result_purge(mac_ctx,
18581 sta_session->stored_roam_profile.bsslist_handle);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018582 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018583 FL("bss list is released for session %d"), session_id);
18584 sta_session->stored_roam_profile.bsslist_handle = NULL;
18585 }
18586 sta_session->stored_roam_profile.bsslist_handle = NULL;
18587 csr_release_profile(mac_ctx, &sta_session->stored_roam_profile.profile);
18588 sta_session->stored_roam_profile.reason = 0;
18589 sta_session->stored_roam_profile.roam_id = 0;
18590 sta_session->stored_roam_profile.imediate_flag = false;
18591 sta_session->stored_roam_profile.clear_flag = false;
18592 return true;
18593}
18594
18595/**
18596 * csr_store_joinreq_param() - This function will store station's join
18597 * request to that station's session.
18598 * @mac_ctx: pointer to mac context.
18599 * @profile: pointer to station's roam profile.
18600 * @scan_cache: pointer to station's scan cache.
18601 * @roam_id: reference to roam_id variable being passed.
18602 * @session_id: station's session id.
18603 *
18604 * This function will store station's join request to one of the
18605 * csr structure and add it to station's session.
18606 *
18607 * Return: true or false based on function's overall success.
18608 **/
18609bool csr_store_joinreq_param(tpAniSirGlobal mac_ctx,
18610 tCsrRoamProfile *profile,
18611 tScanResultHandle scan_cache,
18612 uint32_t *roam_id,
18613 uint32_t session_id)
18614{
18615 tCsrRoamSession *sta_session;
18616
18617 if (NULL == mac_ctx)
18618 return false;
18619
18620 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
18621 if (NULL == sta_session)
18622 return false;
18623
18624 sta_session->stored_roam_profile.session_id = session_id;
18625 csr_roam_copy_profile(mac_ctx,
18626 &sta_session->stored_roam_profile.profile, profile);
18627 /* new bsslist_handle's memory will be relased later */
18628 sta_session->stored_roam_profile.bsslist_handle = scan_cache;
18629 sta_session->stored_roam_profile.reason = eCsrHddIssued;
18630 sta_session->stored_roam_profile.roam_id = *roam_id;
18631 sta_session->stored_roam_profile.imediate_flag = false;
18632 sta_session->stored_roam_profile.clear_flag = false;
18633
18634 return true;
18635}
18636
18637/**
18638 * csr_issue_stored_joinreq() - This function will issues station's stored
18639 * the join request.
18640 * @mac_ctx: pointer to mac context.
18641 * @roam_id: reference to roam_id variable being passed.
18642 * @session_id: station's session id.
18643 *
18644 * This function will issue station's stored join request, from this point
18645 * onwards the flow will be just like normal connect request.
18646 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018647 * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018648 **/
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018649QDF_STATUS csr_issue_stored_joinreq(tpAniSirGlobal mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018650 uint32_t *roam_id,
18651 uint32_t session_id)
18652{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018653 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018654 tCsrRoamSession *sta_session;
18655 uint32_t new_roam_id;
18656
18657 sta_session = CSR_GET_SESSION(mac_ctx, session_id);
18658 if (NULL == sta_session)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018659 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018660 new_roam_id = GET_NEXT_ROAM_ID(&mac_ctx->roam);
18661 *roam_id = new_roam_id;
18662 status = csr_roam_issue_connect(mac_ctx,
18663 sta_session->stored_roam_profile.session_id,
18664 &sta_session->stored_roam_profile.profile,
18665 sta_session->stored_roam_profile.bsslist_handle,
18666 sta_session->stored_roam_profile.reason,
18667 new_roam_id,
18668 sta_session->stored_roam_profile.imediate_flag,
18669 sta_session->stored_roam_profile.clear_flag);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018670 if (QDF_STATUS_SUCCESS != status) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018671 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018672 FL
18673 ("CSR failed issuing connect cmd with status = 0x%08X"),
18674 status);
18675 csr_clear_joinreq_param(mac_ctx, session_id);
18676 }
18677 return status;
18678}
18679
18680/**
18681 * csr_process_set_hw_mode() - Set HW mode command to PE
18682 * @mac: Globacl MAC pointer
18683 * @command: Command received from SME
18684 *
18685 * Posts the set HW mode command to PE. This message passing
18686 * through PE is required for PE's internal management
18687 *
18688 * Return: None
18689 */
18690void csr_process_set_hw_mode(tpAniSirGlobal mac, tSmeCmd *command)
18691{
18692 uint32_t len;
18693 struct s_sir_set_hw_mode *cmd;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018694 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018695 tSirMsgQ msg;
18696 struct sir_set_hw_mode_resp *param;
18697
18698 /* Setting HW mode is for the entire system.
18699 * So, no need to check session
18700 */
18701
18702 if (!command) {
18703 sms_log(mac, LOGE, FL("Set HW mode param is NULL"));
18704 goto fail;
18705 }
18706
18707 len = sizeof(*cmd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018708 cmd = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018709 if (!cmd) {
18710 sms_log(mac, LOGE, FL("Memory allocation failed"));
18711 /* Probably the fail response will also fail during malloc.
18712 * Still proceeding to send response!
18713 */
18714 goto fail;
18715 }
18716
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053018717 /* For hidden SSID case, if there is any scan command pending
18718 * it needs to be cleared before issuing set HW mode
18719 */
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053018720 if (command->u.set_hw_mode_cmd.reason == SIR_UPDATE_REASON_HIDDEN_STA) {
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053018721 sms_log(mac, LOGE, FL("clear any pending scan command"));
18722 status = csr_scan_abort_mac_scan_not_for_connect(mac,
18723 command->u.set_hw_mode_cmd.session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018724 if (!QDF_IS_STATUS_SUCCESS(status)) {
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053018725 sms_log(mac, LOGE, FL("Failed to clear scan cmd"));
18726 goto fail;
18727 }
18728 }
18729
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018730 qdf_mem_set(cmd, len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018731
18732 cmd->messageType = eWNI_SME_SET_HW_MODE_REQ;
18733 cmd->length = len;
18734 cmd->set_hw.hw_mode_index = command->u.set_hw_mode_cmd.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +053018735 cmd->set_hw.reason = command->u.set_hw_mode_cmd.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018736 /*
18737 * Below callback and context info are not needed for PE as of now.
18738 * Storing the passed value in the same s_sir_set_hw_mode format.
18739 */
18740 cmd->set_hw.set_hw_mode_cb = command->u.set_hw_mode_cmd.set_hw_mode_cb;
18741
18742 sms_log(mac, LOG1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +053018743 FL("Posting set hw mode req to PE session:%d reason:%d"),
18744 command->u.set_hw_mode_cmd.session_id,
18745 command->u.set_hw_mode_cmd.reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018746
18747 status = cds_send_mb_message_to_mac(cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018748 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018749 sms_log(mac, LOGE, FL("Posting to PE failed"));
18750 return;
18751 }
18752 return;
18753fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018754 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018755 if (!param) {
18756 sms_log(mac, LOGE,
18757 FL("Malloc fail: Fail to send response to SME"));
18758 return;
18759 }
18760 sms_log(mac, LOGE, FL("Sending set HW fail response to SME"));
18761 param->status = SET_HW_MODE_STATUS_ECANCELED;
18762 param->cfgd_hw_mode_index = 0;
18763 param->num_vdev_mac_entries = 0;
18764 msg.type = eWNI_SME_SET_HW_MODE_RESP;
18765 msg.bodyptr = param;
18766 msg.bodyval = 0;
18767 sys_process_mmh_msg(mac, &msg);
18768}
18769
18770/**
18771 * csr_process_set_dual_mac_config() - Set HW mode command to PE
18772 * @mac: Global MAC pointer
18773 * @command: Command received from SME
18774 *
18775 * Posts the set dual mac config command to PE.
18776 *
18777 * Return: None
18778 */
18779void csr_process_set_dual_mac_config(tpAniSirGlobal mac, tSmeCmd *command)
18780{
18781 uint32_t len;
18782 struct sir_set_dual_mac_cfg *cmd;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018783 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018784 tSirMsgQ msg;
18785 struct sir_dual_mac_config_resp *param;
18786
18787 /* Setting MAC configuration is for the entire system.
18788 * So, no need to check session
18789 */
18790
18791 if (!command) {
18792 sms_log(mac, LOGE, FL("Set HW mode param is NULL"));
18793 goto fail;
18794 }
18795
18796 len = sizeof(*cmd);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018797 cmd = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018798 if (!cmd) {
18799 sms_log(mac, LOGE, FL("Memory allocation failed"));
18800 /* Probably the fail response will also fail during malloc.
18801 * Still proceeding to send response!
18802 */
18803 goto fail;
18804 }
18805
18806 cmd->message_type = eWNI_SME_SET_DUAL_MAC_CFG_REQ;
18807 cmd->length = len;
18808 cmd->set_dual_mac.scan_config = command->u.set_dual_mac_cmd.scan_config;
18809 cmd->set_dual_mac.fw_mode_config =
18810 command->u.set_dual_mac_cmd.fw_mode_config;
18811 /*
18812 * Below callback and context info are not needed for PE as of now.
18813 * Storing the passed value in the same sir_set_dual_mac_cfg format.
18814 */
18815 cmd->set_dual_mac.set_dual_mac_cb =
18816 command->u.set_dual_mac_cmd.set_dual_mac_cb;
18817
18818 sms_log(mac, LOG1,
18819 FL("Posting eWNI_SME_SET_DUAL_MAC_CFG_REQ to PE: %x %x"),
18820 cmd->set_dual_mac.scan_config,
18821 cmd->set_dual_mac.fw_mode_config);
18822
18823 status = cds_send_mb_message_to_mac(cmd);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018824 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018825 sms_log(mac, LOGE, FL("Posting to PE failed"));
18826 return;
18827 }
18828 return;
18829fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018830 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018831 if (!param) {
18832 sms_log(mac, LOGE,
18833 FL("Malloc fail: Fail to send response to SME"));
18834 return;
18835 }
18836 sms_log(mac, LOGE, FL("Sending set dual mac fail response to SME"));
18837 param->status = SET_HW_MODE_STATUS_ECANCELED;
18838 msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
18839 msg.bodyptr = param;
18840 msg.bodyval = 0;
18841 sys_process_mmh_msg(mac, &msg);
18842}
18843
18844/**
18845 * csr_process_nss_update_req() - Update nss command to PE
18846 * @mac: Globacl MAC pointer
18847 * @command: Command received from SME
18848 *
18849 * Posts the nss update command to PE. This message passing
18850 * through PE is required for PE's internal management
18851 *
18852 * Return: None
18853 */
18854void csr_process_nss_update_req(tpAniSirGlobal mac, tSmeCmd *command)
18855{
18856 uint32_t len;
18857 struct sir_nss_update_request *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018858 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018859 tSirMsgQ msg_return;
18860 struct sir_beacon_tx_complete_rsp *param;
18861
18862 tCsrRoamSession *session =
18863 CSR_GET_SESSION(mac, command->sessionId);
18864
18865 if (!session) {
18866 sms_log(mac, LOGE, FL("Session not found"));
18867 goto fail;
18868 }
18869
18870 if (!command) {
18871 sms_log(mac, LOGE, FL("nss update param is NULL"));
18872 goto fail;
18873 }
18874
18875 len = sizeof(*msg);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018876 msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018877 if (!msg) {
18878 sms_log(mac, LOGE, FL("Memory allocation failed"));
18879 /* Probably the fail response is also fail during malloc.
18880 * Still proceeding to send response!
18881 */
18882 goto fail;
18883 }
18884
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018885 qdf_mem_set((void *)msg, sizeof(*msg), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018886 msg->msgType = eWNI_SME_NSS_UPDATE_REQ;
18887 msg->msgLen = sizeof(*msg);
18888
18889 msg->new_nss = command->u.nss_update_cmd.new_nss;
18890 msg->vdev_id = command->u.nss_update_cmd.session_id;
18891
18892 sms_log(mac, LOG1,
18893 FL("Posting eWNI_SME_NSS_UPDATE_REQ to PE"));
18894
18895 status = cds_send_mb_message_to_mac(msg);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018896 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018897 sms_log(mac, LOGE, FL("Posting to PE failed"));
18898 return;
18899 }
18900 return;
18901fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018902 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018903 if (!param) {
18904 sms_log(mac, LOGE,
18905 FL("Malloc fail: Fail to send response to SME"));
18906 return;
18907 }
18908 sms_log(mac, LOGE, FL("Sending nss update fail response to SME"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018909 param->tx_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080018910 param->session_id = command->u.nss_update_cmd.session_id;
18911 msg_return.type = eWNI_SME_NSS_UPDATE_RSP;
18912 msg_return.bodyptr = param;
18913 msg_return.bodyval = 0;
18914 sys_process_mmh_msg(mac, &msg_return);
18915}
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018916#ifdef FEATURE_WLAN_TDLS
18917/**
18918 * csr_roam_fill_tdls_info() - Fill TDLS information
18919 * @roam_info: Roaming information buffer
18920 * @join_rsp: Join response which has TDLS info
18921 *
18922 * Return: None
18923 */
18924void csr_roam_fill_tdls_info(tCsrRoamInfo *roam_info, tpSirSmeJoinRsp join_rsp)
18925{
18926 roam_info->tdls_prohibited = join_rsp->tdls_prohibited;
18927 roam_info->tdls_chan_swit_prohibited =
18928 join_rsp->tdls_chan_swit_prohibited;
18929}
18930#endif
18931
18932/**
18933 * csr_roam_synch_callback() - SME level callback for roam synch propagation
18934 * @mac_ctx: MAC Context
18935 * @roam_synch_data: Roam synch data buffer pointer
18936 * @bss_desc: BSS descriptor pointer
18937 * @reason: Reason for calling the callback
18938 *
18939 * This callback is registered with WMA and used after roaming happens in
18940 * firmware and the call to this routine completes the roam synch
18941 * propagation at both CSR and HDD levels. The HDD level propagation
18942 * is achieved through the already defined callback for assoc completion
18943 * handler.
18944 *
18945 * Return: None.
18946 */
18947void csr_roam_synch_callback(tpAniSirGlobal mac_ctx,
18948 roam_offload_synch_ind *roam_synch_data,
18949 tpSirBssDescription bss_desc, uint8_t reason)
18950{
18951 uint8_t session_id = roam_synch_data->roamedVdevId;
18952 tCsrRoamSession *session = CSR_GET_SESSION(mac_ctx, session_id);
18953 tDot11fBeaconIEs *ies_local = NULL;
18954 struct ps_global_info *ps_global_info = &mac_ctx->sme.ps_global_info;
18955 tCsrRoamInfo *roam_info;
18956 tCsrRoamConnectedProfile *conn_profile = NULL;
18957 sme_QosAssocInfo assoc_info;
Anurag Chouhan6d760662016-02-20 16:05:43 +053018958 struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018959 tpAddBssParams add_bss_params;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018960 QDF_STATUS status = QDF_STATUS_SUCCESS;
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018961
18962 status = sme_acquire_global_lock(&mac_ctx->sme);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018963 if (!QDF_IS_STATUS_SUCCESS(status)) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018964 sms_log(mac_ctx, LOGE, FL("LFR3: Locking failed, bailing out"));
18965 return;
18966 }
18967 if (!session) {
18968 sms_log(mac_ctx, LOGE, FL("LFR3: Session not found"));
18969 sme_release_global_lock(&mac_ctx->sme);
18970 return;
18971 }
18972 session->roam_synch_in_progress = true;
18973 if (reason == ROAMING_TX_QUEUE_DISABLE) {
18974 csr_roam_call_callback(mac_ctx, session_id, NULL, 0,
18975 eCSR_ROAM_FT_START, eSIR_SME_SUCCESS);
18976 sme_release_global_lock(&mac_ctx->sme);
18977 return;
18978 }
18979 session->roam_synch_data = roam_synch_data;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053018980 if (!QDF_IS_STATUS_SUCCESS(csr_get_parsed_bss_description_ies(mac_ctx,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018981 bss_desc, &ies_local))) {
18982 sms_log(mac_ctx, LOGE, FL("LFR3: fail to parse IEs"));
18983 session->roam_synch_in_progress = false;
18984 sme_release_global_lock(&mac_ctx->sme);
18985 return;
18986 }
18987 conn_profile = &session->connectedProfile;
18988 csr_roam_stop_network(mac_ctx, session_id,
18989 session->pCurRoamProfile,
18990 bss_desc,
18991 ies_local);
18992 ps_global_info->remain_in_power_active_till_dhcp = false;
18993 session->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053018994 roam_info = qdf_mem_malloc(sizeof(tCsrRoamInfo));
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018995 if (NULL == roam_info) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053018996 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080018997 FL("LFR3: Mem Alloc failed for roam info"));
18998 session->roam_synch_in_progress = false;
18999 sme_release_global_lock(&mac_ctx->sme);
19000 return;
19001 }
19002 csr_scan_save_roam_offload_ap_to_scan_cache(mac_ctx, roam_synch_data,
19003 bss_desc);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019004 qdf_mem_zero(roam_info, sizeof(tCsrRoamInfo));
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019005 roam_info->sessionId = session_id;
19006 csr_roam_call_callback(mac_ctx, roam_synch_data->roamedVdevId,
19007 roam_info, 0, eCSR_ROAM_TDLS_STATUS_UPDATE,
19008 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019009 qdf_mem_copy(&roam_info->bssid.bytes, &bss_desc->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +053019010 sizeof(struct qdf_mac_addr));
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019011 csr_roam_save_connected_infomation(mac_ctx, session_id,
19012 session->pCurRoamProfile,
19013 bss_desc,
19014 ies_local);
19015 csr_roam_save_security_rsp_ie(mac_ctx, session_id,
19016 session->pCurRoamProfile->negotiatedAuthType,
19017 bss_desc, ies_local);
19018 roam_info->isESEAssoc = conn_profile->isESEAssoc;
19019 if (CSR_IS_ENC_TYPE_STATIC
19020 (session->pCurRoamProfile->negotiatedUCEncryptionType) &&
19021 !session->pCurRoamProfile->bWPSAssociation) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019022 if (!QDF_IS_STATUS_SUCCESS(
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019023 csr_roam_issue_set_context_req(mac_ctx,
19024 session_id,
19025 session->pCurRoamProfile->negotiatedUCEncryptionType,
19026 bss_desc,
19027 &(bss_desc->bssId),
19028 false, true,
19029 eSIR_TX_RX, 0, 0, NULL, 0))) {
19030 /* NO keys. these key parameters don't matter */
19031 sms_log(mac_ctx, LOGE,
19032 FL("Set context for unicast fail"));
19033 csr_roam_substate_change(mac_ctx,
19034 eCSR_ROAM_SUBSTATE_NONE, session_id);
19035 }
19036 csr_roam_issue_set_context_req(mac_ctx, session_id,
19037 session->pCurRoamProfile->negotiatedMCEncryptionType,
19038 bss_desc,
19039 &bcast_mac.bytes, false, false,
19040 eSIR_TX_RX, 0, 0, NULL, 0);
19041 }
19042 if ((roam_synch_data->authStatus
19043 == CSR_ROAM_AUTH_STATUS_AUTHENTICATED)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019044 QDF_TRACE(QDF_MODULE_ID_SME,
19045 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019046 FL("LFR3:Don't start waitforkey timer"));
19047 csr_roam_substate_change(mac_ctx,
19048 eCSR_ROAM_SUBSTATE_NONE, session_id);
19049 } else {
19050 roam_info->fAuthRequired = true;
19051 csr_roam_substate_change(mac_ctx,
19052 eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY,
19053 session_id);
19054
19055 ps_global_info->remain_in_power_active_till_dhcp = true;
19056 mac_ctx->roam.WaitForKeyTimerInfo.sessionId = session_id;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +053019057 if (!QDF_IS_STATUS_SUCCESS(csr_roam_start_wait_for_key_timer(
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019058 mac_ctx, CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD))
19059 ) {
19060 sms_log(mac_ctx, LOGE, FL
19061 ("Failed wait for key timer start"));
19062 csr_roam_substate_change(mac_ctx,
19063 eCSR_ROAM_SUBSTATE_NONE,
19064 session_id);
19065 }
19066 }
19067 roam_info->nBeaconLength = 0;
19068 roam_info->nAssocReqLength = roam_synch_data->reassoc_req_length -
19069 SIR_MAC_HDR_LEN_3A - SIR_MAC_REASSOC_SSID_OFFSET;
19070 roam_info->nAssocRspLength = roam_synch_data->reassocRespLength -
19071 SIR_MAC_HDR_LEN_3A;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019072 roam_info->pbFrames = qdf_mem_malloc(roam_info->nBeaconLength +
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019073 roam_info->nAssocReqLength + roam_info->nAssocRspLength);
19074 if (NULL == roam_info->pbFrames) {
19075 sms_log(mac_ctx, LOGE, FL("no memory available"));
19076 session->roam_synch_in_progress = false;
19077 if (roam_info)
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019078 qdf_mem_free(roam_info);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019079 sme_release_global_lock(&mac_ctx->sme);
19080 return;
19081 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019082 qdf_mem_zero(roam_info->pbFrames, roam_info->nBeaconLength +
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019083 roam_info->nAssocReqLength + roam_info->nAssocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019084 qdf_mem_copy(roam_info->pbFrames,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019085 (uint8_t *)roam_synch_data +
19086 roam_synch_data->reassoc_req_offset +
19087 SIR_MAC_HDR_LEN_3A + SIR_MAC_REASSOC_SSID_OFFSET,
19088 roam_info->nAssocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019089 qdf_mem_copy(roam_info->pbFrames + roam_info->nAssocReqLength,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019090 (uint8_t *)roam_synch_data +
19091 roam_synch_data->reassocRespOffset +
19092 SIR_MAC_HDR_LEN_3A,
19093 roam_info->nAssocRspLength);
19094
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019095 QDF_TRACE(QDF_MODULE_ID_SME,
19096 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019097 FL("LFR3:Clear Connected info"));
19098 csr_roam_free_connected_info(mac_ctx,
19099 &session->connectedInfo);
19100 conn_profile->vht_channel_width =
19101 roam_synch_data->join_rsp->vht_channel_width;
19102 add_bss_params = (tpAddBssParams)roam_synch_data->add_bss_params;
19103 session->connectedInfo.staId = add_bss_params->staContext.staIdx;
19104 roam_info->staId = session->connectedInfo.staId;
19105 roam_info->ucastSig =
19106 (uint8_t) roam_synch_data->join_rsp->ucastSig;
19107 roam_info->bcastSig =
19108 (uint8_t) roam_synch_data->join_rsp->bcastSig;
19109 roam_info->timingMeasCap =
19110 roam_synch_data->join_rsp->timingMeasCap;
19111 roam_info->chan_info.nss = roam_synch_data->join_rsp->nss;
19112 roam_info->chan_info.rate_flags =
19113 roam_synch_data->join_rsp->max_rate_flags;
19114 csr_roam_fill_tdls_info(roam_info, roam_synch_data->join_rsp);
19115 sms_log(mac_ctx, LOG1,
19116 FL("tdls:prohibit: %d, chan_swit_prohibit: %d"),
19117 roam_info->tdls_prohibited,
19118 roam_info->tdls_chan_swit_prohibited);
19119#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
19120 src_profile = &roam_synch_data->join_rsp->HTProfile;
19121 dst_profile = &conn_profile->HTProfile;
19122 if (mac_ctx->roam.configParam.cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +053019123 != QDF_MCC_TO_SCC_SWITCH_DISABLE)
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019124 csr_roam_copy_ht_profile(dst_profile,
19125 src_profile);
19126#endif
19127 assoc_info.pBssDesc = bss_desc;
19128 roam_info->statusCode = eSIR_SME_SUCCESS;
19129 roam_info->reasonCode = eSIR_SME_SUCCESS;
19130 assoc_info.pProfile = session->pCurRoamProfile;
19131 mac_ctx->roam.roamSession[session_id].connectState =
19132 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
19133 sme_qos_csr_event_ind(mac_ctx, session_id,
19134 SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
19135 sme_qos_csr_event_ind(mac_ctx, session_id,
19136 SME_QOS_CSR_REASSOC_REQ, NULL);
19137 sme_qos_csr_event_ind(mac_ctx, session_id,
19138 SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
19139 mac_ctx->roam.roamSession[session_id].connectState =
19140 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
19141 sme_qos_csr_event_ind(mac_ctx, session_id,
19142 SME_QOS_CSR_REASSOC_COMPLETE, &assoc_info);
19143 roam_info->pBssDesc = bss_desc;
19144 conn_profile->acm_mask = sme_qos_get_acm_mask(mac_ctx,
19145 bss_desc, NULL);
19146 if (conn_profile->modifyProfileFields.uapsd_mask) {
Varun Reddy Yeturu90444892016-02-04 10:43:20 -080019147 sms_log(mac_ctx, LOG1,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019148 " uapsd_mask (0x%X) set, request UAPSD now",
19149 conn_profile->modifyProfileFields.uapsd_mask);
19150 sme_ps_start_uapsd(mac_ctx, session_id,
19151 NULL, NULL);
19152 }
19153 conn_profile->dot11Mode = session->bssParams.uCfgDot11Mode;
19154 roam_info->u.pConnectedProfile = conn_profile;
19155
19156 if (!IS_FEATURE_SUPPORTED_BY_FW
19157 (SLM_SESSIONIZATION) &&
19158 (csr_is_concurrent_session_running(mac_ctx))) {
19159 mac_ctx->roam.configParam.doBMPSWorkaround = 1;
19160 }
19161 roam_info->roamSynchInProgress = true;
19162 roam_info->synchAuthStatus = roam_synch_data->authStatus;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019163 qdf_mem_copy(roam_info->kck, roam_synch_data->kck, SIR_KCK_KEY_LEN);
19164 qdf_mem_copy(roam_info->kek, roam_synch_data->kek, SIR_KEK_KEY_LEN);
19165 qdf_mem_copy(roam_info->replay_ctr, roam_synch_data->replay_ctr,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019166 SIR_REPLAY_CTR_LEN);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019167 QDF_TRACE(QDF_MODULE_ID_SME, QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019168 FL("LFR3: Copy KCK, KEK and Replay Ctr"));
19169 roam_info->subnet_change_status =
19170 CSR_GET_SUBNET_STATUS(roam_synch_data->roamReason);
19171 csr_roam_call_callback(mac_ctx, session_id, roam_info, 0,
19172 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
19173 csr_reset_pmkid_candidate_list(mac_ctx, session_id);
19174#ifdef FEATURE_WLAN_WAPI
19175 csr_reset_bkid_candidate_list(mac_ctx, session_id);
19176#endif
19177 if (!CSR_IS_WAIT_FOR_KEY(mac_ctx, session_id)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053019178 QDF_TRACE(QDF_MODULE_ID_SME,
19179 QDF_TRACE_LEVEL_DEBUG,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019180 FL
19181 ("NO CSR_IS_WAIT_FOR_KEY -> csr_roam_link_up"));
19182 csr_roam_link_up(mac_ctx, conn_profile->bssid);
19183 }
19184 session->fRoaming = false;
19185 session->roam_synch_in_progress = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053019186 qdf_mem_free(roam_info->pbFrames);
19187 qdf_mem_free(roam_info);
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -080019188 sme_release_global_lock(&mac_ctx->sme);
19189}