blob: 9874899a4f117ecf101fadad7485786a576e185c [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"
Bala Venkatesh41837792018-11-01 18:22:13 +053040#include "cfg_ucfg_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080041
Qiwei Cai50a21082018-08-07 14:30:09 +080042#ifdef WLAN_ALLOCATE_GLOBAL_BUFFERS_DYNAMICALLY
43static struct sDphHashNode *g_dph_node_array;
Naveen Rawatb0c5b6b2017-11-27 17:37:40 -080044
Qiwei Cai50a21082018-08-07 14:30:09 +080045QDF_STATUS pe_allocate_dph_node_array_buffer(void)
46{
47 uint32_t buf_size;
48
49 buf_size = SIR_MAX_SUPPORTED_BSS * (SIR_SAP_MAX_NUM_PEERS + 1)
50 * sizeof(struct sDphHashNode);
51 g_dph_node_array = qdf_mem_malloc(buf_size);
Arif Hussainf5b6c412018-10-10 19:41:09 -070052 if (!g_dph_node_array)
Qiwei Cai50a21082018-08-07 14:30:09 +080053 return QDF_STATUS_E_NOMEM;
Arif Hussainf5b6c412018-10-10 19:41:09 -070054
55 return QDF_STATUS_SUCCESS;
Qiwei Cai50a21082018-08-07 14:30:09 +080056}
57
58void pe_free_dph_node_array_buffer(void)
59{
60 qdf_mem_free(g_dph_node_array);
61 g_dph_node_array = NULL;
62}
63
64static inline
65struct sDphHashNode *pe_get_session_dph_node_array(uint8_t session_id)
66{
67 return &g_dph_node_array[session_id * (SIR_SAP_MAX_NUM_PEERS + 1)];
68}
69
70#else /* WLAN_ALLOCATE_GLOBAL_BUFFERS_DYNAMICALLY */
Naveen Rawatb0c5b6b2017-11-27 17:37:40 -080071static struct sDphHashNode
72 g_dph_node_array[SIR_MAX_SUPPORTED_BSS][SIR_SAP_MAX_NUM_PEERS + 1];
73
Qiwei Cai50a21082018-08-07 14:30:09 +080074static inline
75struct sDphHashNode *pe_get_session_dph_node_array(uint8_t session_id)
76{
77 return g_dph_node_array[session_id];
78}
79#endif /* WLAN_ALLOCATE_GLOBAL_BUFFERS_DYNAMICALLY */
80
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080081/*--------------------------------------------------------------------------
82
83 \brief pe_init_beacon_params() - Initialize the beaconParams structure
84
Jeff Johnson0bb33162018-11-18 22:20:42 -080085 \param struct pe_session * - pointer to the session context or NULL if session can not be created.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086 \return void
87 \sa
88
89 --------------------------------------------------------------------------*/
90
Jeff Johnson9320c1e2018-12-02 13:09:20 -080091static void pe_init_beacon_params(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -080092 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080093{
Jeff Johnsonb5c13332018-12-03 09:54:51 -080094 pe_session->beaconParams.beaconInterval = 0;
95 pe_session->beaconParams.fShortPreamble = 0;
96 pe_session->beaconParams.llaCoexist = 0;
97 pe_session->beaconParams.llbCoexist = 0;
98 pe_session->beaconParams.llgCoexist = 0;
99 pe_session->beaconParams.ht20Coexist = 0;
100 pe_session->beaconParams.llnNonGFCoexist = 0;
101 pe_session->beaconParams.fRIFSMode = 0;
102 pe_session->beaconParams.fLsigTXOPProtectionFullSupport = 0;
103 pe_session->beaconParams.gHTObssMode = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800104
105 /* Number of legacy STAs associated */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800106 qdf_mem_set((void *)&pe_session->gLim11bParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800107 sizeof(tLimProtStaParams), 0);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800108 qdf_mem_set((void *)&pe_session->gLim11aParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800109 sizeof(tLimProtStaParams), 0);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800110 qdf_mem_set((void *)&pe_session->gLim11gParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111 sizeof(tLimProtStaParams), 0);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800112 qdf_mem_set((void *)&pe_session->gLimNonGfParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113 sizeof(tLimProtStaParams), 0);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800114 qdf_mem_set((void *)&pe_session->gLimHt20Params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800115 sizeof(tLimProtStaParams), 0);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800116 qdf_mem_set((void *)&pe_session->gLimLsigTxopParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117 sizeof(tLimProtStaParams), 0);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800118 qdf_mem_set((void *)&pe_session->gLimOlbcParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800119 sizeof(tLimProtStaParams), 0);
120}
121
122/*
123 * pe_reset_protection_callback() - resets protection structs so that when an AP
124 * causing use of protection goes away, corresponding protection bit can be
125 * reset
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800126 * @ptr: pointer to pe_session
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127 *
128 * This function resets protection structs so that when an AP causing use of
129 * protection goes away, corresponding protection bit can be reset. This allowes
130 * protection bits to be reset once legacy overlapping APs are gone.
131 *
132 * Return: void
133 */
Jeff Johnson97699002016-10-07 07:32:55 -0700134static void pe_reset_protection_callback(void *ptr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800135{
Jeff Johnson0bb33162018-11-18 22:20:42 -0800136 struct pe_session *pe_session_entry = (struct pe_session *)ptr;
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800137 struct mac_context *mac_ctx = pe_session_entry->mac_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800138 int8_t i = 0;
139 tUpdateBeaconParams beacon_params;
140 uint16_t current_protection_state = 0;
141 tpDphHashNode station_hash_node = NULL;
142 tSirMacHTOperatingMode old_op_mode;
143 bool bcn_prms_changed = false;
144
145 if (pe_session_entry->valid == false) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530146 pe_err("session already deleted. exiting timer callback");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800147 return;
148 }
149
Manishekar Chandrasekaran9e8c7be2016-08-03 14:57:14 +0530150 /*
151 * During CAC period, if the callback is triggered, the beacon
152 * template may get updated. Subsequently if the vdev is not up, the
153 * vdev would be made up -- which should not happen during the CAC
154 * period. To avoid this, ignore the protection callback if the session
155 * is not yet up.
156 */
157 if (!wma_is_vdev_up(pe_session_entry->smeSessionId)) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530158 pe_err("session is not up yet. exiting timer callback");
Manishekar Chandrasekaran9e8c7be2016-08-03 14:57:14 +0530159 return;
160 }
161
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +0530162 /*
163 * If dfsIncludeChanSwIe is set restrat timer as we are going to change
164 * channel and no point in checking protection mode for this channel.
165 */
166 if (pe_session_entry->dfsIncludeChanSwIe) {
167 pe_err("CSA going on restart timer");
168 goto restart_timer;
169 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 current_protection_state |=
171 pe_session_entry->gLimOverlap11gParams.protectionEnabled |
172 pe_session_entry->gLimOverlap11aParams.protectionEnabled << 1 |
173 pe_session_entry->gLimOverlapHt20Params.protectionEnabled << 2 |
174 pe_session_entry->gLimOverlapNonGfParams.protectionEnabled << 3 |
175 pe_session_entry->gLimOlbcParams.protectionEnabled << 4;
176
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530177 pe_debug("old protection state: 0x%04X, new protection state: 0x%04X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 pe_session_entry->old_protection_state,
179 current_protection_state);
180
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530181 qdf_mem_zero(&pe_session_entry->gLimOverlap11gParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 sizeof(pe_session_entry->gLimOverlap11gParams));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530183 qdf_mem_zero(&pe_session_entry->gLimOverlap11aParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 sizeof(pe_session_entry->gLimOverlap11aParams));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530185 qdf_mem_zero(&pe_session_entry->gLimOverlapHt20Params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186 sizeof(pe_session_entry->gLimOverlapHt20Params));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530187 qdf_mem_zero(&pe_session_entry->gLimOverlapNonGfParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800188 sizeof(pe_session_entry->gLimOverlapNonGfParams));
189
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530190 qdf_mem_zero(&pe_session_entry->gLimOlbcParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191 sizeof(pe_session_entry->gLimOlbcParams));
192
Abhishek Singhaf7e7fa2016-08-08 17:59:31 +0530193 /*
194 * Do not reset fShortPreamble and beaconInterval, as they
195 * are not updated.
196 */
197 pe_session_entry->beaconParams.llaCoexist = 0;
198 pe_session_entry->beaconParams.llbCoexist = 0;
199 pe_session_entry->beaconParams.llgCoexist = 0;
200 pe_session_entry->beaconParams.ht20Coexist = 0;
201 pe_session_entry->beaconParams.llnNonGFCoexist = 0;
202 pe_session_entry->beaconParams.fRIFSMode = 0;
203 pe_session_entry->beaconParams.fLsigTXOPProtectionFullSupport = 0;
204 pe_session_entry->beaconParams.gHTObssMode = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206
207 old_op_mode = pe_session_entry->htOperMode;
208 pe_session_entry->htOperMode = eSIR_HT_OP_MODE_PURE;
Masti, Narayanraddi4d8860c2016-08-22 15:46:48 +0530209 mac_ctx->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800210
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530211 qdf_mem_zero(&beacon_params, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212 /* index 0, is self node, peers start from 1 */
Bala Venkatesh2fde2c62018-09-11 20:33:24 +0530213 for (i = 1 ; i <= mac_ctx->mlme_cfg->sap_cfg.assoc_sta_limit ; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800214 station_hash_node = dph_get_hash_entry(mac_ctx, i,
215 &pe_session_entry->dph.dphHashTable);
216 if (NULL == station_hash_node)
217 continue;
218 lim_decide_ap_protection(mac_ctx, station_hash_node->staAddr,
219 &beacon_params, pe_session_entry);
220 }
221
222 if (pe_session_entry->htOperMode != old_op_mode)
223 bcn_prms_changed = true;
224
225 if ((current_protection_state !=
226 pe_session_entry->old_protection_state) &&
227 (false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530228 pe_debug("protection changed, update beacon template");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 /* update beacon fix params and send update to FW */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530230 qdf_mem_zero(&beacon_params, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 beacon_params.bssIdx = pe_session_entry->bssIdx;
232 beacon_params.fShortPreamble =
233 pe_session_entry->beaconParams.fShortPreamble;
234 beacon_params.beaconInterval =
235 pe_session_entry->beaconParams.beaconInterval;
236 beacon_params.llaCoexist =
237 pe_session_entry->beaconParams.llaCoexist;
238 beacon_params.llbCoexist =
239 pe_session_entry->beaconParams.llbCoexist;
240 beacon_params.llgCoexist =
241 pe_session_entry->beaconParams.llgCoexist;
242 beacon_params.ht20MhzCoexist =
243 pe_session_entry->beaconParams.ht20Coexist;
244 beacon_params.llnNonGFCoexist =
245 pe_session_entry->beaconParams.llnNonGFCoexist;
246 beacon_params.fLsigTXOPProtectionFullSupport =
247 pe_session_entry->beaconParams.
248 fLsigTXOPProtectionFullSupport;
249 beacon_params.fRIFSMode =
250 pe_session_entry->beaconParams.fRIFSMode;
251 beacon_params.smeSessionId =
252 pe_session_entry->smeSessionId;
Selvaraj, Sridhardc038ee2016-06-24 15:22:14 +0530253 beacon_params.paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800254 bcn_prms_changed = true;
255 }
256
257 if (bcn_prms_changed) {
258 sch_set_fixed_beacon_fields(mac_ctx, pe_session_entry);
259 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session_entry);
260 }
261
262 pe_session_entry->old_protection_state = current_protection_state;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +0530263restart_timer:
Anurag Chouhan210db072016-02-22 18:42:15 +0530264 if (qdf_mc_timer_start(&pe_session_entry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265 protection_fields_reset_timer,
266 SCH_PROTECTION_RESET_TIME)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530267 != QDF_STATUS_SUCCESS) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530268 pe_err("cannot create or start protectionFieldsResetTimer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269 }
270}
271
Abhishek Singhcfb44482017-03-10 12:42:37 +0530272#ifdef WLAN_FEATURE_11W
273/**
274 * pe_init_pmf_comeback_timer: init PMF comeback timer
275 * @mac_ctx: pointer to global adapter context
276 * @session: pe session
277 * @session_id: session ID
278 *
279 * Return: void
280 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800281static void pe_init_pmf_comeback_timer(struct mac_context *mac_ctx,
Jeff Johnson0bb33162018-11-18 22:20:42 -0800282struct pe_session *session, uint8_t session_id)
Abhishek Singhcfb44482017-03-10 12:42:37 +0530283{
284 QDF_STATUS status;
285
Jeff Johnson4a07a9b2018-11-21 23:51:02 -0800286 session->pmfComebackTimerInfo.mac = mac_ctx;
287 session->pmfComebackTimerInfo.session_id = session_id;
Abhishek Singhcfb44482017-03-10 12:42:37 +0530288 status = qdf_mc_timer_init(&session->pmfComebackTimer,
289 QDF_TIMER_TYPE_SW, lim_pmf_comeback_timer_callback,
290 (void *)&session->pmfComebackTimerInfo);
291 if (!QDF_IS_STATUS_SUCCESS(status))
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530292 pe_err("cannot init pmf comeback timer");
Abhishek Singhcfb44482017-03-10 12:42:37 +0530293}
294#else
295static inline void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800296pe_init_pmf_comeback_timer(struct mac_context *mac_ctx,
Jeff Johnson0bb33162018-11-18 22:20:42 -0800297 struct pe_session *session, uint8_t session_id)
Abhishek Singhcfb44482017-03-10 12:42:37 +0530298{
299}
300#endif
301
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530302#ifdef WLAN_FEATURE_FILS_SK
303/**
304 * pe_delete_fils_info: API to delete fils session info
305 * @session: pe session
306 *
307 * Return: void
308 */
Jeff Johnson0bb33162018-11-18 22:20:42 -0800309void pe_delete_fils_info(struct pe_session *session)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530310{
311 struct pe_fils_session *fils_info;
312
313 if (!session || (session && !session->valid)) {
314 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
315 FL("session is not valid"));
316 return;
317 }
318 fils_info = session->fils_info;
319 if (!fils_info) {
320 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
321 FL("fils info not found"));
322 return;
323 }
324 if (fils_info->keyname_nai_data)
325 qdf_mem_free(fils_info->keyname_nai_data);
326 if (fils_info->fils_erp_reauth_pkt)
327 qdf_mem_free(fils_info->fils_erp_reauth_pkt);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +0530328 if (fils_info->fils_rrk)
329 qdf_mem_free(fils_info->fils_rrk);
330 if (fils_info->fils_rik)
331 qdf_mem_free(fils_info->fils_rik);
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530332 if (fils_info->fils_eap_finish_pkt)
333 qdf_mem_free(fils_info->fils_eap_finish_pkt);
334 if (fils_info->fils_rmsk)
335 qdf_mem_free(fils_info->fils_rmsk);
336 if (fils_info->fils_pmk)
337 qdf_mem_free(fils_info->fils_pmk);
338 if (fils_info->auth_info.keyname)
339 qdf_mem_free(fils_info->auth_info.keyname);
340 if (fils_info->auth_info.domain_name)
341 qdf_mem_free(fils_info->auth_info.domain_name);
Vignesh Viswanathana1bb0922017-09-15 12:58:48 +0530342 if (fils_info->hlp_data)
343 qdf_mem_free(fils_info->hlp_data);
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530344 qdf_mem_free(fils_info);
345 session->fils_info = NULL;
346}
347/**
348 * pe_init_fils_info: API to initialize fils session info elements to null
349 * @session: pe session
350 *
351 * Return: void
352 */
Jeff Johnson0bb33162018-11-18 22:20:42 -0800353static void pe_init_fils_info(struct pe_session *session)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530354{
355 struct pe_fils_session *fils_info;
356
357 if (!session || (session && !session->valid)) {
358 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
359 FL("session is not valid"));
360 return;
361 }
362 session->fils_info = qdf_mem_malloc(sizeof(struct pe_fils_session));
363 fils_info = session->fils_info;
Arif Hussainf5b6c412018-10-10 19:41:09 -0700364 if (!fils_info)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530365 return;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530366 fils_info->keyname_nai_data = NULL;
367 fils_info->fils_erp_reauth_pkt = NULL;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +0530368 fils_info->fils_rrk = NULL;
369 fils_info->fils_rik = NULL;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530370 fils_info->fils_eap_finish_pkt = NULL;
371 fils_info->fils_rmsk = NULL;
372 fils_info->fils_pmk = NULL;
373 fils_info->auth_info.keyname = NULL;
374 fils_info->auth_info.domain_name = NULL;
375}
376#else
Jeff Johnson0bb33162018-11-18 22:20:42 -0800377static void pe_delete_fils_info(struct pe_session *session) { }
378static void pe_init_fils_info(struct pe_session *session) { }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530379#endif
380
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381/**
Abhishek Singh47888602017-05-10 12:50:50 +0530382 * lim_get_peer_idxpool_size: get number of peer idx pool size
383 * @num_sta: Max number of STA
384 * @bss_type: BSS type
385 *
386 * The peer index start from 1 and thus index 0 is not used, so
387 * add 1 to the max sta. For STA if TDLS is enabled add 2 as
388 * index 1 is reserved for peer BSS.
389 *
390 * Return: number of peer idx pool size
391 */
392#ifdef FEATURE_WLAN_TDLS
393static inline uint8_t
394lim_get_peer_idxpool_size(uint16_t num_sta, tSirBssType bss_type)
395{
396 /*
397 * In station role, index 1 is reserved for peer
398 * corresponding to AP. For TDLS the index should
399 * start from 2
400 */
401 if (bss_type == eSIR_INFRASTRUCTURE_MODE)
402 return num_sta + 2;
403 else
404 return num_sta + 1;
405
406}
407#else
408static inline uint8_t
409lim_get_peer_idxpool_size(uint16_t num_sta, tSirBssType bss_type)
410{
411 return num_sta + 1;
412}
413#endif
414
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800415void lim_set_bcn_probe_filter(struct mac_context *mac_ctx,
Jeff Johnson0bb33162018-11-18 22:20:42 -0800416 struct pe_session *session,
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530417 tSirMacSSid *ibss_ssid,
418 uint8_t sap_channel)
419{
420 struct mgmt_beacon_probe_filter *filter;
421 tSirBssType bss_type;
422 uint8_t session_id;
423 tSirMacAddr *bssid;
424
425 if (!session) {
426 pe_err("Invalid session pointer");
427 return;
428 }
429
430 bss_type = session->bssType;
431 session_id = session->peSessionId;
432 bssid = &session->bssId;
433
434 if (session_id >= SIR_MAX_SUPPORTED_BSS) {
435 pe_err("Invalid session_id %d of type %d",
436 session_id, bss_type);
437 return;
438 }
439
440 filter = &mac_ctx->bcn_filter;
441
442 if (eSIR_INFRASTRUCTURE_MODE == bss_type) {
443 filter->num_sta_sessions++;
444 sir_copy_mac_addr(filter->sta_bssid[session_id], *bssid);
445 pe_debug("Set filter for STA Session %d bssid "MAC_ADDRESS_STR,
446 session_id, MAC_ADDR_ARRAY(*bssid));
447 } else if (eSIR_IBSS_MODE == bss_type) {
448 if (!ibss_ssid) {
449 pe_err("IBSS Type with NULL SSID");
450 goto done;
451 }
452 filter->num_ibss_sessions++;
453 filter->ibss_ssid[session_id].length = ibss_ssid->length;
454 qdf_mem_copy(&filter->ibss_ssid[session_id].length,
455 ibss_ssid->ssId,
456 ibss_ssid->length);
457 pe_debug("Set filter for IBSS session %d ssid %s",
458 session_id, ibss_ssid->ssId);
459 } else if (eSIR_INFRA_AP_MODE == bss_type) {
460 if (!sap_channel) {
461 pe_err("SAP Type with invalid channel");
462 goto done;
463 }
464 filter->num_sap_sessions++;
465 filter->sap_channel[session_id] = sap_channel;
466 pe_debug("Set filter for SAP session %d channel %d",
467 session_id, sap_channel);
468 }
469
470done:
471 pe_debug("sta %d ibss %d sap %d",
472 filter->num_sta_sessions, filter->num_ibss_sessions,
473 filter->num_sap_sessions);
474}
475
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800476void lim_reset_bcn_probe_filter(struct mac_context *mac_ctx,
Jeff Johnson0bb33162018-11-18 22:20:42 -0800477 struct pe_session *session)
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530478{
479 struct mgmt_beacon_probe_filter *filter;
480 tSirBssType bss_type;
481 uint8_t session_id;
482
483 if (!session) {
484 pe_err("Invalid session pointer");
485 return;
486 }
487
488 bss_type = session->bssType;
489 session_id = session->peSessionId;
490
491 if (session_id >= SIR_MAX_SUPPORTED_BSS) {
492 pe_err("Invalid session_id %d of type %d",
493 session_id, bss_type);
494 return;
495 }
496
497 filter = &mac_ctx->bcn_filter;
498
499 if (eSIR_INFRASTRUCTURE_MODE == bss_type) {
500 if (filter->num_sta_sessions)
501 filter->num_sta_sessions--;
502 qdf_mem_set(&filter->sta_bssid[session_id],
503 sizeof(tSirMacAddr), 0);
504 pe_debug("Cleared STA Filter for session %d", session_id);
505 } else if (eSIR_IBSS_MODE == bss_type) {
506 if (filter->num_ibss_sessions)
507 filter->num_ibss_sessions--;
508 filter->ibss_ssid[session_id].length = 0;
509 qdf_mem_set(&filter->ibss_ssid[session_id].ssId,
510 SIR_MAC_MAX_SSID_LENGTH, 0);
511 pe_debug("Cleared IBSS Filter for session %d", session_id);
512 } else if (eSIR_INFRA_AP_MODE == bss_type) {
513 if (filter->num_sap_sessions)
514 filter->num_sap_sessions--;
515 filter->sap_channel[session_id] = 0;
516 pe_debug("Cleared SAP Filter for session %d", session_id);
517 }
518
519 pe_debug("sta %d ibss %d sap %d",
520 filter->num_sta_sessions, filter->num_ibss_sessions,
521 filter->num_sap_sessions);
522}
523
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800524void lim_update_bcn_probe_filter(struct mac_context *mac_ctx,
Jeff Johnson0bb33162018-11-18 22:20:42 -0800525 struct pe_session *session)
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530526{
527 struct mgmt_beacon_probe_filter *filter;
528 tSirBssType bss_type;
529 uint8_t session_id;
530
531 if (!session) {
532 pe_err("Invalid session pointer");
533 return;
534 }
535
536 bss_type = session->bssType;
537 session_id = session->peSessionId;
538
539 if (session_id >= SIR_MAX_SUPPORTED_BSS) {
540 pe_err("Invalid session_id %d of type %d",
541 session_id, bss_type);
542 return;
543 }
544
545 filter = &mac_ctx->bcn_filter;
546
547 if (eSIR_INFRA_AP_MODE == bss_type) {
548 filter->sap_channel[session_id] = session->currentOperChannel;
549 pe_debug("Updated SAP Filter for session %d channel %d",
550 session_id, filter->sap_channel[session_id]);
551 } else {
552 pe_debug("Invalid session type %d session id %d",
553 bss_type, session_id);
554 }
555
556 pe_debug("sta %d ibss %d sap %d",
557 filter->num_sta_sessions, filter->num_ibss_sessions,
558 filter->num_sap_sessions);
559}
560
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800561struct pe_session *pe_create_session(struct mac_context *mac,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530562 uint8_t *bssid,
563 uint8_t *sessionId,
564 uint16_t numSta, tSirBssType bssType,
565 uint8_t sme_session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800566{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530567 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568 uint8_t i;
Jeff Johnson0bb33162018-11-18 22:20:42 -0800569 struct pe_session *session_ptr;
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530570 struct wlan_objmgr_vdev *vdev;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700571
Jeff Johnson348973e2018-11-22 16:51:12 -0800572 for (i = 0; i < mac->lim.maxBssId; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573 /* Find first free room in session table */
Jeff Johnson348973e2018-11-22 16:51:12 -0800574 if (mac->lim.gpSession[i].valid == true)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575 continue;
576 break;
577 }
578
Jeff Johnson348973e2018-11-22 16:51:12 -0800579 if (i == mac->lim.maxBssId) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530580 pe_err("Session can't be created. Reached max sessions");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800581 return NULL;
582 }
583
Jeff Johnson348973e2018-11-22 16:51:12 -0800584 session_ptr = &mac->lim.gpSession[i];
Jeff Johnsonc47d7b12018-11-18 19:12:51 -0800585 qdf_mem_set((void *)session_ptr, sizeof(struct pe_session), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586 /* Allocate space for Station Table for this session. */
587 session_ptr->dph.dphHashTable.pHashTable =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530588 qdf_mem_malloc(sizeof(tpDphHashNode) * (numSta + 1));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700589 if (!session_ptr->dph.dphHashTable.pHashTable)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800590 return NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800591
Qiwei Cai50a21082018-08-07 14:30:09 +0800592 session_ptr->dph.dphHashTable.pDphNodeArray =
593 pe_get_session_dph_node_array(i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594 session_ptr->dph.dphHashTable.size = numSta + 1;
Jeff Johnson348973e2018-11-22 16:51:12 -0800595 dph_hash_table_class_init(mac, &session_ptr->dph.dphHashTable);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530596 session_ptr->gpLimPeerIdxpool = qdf_mem_malloc(
Abhishek Singh47888602017-05-10 12:50:50 +0530597 sizeof(*(session_ptr->gpLimPeerIdxpool)) *
598 lim_get_peer_idxpool_size(numSta, bssType));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700599 if (!session_ptr->gpLimPeerIdxpool)
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530600 goto free_dp_hash_table;
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530601
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800602 session_ptr->freePeerIdxHead = 0;
603 session_ptr->freePeerIdxTail = 0;
604 session_ptr->gLimNumOfCurrentSTAs = 0;
605 /* Copy the BSSID to the session table */
606 sir_copy_mac_addr(session_ptr->bssId, bssid);
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700607 if (bssType == eSIR_MONITOR_MODE)
Jeff Johnson348973e2018-11-22 16:51:12 -0800608 sir_copy_mac_addr(mac->lim.gpSession[i].selfMacAddr, bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 session_ptr->valid = true;
Jeff Johnson47d75242018-05-12 15:58:53 -0700610 /* Initialize the SME and MLM states to IDLE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611 session_ptr->limMlmState = eLIM_MLM_IDLE_STATE;
612 session_ptr->limSmeState = eLIM_SME_IDLE_STATE;
613 session_ptr->limCurrentAuthType = eSIR_OPEN_SYSTEM;
Jeff Johnson348973e2018-11-22 16:51:12 -0800614 pe_init_beacon_params(mac, &mac->lim.gpSession[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615 session_ptr->is11Rconnection = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800616#ifdef FEATURE_WLAN_ESE
617 session_ptr->isESEconnection = false;
618#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 session_ptr->isFastTransitionEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800620 session_ptr->isFastRoamIniFeatureEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800621 *sessionId = i;
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530622 session_ptr->peSessionId = i;
623 session_ptr->bssType = bssType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800624 session_ptr->gLimPhyMode = WNI_CFG_PHY_MODE_11G;
625 /* Initialize CB mode variables when session is created */
626 session_ptr->htSupportedChannelWidthSet = 0;
627 session_ptr->htRecommendedTxWidthSet = 0;
628 session_ptr->htSecondaryChannelOffset = 0;
629#ifdef FEATURE_WLAN_TDLS
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530630 qdf_mem_set(session_ptr->peerAIDBitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 sizeof(session_ptr->peerAIDBitmap), 0);
632 session_ptr->tdls_prohibited = false;
633 session_ptr->tdls_chan_swit_prohibited = false;
634#endif
635 session_ptr->fWaitForProbeRsp = 0;
636 session_ptr->fIgnoreCapsChange = 0;
Jeff Johnson348973e2018-11-22 16:51:12 -0800637 session_ptr->ignore_assoc_disallowed = mac->ignore_assoc_disallowed;
Arif Hussain05fb4872018-01-03 16:02:55 -0800638 session_ptr->is_session_obss_color_collision_det_enabled =
Jeff Johnson348973e2018-11-22 16:51:12 -0800639 mac->lim.global_obss_color_collision_det_offload;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530641 pe_debug("Create a new PE session: %d BSSID: "MAC_ADDRESS_STR" Max No of STA: %d",
Kapil Guptabf4943c2016-10-13 12:15:39 +0530642 *sessionId, MAC_ADDR_ARRAY(bssid), numSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800643
Rajeev Kumarcf835a02016-04-15 15:01:31 -0700644 if (eSIR_INFRA_AP_MODE == bssType || eSIR_IBSS_MODE == bssType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645 session_ptr->pSchProbeRspTemplate =
Abhinav Kumar68834222018-07-18 19:06:14 +0530646 qdf_mem_malloc(SIR_MAX_PROBE_RESP_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647 session_ptr->pSchBeaconFrameBegin =
Abhinav Kumar68834222018-07-18 19:06:14 +0530648 qdf_mem_malloc(SIR_MAX_BEACON_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649 session_ptr->pSchBeaconFrameEnd =
Abhinav Kumar68834222018-07-18 19:06:14 +0530650 qdf_mem_malloc(SIR_MAX_BEACON_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800651 if ((NULL == session_ptr->pSchProbeRspTemplate)
652 || (NULL == session_ptr->pSchBeaconFrameBegin)
653 || (NULL == session_ptr->pSchBeaconFrameEnd)) {
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530654 goto free_session_attrs;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655 }
656 }
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530657
658 /*
659 * Get vdev object from soc which automatically increments
660 * reference count.
661 */
Jeff Johnson348973e2018-11-22 16:51:12 -0800662 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(mac->psoc,
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530663 sme_session_id,
664 WLAN_LEGACY_MAC_ID);
665 if (!vdev) {
666 pe_err("vdev is NULL for vdev_id: %u", sme_session_id);
667 goto free_session_attrs;
668 }
669 session_ptr->vdev = vdev;
670 session_ptr->smeSessionId = sme_session_id;
Jeff Johnson348973e2018-11-22 16:51:12 -0800671 session_ptr->mac_ctx = mac;
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530672
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673 if (eSIR_INFRASTRUCTURE_MODE == bssType)
Jeff Johnson348973e2018-11-22 16:51:12 -0800674 lim_ft_open(mac, &mac->lim.gpSession[i]);
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700675
676 if (eSIR_MONITOR_MODE == bssType)
Jeff Johnson348973e2018-11-22 16:51:12 -0800677 lim_ft_open(mac, &mac->lim.gpSession[i]);
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700678
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800679 if (eSIR_INFRA_AP_MODE == bssType) {
680 session_ptr->old_protection_state = 0;
Arif Hussain1513cb22018-01-05 19:56:31 -0800681 session_ptr->is_session_obss_offload_enabled = false;
682 session_ptr->is_obss_reset_timer_initialized = false;
Arif Hussain1513cb22018-01-05 19:56:31 -0800683
684 status = qdf_mc_timer_init(&session_ptr->
685 protection_fields_reset_timer,
686 QDF_TIMER_TYPE_SW,
687 pe_reset_protection_callback,
Jeff Johnson348973e2018-11-22 16:51:12 -0800688 (void *)&mac->lim.gpSession[i]);
Arif Hussain1513cb22018-01-05 19:56:31 -0800689
690 if (QDF_IS_STATUS_ERROR(status))
691 pe_err("cannot create protection fields reset timer");
692 else
693 session_ptr->is_obss_reset_timer_initialized = true;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +0530694
695 status = qdf_mc_timer_init(&session_ptr->ap_ecsa_timer,
696 QDF_TIMER_TYPE_WAKE_APPS,
697 lim_process_ap_ecsa_timeout,
Jeff Johnson348973e2018-11-22 16:51:12 -0800698 (void *)&mac->lim.gpSession[i]);
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +0530699 if (status != QDF_STATUS_SUCCESS)
700 pe_err("cannot create ap_ecsa_timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800701 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +0530702 pe_init_fils_info(session_ptr);
Jeff Johnson348973e2018-11-22 16:51:12 -0800703 pe_init_pmf_comeback_timer(mac, session_ptr, *sessionId);
Tushnim Bhattacharyya3d17def2017-06-19 11:13:43 -0700704 session_ptr->ht_client_cnt = 0;
Naveen Rawat6fc3c502017-09-06 16:14:11 -0700705 /* following is invalid value since seq number is 12 bit */
706 session_ptr->prev_auth_seq_num = 0xFFFF;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -0800707
Jeff Johnson348973e2018-11-22 16:51:12 -0800708 return &mac->lim.gpSession[i];
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530709
710free_session_attrs:
711 qdf_mem_free(session_ptr->gpLimPeerIdxpool);
712 qdf_mem_free(session_ptr->pSchProbeRspTemplate);
713 qdf_mem_free(session_ptr->pSchBeaconFrameBegin);
714 qdf_mem_free(session_ptr->pSchBeaconFrameEnd);
715
716 session_ptr->gpLimPeerIdxpool = NULL;
717 session_ptr->pSchProbeRspTemplate = NULL;
718 session_ptr->pSchBeaconFrameBegin = NULL;
719 session_ptr->pSchBeaconFrameEnd = NULL;
720
721free_dp_hash_table:
722 qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable);
723 qdf_mem_zero(session_ptr->dph.dphHashTable.pDphNodeArray,
724 sizeof(struct sDphHashNode) * (SIR_SAP_MAX_NUM_PEERS + 1));
725
726 session_ptr->dph.dphHashTable.pHashTable = NULL;
727 session_ptr->dph.dphHashTable.pDphNodeArray = NULL;
Abhishek Singhdfa69c32018-08-30 15:39:34 +0530728 session_ptr->valid = false;
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530729
730 return NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731}
732
733/*--------------------------------------------------------------------------
734 \brief pe_find_session_by_bssid() - looks up the PE session given the BSSID.
735
736 This function returns the session context and the session ID if the session
737 corresponding to the given BSSID is found in the PE session table.
738
Jeff Johnson348973e2018-11-22 16:51:12 -0800739 \param mac - pointer to global adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800740 \param bssid - BSSID of the session
741 \param sessionId -session ID is returned here, if session is found.
742
Jeff Johnson0bb33162018-11-18 22:20:42 -0800743 \return struct pe_session * - pointer to the session context or NULL if session is not found.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800744
745 \sa
746 --------------------------------------------------------------------------*/
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800747struct pe_session *pe_find_session_by_bssid(struct mac_context *mac, uint8_t *bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 uint8_t *sessionId)
749{
750 uint8_t i;
751
Jeff Johnson348973e2018-11-22 16:51:12 -0800752 for (i = 0; i < mac->lim.maxBssId; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753 /* If BSSID matches return corresponding tables address */
Jeff Johnson348973e2018-11-22 16:51:12 -0800754 if ((mac->lim.gpSession[i].valid)
755 && (sir_compare_mac_addr(mac->lim.gpSession[i].bssId,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530756 bssid))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 *sessionId = i;
Jeff Johnson348973e2018-11-22 16:51:12 -0800758 return &mac->lim.gpSession[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759 }
760 }
761
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530762 return NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763
764}
765
766/*--------------------------------------------------------------------------
767 \brief pe_find_session_by_bss_idx() - looks up the PE session given the bssIdx.
768
769 This function returns the session context if the session
770 corresponding to the given bssIdx is found in the PE session table.
Jeff Johnson348973e2018-11-22 16:51:12 -0800771 \param mac - pointer to global adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772 \param bssIdx - bss index of the session
Jeff Johnson0bb33162018-11-18 22:20:42 -0800773 \return struct pe_session * - pointer to the session context or NULL if session is not found.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800774 \sa
775 --------------------------------------------------------------------------*/
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800776struct pe_session *pe_find_session_by_bss_idx(struct mac_context *mac, uint8_t bssIdx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777{
778 uint8_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700779
Jeff Johnson348973e2018-11-22 16:51:12 -0800780 for (i = 0; i < mac->lim.maxBssId; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800781 /* If BSSID matches return corresponding tables address */
Jeff Johnson348973e2018-11-22 16:51:12 -0800782 if ((mac->lim.gpSession[i].valid)
783 && (mac->lim.gpSession[i].bssIdx == bssIdx)) {
784 return &mac->lim.gpSession[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 }
786 }
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530787 pe_debug("Session lookup fails for bssIdx: %d", bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788 return NULL;
789}
790
791/*--------------------------------------------------------------------------
792 \brief pe_find_session_by_session_id() - looks up the PE session given the session ID.
793
794 This function returns the session context if the session
795 corresponding to the given session ID is found in the PE session table.
796
Jeff Johnson348973e2018-11-22 16:51:12 -0800797 \param mac - pointer to global adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798 \param sessionId -session ID for which session context needs to be looked up.
799
Jeff Johnson0bb33162018-11-18 22:20:42 -0800800 \return struct pe_session * - pointer to the session context or NULL if session is not found.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801
802 \sa
803 --------------------------------------------------------------------------*/
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800804struct pe_session *pe_find_session_by_session_id(struct mac_context *mac,
Srinivas Girigowdaf326dfe2017-08-03 11:28:32 -0700805 uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806{
Jeff Johnson348973e2018-11-22 16:51:12 -0800807 if (sessionId >= mac->lim.maxBssId) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530808 pe_err("Invalid sessionId: %d", sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530809 return NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800811
Jeff Johnson348973e2018-11-22 16:51:12 -0800812 if (mac->lim.gpSession[sessionId].valid)
813 return &mac->lim.gpSession[sessionId];
Srinivas Girigowdaf326dfe2017-08-03 11:28:32 -0700814
815 return NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816}
817
818/**
819 * pe_find_session_by_sta_id() - looks up the PE session given staid.
820 * @mac_ctx: pointer to global adapter context
821 * @staid: StaId of the session
822 * @session_id: session ID is returned here, if session is found.
823 *
824 * This function returns the session context and the session ID if the session
825 * corresponding to the given StaId is found in the PE session table.
826 *
827 * Return: session pointer
828 */
Jeff Johnson0bb33162018-11-18 22:20:42 -0800829struct pe_session *
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800830pe_find_session_by_sta_id(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 uint8_t staid,
832 uint8_t *session_id)
833{
834 uint8_t i, j;
Jeff Johnson0bb33162018-11-18 22:20:42 -0800835 struct pe_session *session_ptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836 dphHashTableClass *dph_ptr;
837
838 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
839 if (!mac_ctx->lim.gpSession[i].valid)
840 continue;
841 session_ptr = &mac_ctx->lim.gpSession[i];
842 dph_ptr = &session_ptr->dph.dphHashTable;
843 for (j = 0; j < dph_ptr->size; j++) {
844 if (dph_ptr->pDphNodeArray[j].valid
845 && dph_ptr->pDphNodeArray[j].added
846 && staid == dph_ptr->pDphNodeArray[j].staIndex) {
847 *session_id = i;
848 return session_ptr;
849 }
850 }
851 }
852
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530853 pe_debug("Session lookup fails for StaId: %d", staid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 return NULL;
855}
856
857/**
858 * pe_delete_session() - deletes the PE session given the session ID.
859 * @mac_ctx: pointer to global adapter context
860 * @session: session to be deleted.
861 *
862 * Deletes the given PE session
863 *
864 * Return: void
865 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800866void pe_delete_session(struct mac_context *mac_ctx, struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867{
868 uint16_t i = 0;
869 uint16_t n;
870 TX_TIMER *timer_ptr;
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +0530871 struct wlan_objmgr_vdev *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872
Krishna Kumaar Natarajan03cc3862015-12-15 17:51:19 -0800873 if (!session || (session && !session->valid)) {
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530874 pe_err("session is not valid");
Krishna Kumaar Natarajan03cc3862015-12-15 17:51:19 -0800875 return;
876 }
877
Nishank Aggarwalc7c65922017-03-24 19:56:23 +0530878 pe_debug("Trying to delete PE session: %d Opmode: %d BssIdx: %d BSSID: "MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800879 session->peSessionId, session->operMode,
880 session->bssIdx,
881 MAC_ADDR_ARRAY(session->bssId));
Vignesh Viswanathanb3dbbc82018-04-06 00:06:27 +0530882
883 lim_reset_bcn_probe_filter(mac_ctx, session);
884
Bala Venkatesh41837792018-11-01 18:22:13 +0530885 /* Restore default failure timeout */
886 if (session->defaultAuthFailureTimeout) {
887 pe_debug("Restore default failure timeout");
888 if (cfg_in_range(CFG_AUTH_FAILURE_TIMEOUT,
889 session->defaultAuthFailureTimeout))
890 mac_ctx->mlme_cfg->timeouts.auth_failure_timeout =
891 session->defaultAuthFailureTimeout;
892 else
893 mac_ctx->mlme_cfg->timeouts.auth_failure_timeout =
894 cfg_default(CFG_AUTH_FAILURE_TIMEOUT);
895 }
896
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 for (n = 0; n < (mac_ctx->lim.maxStation + 1); n++) {
898 timer_ptr = &mac_ctx->lim.limTimers.gpLimCnfWaitTimer[n];
899 if (session->peSessionId == timer_ptr->sessionId)
900 if (true == tx_timer_running(timer_ptr))
901 tx_timer_deactivate(timer_ptr);
902 }
903
Karthick S7a17a712015-10-14 16:12:48 +0530904 if (LIM_IS_AP_ROLE(session)) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530905 qdf_mc_timer_stop(&session->protection_fields_reset_timer);
906 qdf_mc_timer_destroy(&session->protection_fields_reset_timer);
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +0530907 qdf_mc_timer_stop(&session->ap_ecsa_timer);
908 qdf_mc_timer_destroy(&session->ap_ecsa_timer);
Krunal Soni6de1b212017-10-30 23:29:20 -0700909 lim_del_pmf_sa_query_timer(mac_ctx, session);
Karthick S7a17a712015-10-14 16:12:48 +0530910 }
911
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912 /* Delete FT related information */
913 lim_ft_cleanup(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 if (session->pLimStartBssReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530915 qdf_mem_free(session->pLimStartBssReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 session->pLimStartBssReq = NULL;
917 }
918
919 if (session->pLimJoinReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530920 qdf_mem_free(session->pLimJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 session->pLimJoinReq = NULL;
922 }
923
924 if (session->pLimReAssocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530925 qdf_mem_free(session->pLimReAssocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 session->pLimReAssocReq = NULL;
927 }
928
929 if (session->pLimMlmJoinReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530930 qdf_mem_free(session->pLimMlmJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800931 session->pLimMlmJoinReq = NULL;
932 }
933
934 if (session->dph.dphHashTable.pHashTable != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530935 qdf_mem_free(session->dph.dphHashTable.pHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936 session->dph.dphHashTable.pHashTable = NULL;
937 }
938
939 if (session->dph.dphHashTable.pDphNodeArray != NULL) {
Naveen Rawatb0c5b6b2017-11-27 17:37:40 -0800940 qdf_mem_zero(session->dph.dphHashTable.pDphNodeArray,
941 sizeof(struct sDphHashNode) *
942 (SIR_SAP_MAX_NUM_PEERS + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 session->dph.dphHashTable.pDphNodeArray = NULL;
944 }
945
946 if (session->gpLimPeerIdxpool != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530947 qdf_mem_free(session->gpLimPeerIdxpool);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 session->gpLimPeerIdxpool = NULL;
949 }
950
951 if (session->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530952 qdf_mem_free(session->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953 session->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530954 session->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955 }
956
957 if (session->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530958 qdf_mem_free(session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959 session->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530960 session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961 }
962
963 if (session->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530964 qdf_mem_free(session->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 session->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530966 session->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 }
968
969 if (session->parsedAssocReq != NULL) {
970 tpSirAssocReq tmp_ptr = NULL;
971 /* Cleanup the individual allocation first */
972 for (i = 0; i < session->dph.dphHashTable.size; i++) {
973 if (session->parsedAssocReq[i] == NULL)
974 continue;
975 tmp_ptr = ((tpSirAssocReq)
976 (session->parsedAssocReq[i]));
977 if (tmp_ptr->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530978 qdf_mem_free(tmp_ptr->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 tmp_ptr->assocReqFrame = NULL;
980 tmp_ptr->assocReqFrameLength = 0;
981 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530982 qdf_mem_free(session->parsedAssocReq[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983 session->parsedAssocReq[i] = NULL;
984 }
985 /* Cleanup the whole block */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530986 qdf_mem_free(session->parsedAssocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 session->parsedAssocReq = NULL;
988 }
989 if (NULL != session->limAssocResponseData) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530990 qdf_mem_free(session->limAssocResponseData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 session->limAssocResponseData = NULL;
992 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993 if (NULL != session->pLimMlmReassocRetryReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530994 qdf_mem_free(session->pLimMlmReassocRetryReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 session->pLimMlmReassocRetryReq = NULL;
996 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800997 if (NULL != session->pLimMlmReassocReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530998 qdf_mem_free(session->pLimMlmReassocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999 session->pLimMlmReassocReq = NULL;
1000 }
1001
1002 if (NULL != session->pSchProbeRspTemplate) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301003 qdf_mem_free(session->pSchProbeRspTemplate);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004 session->pSchProbeRspTemplate = NULL;
1005 }
1006
1007 if (NULL != session->pSchBeaconFrameBegin) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301008 qdf_mem_free(session->pSchBeaconFrameBegin);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009 session->pSchBeaconFrameBegin = NULL;
1010 }
1011
1012 if (NULL != session->pSchBeaconFrameEnd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301013 qdf_mem_free(session->pSchBeaconFrameEnd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014 session->pSchBeaconFrameEnd = NULL;
1015 }
1016
1017 /* Must free the buffer before peSession invalid */
1018 if (NULL != session->addIeParams.probeRespData_buff) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301019 qdf_mem_free(session->addIeParams.probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001020 session->addIeParams.probeRespData_buff = NULL;
1021 session->addIeParams.probeRespDataLen = 0;
1022 }
1023 if (NULL != session->addIeParams.assocRespData_buff) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301024 qdf_mem_free(session->addIeParams.assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 session->addIeParams.assocRespData_buff = NULL;
1026 session->addIeParams.assocRespDataLen = 0;
1027 }
1028 if (NULL != session->addIeParams.probeRespBCNData_buff) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301029 qdf_mem_free(session->addIeParams.probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 session->addIeParams.probeRespBCNData_buff = NULL;
1031 session->addIeParams.probeRespBCNDataLen = 0;
1032 }
1033#ifdef WLAN_FEATURE_11W
Anurag Chouhan210db072016-02-22 18:42:15 +05301034 if (QDF_TIMER_STATE_RUNNING ==
1035 qdf_mc_timer_get_current_state(&session->pmfComebackTimer))
1036 qdf_mc_timer_stop(&session->pmfComebackTimer);
1037 qdf_mc_timer_destroy(&session->pmfComebackTimer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038#endif
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301039 pe_delete_fils_info(session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 session->valid = false;
1041
Abhishek Singhdfa69c32018-08-30 15:39:34 +05301042 session->mac_ctx = NULL;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05301043 if (session->access_policy_vendor_ie)
1044 qdf_mem_free(session->access_policy_vendor_ie);
1045
1046 session->access_policy_vendor_ie = NULL;
1047
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 if (LIM_IS_AP_ROLE(session))
1049 lim_check_and_reset_protection_params(mac_ctx);
1050
Rajeev Kumar Sirasanagandlae3b59912018-08-24 15:53:31 +05301051 vdev = session->vdev;
1052 session->vdev = NULL;
1053 if (vdev)
1054 wlan_objmgr_vdev_release_ref(vdev, WLAN_LEGACY_MAC_ID);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055}
1056
1057/*--------------------------------------------------------------------------
1058 \brief pe_find_session_by_peer_sta() - looks up the PE session given the Station Address.
1059
1060 This function returns the session context and the session ID if the session
1061 corresponding to the given station address is found in the PE session table.
1062
Jeff Johnson348973e2018-11-22 16:51:12 -08001063 \param mac - pointer to global adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 \param sa - Peer STA Address of the session
1065 \param sessionId -session ID is returned here, if session is found.
1066
Jeff Johnson0bb33162018-11-18 22:20:42 -08001067 \return struct pe_session * - pointer to the session context or NULL if session is not found.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068
1069 \sa
1070 --------------------------------------------------------------------------*/
1071
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001072struct pe_session *pe_find_session_by_peer_sta(struct mac_context *mac, uint8_t *sa,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 uint8_t *sessionId)
1074{
1075 uint8_t i;
1076 tpDphHashNode pSta;
1077 uint16_t aid;
1078
Jeff Johnson348973e2018-11-22 16:51:12 -08001079 for (i = 0; i < mac->lim.maxBssId; i++) {
1080 if ((mac->lim.gpSession[i].valid)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081 pSta =
Jeff Johnson348973e2018-11-22 16:51:12 -08001082 dph_lookup_hash_entry(mac, sa, &aid,
1083 &mac->lim.gpSession[i].dph.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084 dphHashTable);
1085 if (pSta != NULL) {
1086 *sessionId = i;
Jeff Johnson348973e2018-11-22 16:51:12 -08001087 return &mac->lim.gpSession[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088 }
1089 }
1090 }
1091
Nishank Aggarwalc7c65922017-03-24 19:56:23 +05301092 pe_debug("Session lookup fails for Peer StaId:");
Jeff Johnson348973e2018-11-22 16:51:12 -08001093 lim_print_mac_addr(mac, sa, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094 return NULL;
1095}
1096
1097/**
1098 * pe_find_session_by_sme_session_id() - looks up the PE session for given sme
1099 * session id
1100 * @mac_ctx: pointer to global adapter context
1101 * @sme_session_id: sme session id
1102 *
1103 * looks up the PE session for given sme session id
1104 *
1105 * Return: pe session entry for given sme session if found else NULL
1106 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001107struct pe_session *pe_find_session_by_sme_session_id(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108 uint8_t sme_session_id)
1109{
1110 uint8_t i;
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -07001111
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001112 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
1113 if ((mac_ctx->lim.gpSession[i].valid) &&
1114 (mac_ctx->lim.gpSession[i].smeSessionId ==
1115 sme_session_id)) {
1116 return &mac_ctx->lim.gpSession[i];
1117 }
1118 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001119 return NULL;
1120}
1121
1122/**
Min Liu93073af2018-09-18 19:10:41 +08001123 * pe_find_session_by_scan_id() - looks up the PE session for given scan id
1124 * @mac_ctx: pointer to global adapter context
1125 * @scan_id: scan id
1126 *
1127 * looks up the PE session for given scan id
1128 *
1129 * Return: pe session entry for given scan id if found else NULL
1130 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001131struct pe_session *pe_find_session_by_scan_id(struct mac_context *mac_ctx,
Min Liu93073af2018-09-18 19:10:41 +08001132 uint32_t scan_id)
1133{
1134 uint8_t i;
1135
1136 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
1137 if ((mac_ctx->lim.gpSession[i].valid) &&
1138 (mac_ctx->lim.gpSession[i].ftPEContext.pFTPreAuthReq) &&
1139 (mac_ctx->lim.gpSession[i].ftPEContext.pFTPreAuthReq
1140 ->scan_id == scan_id)) {
1141 return &mac_ctx->lim.gpSession[i];
1142 }
1143 }
1144 return NULL;
1145}
1146
1147/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001148 * pe_get_active_session_count() - function to return active pe session count
1149 *
1150 * @mac_ctx: pointer to global mac structure
1151 *
1152 * returns number of active pe session count
1153 *
1154 * Return: 0 if there are no active sessions else return number of active
1155 * sessions
1156 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001157uint8_t pe_get_active_session_count(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158{
1159 uint8_t i, active_session_count = 0;
1160
1161 for (i = 0; i < mac_ctx->lim.maxBssId; i++)
1162 if (mac_ctx->lim.gpSession[i].valid)
1163 active_session_count++;
1164
1165 return active_session_count;
1166}