blob: 6d2b68d7ecf5ab3850b8caa29d6b7b16832ee530 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Abhishek Singhcfb44482017-03-10 12:42:37 +05302 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**=========================================================================
29
30 \file lim_session.c
31
32 \brief implementation for lim Session related APIs
33
34 \author Sunit Bhatia
35
36 ========================================================================*/
37
38/*--------------------------------------------------------------------------
39 Include Files
40 ------------------------------------------------------------------------*/
41#include "ani_global.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080042#include "lim_ft_defs.h"
43#include "lim_ft.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080044#include "lim_session.h"
45#include "lim_utils.h"
46
47#include "sch_api.h"
48#include "lim_send_messages.h"
49
50/*--------------------------------------------------------------------------
51
52 \brief pe_init_beacon_params() - Initialize the beaconParams structure
53
54 \param tpPESession - pointer to the session context or NULL if session can not be created.
55 \return void
56 \sa
57
58 --------------------------------------------------------------------------*/
59
Jeff Johnson97699002016-10-07 07:32:55 -070060static void pe_init_beacon_params(tpAniSirGlobal pMac,
61 tpPESession psessionEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080062{
63 psessionEntry->beaconParams.beaconInterval = 0;
64 psessionEntry->beaconParams.fShortPreamble = 0;
65 psessionEntry->beaconParams.llaCoexist = 0;
66 psessionEntry->beaconParams.llbCoexist = 0;
67 psessionEntry->beaconParams.llgCoexist = 0;
68 psessionEntry->beaconParams.ht20Coexist = 0;
69 psessionEntry->beaconParams.llnNonGFCoexist = 0;
70 psessionEntry->beaconParams.fRIFSMode = 0;
71 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = 0;
72 psessionEntry->beaconParams.gHTObssMode = 0;
73
74 /* Number of legacy STAs associated */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053075 qdf_mem_set((void *)&psessionEntry->gLim11bParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080076 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053077 qdf_mem_set((void *)&psessionEntry->gLim11aParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080078 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053079 qdf_mem_set((void *)&psessionEntry->gLim11gParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053081 qdf_mem_set((void *)&psessionEntry->gLimNonGfParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053083 qdf_mem_set((void *)&psessionEntry->gLimHt20Params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053085 qdf_mem_set((void *)&psessionEntry->gLimLsigTxopParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053087 qdf_mem_set((void *)&psessionEntry->gLimOlbcParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088 sizeof(tLimProtStaParams), 0);
89}
90
91/*
92 * pe_reset_protection_callback() - resets protection structs so that when an AP
93 * causing use of protection goes away, corresponding protection bit can be
94 * reset
95 * @ptr: pointer to pSessionEntry
96 *
97 * This function resets protection structs so that when an AP causing use of
98 * protection goes away, corresponding protection bit can be reset. This allowes
99 * protection bits to be reset once legacy overlapping APs are gone.
100 *
101 * Return: void
102 */
Jeff Johnson97699002016-10-07 07:32:55 -0700103static void pe_reset_protection_callback(void *ptr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800104{
105 tpPESession pe_session_entry = (tpPESession)ptr;
106 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)pe_session_entry->mac_ctx;
107 int8_t i = 0;
108 tUpdateBeaconParams beacon_params;
109 uint16_t current_protection_state = 0;
110 tpDphHashNode station_hash_node = NULL;
111 tSirMacHTOperatingMode old_op_mode;
112 bool bcn_prms_changed = false;
113
114 if (pe_session_entry->valid == false) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530115 pe_err("session already deleted. exiting timer callback");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800116 return;
117 }
118
Manishekar Chandrasekaran9e8c7be2016-08-03 14:57:14 +0530119 /*
120 * During CAC period, if the callback is triggered, the beacon
121 * template may get updated. Subsequently if the vdev is not up, the
122 * vdev would be made up -- which should not happen during the CAC
123 * period. To avoid this, ignore the protection callback if the session
124 * is not yet up.
125 */
126 if (!wma_is_vdev_up(pe_session_entry->smeSessionId)) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530127 pe_err("session is not up yet. exiting timer callback");
Manishekar Chandrasekaran9e8c7be2016-08-03 14:57:14 +0530128 return;
129 }
130
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800131 current_protection_state |=
132 pe_session_entry->gLimOverlap11gParams.protectionEnabled |
133 pe_session_entry->gLimOverlap11aParams.protectionEnabled << 1 |
134 pe_session_entry->gLimOverlapHt20Params.protectionEnabled << 2 |
135 pe_session_entry->gLimOverlapNonGfParams.protectionEnabled << 3 |
136 pe_session_entry->gLimOlbcParams.protectionEnabled << 4;
137
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530138 pe_debug("old protection state: 0x%04X, new protection state: 0x%04X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139 pe_session_entry->old_protection_state,
140 current_protection_state);
141
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530142 qdf_mem_zero(&pe_session_entry->gLimOverlap11gParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800143 sizeof(pe_session_entry->gLimOverlap11gParams));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530144 qdf_mem_zero(&pe_session_entry->gLimOverlap11aParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800145 sizeof(pe_session_entry->gLimOverlap11aParams));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530146 qdf_mem_zero(&pe_session_entry->gLimOverlapHt20Params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800147 sizeof(pe_session_entry->gLimOverlapHt20Params));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530148 qdf_mem_zero(&pe_session_entry->gLimOverlapNonGfParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 sizeof(pe_session_entry->gLimOverlapNonGfParams));
150
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530151 qdf_mem_zero(&pe_session_entry->gLimOlbcParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 sizeof(pe_session_entry->gLimOlbcParams));
153
Abhishek Singhaf7e7fa2016-08-08 17:59:31 +0530154 /*
155 * Do not reset fShortPreamble and beaconInterval, as they
156 * are not updated.
157 */
158 pe_session_entry->beaconParams.llaCoexist = 0;
159 pe_session_entry->beaconParams.llbCoexist = 0;
160 pe_session_entry->beaconParams.llgCoexist = 0;
161 pe_session_entry->beaconParams.ht20Coexist = 0;
162 pe_session_entry->beaconParams.llnNonGFCoexist = 0;
163 pe_session_entry->beaconParams.fRIFSMode = 0;
164 pe_session_entry->beaconParams.fLsigTXOPProtectionFullSupport = 0;
165 pe_session_entry->beaconParams.gHTObssMode = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530167 qdf_mem_zero(&mac_ctx->lim.gLimOverlap11gParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 sizeof(mac_ctx->lim.gLimOverlap11gParams));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530169 qdf_mem_zero(&mac_ctx->lim.gLimOverlap11aParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 sizeof(mac_ctx->lim.gLimOverlap11aParams));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530171 qdf_mem_zero(&mac_ctx->lim.gLimOverlapHt20Params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 sizeof(mac_ctx->lim.gLimOverlapHt20Params));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530173 qdf_mem_zero(&mac_ctx->lim.gLimOverlapNonGfParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 sizeof(mac_ctx->lim.gLimOverlapNonGfParams));
175
176 old_op_mode = pe_session_entry->htOperMode;
177 pe_session_entry->htOperMode = eSIR_HT_OP_MODE_PURE;
Masti, Narayanraddi4d8860c2016-08-22 15:46:48 +0530178 mac_ctx->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530180 qdf_mem_zero(&beacon_params, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800181 /* index 0, is self node, peers start from 1 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530182 for (i = 1 ; i <= mac_ctx->lim.gLimAssocStaLimit ; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183 station_hash_node = dph_get_hash_entry(mac_ctx, i,
184 &pe_session_entry->dph.dphHashTable);
185 if (NULL == station_hash_node)
186 continue;
187 lim_decide_ap_protection(mac_ctx, station_hash_node->staAddr,
188 &beacon_params, pe_session_entry);
189 }
190
191 if (pe_session_entry->htOperMode != old_op_mode)
192 bcn_prms_changed = true;
193
194 if ((current_protection_state !=
195 pe_session_entry->old_protection_state) &&
196 (false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530197 pe_debug("protection changed, update beacon template");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800198 /* update beacon fix params and send update to FW */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530199 qdf_mem_zero(&beacon_params, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800200 beacon_params.bssIdx = pe_session_entry->bssIdx;
201 beacon_params.fShortPreamble =
202 pe_session_entry->beaconParams.fShortPreamble;
203 beacon_params.beaconInterval =
204 pe_session_entry->beaconParams.beaconInterval;
205 beacon_params.llaCoexist =
206 pe_session_entry->beaconParams.llaCoexist;
207 beacon_params.llbCoexist =
208 pe_session_entry->beaconParams.llbCoexist;
209 beacon_params.llgCoexist =
210 pe_session_entry->beaconParams.llgCoexist;
211 beacon_params.ht20MhzCoexist =
212 pe_session_entry->beaconParams.ht20Coexist;
213 beacon_params.llnNonGFCoexist =
214 pe_session_entry->beaconParams.llnNonGFCoexist;
215 beacon_params.fLsigTXOPProtectionFullSupport =
216 pe_session_entry->beaconParams.
217 fLsigTXOPProtectionFullSupport;
218 beacon_params.fRIFSMode =
219 pe_session_entry->beaconParams.fRIFSMode;
220 beacon_params.smeSessionId =
221 pe_session_entry->smeSessionId;
Selvaraj, Sridhardc038ee2016-06-24 15:22:14 +0530222 beacon_params.paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223 bcn_prms_changed = true;
224 }
225
226 if (bcn_prms_changed) {
227 sch_set_fixed_beacon_fields(mac_ctx, pe_session_entry);
228 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session_entry);
229 }
230
231 pe_session_entry->old_protection_state = current_protection_state;
Anurag Chouhan210db072016-02-22 18:42:15 +0530232 if (qdf_mc_timer_start(&pe_session_entry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 protection_fields_reset_timer,
234 SCH_PROTECTION_RESET_TIME)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530235 != QDF_STATUS_SUCCESS) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530236 pe_err("cannot create or start protectionFieldsResetTimer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237 }
238}
239
Abhishek Singhcfb44482017-03-10 12:42:37 +0530240#ifdef WLAN_FEATURE_11W
241/**
242 * pe_init_pmf_comeback_timer: init PMF comeback timer
243 * @mac_ctx: pointer to global adapter context
244 * @session: pe session
245 * @session_id: session ID
246 *
247 * Return: void
248 */
249static void pe_init_pmf_comeback_timer(tpAniSirGlobal mac_ctx,
250tpPESession session, uint8_t session_id)
251{
252 QDF_STATUS status;
253
254 session->pmfComebackTimerInfo.pMac = mac_ctx;
255 session->pmfComebackTimerInfo.sessionID = session_id;
256 status = qdf_mc_timer_init(&session->pmfComebackTimer,
257 QDF_TIMER_TYPE_SW, lim_pmf_comeback_timer_callback,
258 (void *)&session->pmfComebackTimerInfo);
259 if (!QDF_IS_STATUS_SUCCESS(status))
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530260 pe_err("cannot init pmf comeback timer");
Abhishek Singhcfb44482017-03-10 12:42:37 +0530261}
262#else
263static inline void
264pe_init_pmf_comeback_timer(tpAniSirGlobal mac_ctx,
265 tpPESession session, uint8_t session_id)
266{
267}
268#endif
269
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530270#ifdef WLAN_FEATURE_FILS_SK
271/**
272 * pe_delete_fils_info: API to delete fils session info
273 * @session: pe session
274 *
275 * Return: void
276 */
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530277void pe_delete_fils_info(tpPESession session)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530278{
279 struct pe_fils_session *fils_info;
280
281 if (!session || (session && !session->valid)) {
282 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
283 FL("session is not valid"));
284 return;
285 }
286 fils_info = session->fils_info;
287 if (!fils_info) {
288 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
289 FL("fils info not found"));
290 return;
291 }
292 if (fils_info->keyname_nai_data)
293 qdf_mem_free(fils_info->keyname_nai_data);
294 if (fils_info->fils_erp_reauth_pkt)
295 qdf_mem_free(fils_info->fils_erp_reauth_pkt);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +0530296 if (fils_info->fils_rrk)
297 qdf_mem_free(fils_info->fils_rrk);
298 if (fils_info->fils_rik)
299 qdf_mem_free(fils_info->fils_rik);
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530300 if (fils_info->fils_eap_finish_pkt)
301 qdf_mem_free(fils_info->fils_eap_finish_pkt);
302 if (fils_info->fils_rmsk)
303 qdf_mem_free(fils_info->fils_rmsk);
304 if (fils_info->fils_pmk)
305 qdf_mem_free(fils_info->fils_pmk);
306 if (fils_info->auth_info.keyname)
307 qdf_mem_free(fils_info->auth_info.keyname);
308 if (fils_info->auth_info.domain_name)
309 qdf_mem_free(fils_info->auth_info.domain_name);
Vignesh Viswanathana1bb0922017-09-15 12:58:48 +0530310 if (fils_info->hlp_data)
311 qdf_mem_free(fils_info->hlp_data);
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530312 qdf_mem_free(fils_info);
313 session->fils_info = NULL;
314}
315/**
316 * pe_init_fils_info: API to initialize fils session info elements to null
317 * @session: pe session
318 *
319 * Return: void
320 */
321static void pe_init_fils_info(tpPESession session)
322{
323 struct pe_fils_session *fils_info;
324
325 if (!session || (session && !session->valid)) {
326 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
327 FL("session is not valid"));
328 return;
329 }
330 session->fils_info = qdf_mem_malloc(sizeof(struct pe_fils_session));
331 fils_info = session->fils_info;
332 if (!fils_info) {
333 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
334 FL("fils info not found"));
335 return;
336 }
337 fils_info->keyname_nai_data = NULL;
338 fils_info->fils_erp_reauth_pkt = NULL;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +0530339 fils_info->fils_rrk = NULL;
340 fils_info->fils_rik = NULL;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530341 fils_info->fils_eap_finish_pkt = NULL;
342 fils_info->fils_rmsk = NULL;
343 fils_info->fils_pmk = NULL;
344 fils_info->auth_info.keyname = NULL;
345 fils_info->auth_info.domain_name = NULL;
346}
347#else
348static void pe_delete_fils_info(tpPESession session) { }
349static void pe_init_fils_info(tpPESession session) { }
350#endif
351
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352/**
Abhishek Singh47888602017-05-10 12:50:50 +0530353 * lim_get_peer_idxpool_size: get number of peer idx pool size
354 * @num_sta: Max number of STA
355 * @bss_type: BSS type
356 *
357 * The peer index start from 1 and thus index 0 is not used, so
358 * add 1 to the max sta. For STA if TDLS is enabled add 2 as
359 * index 1 is reserved for peer BSS.
360 *
361 * Return: number of peer idx pool size
362 */
363#ifdef FEATURE_WLAN_TDLS
364static inline uint8_t
365lim_get_peer_idxpool_size(uint16_t num_sta, tSirBssType bss_type)
366{
367 /*
368 * In station role, index 1 is reserved for peer
369 * corresponding to AP. For TDLS the index should
370 * start from 2
371 */
372 if (bss_type == eSIR_INFRASTRUCTURE_MODE)
373 return num_sta + 2;
374 else
375 return num_sta + 1;
376
377}
378#else
379static inline uint8_t
380lim_get_peer_idxpool_size(uint16_t num_sta, tSirBssType bss_type)
381{
382 return num_sta + 1;
383}
384#endif
385
386/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387 * pe_create_session() creates a new PE session given the BSSID
388 * @param pMac: pointer to global adapter context
389 * @param bssid: BSSID of the new session
390 * @param sessionId: session ID is returned here, if session is created.
391 * @param bssType: station or a
392 *
393 * This function returns the session context and the session ID if the session
394 * corresponding to the passed BSSID is found in the PE session table.
395 *
396 * Return: tpPESession: pointer to the session context or NULL if session
397 * can not be created.
398 */
399
400tpPESession
401pe_create_session(tpAniSirGlobal pMac, uint8_t *bssid, uint8_t *sessionId,
402 uint16_t numSta, tSirBssType bssType)
403{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530404 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 uint8_t i;
406 tpPESession session_ptr;
407 for (i = 0; i < pMac->lim.maxBssId; i++) {
408 /* Find first free room in session table */
409 if (pMac->lim.gpSession[i].valid == true)
410 continue;
411 break;
412 }
413
414 if (i == pMac->lim.maxBssId) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530415 pe_err("Session can't be created. Reached max sessions");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416 return NULL;
417 }
418
419 session_ptr = &pMac->lim.gpSession[i];
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530420 qdf_mem_set((void *)session_ptr, sizeof(tPESession), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421 /* Allocate space for Station Table for this session. */
422 session_ptr->dph.dphHashTable.pHashTable =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530423 qdf_mem_malloc(sizeof(tpDphHashNode) * (numSta + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800424 if (NULL == session_ptr->dph.dphHashTable.pHashTable) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530425 pe_err("memory allocate failed!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800426 return NULL;
427 }
428
429 session_ptr->dph.dphHashTable.pDphNodeArray =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530430 qdf_mem_malloc(sizeof(tDphHashNode) * (numSta + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 if (NULL == session_ptr->dph.dphHashTable.pDphNodeArray) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530432 pe_err("memory allocate failed!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530433 qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 session_ptr->dph.dphHashTable.
435 pHashTable = NULL;
436 return NULL;
437 }
438
Abhishek Singh47888602017-05-10 12:50:50 +0530439
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440 session_ptr->dph.dphHashTable.size = numSta + 1;
441 dph_hash_table_class_init(pMac, &session_ptr->dph.dphHashTable);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530442 session_ptr->gpLimPeerIdxpool = qdf_mem_malloc(
Abhishek Singh47888602017-05-10 12:50:50 +0530443 sizeof(*(session_ptr->gpLimPeerIdxpool)) *
444 lim_get_peer_idxpool_size(numSta, bssType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800445 if (NULL == session_ptr->gpLimPeerIdxpool) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530446 pe_err("memory allocate failed!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530447 qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable);
448 qdf_mem_free(session_ptr->dph.dphHashTable.pDphNodeArray);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800449 session_ptr->dph.dphHashTable.pHashTable = NULL;
450 session_ptr->dph.dphHashTable.pDphNodeArray = NULL;
451 return NULL;
452 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800453 session_ptr->freePeerIdxHead = 0;
454 session_ptr->freePeerIdxTail = 0;
455 session_ptr->gLimNumOfCurrentSTAs = 0;
456 /* Copy the BSSID to the session table */
457 sir_copy_mac_addr(session_ptr->bssId, bssid);
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700458 if (bssType == eSIR_MONITOR_MODE)
459 sir_copy_mac_addr(pMac->lim.gpSession[i].selfMacAddr, bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460 session_ptr->valid = true;
461 /* Intialize the SME and MLM states to IDLE */
462 session_ptr->limMlmState = eLIM_MLM_IDLE_STATE;
463 session_ptr->limSmeState = eLIM_SME_IDLE_STATE;
464 session_ptr->limCurrentAuthType = eSIR_OPEN_SYSTEM;
465 pe_init_beacon_params(pMac, &pMac->lim.gpSession[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466 session_ptr->is11Rconnection = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800467#ifdef FEATURE_WLAN_ESE
468 session_ptr->isESEconnection = false;
469#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470 session_ptr->isFastTransitionEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800471 session_ptr->isFastRoamIniFeatureEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 *sessionId = i;
473 session_ptr->gLimPhyMode = WNI_CFG_PHY_MODE_11G;
474 /* Initialize CB mode variables when session is created */
475 session_ptr->htSupportedChannelWidthSet = 0;
476 session_ptr->htRecommendedTxWidthSet = 0;
477 session_ptr->htSecondaryChannelOffset = 0;
478#ifdef FEATURE_WLAN_TDLS
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530479 qdf_mem_set(session_ptr->peerAIDBitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 sizeof(session_ptr->peerAIDBitmap), 0);
481 session_ptr->tdls_prohibited = false;
482 session_ptr->tdls_chan_swit_prohibited = false;
483#endif
484 session_ptr->fWaitForProbeRsp = 0;
485 session_ptr->fIgnoreCapsChange = 0;
Selvaraj, Sridhar5b5a0652017-05-04 11:23:07 +0530486 session_ptr->ignore_assoc_disallowed = pMac->ignore_assoc_disallowed;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530488 pe_debug("Create a new PE session: %d BSSID: "MAC_ADDRESS_STR" Max No of STA: %d",
Kapil Guptabf4943c2016-10-13 12:15:39 +0530489 *sessionId, MAC_ADDR_ARRAY(bssid), numSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800490
Rajeev Kumarcf835a02016-04-15 15:01:31 -0700491 if (eSIR_INFRA_AP_MODE == bssType || eSIR_IBSS_MODE == bssType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800492 session_ptr->pSchProbeRspTemplate =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530493 qdf_mem_malloc(SCH_MAX_PROBE_RESP_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494 session_ptr->pSchBeaconFrameBegin =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530495 qdf_mem_malloc(SCH_MAX_BEACON_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800496 session_ptr->pSchBeaconFrameEnd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530497 qdf_mem_malloc(SCH_MAX_BEACON_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800498 if ((NULL == session_ptr->pSchProbeRspTemplate)
499 || (NULL == session_ptr->pSchBeaconFrameBegin)
500 || (NULL == session_ptr->pSchBeaconFrameEnd)) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530501 pe_err("memory allocate failed!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530502 qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable);
503 qdf_mem_free(session_ptr->dph.dphHashTable.pDphNodeArray);
504 qdf_mem_free(session_ptr->gpLimPeerIdxpool);
505 qdf_mem_free(session_ptr->pSchProbeRspTemplate);
506 qdf_mem_free(session_ptr->pSchBeaconFrameBegin);
507 qdf_mem_free(session_ptr->pSchBeaconFrameEnd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800508
509 session_ptr->dph.dphHashTable.pHashTable = NULL;
510 session_ptr->dph.dphHashTable.pDphNodeArray = NULL;
511 session_ptr->gpLimPeerIdxpool = NULL;
512 session_ptr->pSchProbeRspTemplate = NULL;
513 session_ptr->pSchBeaconFrameBegin = NULL;
514 session_ptr->pSchBeaconFrameEnd = NULL;
515 return NULL;
516 }
517 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800518 if (eSIR_INFRASTRUCTURE_MODE == bssType)
519 lim_ft_open(pMac, &pMac->lim.gpSession[i]);
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700520
521 if (eSIR_MONITOR_MODE == bssType)
522 lim_ft_open(pMac, &pMac->lim.gpSession[i]);
523
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800524 if (eSIR_INFRA_AP_MODE == bssType) {
525 session_ptr->old_protection_state = 0;
526 session_ptr->mac_ctx = (void *)pMac;
Anurag Chouhan210db072016-02-22 18:42:15 +0530527 status = qdf_mc_timer_init(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800528 &session_ptr->protection_fields_reset_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530529 QDF_TIMER_TYPE_SW, pe_reset_protection_callback,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800530 (void *)&pMac->lim.gpSession[i]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530531 if (status == QDF_STATUS_SUCCESS) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530532 status = qdf_mc_timer_start(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800533 &session_ptr->protection_fields_reset_timer,
534 SCH_PROTECTION_RESET_TIME);
535 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530536 if (status != QDF_STATUS_SUCCESS)
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530537 pe_err("cannot create or start protectionFieldsResetTimer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800538 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530539 pe_init_fils_info(session_ptr);
Abhishek Singhcfb44482017-03-10 12:42:37 +0530540 pe_init_pmf_comeback_timer(pMac, session_ptr, *sessionId);
Tushnim Bhattacharyya3d17def2017-06-19 11:13:43 -0700541 session_ptr->ht_client_cnt = 0;
Naveen Rawat6fc3c502017-09-06 16:14:11 -0700542 /* following is invalid value since seq number is 12 bit */
543 session_ptr->prev_auth_seq_num = 0xFFFF;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -0800544
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545 return &pMac->lim.gpSession[i];
546}
547
548/*--------------------------------------------------------------------------
549 \brief pe_find_session_by_bssid() - looks up the PE session given the BSSID.
550
551 This function returns the session context and the session ID if the session
552 corresponding to the given BSSID is found in the PE session table.
553
554 \param pMac - pointer to global adapter context
555 \param bssid - BSSID of the session
556 \param sessionId -session ID is returned here, if session is found.
557
558 \return tpPESession - pointer to the session context or NULL if session is not found.
559
560 \sa
561 --------------------------------------------------------------------------*/
562tpPESession pe_find_session_by_bssid(tpAniSirGlobal pMac, uint8_t *bssid,
563 uint8_t *sessionId)
564{
565 uint8_t i;
566
567 for (i = 0; i < pMac->lim.maxBssId; i++) {
568 /* If BSSID matches return corresponding tables address */
569 if ((pMac->lim.gpSession[i].valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530570 && (sir_compare_mac_addr(pMac->lim.gpSession[i].bssId,
571 bssid))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800572 *sessionId = i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530573 return &pMac->lim.gpSession[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574 }
575 }
576
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530577 pe_debug("Session lookup fails for BSSID:");
578 lim_print_mac_addr(pMac, bssid, LOGD);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530579 return NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800580
581}
582
583/*--------------------------------------------------------------------------
584 \brief pe_find_session_by_bss_idx() - looks up the PE session given the bssIdx.
585
586 This function returns the session context if the session
587 corresponding to the given bssIdx is found in the PE session table.
588 \param pMac - pointer to global adapter context
589 \param bssIdx - bss index of the session
590 \return tpPESession - pointer to the session context or NULL if session is not found.
591 \sa
592 --------------------------------------------------------------------------*/
593tpPESession pe_find_session_by_bss_idx(tpAniSirGlobal pMac, uint8_t bssIdx)
594{
595 uint8_t i;
596 for (i = 0; i < pMac->lim.maxBssId; i++) {
597 /* If BSSID matches return corresponding tables address */
598 if ((pMac->lim.gpSession[i].valid)
599 && (pMac->lim.gpSession[i].bssIdx == bssIdx)) {
600 return &pMac->lim.gpSession[i];
601 }
602 }
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530603 pe_debug("Session lookup fails for bssIdx: %d", bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800604 return NULL;
605}
606
607/*--------------------------------------------------------------------------
608 \brief pe_find_session_by_session_id() - looks up the PE session given the session ID.
609
610 This function returns the session context if the session
611 corresponding to the given session ID is found in the PE session table.
612
613 \param pMac - pointer to global adapter context
614 \param sessionId -session ID for which session context needs to be looked up.
615
616 \return tpPESession - pointer to the session context or NULL if session is not found.
617
618 \sa
619 --------------------------------------------------------------------------*/
Srinivas Girigowdaf326dfe2017-08-03 11:28:32 -0700620tpPESession pe_find_session_by_session_id(tpAniSirGlobal pMac,
621 uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800622{
623 if (sessionId >= pMac->lim.maxBssId) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530624 pe_err("Invalid sessionId: %d", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530625 return NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800626 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800627
Srinivas Girigowdaf326dfe2017-08-03 11:28:32 -0700628 if (pMac->lim.gpSession[sessionId].valid)
629 return &pMac->lim.gpSession[sessionId];
630
631 return NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632}
633
634/**
635 * pe_find_session_by_sta_id() - looks up the PE session given staid.
636 * @mac_ctx: pointer to global adapter context
637 * @staid: StaId of the session
638 * @session_id: session ID is returned here, if session is found.
639 *
640 * This function returns the session context and the session ID if the session
641 * corresponding to the given StaId is found in the PE session table.
642 *
643 * Return: session pointer
644 */
645tpPESession
646pe_find_session_by_sta_id(tpAniSirGlobal mac_ctx,
647 uint8_t staid,
648 uint8_t *session_id)
649{
650 uint8_t i, j;
651 tpPESession session_ptr;
652 dphHashTableClass *dph_ptr;
653
654 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
655 if (!mac_ctx->lim.gpSession[i].valid)
656 continue;
657 session_ptr = &mac_ctx->lim.gpSession[i];
658 dph_ptr = &session_ptr->dph.dphHashTable;
659 for (j = 0; j < dph_ptr->size; j++) {
660 if (dph_ptr->pDphNodeArray[j].valid
661 && dph_ptr->pDphNodeArray[j].added
662 && staid == dph_ptr->pDphNodeArray[j].staIndex) {
663 *session_id = i;
664 return session_ptr;
665 }
666 }
667 }
668
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530669 pe_debug("Session lookup fails for StaId: %d", staid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670 return NULL;
671}
672
673/**
674 * pe_delete_session() - deletes the PE session given the session ID.
675 * @mac_ctx: pointer to global adapter context
676 * @session: session to be deleted.
677 *
678 * Deletes the given PE session
679 *
680 * Return: void
681 */
682void pe_delete_session(tpAniSirGlobal mac_ctx, tpPESession session)
683{
684 uint16_t i = 0;
685 uint16_t n;
686 TX_TIMER *timer_ptr;
687
Krishna Kumaar Natarajan03cc3862015-12-15 17:51:19 -0800688 if (!session || (session && !session->valid)) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530689 pe_err("session is not valid");
Krishna Kumaar Natarajan03cc3862015-12-15 17:51:19 -0800690 return;
691 }
692
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530693 pe_debug("Trying to delete PE session: %d Opmode: %d BssIdx: %d BSSID: "MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800694 session->peSessionId, session->operMode,
695 session->bssIdx,
696 MAC_ADDR_ARRAY(session->bssId));
697 for (n = 0; n < (mac_ctx->lim.maxStation + 1); n++) {
698 timer_ptr = &mac_ctx->lim.limTimers.gpLimCnfWaitTimer[n];
699 if (session->peSessionId == timer_ptr->sessionId)
700 if (true == tx_timer_running(timer_ptr))
701 tx_timer_deactivate(timer_ptr);
702 }
703
Karthick S7a17a712015-10-14 16:12:48 +0530704 if (LIM_IS_AP_ROLE(session)) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530705 qdf_mc_timer_stop(&session->protection_fields_reset_timer);
706 qdf_mc_timer_destroy(&session->protection_fields_reset_timer);
Karthick S7a17a712015-10-14 16:12:48 +0530707 }
708
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709 /* Delete FT related information */
710 lim_ft_cleanup(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800711 if (session->pLimStartBssReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530712 qdf_mem_free(session->pLimStartBssReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800713 session->pLimStartBssReq = NULL;
714 }
715
716 if (session->pLimJoinReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530717 qdf_mem_free(session->pLimJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800718 session->pLimJoinReq = NULL;
719 }
720
721 if (session->pLimReAssocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530722 qdf_mem_free(session->pLimReAssocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723 session->pLimReAssocReq = NULL;
724 }
725
726 if (session->pLimMlmJoinReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530727 qdf_mem_free(session->pLimMlmJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728 session->pLimMlmJoinReq = NULL;
729 }
730
731 if (session->dph.dphHashTable.pHashTable != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530732 qdf_mem_free(session->dph.dphHashTable.pHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733 session->dph.dphHashTable.pHashTable = NULL;
734 }
735
736 if (session->dph.dphHashTable.pDphNodeArray != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530737 qdf_mem_free(session->dph.dphHashTable.pDphNodeArray);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738 session->dph.dphHashTable.pDphNodeArray = NULL;
739 }
740
741 if (session->gpLimPeerIdxpool != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530742 qdf_mem_free(session->gpLimPeerIdxpool);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 session->gpLimPeerIdxpool = NULL;
744 }
745
746 if (session->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530747 qdf_mem_free(session->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 session->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530749 session->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750 }
751
752 if (session->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530753 qdf_mem_free(session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754 session->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530755 session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800756 }
757
758 if (session->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530759 qdf_mem_free(session->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760 session->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530761 session->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762 }
763
764 if (session->parsedAssocReq != NULL) {
765 tpSirAssocReq tmp_ptr = NULL;
766 /* Cleanup the individual allocation first */
767 for (i = 0; i < session->dph.dphHashTable.size; i++) {
768 if (session->parsedAssocReq[i] == NULL)
769 continue;
770 tmp_ptr = ((tpSirAssocReq)
771 (session->parsedAssocReq[i]));
772 if (tmp_ptr->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530773 qdf_mem_free(tmp_ptr->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800774 tmp_ptr->assocReqFrame = NULL;
775 tmp_ptr->assocReqFrameLength = 0;
776 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530777 qdf_mem_free(session->parsedAssocReq[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800778 session->parsedAssocReq[i] = NULL;
779 }
780 /* Cleanup the whole block */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530781 qdf_mem_free(session->parsedAssocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800782 session->parsedAssocReq = NULL;
783 }
784 if (NULL != session->limAssocResponseData) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530785 qdf_mem_free(session->limAssocResponseData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800786 session->limAssocResponseData = NULL;
787 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788 if (NULL != session->pLimMlmReassocRetryReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530789 qdf_mem_free(session->pLimMlmReassocRetryReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800790 session->pLimMlmReassocRetryReq = NULL;
791 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792 if (NULL != session->pLimMlmReassocReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530793 qdf_mem_free(session->pLimMlmReassocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794 session->pLimMlmReassocReq = NULL;
795 }
796
797 if (NULL != session->pSchProbeRspTemplate) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530798 qdf_mem_free(session->pSchProbeRspTemplate);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799 session->pSchProbeRspTemplate = NULL;
800 }
801
802 if (NULL != session->pSchBeaconFrameBegin) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530803 qdf_mem_free(session->pSchBeaconFrameBegin);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800804 session->pSchBeaconFrameBegin = NULL;
805 }
806
807 if (NULL != session->pSchBeaconFrameEnd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530808 qdf_mem_free(session->pSchBeaconFrameEnd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809 session->pSchBeaconFrameEnd = NULL;
810 }
811
812 /* Must free the buffer before peSession invalid */
813 if (NULL != session->addIeParams.probeRespData_buff) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530814 qdf_mem_free(session->addIeParams.probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 session->addIeParams.probeRespData_buff = NULL;
816 session->addIeParams.probeRespDataLen = 0;
817 }
818 if (NULL != session->addIeParams.assocRespData_buff) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530819 qdf_mem_free(session->addIeParams.assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 session->addIeParams.assocRespData_buff = NULL;
821 session->addIeParams.assocRespDataLen = 0;
822 }
823 if (NULL != session->addIeParams.probeRespBCNData_buff) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530824 qdf_mem_free(session->addIeParams.probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825 session->addIeParams.probeRespBCNData_buff = NULL;
826 session->addIeParams.probeRespBCNDataLen = 0;
827 }
828#ifdef WLAN_FEATURE_11W
Anurag Chouhan210db072016-02-22 18:42:15 +0530829 if (QDF_TIMER_STATE_RUNNING ==
830 qdf_mc_timer_get_current_state(&session->pmfComebackTimer))
831 qdf_mc_timer_stop(&session->pmfComebackTimer);
832 qdf_mc_timer_destroy(&session->pmfComebackTimer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800833#endif
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530834 pe_delete_fils_info(session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 session->valid = false;
836
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +0530837 if (session->access_policy_vendor_ie)
838 qdf_mem_free(session->access_policy_vendor_ie);
839
840 session->access_policy_vendor_ie = NULL;
841
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 if (LIM_IS_AP_ROLE(session))
843 lim_check_and_reset_protection_params(mac_ctx);
844
845 return;
846}
847
848/*--------------------------------------------------------------------------
849 \brief pe_find_session_by_peer_sta() - looks up the PE session given the Station Address.
850
851 This function returns the session context and the session ID if the session
852 corresponding to the given station address is found in the PE session table.
853
854 \param pMac - pointer to global adapter context
855 \param sa - Peer STA Address of the session
856 \param sessionId -session ID is returned here, if session is found.
857
858 \return tpPESession - pointer to the session context or NULL if session is not found.
859
860 \sa
861 --------------------------------------------------------------------------*/
862
863tpPESession pe_find_session_by_peer_sta(tpAniSirGlobal pMac, uint8_t *sa,
864 uint8_t *sessionId)
865{
866 uint8_t i;
867 tpDphHashNode pSta;
868 uint16_t aid;
869
870 for (i = 0; i < pMac->lim.maxBssId; i++) {
871 if ((pMac->lim.gpSession[i].valid)) {
872 pSta =
873 dph_lookup_hash_entry(pMac, sa, &aid,
874 &pMac->lim.gpSession[i].dph.
875 dphHashTable);
876 if (pSta != NULL) {
877 *sessionId = i;
878 return &pMac->lim.gpSession[i];
879 }
880 }
881 }
882
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530883 pe_debug("Session lookup fails for Peer StaId:");
884 lim_print_mac_addr(pMac, sa, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800885 return NULL;
886}
887
888/**
889 * pe_find_session_by_sme_session_id() - looks up the PE session for given sme
890 * session id
891 * @mac_ctx: pointer to global adapter context
892 * @sme_session_id: sme session id
893 *
894 * looks up the PE session for given sme session id
895 *
896 * Return: pe session entry for given sme session if found else NULL
897 */
898tpPESession pe_find_session_by_sme_session_id(tpAniSirGlobal mac_ctx,
899 uint8_t sme_session_id)
900{
901 uint8_t i;
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -0700902
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
904 if ((mac_ctx->lim.gpSession[i].valid) &&
905 (mac_ctx->lim.gpSession[i].smeSessionId ==
906 sme_session_id)) {
907 return &mac_ctx->lim.gpSession[i];
908 }
909 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 return NULL;
911}
912
913/**
914 * pe_get_active_session_count() - function to return active pe session count
915 *
916 * @mac_ctx: pointer to global mac structure
917 *
918 * returns number of active pe session count
919 *
920 * Return: 0 if there are no active sessions else return number of active
921 * sessions
922 */
923uint8_t pe_get_active_session_count(tpAniSirGlobal mac_ctx)
924{
925 uint8_t i, active_session_count = 0;
926
927 for (i = 0; i < mac_ctx->lim.maxBssId; i++)
928 if (mac_ctx->lim.gpSession[i].valid)
929 active_session_count++;
930
931 return active_session_count;
932}