blob: ef5b12e58a92506c0e57f76e2e5c960a788f1d01 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Yeshwanth Sriram Guntuka72a2fb22018-01-03 11:25:36 +05302 * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019/**=========================================================================
20
21 \file lim_session.c
22
23 \brief implementation for lim Session related APIs
24
25 \author Sunit Bhatia
26
27 ========================================================================*/
28
29/*--------------------------------------------------------------------------
30 Include Files
31 ------------------------------------------------------------------------*/
32#include "ani_global.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080033#include "lim_ft_defs.h"
34#include "lim_ft.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080035#include "lim_session.h"
36#include "lim_utils.h"
37
38#include "sch_api.h"
39#include "lim_send_messages.h"
40
Qiwei Cai50a21082018-08-07 14:30:09 +080041#ifdef WLAN_ALLOCATE_GLOBAL_BUFFERS_DYNAMICALLY
42static struct sDphHashNode *g_dph_node_array;
Naveen Rawatb0c5b6b2017-11-27 17:37:40 -080043
Qiwei Cai50a21082018-08-07 14:30:09 +080044QDF_STATUS pe_allocate_dph_node_array_buffer(void)
45{
46 uint32_t buf_size;
47
48 buf_size = SIR_MAX_SUPPORTED_BSS * (SIR_SAP_MAX_NUM_PEERS + 1)
49 * sizeof(struct sDphHashNode);
50 g_dph_node_array = qdf_mem_malloc(buf_size);
51
52 if (!g_dph_node_array) {
53 pe_err("%s: Failed to allocate %d bytes", __func__, buf_size);
54 return QDF_STATUS_E_NOMEM;
55 } else {
56 return QDF_STATUS_SUCCESS;
57 }
58}
59
60void pe_free_dph_node_array_buffer(void)
61{
62 qdf_mem_free(g_dph_node_array);
63 g_dph_node_array = NULL;
64}
65
66static inline
67struct sDphHashNode *pe_get_session_dph_node_array(uint8_t session_id)
68{
69 return &g_dph_node_array[session_id * (SIR_SAP_MAX_NUM_PEERS + 1)];
70}
71
72#else /* WLAN_ALLOCATE_GLOBAL_BUFFERS_DYNAMICALLY */
Naveen Rawatb0c5b6b2017-11-27 17:37:40 -080073static struct sDphHashNode
74 g_dph_node_array[SIR_MAX_SUPPORTED_BSS][SIR_SAP_MAX_NUM_PEERS + 1];
75
Qiwei Cai50a21082018-08-07 14:30:09 +080076static inline
77struct sDphHashNode *pe_get_session_dph_node_array(uint8_t session_id)
78{
79 return g_dph_node_array[session_id];
80}
81#endif /* WLAN_ALLOCATE_GLOBAL_BUFFERS_DYNAMICALLY */
82
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083/*--------------------------------------------------------------------------
84
85 \brief pe_init_beacon_params() - Initialize the beaconParams structure
86
87 \param tpPESession - pointer to the session context or NULL if session can not be created.
88 \return void
89 \sa
90
91 --------------------------------------------------------------------------*/
92
Jeff Johnson97699002016-10-07 07:32:55 -070093static void pe_init_beacon_params(tpAniSirGlobal pMac,
94 tpPESession psessionEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080095{
96 psessionEntry->beaconParams.beaconInterval = 0;
97 psessionEntry->beaconParams.fShortPreamble = 0;
98 psessionEntry->beaconParams.llaCoexist = 0;
99 psessionEntry->beaconParams.llbCoexist = 0;
100 psessionEntry->beaconParams.llgCoexist = 0;
101 psessionEntry->beaconParams.ht20Coexist = 0;
102 psessionEntry->beaconParams.llnNonGFCoexist = 0;
103 psessionEntry->beaconParams.fRIFSMode = 0;
104 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = 0;
105 psessionEntry->beaconParams.gHTObssMode = 0;
106
107 /* Number of legacy STAs associated */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530108 qdf_mem_set((void *)&psessionEntry->gLim11bParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800109 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530110 qdf_mem_set((void *)&psessionEntry->gLim11aParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530112 qdf_mem_set((void *)&psessionEntry->gLim11gParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530114 qdf_mem_set((void *)&psessionEntry->gLimNonGfParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800115 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530116 qdf_mem_set((void *)&psessionEntry->gLimHt20Params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530118 qdf_mem_set((void *)&psessionEntry->gLimLsigTxopParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800119 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530120 qdf_mem_set((void *)&psessionEntry->gLimOlbcParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800121 sizeof(tLimProtStaParams), 0);
122}
123
124/*
125 * pe_reset_protection_callback() - resets protection structs so that when an AP
126 * causing use of protection goes away, corresponding protection bit can be
127 * reset
128 * @ptr: pointer to pSessionEntry
129 *
130 * This function resets protection structs so that when an AP causing use of
131 * protection goes away, corresponding protection bit can be reset. This allowes
132 * protection bits to be reset once legacy overlapping APs are gone.
133 *
134 * Return: void
135 */
Jeff Johnson97699002016-10-07 07:32:55 -0700136static void pe_reset_protection_callback(void *ptr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800137{
138 tpPESession pe_session_entry = (tpPESession)ptr;
139 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)pe_session_entry->mac_ctx;
140 int8_t i = 0;
141 tUpdateBeaconParams beacon_params;
142 uint16_t current_protection_state = 0;
143 tpDphHashNode station_hash_node = NULL;
144 tSirMacHTOperatingMode old_op_mode;
145 bool bcn_prms_changed = false;
146
147 if (pe_session_entry->valid == false) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530148 pe_err("session already deleted. exiting timer callback");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 return;
150 }
151
Manishekar Chandrasekaran9e8c7be2016-08-03 14:57:14 +0530152 /*
153 * During CAC period, if the callback is triggered, the beacon
154 * template may get updated. Subsequently if the vdev is not up, the
155 * vdev would be made up -- which should not happen during the CAC
156 * period. To avoid this, ignore the protection callback if the session
157 * is not yet up.
158 */
159 if (!wma_is_vdev_up(pe_session_entry->smeSessionId)) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530160 pe_err("session is not up yet. exiting timer callback");
Manishekar Chandrasekaran9e8c7be2016-08-03 14:57:14 +0530161 return;
162 }
163
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 current_protection_state |=
165 pe_session_entry->gLimOverlap11gParams.protectionEnabled |
166 pe_session_entry->gLimOverlap11aParams.protectionEnabled << 1 |
167 pe_session_entry->gLimOverlapHt20Params.protectionEnabled << 2 |
168 pe_session_entry->gLimOverlapNonGfParams.protectionEnabled << 3 |
169 pe_session_entry->gLimOlbcParams.protectionEnabled << 4;
170
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530171 pe_debug("old protection state: 0x%04X, new protection state: 0x%04X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 pe_session_entry->old_protection_state,
173 current_protection_state);
174
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530175 qdf_mem_zero(&pe_session_entry->gLimOverlap11gParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176 sizeof(pe_session_entry->gLimOverlap11gParams));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530177 qdf_mem_zero(&pe_session_entry->gLimOverlap11aParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 sizeof(pe_session_entry->gLimOverlap11aParams));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530179 qdf_mem_zero(&pe_session_entry->gLimOverlapHt20Params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180 sizeof(pe_session_entry->gLimOverlapHt20Params));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530181 qdf_mem_zero(&pe_session_entry->gLimOverlapNonGfParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 sizeof(pe_session_entry->gLimOverlapNonGfParams));
183
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530184 qdf_mem_zero(&pe_session_entry->gLimOlbcParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800185 sizeof(pe_session_entry->gLimOlbcParams));
186
Abhishek Singhaf7e7fa2016-08-08 17:59:31 +0530187 /*
188 * Do not reset fShortPreamble and beaconInterval, as they
189 * are not updated.
190 */
191 pe_session_entry->beaconParams.llaCoexist = 0;
192 pe_session_entry->beaconParams.llbCoexist = 0;
193 pe_session_entry->beaconParams.llgCoexist = 0;
194 pe_session_entry->beaconParams.ht20Coexist = 0;
195 pe_session_entry->beaconParams.llnNonGFCoexist = 0;
196 pe_session_entry->beaconParams.fRIFSMode = 0;
197 pe_session_entry->beaconParams.fLsigTXOPProtectionFullSupport = 0;
198 pe_session_entry->beaconParams.gHTObssMode = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800200
201 old_op_mode = pe_session_entry->htOperMode;
202 pe_session_entry->htOperMode = eSIR_HT_OP_MODE_PURE;
Masti, Narayanraddi4d8860c2016-08-22 15:46:48 +0530203 mac_ctx->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530205 qdf_mem_zero(&beacon_params, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 /* index 0, is self node, peers start from 1 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530207 for (i = 1 ; i <= mac_ctx->lim.gLimAssocStaLimit ; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208 station_hash_node = dph_get_hash_entry(mac_ctx, i,
209 &pe_session_entry->dph.dphHashTable);
210 if (NULL == station_hash_node)
211 continue;
212 lim_decide_ap_protection(mac_ctx, station_hash_node->staAddr,
213 &beacon_params, pe_session_entry);
214 }
215
216 if (pe_session_entry->htOperMode != old_op_mode)
217 bcn_prms_changed = true;
218
219 if ((current_protection_state !=
220 pe_session_entry->old_protection_state) &&
221 (false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530222 pe_debug("protection changed, update beacon template");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223 /* update beacon fix params and send update to FW */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530224 qdf_mem_zero(&beacon_params, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 beacon_params.bssIdx = pe_session_entry->bssIdx;
226 beacon_params.fShortPreamble =
227 pe_session_entry->beaconParams.fShortPreamble;
228 beacon_params.beaconInterval =
229 pe_session_entry->beaconParams.beaconInterval;
230 beacon_params.llaCoexist =
231 pe_session_entry->beaconParams.llaCoexist;
232 beacon_params.llbCoexist =
233 pe_session_entry->beaconParams.llbCoexist;
234 beacon_params.llgCoexist =
235 pe_session_entry->beaconParams.llgCoexist;
236 beacon_params.ht20MhzCoexist =
237 pe_session_entry->beaconParams.ht20Coexist;
238 beacon_params.llnNonGFCoexist =
239 pe_session_entry->beaconParams.llnNonGFCoexist;
240 beacon_params.fLsigTXOPProtectionFullSupport =
241 pe_session_entry->beaconParams.
242 fLsigTXOPProtectionFullSupport;
243 beacon_params.fRIFSMode =
244 pe_session_entry->beaconParams.fRIFSMode;
245 beacon_params.smeSessionId =
246 pe_session_entry->smeSessionId;
Selvaraj, Sridhardc038ee2016-06-24 15:22:14 +0530247 beacon_params.paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 bcn_prms_changed = true;
249 }
250
251 if (bcn_prms_changed) {
252 sch_set_fixed_beacon_fields(mac_ctx, pe_session_entry);
253 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session_entry);
254 }
255
256 pe_session_entry->old_protection_state = current_protection_state;
Anurag Chouhan210db072016-02-22 18:42:15 +0530257 if (qdf_mc_timer_start(&pe_session_entry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258 protection_fields_reset_timer,
259 SCH_PROTECTION_RESET_TIME)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530260 != QDF_STATUS_SUCCESS) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530261 pe_err("cannot create or start protectionFieldsResetTimer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262 }
263}
264
Abhishek Singhcfb44482017-03-10 12:42:37 +0530265#ifdef WLAN_FEATURE_11W
266/**
267 * pe_init_pmf_comeback_timer: init PMF comeback timer
268 * @mac_ctx: pointer to global adapter context
269 * @session: pe session
270 * @session_id: session ID
271 *
272 * Return: void
273 */
274static void pe_init_pmf_comeback_timer(tpAniSirGlobal mac_ctx,
275tpPESession session, uint8_t session_id)
276{
277 QDF_STATUS status;
278
279 session->pmfComebackTimerInfo.pMac = mac_ctx;
280 session->pmfComebackTimerInfo.sessionID = session_id;
281 status = qdf_mc_timer_init(&session->pmfComebackTimer,
282 QDF_TIMER_TYPE_SW, lim_pmf_comeback_timer_callback,
283 (void *)&session->pmfComebackTimerInfo);
284 if (!QDF_IS_STATUS_SUCCESS(status))
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530285 pe_err("cannot init pmf comeback timer");
Abhishek Singhcfb44482017-03-10 12:42:37 +0530286}
287#else
288static inline void
289pe_init_pmf_comeback_timer(tpAniSirGlobal mac_ctx,
290 tpPESession session, uint8_t session_id)
291{
292}
293#endif
294
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530295#ifdef WLAN_FEATURE_FILS_SK
296/**
297 * pe_delete_fils_info: API to delete fils session info
298 * @session: pe session
299 *
300 * Return: void
301 */
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530302void pe_delete_fils_info(tpPESession session)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530303{
304 struct pe_fils_session *fils_info;
305
306 if (!session || (session && !session->valid)) {
307 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
308 FL("session is not valid"));
309 return;
310 }
311 fils_info = session->fils_info;
312 if (!fils_info) {
313 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
314 FL("fils info not found"));
315 return;
316 }
317 if (fils_info->keyname_nai_data)
318 qdf_mem_free(fils_info->keyname_nai_data);
319 if (fils_info->fils_erp_reauth_pkt)
320 qdf_mem_free(fils_info->fils_erp_reauth_pkt);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +0530321 if (fils_info->fils_rrk)
322 qdf_mem_free(fils_info->fils_rrk);
323 if (fils_info->fils_rik)
324 qdf_mem_free(fils_info->fils_rik);
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530325 if (fils_info->fils_eap_finish_pkt)
326 qdf_mem_free(fils_info->fils_eap_finish_pkt);
327 if (fils_info->fils_rmsk)
328 qdf_mem_free(fils_info->fils_rmsk);
329 if (fils_info->fils_pmk)
330 qdf_mem_free(fils_info->fils_pmk);
331 if (fils_info->auth_info.keyname)
332 qdf_mem_free(fils_info->auth_info.keyname);
333 if (fils_info->auth_info.domain_name)
334 qdf_mem_free(fils_info->auth_info.domain_name);
Vignesh Viswanathana1bb0922017-09-15 12:58:48 +0530335 if (fils_info->hlp_data)
336 qdf_mem_free(fils_info->hlp_data);
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530337 qdf_mem_free(fils_info);
338 session->fils_info = NULL;
339}
340/**
341 * pe_init_fils_info: API to initialize fils session info elements to null
342 * @session: pe session
343 *
344 * Return: void
345 */
346static void pe_init_fils_info(tpPESession session)
347{
348 struct pe_fils_session *fils_info;
349
350 if (!session || (session && !session->valid)) {
351 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
352 FL("session is not valid"));
353 return;
354 }
355 session->fils_info = qdf_mem_malloc(sizeof(struct pe_fils_session));
356 fils_info = session->fils_info;
357 if (!fils_info) {
358 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
359 FL("fils info not found"));
360 return;
361 }
362 fils_info->keyname_nai_data = NULL;
363 fils_info->fils_erp_reauth_pkt = NULL;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +0530364 fils_info->fils_rrk = NULL;
365 fils_info->fils_rik = NULL;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530366 fils_info->fils_eap_finish_pkt = NULL;
367 fils_info->fils_rmsk = NULL;
368 fils_info->fils_pmk = NULL;
369 fils_info->auth_info.keyname = NULL;
370 fils_info->auth_info.domain_name = NULL;
371}
372#else
373static void pe_delete_fils_info(tpPESession session) { }
374static void pe_init_fils_info(tpPESession session) { }
375#endif
376
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800377/**
Abhishek Singh47888602017-05-10 12:50:50 +0530378 * lim_get_peer_idxpool_size: get number of peer idx pool size
379 * @num_sta: Max number of STA
380 * @bss_type: BSS type
381 *
382 * The peer index start from 1 and thus index 0 is not used, so
383 * add 1 to the max sta. For STA if TDLS is enabled add 2 as
384 * index 1 is reserved for peer BSS.
385 *
386 * Return: number of peer idx pool size
387 */
388#ifdef FEATURE_WLAN_TDLS
389static inline uint8_t
390lim_get_peer_idxpool_size(uint16_t num_sta, tSirBssType bss_type)
391{
392 /*
393 * In station role, index 1 is reserved for peer
394 * corresponding to AP. For TDLS the index should
395 * start from 2
396 */
397 if (bss_type == eSIR_INFRASTRUCTURE_MODE)
398 return num_sta + 2;
399 else
400 return num_sta + 1;
401
402}
403#else
404static inline uint8_t
405lim_get_peer_idxpool_size(uint16_t num_sta, tSirBssType bss_type)
406{
407 return num_sta + 1;
408}
409#endif
410
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530411void lim_set_bcn_probe_filter(tpAniSirGlobal mac_ctx,
412 tpPESession session,
413 tSirMacSSid *ibss_ssid,
414 uint8_t sap_channel)
415{
416 struct mgmt_beacon_probe_filter *filter;
417 tSirBssType bss_type;
418 uint8_t session_id;
419 tSirMacAddr *bssid;
420
421 if (!session) {
422 pe_err("Invalid session pointer");
423 return;
424 }
425
426 bss_type = session->bssType;
427 session_id = session->peSessionId;
428 bssid = &session->bssId;
429
430 if (session_id >= SIR_MAX_SUPPORTED_BSS) {
431 pe_err("Invalid session_id %d of type %d",
432 session_id, bss_type);
433 return;
434 }
435
436 filter = &mac_ctx->bcn_filter;
437
438 if (eSIR_INFRASTRUCTURE_MODE == bss_type) {
439 filter->num_sta_sessions++;
440 sir_copy_mac_addr(filter->sta_bssid[session_id], *bssid);
441 pe_debug("Set filter for STA Session %d bssid "MAC_ADDRESS_STR,
442 session_id, MAC_ADDR_ARRAY(*bssid));
443 } else if (eSIR_IBSS_MODE == bss_type) {
444 if (!ibss_ssid) {
445 pe_err("IBSS Type with NULL SSID");
446 goto done;
447 }
448 filter->num_ibss_sessions++;
449 filter->ibss_ssid[session_id].length = ibss_ssid->length;
450 qdf_mem_copy(&filter->ibss_ssid[session_id].length,
451 ibss_ssid->ssId,
452 ibss_ssid->length);
453 pe_debug("Set filter for IBSS session %d ssid %s",
454 session_id, ibss_ssid->ssId);
455 } else if (eSIR_INFRA_AP_MODE == bss_type) {
456 if (!sap_channel) {
457 pe_err("SAP Type with invalid channel");
458 goto done;
459 }
460 filter->num_sap_sessions++;
461 filter->sap_channel[session_id] = sap_channel;
462 pe_debug("Set filter for SAP session %d channel %d",
463 session_id, sap_channel);
464 }
465
466done:
467 pe_debug("sta %d ibss %d sap %d",
468 filter->num_sta_sessions, filter->num_ibss_sessions,
469 filter->num_sap_sessions);
470}
471
472void lim_reset_bcn_probe_filter(tpAniSirGlobal mac_ctx,
473 tpPESession session)
474{
475 struct mgmt_beacon_probe_filter *filter;
476 tSirBssType bss_type;
477 uint8_t session_id;
478
479 if (!session) {
480 pe_err("Invalid session pointer");
481 return;
482 }
483
484 bss_type = session->bssType;
485 session_id = session->peSessionId;
486
487 if (session_id >= SIR_MAX_SUPPORTED_BSS) {
488 pe_err("Invalid session_id %d of type %d",
489 session_id, bss_type);
490 return;
491 }
492
493 filter = &mac_ctx->bcn_filter;
494
495 if (eSIR_INFRASTRUCTURE_MODE == bss_type) {
496 if (filter->num_sta_sessions)
497 filter->num_sta_sessions--;
498 qdf_mem_set(&filter->sta_bssid[session_id],
499 sizeof(tSirMacAddr), 0);
500 pe_debug("Cleared STA Filter for session %d", session_id);
501 } else if (eSIR_IBSS_MODE == bss_type) {
502 if (filter->num_ibss_sessions)
503 filter->num_ibss_sessions--;
504 filter->ibss_ssid[session_id].length = 0;
505 qdf_mem_set(&filter->ibss_ssid[session_id].ssId,
506 SIR_MAC_MAX_SSID_LENGTH, 0);
507 pe_debug("Cleared IBSS Filter for session %d", session_id);
508 } else if (eSIR_INFRA_AP_MODE == bss_type) {
509 if (filter->num_sap_sessions)
510 filter->num_sap_sessions--;
511 filter->sap_channel[session_id] = 0;
512 pe_debug("Cleared SAP Filter for session %d", session_id);
513 }
514
515 pe_debug("sta %d ibss %d sap %d",
516 filter->num_sta_sessions, filter->num_ibss_sessions,
517 filter->num_sap_sessions);
518}
519
520void lim_update_bcn_probe_filter(tpAniSirGlobal mac_ctx,
521 tpPESession session)
522{
523 struct mgmt_beacon_probe_filter *filter;
524 tSirBssType bss_type;
525 uint8_t session_id;
526
527 if (!session) {
528 pe_err("Invalid session pointer");
529 return;
530 }
531
532 bss_type = session->bssType;
533 session_id = session->peSessionId;
534
535 if (session_id >= SIR_MAX_SUPPORTED_BSS) {
536 pe_err("Invalid session_id %d of type %d",
537 session_id, bss_type);
538 return;
539 }
540
541 filter = &mac_ctx->bcn_filter;
542
543 if (eSIR_INFRA_AP_MODE == bss_type) {
544 filter->sap_channel[session_id] = session->currentOperChannel;
545 pe_debug("Updated SAP Filter for session %d channel %d",
546 session_id, filter->sap_channel[session_id]);
547 } else {
548 pe_debug("Invalid session type %d session id %d",
549 bss_type, session_id);
550 }
551
552 pe_debug("sta %d ibss %d sap %d",
553 filter->num_sta_sessions, filter->num_ibss_sessions,
554 filter->num_sap_sessions);
555}
556
Abhishek Singh47888602017-05-10 12:50:50 +0530557/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 * pe_create_session() creates a new PE session given the BSSID
559 * @param pMac: pointer to global adapter context
560 * @param bssid: BSSID of the new session
561 * @param sessionId: session ID is returned here, if session is created.
562 * @param bssType: station or a
563 *
564 * This function returns the session context and the session ID if the session
565 * corresponding to the passed BSSID is found in the PE session table.
566 *
567 * Return: tpPESession: pointer to the session context or NULL if session
568 * can not be created.
569 */
570
571tpPESession
572pe_create_session(tpAniSirGlobal pMac, uint8_t *bssid, uint8_t *sessionId,
573 uint16_t numSta, tSirBssType bssType)
574{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530575 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800576 uint8_t i;
577 tpPESession session_ptr;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700578
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800579 for (i = 0; i < pMac->lim.maxBssId; i++) {
580 /* Find first free room in session table */
581 if (pMac->lim.gpSession[i].valid == true)
582 continue;
583 break;
584 }
585
586 if (i == pMac->lim.maxBssId) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530587 pe_err("Session can't be created. Reached max sessions");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588 return NULL;
589 }
590
591 session_ptr = &pMac->lim.gpSession[i];
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530592 qdf_mem_set((void *)session_ptr, sizeof(tPESession), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593 /* Allocate space for Station Table for this session. */
594 session_ptr->dph.dphHashTable.pHashTable =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530595 qdf_mem_malloc(sizeof(tpDphHashNode) * (numSta + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800596 if (NULL == session_ptr->dph.dphHashTable.pHashTable) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530597 pe_err("memory allocate failed!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598 return NULL;
599 }
600
Qiwei Cai50a21082018-08-07 14:30:09 +0800601 session_ptr->dph.dphHashTable.pDphNodeArray =
602 pe_get_session_dph_node_array(i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800603 session_ptr->dph.dphHashTable.size = numSta + 1;
604 dph_hash_table_class_init(pMac, &session_ptr->dph.dphHashTable);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530605 session_ptr->gpLimPeerIdxpool = qdf_mem_malloc(
Abhishek Singh47888602017-05-10 12:50:50 +0530606 sizeof(*(session_ptr->gpLimPeerIdxpool)) *
607 lim_get_peer_idxpool_size(numSta, bssType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608 if (NULL == session_ptr->gpLimPeerIdxpool) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530609 pe_err("memory allocate failed!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530610 qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable);
Naveen Rawatb0c5b6b2017-11-27 17:37:40 -0800611 qdf_mem_zero(session_ptr->dph.dphHashTable.pDphNodeArray,
612 sizeof(struct sDphHashNode) *
613 (SIR_SAP_MAX_NUM_PEERS + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614 session_ptr->dph.dphHashTable.pHashTable = NULL;
615 session_ptr->dph.dphHashTable.pDphNodeArray = NULL;
616 return NULL;
617 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618 session_ptr->freePeerIdxHead = 0;
619 session_ptr->freePeerIdxTail = 0;
620 session_ptr->gLimNumOfCurrentSTAs = 0;
621 /* Copy the BSSID to the session table */
622 sir_copy_mac_addr(session_ptr->bssId, bssid);
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700623 if (bssType == eSIR_MONITOR_MODE)
624 sir_copy_mac_addr(pMac->lim.gpSession[i].selfMacAddr, bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 session_ptr->valid = true;
Jeff Johnson47d75242018-05-12 15:58:53 -0700626 /* Initialize the SME and MLM states to IDLE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800627 session_ptr->limMlmState = eLIM_MLM_IDLE_STATE;
628 session_ptr->limSmeState = eLIM_SME_IDLE_STATE;
629 session_ptr->limCurrentAuthType = eSIR_OPEN_SYSTEM;
630 pe_init_beacon_params(pMac, &pMac->lim.gpSession[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 session_ptr->is11Rconnection = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632#ifdef FEATURE_WLAN_ESE
633 session_ptr->isESEconnection = false;
634#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635 session_ptr->isFastTransitionEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636 session_ptr->isFastRoamIniFeatureEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637 *sessionId = i;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530638 session_ptr->peSessionId = i;
639 session_ptr->bssType = bssType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640 session_ptr->gLimPhyMode = WNI_CFG_PHY_MODE_11G;
641 /* Initialize CB mode variables when session is created */
642 session_ptr->htSupportedChannelWidthSet = 0;
643 session_ptr->htRecommendedTxWidthSet = 0;
644 session_ptr->htSecondaryChannelOffset = 0;
645#ifdef FEATURE_WLAN_TDLS
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530646 qdf_mem_set(session_ptr->peerAIDBitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647 sizeof(session_ptr->peerAIDBitmap), 0);
648 session_ptr->tdls_prohibited = false;
649 session_ptr->tdls_chan_swit_prohibited = false;
650#endif
651 session_ptr->fWaitForProbeRsp = 0;
652 session_ptr->fIgnoreCapsChange = 0;
Selvaraj, Sridhar5b5a0652017-05-04 11:23:07 +0530653 session_ptr->ignore_assoc_disallowed = pMac->ignore_assoc_disallowed;
Arif Hussain05fb4872018-01-03 16:02:55 -0800654 session_ptr->is_session_obss_color_collision_det_enabled =
655 pMac->lim.global_obss_color_collision_det_offload;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800656
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530657 pe_debug("Create a new PE session: %d BSSID: "MAC_ADDRESS_STR" Max No of STA: %d",
Kapil Guptabf4943c2016-10-13 12:15:39 +0530658 *sessionId, MAC_ADDR_ARRAY(bssid), numSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800659
Rajeev Kumarcf835a02016-04-15 15:01:31 -0700660 if (eSIR_INFRA_AP_MODE == bssType || eSIR_IBSS_MODE == bssType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661 session_ptr->pSchProbeRspTemplate =
Abhinav Kumar68834222018-07-18 19:06:14 +0530662 qdf_mem_malloc(SIR_MAX_PROBE_RESP_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800663 session_ptr->pSchBeaconFrameBegin =
Abhinav Kumar68834222018-07-18 19:06:14 +0530664 qdf_mem_malloc(SIR_MAX_BEACON_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800665 session_ptr->pSchBeaconFrameEnd =
Abhinav Kumar68834222018-07-18 19:06:14 +0530666 qdf_mem_malloc(SIR_MAX_BEACON_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667 if ((NULL == session_ptr->pSchProbeRspTemplate)
668 || (NULL == session_ptr->pSchBeaconFrameBegin)
669 || (NULL == session_ptr->pSchBeaconFrameEnd)) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530670 pe_err("memory allocate failed!");
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530671 qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable);
Naveen Rawatb0c5b6b2017-11-27 17:37:40 -0800672 qdf_mem_zero(
673 session_ptr->dph.dphHashTable.pDphNodeArray,
674 sizeof(struct sDphHashNode) *
675 (SIR_SAP_MAX_NUM_PEERS + 1));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530676 qdf_mem_free(session_ptr->gpLimPeerIdxpool);
677 qdf_mem_free(session_ptr->pSchProbeRspTemplate);
678 qdf_mem_free(session_ptr->pSchBeaconFrameBegin);
679 qdf_mem_free(session_ptr->pSchBeaconFrameEnd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680
681 session_ptr->dph.dphHashTable.pHashTable = NULL;
682 session_ptr->dph.dphHashTable.pDphNodeArray = NULL;
683 session_ptr->gpLimPeerIdxpool = NULL;
684 session_ptr->pSchProbeRspTemplate = NULL;
685 session_ptr->pSchBeaconFrameBegin = NULL;
686 session_ptr->pSchBeaconFrameEnd = NULL;
687 return NULL;
688 }
689 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800690 if (eSIR_INFRASTRUCTURE_MODE == bssType)
691 lim_ft_open(pMac, &pMac->lim.gpSession[i]);
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700692
693 if (eSIR_MONITOR_MODE == bssType)
694 lim_ft_open(pMac, &pMac->lim.gpSession[i]);
695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 if (eSIR_INFRA_AP_MODE == bssType) {
697 session_ptr->old_protection_state = 0;
Arif Hussain1513cb22018-01-05 19:56:31 -0800698 session_ptr->is_session_obss_offload_enabled = false;
699 session_ptr->is_obss_reset_timer_initialized = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700 session_ptr->mac_ctx = (void *)pMac;
Arif Hussain1513cb22018-01-05 19:56:31 -0800701
702 status = qdf_mc_timer_init(&session_ptr->
703 protection_fields_reset_timer,
704 QDF_TIMER_TYPE_SW,
705 pe_reset_protection_callback,
706 (void *)&pMac->lim.gpSession[i]);
707
708 if (QDF_IS_STATUS_ERROR(status))
709 pe_err("cannot create protection fields reset timer");
710 else
711 session_ptr->is_obss_reset_timer_initialized = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530713 pe_init_fils_info(session_ptr);
Abhishek Singhcfb44482017-03-10 12:42:37 +0530714 pe_init_pmf_comeback_timer(pMac, session_ptr, *sessionId);
Tushnim Bhattacharyya3d17def2017-06-19 11:13:43 -0700715 session_ptr->ht_client_cnt = 0;
Naveen Rawat6fc3c502017-09-06 16:14:11 -0700716 /* following is invalid value since seq number is 12 bit */
717 session_ptr->prev_auth_seq_num = 0xFFFF;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -0800718
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719 return &pMac->lim.gpSession[i];
720}
721
722/*--------------------------------------------------------------------------
723 \brief pe_find_session_by_bssid() - looks up the PE session given the BSSID.
724
725 This function returns the session context and the session ID if the session
726 corresponding to the given BSSID is found in the PE session table.
727
728 \param pMac - pointer to global adapter context
729 \param bssid - BSSID of the session
730 \param sessionId -session ID is returned here, if session is found.
731
732 \return tpPESession - pointer to the session context or NULL if session is not found.
733
734 \sa
735 --------------------------------------------------------------------------*/
736tpPESession pe_find_session_by_bssid(tpAniSirGlobal pMac, uint8_t *bssid,
737 uint8_t *sessionId)
738{
739 uint8_t i;
740
741 for (i = 0; i < pMac->lim.maxBssId; i++) {
742 /* If BSSID matches return corresponding tables address */
743 if ((pMac->lim.gpSession[i].valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530744 && (sir_compare_mac_addr(pMac->lim.gpSession[i].bssId,
745 bssid))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746 *sessionId = i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530747 return &pMac->lim.gpSession[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 }
749 }
750
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530751 return NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752
753}
754
755/*--------------------------------------------------------------------------
756 \brief pe_find_session_by_bss_idx() - looks up the PE session given the bssIdx.
757
758 This function returns the session context if the session
759 corresponding to the given bssIdx is found in the PE session table.
760 \param pMac - pointer to global adapter context
761 \param bssIdx - bss index of the session
762 \return tpPESession - pointer to the session context or NULL if session is not found.
763 \sa
764 --------------------------------------------------------------------------*/
765tpPESession pe_find_session_by_bss_idx(tpAniSirGlobal pMac, uint8_t bssIdx)
766{
767 uint8_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700768
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800769 for (i = 0; i < pMac->lim.maxBssId; i++) {
770 /* If BSSID matches return corresponding tables address */
771 if ((pMac->lim.gpSession[i].valid)
772 && (pMac->lim.gpSession[i].bssIdx == bssIdx)) {
773 return &pMac->lim.gpSession[i];
774 }
775 }
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530776 pe_debug("Session lookup fails for bssIdx: %d", bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777 return NULL;
778}
779
780/*--------------------------------------------------------------------------
781 \brief pe_find_session_by_session_id() - looks up the PE session given the session ID.
782
783 This function returns the session context if the session
784 corresponding to the given session ID is found in the PE session table.
785
786 \param pMac - pointer to global adapter context
787 \param sessionId -session ID for which session context needs to be looked up.
788
789 \return tpPESession - pointer to the session context or NULL if session is not found.
790
791 \sa
792 --------------------------------------------------------------------------*/
Srinivas Girigowdaf326dfe2017-08-03 11:28:32 -0700793tpPESession pe_find_session_by_session_id(tpAniSirGlobal pMac,
794 uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795{
796 if (sessionId >= pMac->lim.maxBssId) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530797 pe_err("Invalid sessionId: %d", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530798 return NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800
Srinivas Girigowdaf326dfe2017-08-03 11:28:32 -0700801 if (pMac->lim.gpSession[sessionId].valid)
802 return &pMac->lim.gpSession[sessionId];
803
804 return NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805}
806
807/**
808 * pe_find_session_by_sta_id() - looks up the PE session given staid.
809 * @mac_ctx: pointer to global adapter context
810 * @staid: StaId of the session
811 * @session_id: session ID is returned here, if session is found.
812 *
813 * This function returns the session context and the session ID if the session
814 * corresponding to the given StaId is found in the PE session table.
815 *
816 * Return: session pointer
817 */
818tpPESession
819pe_find_session_by_sta_id(tpAniSirGlobal mac_ctx,
820 uint8_t staid,
821 uint8_t *session_id)
822{
823 uint8_t i, j;
824 tpPESession session_ptr;
825 dphHashTableClass *dph_ptr;
826
827 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
828 if (!mac_ctx->lim.gpSession[i].valid)
829 continue;
830 session_ptr = &mac_ctx->lim.gpSession[i];
831 dph_ptr = &session_ptr->dph.dphHashTable;
832 for (j = 0; j < dph_ptr->size; j++) {
833 if (dph_ptr->pDphNodeArray[j].valid
834 && dph_ptr->pDphNodeArray[j].added
835 && staid == dph_ptr->pDphNodeArray[j].staIndex) {
836 *session_id = i;
837 return session_ptr;
838 }
839 }
840 }
841
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530842 pe_debug("Session lookup fails for StaId: %d", staid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843 return NULL;
844}
845
846/**
847 * pe_delete_session() - deletes the PE session given the session ID.
848 * @mac_ctx: pointer to global adapter context
849 * @session: session to be deleted.
850 *
851 * Deletes the given PE session
852 *
853 * Return: void
854 */
855void pe_delete_session(tpAniSirGlobal mac_ctx, tpPESession session)
856{
857 uint16_t i = 0;
858 uint16_t n;
859 TX_TIMER *timer_ptr;
860
Krishna Kumaar Natarajan03cc3862015-12-15 17:51:19 -0800861 if (!session || (session && !session->valid)) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530862 pe_err("session is not valid");
Krishna Kumaar Natarajan03cc3862015-12-15 17:51:19 -0800863 return;
864 }
865
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530866 pe_debug("Trying to delete PE session: %d Opmode: %d BssIdx: %d BSSID: "MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 session->peSessionId, session->operMode,
868 session->bssIdx,
869 MAC_ADDR_ARRAY(session->bssId));
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530870
871 lim_reset_bcn_probe_filter(mac_ctx, session);
872
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 for (n = 0; n < (mac_ctx->lim.maxStation + 1); n++) {
874 timer_ptr = &mac_ctx->lim.limTimers.gpLimCnfWaitTimer[n];
875 if (session->peSessionId == timer_ptr->sessionId)
876 if (true == tx_timer_running(timer_ptr))
877 tx_timer_deactivate(timer_ptr);
878 }
879
Karthick S7a17a712015-10-14 16:12:48 +0530880 if (LIM_IS_AP_ROLE(session)) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530881 qdf_mc_timer_stop(&session->protection_fields_reset_timer);
882 qdf_mc_timer_destroy(&session->protection_fields_reset_timer);
Krunal Soni6de1b212017-10-30 23:29:20 -0700883 lim_del_pmf_sa_query_timer(mac_ctx, session);
Karthick S7a17a712015-10-14 16:12:48 +0530884 }
885
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886 /* Delete FT related information */
887 lim_ft_cleanup(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888 if (session->pLimStartBssReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530889 qdf_mem_free(session->pLimStartBssReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890 session->pLimStartBssReq = NULL;
891 }
892
893 if (session->pLimJoinReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530894 qdf_mem_free(session->pLimJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895 session->pLimJoinReq = NULL;
896 }
897
898 if (session->pLimReAssocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530899 qdf_mem_free(session->pLimReAssocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 session->pLimReAssocReq = NULL;
901 }
902
903 if (session->pLimMlmJoinReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530904 qdf_mem_free(session->pLimMlmJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 session->pLimMlmJoinReq = NULL;
906 }
907
908 if (session->dph.dphHashTable.pHashTable != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530909 qdf_mem_free(session->dph.dphHashTable.pHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 session->dph.dphHashTable.pHashTable = NULL;
911 }
912
913 if (session->dph.dphHashTable.pDphNodeArray != NULL) {
Naveen Rawatb0c5b6b2017-11-27 17:37:40 -0800914 qdf_mem_zero(session->dph.dphHashTable.pDphNodeArray,
915 sizeof(struct sDphHashNode) *
916 (SIR_SAP_MAX_NUM_PEERS + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800917 session->dph.dphHashTable.pDphNodeArray = NULL;
918 }
919
920 if (session->gpLimPeerIdxpool != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530921 qdf_mem_free(session->gpLimPeerIdxpool);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800922 session->gpLimPeerIdxpool = NULL;
923 }
924
925 if (session->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530926 qdf_mem_free(session->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927 session->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530928 session->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 }
930
931 if (session->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530932 qdf_mem_free(session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933 session->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530934 session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935 }
936
937 if (session->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530938 qdf_mem_free(session->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800939 session->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530940 session->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941 }
942
943 if (session->parsedAssocReq != NULL) {
944 tpSirAssocReq tmp_ptr = NULL;
945 /* Cleanup the individual allocation first */
946 for (i = 0; i < session->dph.dphHashTable.size; i++) {
947 if (session->parsedAssocReq[i] == NULL)
948 continue;
949 tmp_ptr = ((tpSirAssocReq)
950 (session->parsedAssocReq[i]));
951 if (tmp_ptr->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530952 qdf_mem_free(tmp_ptr->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953 tmp_ptr->assocReqFrame = NULL;
954 tmp_ptr->assocReqFrameLength = 0;
955 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530956 qdf_mem_free(session->parsedAssocReq[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800957 session->parsedAssocReq[i] = NULL;
958 }
959 /* Cleanup the whole block */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530960 qdf_mem_free(session->parsedAssocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961 session->parsedAssocReq = NULL;
962 }
963 if (NULL != session->limAssocResponseData) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530964 qdf_mem_free(session->limAssocResponseData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 session->limAssocResponseData = NULL;
966 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 if (NULL != session->pLimMlmReassocRetryReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530968 qdf_mem_free(session->pLimMlmReassocRetryReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969 session->pLimMlmReassocRetryReq = NULL;
970 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 if (NULL != session->pLimMlmReassocReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530972 qdf_mem_free(session->pLimMlmReassocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 session->pLimMlmReassocReq = NULL;
974 }
975
976 if (NULL != session->pSchProbeRspTemplate) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530977 qdf_mem_free(session->pSchProbeRspTemplate);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978 session->pSchProbeRspTemplate = NULL;
979 }
980
981 if (NULL != session->pSchBeaconFrameBegin) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530982 qdf_mem_free(session->pSchBeaconFrameBegin);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983 session->pSchBeaconFrameBegin = NULL;
984 }
985
986 if (NULL != session->pSchBeaconFrameEnd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530987 qdf_mem_free(session->pSchBeaconFrameEnd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988 session->pSchBeaconFrameEnd = NULL;
989 }
990
991 /* Must free the buffer before peSession invalid */
992 if (NULL != session->addIeParams.probeRespData_buff) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530993 qdf_mem_free(session->addIeParams.probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800994 session->addIeParams.probeRespData_buff = NULL;
995 session->addIeParams.probeRespDataLen = 0;
996 }
997 if (NULL != session->addIeParams.assocRespData_buff) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530998 qdf_mem_free(session->addIeParams.assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999 session->addIeParams.assocRespData_buff = NULL;
1000 session->addIeParams.assocRespDataLen = 0;
1001 }
1002 if (NULL != session->addIeParams.probeRespBCNData_buff) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301003 qdf_mem_free(session->addIeParams.probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004 session->addIeParams.probeRespBCNData_buff = NULL;
1005 session->addIeParams.probeRespBCNDataLen = 0;
1006 }
1007#ifdef WLAN_FEATURE_11W
Anurag Chouhan210db072016-02-22 18:42:15 +05301008 if (QDF_TIMER_STATE_RUNNING ==
1009 qdf_mc_timer_get_current_state(&session->pmfComebackTimer))
1010 qdf_mc_timer_stop(&session->pmfComebackTimer);
1011 qdf_mc_timer_destroy(&session->pmfComebackTimer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012#endif
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301013 pe_delete_fils_info(session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014 session->valid = false;
1015
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05301016 if (session->access_policy_vendor_ie)
1017 qdf_mem_free(session->access_policy_vendor_ie);
1018
1019 session->access_policy_vendor_ie = NULL;
1020
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021 if (LIM_IS_AP_ROLE(session))
1022 lim_check_and_reset_protection_params(mac_ctx);
1023
1024 return;
1025}
1026
1027/*--------------------------------------------------------------------------
1028 \brief pe_find_session_by_peer_sta() - looks up the PE session given the Station Address.
1029
1030 This function returns the session context and the session ID if the session
1031 corresponding to the given station address is found in the PE session table.
1032
1033 \param pMac - pointer to global adapter context
1034 \param sa - Peer STA Address of the session
1035 \param sessionId -session ID is returned here, if session is found.
1036
1037 \return tpPESession - pointer to the session context or NULL if session is not found.
1038
1039 \sa
1040 --------------------------------------------------------------------------*/
1041
1042tpPESession pe_find_session_by_peer_sta(tpAniSirGlobal pMac, uint8_t *sa,
1043 uint8_t *sessionId)
1044{
1045 uint8_t i;
1046 tpDphHashNode pSta;
1047 uint16_t aid;
1048
1049 for (i = 0; i < pMac->lim.maxBssId; i++) {
1050 if ((pMac->lim.gpSession[i].valid)) {
1051 pSta =
1052 dph_lookup_hash_entry(pMac, sa, &aid,
1053 &pMac->lim.gpSession[i].dph.
1054 dphHashTable);
1055 if (pSta != NULL) {
1056 *sessionId = i;
1057 return &pMac->lim.gpSession[i];
1058 }
1059 }
1060 }
1061
Nishank Aggarwalc7c65922017-03-24 19:56:23 +05301062 pe_debug("Session lookup fails for Peer StaId:");
1063 lim_print_mac_addr(pMac, sa, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 return NULL;
1065}
1066
1067/**
1068 * pe_find_session_by_sme_session_id() - looks up the PE session for given sme
1069 * session id
1070 * @mac_ctx: pointer to global adapter context
1071 * @sme_session_id: sme session id
1072 *
1073 * looks up the PE session for given sme session id
1074 *
1075 * Return: pe session entry for given sme session if found else NULL
1076 */
1077tpPESession pe_find_session_by_sme_session_id(tpAniSirGlobal mac_ctx,
1078 uint8_t sme_session_id)
1079{
1080 uint8_t i;
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -07001081
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
1083 if ((mac_ctx->lim.gpSession[i].valid) &&
1084 (mac_ctx->lim.gpSession[i].smeSessionId ==
1085 sme_session_id)) {
1086 return &mac_ctx->lim.gpSession[i];
1087 }
1088 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089 return NULL;
1090}
1091
1092/**
1093 * pe_get_active_session_count() - function to return active pe session count
1094 *
1095 * @mac_ctx: pointer to global mac structure
1096 *
1097 * returns number of active pe session count
1098 *
1099 * Return: 0 if there are no active sessions else return number of active
1100 * sessions
1101 */
1102uint8_t pe_get_active_session_count(tpAniSirGlobal mac_ctx)
1103{
1104 uint8_t i, active_session_count = 0;
1105
1106 for (i = 0; i < mac_ctx->lim.maxBssId; i++)
1107 if (mac_ctx->lim.gpSession[i].valid)
1108 active_session_count++;
1109
1110 return active_session_count;
1111}