blob: 12eabca447f8a34d6441a1fb56fa0e33fe05e81e [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Abhishek Singhcfb44482017-03-10 12:42:37 +05302 * Copyright (c) 2011-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**=========================================================================
29
30 \file lim_session.c
31
32 \brief implementation for lim Session related APIs
33
34 \author Sunit Bhatia
35
36 ========================================================================*/
37
38/*--------------------------------------------------------------------------
39 Include Files
40 ------------------------------------------------------------------------*/
41#include "ani_global.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080042#include "lim_ft_defs.h"
43#include "lim_ft.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080044#include "lim_session.h"
45#include "lim_utils.h"
46
47#include "sch_api.h"
48#include "lim_send_messages.h"
49
50/*--------------------------------------------------------------------------
51
52 \brief pe_init_beacon_params() - Initialize the beaconParams structure
53
54 \param tpPESession - pointer to the session context or NULL if session can not be created.
55 \return void
56 \sa
57
58 --------------------------------------------------------------------------*/
59
Jeff Johnson97699002016-10-07 07:32:55 -070060static void pe_init_beacon_params(tpAniSirGlobal pMac,
61 tpPESession psessionEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080062{
63 psessionEntry->beaconParams.beaconInterval = 0;
64 psessionEntry->beaconParams.fShortPreamble = 0;
65 psessionEntry->beaconParams.llaCoexist = 0;
66 psessionEntry->beaconParams.llbCoexist = 0;
67 psessionEntry->beaconParams.llgCoexist = 0;
68 psessionEntry->beaconParams.ht20Coexist = 0;
69 psessionEntry->beaconParams.llnNonGFCoexist = 0;
70 psessionEntry->beaconParams.fRIFSMode = 0;
71 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = 0;
72 psessionEntry->beaconParams.gHTObssMode = 0;
73
74 /* Number of legacy STAs associated */
Anurag Chouhan600c3a02016-03-01 10:33:54 +053075 qdf_mem_set((void *)&psessionEntry->gLim11bParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080076 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053077 qdf_mem_set((void *)&psessionEntry->gLim11aParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080078 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053079 qdf_mem_set((void *)&psessionEntry->gLim11gParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053081 qdf_mem_set((void *)&psessionEntry->gLimNonGfParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053083 qdf_mem_set((void *)&psessionEntry->gLimHt20Params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053085 qdf_mem_set((void *)&psessionEntry->gLimLsigTxopParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086 sizeof(tLimProtStaParams), 0);
Anurag Chouhan600c3a02016-03-01 10:33:54 +053087 qdf_mem_set((void *)&psessionEntry->gLimOlbcParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088 sizeof(tLimProtStaParams), 0);
89}
90
91/*
92 * pe_reset_protection_callback() - resets protection structs so that when an AP
93 * causing use of protection goes away, corresponding protection bit can be
94 * reset
95 * @ptr: pointer to pSessionEntry
96 *
97 * This function resets protection structs so that when an AP causing use of
98 * protection goes away, corresponding protection bit can be reset. This allowes
99 * protection bits to be reset once legacy overlapping APs are gone.
100 *
101 * Return: void
102 */
Jeff Johnson97699002016-10-07 07:32:55 -0700103static void pe_reset_protection_callback(void *ptr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800104{
105 tpPESession pe_session_entry = (tpPESession)ptr;
106 tpAniSirGlobal mac_ctx = (tpAniSirGlobal)pe_session_entry->mac_ctx;
107 int8_t i = 0;
108 tUpdateBeaconParams beacon_params;
109 uint16_t current_protection_state = 0;
110 tpDphHashNode station_hash_node = NULL;
111 tSirMacHTOperatingMode old_op_mode;
112 bool bcn_prms_changed = false;
113
114 if (pe_session_entry->valid == false) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530115 QDF_TRACE(QDF_MODULE_ID_PE,
116 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117 FL("session already deleted. exiting timer callback"));
118 return;
119 }
120
Manishekar Chandrasekaran9e8c7be2016-08-03 14:57:14 +0530121 /*
122 * During CAC period, if the callback is triggered, the beacon
123 * template may get updated. Subsequently if the vdev is not up, the
124 * vdev would be made up -- which should not happen during the CAC
125 * period. To avoid this, ignore the protection callback if the session
126 * is not yet up.
127 */
128 if (!wma_is_vdev_up(pe_session_entry->smeSessionId)) {
129 QDF_TRACE(QDF_MODULE_ID_PE,
130 QDF_TRACE_LEVEL_ERROR,
131 FL("session is not up yet. exiting timer callback"));
132 return;
133 }
134
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800135 current_protection_state |=
136 pe_session_entry->gLimOverlap11gParams.protectionEnabled |
137 pe_session_entry->gLimOverlap11aParams.protectionEnabled << 1 |
138 pe_session_entry->gLimOverlapHt20Params.protectionEnabled << 2 |
139 pe_session_entry->gLimOverlapNonGfParams.protectionEnabled << 3 |
140 pe_session_entry->gLimOlbcParams.protectionEnabled << 4;
141
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530142 QDF_TRACE(QDF_MODULE_ID_PE,
143 QDF_TRACE_LEVEL_INFO,
Kaushik, Sushantee3ed032016-08-04 16:40:46 +0530144 FL("old protection state: 0x%04X, new protection state: 0x%04X"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800145 pe_session_entry->old_protection_state,
146 current_protection_state);
147
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530148 qdf_mem_zero(&pe_session_entry->gLimOverlap11gParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 sizeof(pe_session_entry->gLimOverlap11gParams));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530150 qdf_mem_zero(&pe_session_entry->gLimOverlap11aParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 sizeof(pe_session_entry->gLimOverlap11aParams));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530152 qdf_mem_zero(&pe_session_entry->gLimOverlapHt20Params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 sizeof(pe_session_entry->gLimOverlapHt20Params));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530154 qdf_mem_zero(&pe_session_entry->gLimOverlapNonGfParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800155 sizeof(pe_session_entry->gLimOverlapNonGfParams));
156
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530157 qdf_mem_zero(&pe_session_entry->gLimOlbcParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800158 sizeof(pe_session_entry->gLimOlbcParams));
159
Abhishek Singhaf7e7fa2016-08-08 17:59:31 +0530160 /*
161 * Do not reset fShortPreamble and beaconInterval, as they
162 * are not updated.
163 */
164 pe_session_entry->beaconParams.llaCoexist = 0;
165 pe_session_entry->beaconParams.llbCoexist = 0;
166 pe_session_entry->beaconParams.llgCoexist = 0;
167 pe_session_entry->beaconParams.ht20Coexist = 0;
168 pe_session_entry->beaconParams.llnNonGFCoexist = 0;
169 pe_session_entry->beaconParams.fRIFSMode = 0;
170 pe_session_entry->beaconParams.fLsigTXOPProtectionFullSupport = 0;
171 pe_session_entry->beaconParams.gHTObssMode = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530173 qdf_mem_zero(&mac_ctx->lim.gLimOverlap11gParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 sizeof(mac_ctx->lim.gLimOverlap11gParams));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530175 qdf_mem_zero(&mac_ctx->lim.gLimOverlap11aParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176 sizeof(mac_ctx->lim.gLimOverlap11aParams));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530177 qdf_mem_zero(&mac_ctx->lim.gLimOverlapHt20Params,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 sizeof(mac_ctx->lim.gLimOverlapHt20Params));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530179 qdf_mem_zero(&mac_ctx->lim.gLimOverlapNonGfParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180 sizeof(mac_ctx->lim.gLimOverlapNonGfParams));
181
182 old_op_mode = pe_session_entry->htOperMode;
183 pe_session_entry->htOperMode = eSIR_HT_OP_MODE_PURE;
Masti, Narayanraddi4d8860c2016-08-22 15:46:48 +0530184 mac_ctx->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800185
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530186 qdf_mem_zero(&beacon_params, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800187 /* index 0, is self node, peers start from 1 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530188 for (i = 1 ; i <= mac_ctx->lim.gLimAssocStaLimit ; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189 station_hash_node = dph_get_hash_entry(mac_ctx, i,
190 &pe_session_entry->dph.dphHashTable);
191 if (NULL == station_hash_node)
192 continue;
193 lim_decide_ap_protection(mac_ctx, station_hash_node->staAddr,
194 &beacon_params, pe_session_entry);
195 }
196
197 if (pe_session_entry->htOperMode != old_op_mode)
198 bcn_prms_changed = true;
199
200 if ((current_protection_state !=
201 pe_session_entry->old_protection_state) &&
202 (false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530203 QDF_TRACE(QDF_MODULE_ID_PE,
Srinivas Girigowdaf936d822017-03-19 23:23:59 -0700204 QDF_TRACE_LEVEL_DEBUG,
Kaushik, Sushantee3ed032016-08-04 16:40:46 +0530205 FL("protection changed, update beacon template"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 /* update beacon fix params and send update to FW */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530207 qdf_mem_zero(&beacon_params, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208 beacon_params.bssIdx = pe_session_entry->bssIdx;
209 beacon_params.fShortPreamble =
210 pe_session_entry->beaconParams.fShortPreamble;
211 beacon_params.beaconInterval =
212 pe_session_entry->beaconParams.beaconInterval;
213 beacon_params.llaCoexist =
214 pe_session_entry->beaconParams.llaCoexist;
215 beacon_params.llbCoexist =
216 pe_session_entry->beaconParams.llbCoexist;
217 beacon_params.llgCoexist =
218 pe_session_entry->beaconParams.llgCoexist;
219 beacon_params.ht20MhzCoexist =
220 pe_session_entry->beaconParams.ht20Coexist;
221 beacon_params.llnNonGFCoexist =
222 pe_session_entry->beaconParams.llnNonGFCoexist;
223 beacon_params.fLsigTXOPProtectionFullSupport =
224 pe_session_entry->beaconParams.
225 fLsigTXOPProtectionFullSupport;
226 beacon_params.fRIFSMode =
227 pe_session_entry->beaconParams.fRIFSMode;
228 beacon_params.smeSessionId =
229 pe_session_entry->smeSessionId;
Selvaraj, Sridhardc038ee2016-06-24 15:22:14 +0530230 beacon_params.paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 bcn_prms_changed = true;
232 }
233
234 if (bcn_prms_changed) {
235 sch_set_fixed_beacon_fields(mac_ctx, pe_session_entry);
236 lim_send_beacon_params(mac_ctx, &beacon_params, pe_session_entry);
237 }
238
239 pe_session_entry->old_protection_state = current_protection_state;
Anurag Chouhan210db072016-02-22 18:42:15 +0530240 if (qdf_mc_timer_start(&pe_session_entry->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241 protection_fields_reset_timer,
242 SCH_PROTECTION_RESET_TIME)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530243 != QDF_STATUS_SUCCESS) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530244 QDF_TRACE(QDF_MODULE_ID_PE,
245 QDF_TRACE_LEVEL_ERROR,
Kaushik, Sushantee3ed032016-08-04 16:40:46 +0530246 FL("cannot create or start protectionFieldsResetTimer"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 }
248}
249
Abhishek Singhcfb44482017-03-10 12:42:37 +0530250#ifdef WLAN_FEATURE_11W
251/**
252 * pe_init_pmf_comeback_timer: init PMF comeback timer
253 * @mac_ctx: pointer to global adapter context
254 * @session: pe session
255 * @session_id: session ID
256 *
257 * Return: void
258 */
259static void pe_init_pmf_comeback_timer(tpAniSirGlobal mac_ctx,
260tpPESession session, uint8_t session_id)
261{
262 QDF_STATUS status;
263
264 session->pmfComebackTimerInfo.pMac = mac_ctx;
265 session->pmfComebackTimerInfo.sessionID = session_id;
266 status = qdf_mc_timer_init(&session->pmfComebackTimer,
267 QDF_TIMER_TYPE_SW, lim_pmf_comeback_timer_callback,
268 (void *)&session->pmfComebackTimerInfo);
269 if (!QDF_IS_STATUS_SUCCESS(status))
270 lim_log(mac_ctx, LOGE, FL("cannot init pmf comeback timer."));
271}
272#else
273static inline void
274pe_init_pmf_comeback_timer(tpAniSirGlobal mac_ctx,
275 tpPESession session, uint8_t session_id)
276{
277}
278#endif
279
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800280/**
281 * pe_create_session() creates a new PE session given the BSSID
282 * @param pMac: pointer to global adapter context
283 * @param bssid: BSSID of the new session
284 * @param sessionId: session ID is returned here, if session is created.
285 * @param bssType: station or a
286 *
287 * This function returns the session context and the session ID if the session
288 * corresponding to the passed BSSID is found in the PE session table.
289 *
290 * Return: tpPESession: pointer to the session context or NULL if session
291 * can not be created.
292 */
293
294tpPESession
295pe_create_session(tpAniSirGlobal pMac, uint8_t *bssid, uint8_t *sessionId,
296 uint16_t numSta, tSirBssType bssType)
297{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530298 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299 uint8_t i;
300 tpPESession session_ptr;
301 for (i = 0; i < pMac->lim.maxBssId; i++) {
302 /* Find first free room in session table */
303 if (pMac->lim.gpSession[i].valid == true)
304 continue;
305 break;
306 }
307
308 if (i == pMac->lim.maxBssId) {
309 lim_log(pMac, LOGE,
Kaushik, Sushantee3ed032016-08-04 16:40:46 +0530310 FL("Session can't be created. Reached max sessions"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311 return NULL;
312 }
313
314 session_ptr = &pMac->lim.gpSession[i];
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530315 qdf_mem_set((void *)session_ptr, sizeof(tPESession), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800316 /* Allocate space for Station Table for this session. */
317 session_ptr->dph.dphHashTable.pHashTable =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530318 qdf_mem_malloc(sizeof(tpDphHashNode) * (numSta + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319 if (NULL == session_ptr->dph.dphHashTable.pHashTable) {
320 lim_log(pMac, LOGE, FL("memory allocate failed!"));
321 return NULL;
322 }
323
324 session_ptr->dph.dphHashTable.pDphNodeArray =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530325 qdf_mem_malloc(sizeof(tDphHashNode) * (numSta + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800326 if (NULL == session_ptr->dph.dphHashTable.pDphNodeArray) {
327 lim_log(pMac, LOGE, FL("memory allocate failed!"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530328 qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800329 session_ptr->dph.dphHashTable.
330 pHashTable = NULL;
331 return NULL;
332 }
333
334 session_ptr->dph.dphHashTable.size = numSta + 1;
335 dph_hash_table_class_init(pMac, &session_ptr->dph.dphHashTable);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530336 session_ptr->gpLimPeerIdxpool = qdf_mem_malloc(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800337 sizeof(*(session_ptr->gpLimPeerIdxpool)) * (numSta + 1));
338 if (NULL == session_ptr->gpLimPeerIdxpool) {
339 lim_log(pMac, LOGE, FL("memory allocate failed!"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530340 qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable);
341 qdf_mem_free(session_ptr->dph.dphHashTable.pDphNodeArray);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 session_ptr->dph.dphHashTable.pHashTable = NULL;
343 session_ptr->dph.dphHashTable.pDphNodeArray = NULL;
344 return NULL;
345 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346 session_ptr->freePeerIdxHead = 0;
347 session_ptr->freePeerIdxTail = 0;
348 session_ptr->gLimNumOfCurrentSTAs = 0;
349 /* Copy the BSSID to the session table */
350 sir_copy_mac_addr(session_ptr->bssId, bssid);
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700351 if (bssType == eSIR_MONITOR_MODE)
352 sir_copy_mac_addr(pMac->lim.gpSession[i].selfMacAddr, bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800353 session_ptr->valid = true;
354 /* Intialize the SME and MLM states to IDLE */
355 session_ptr->limMlmState = eLIM_MLM_IDLE_STATE;
356 session_ptr->limSmeState = eLIM_SME_IDLE_STATE;
357 session_ptr->limCurrentAuthType = eSIR_OPEN_SYSTEM;
358 pe_init_beacon_params(pMac, &pMac->lim.gpSession[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359 session_ptr->is11Rconnection = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360#ifdef FEATURE_WLAN_ESE
361 session_ptr->isESEconnection = false;
362#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363 session_ptr->isFastTransitionEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364 session_ptr->isFastRoamIniFeatureEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365 *sessionId = i;
366 session_ptr->gLimPhyMode = WNI_CFG_PHY_MODE_11G;
367 /* Initialize CB mode variables when session is created */
368 session_ptr->htSupportedChannelWidthSet = 0;
369 session_ptr->htRecommendedTxWidthSet = 0;
370 session_ptr->htSecondaryChannelOffset = 0;
371#ifdef FEATURE_WLAN_TDLS
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530372 qdf_mem_set(session_ptr->peerAIDBitmap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800373 sizeof(session_ptr->peerAIDBitmap), 0);
374 session_ptr->tdls_prohibited = false;
375 session_ptr->tdls_chan_swit_prohibited = false;
376#endif
377 session_ptr->fWaitForProbeRsp = 0;
378 session_ptr->fIgnoreCapsChange = 0;
379
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530380 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 FL("Create a new PE session(%d), BSSID: "MAC_ADDRESS_STR" Max No. of STA %d"),
Kapil Guptabf4943c2016-10-13 12:15:39 +0530382 *sessionId, MAC_ADDR_ARRAY(bssid), numSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383
Rajeev Kumarcf835a02016-04-15 15:01:31 -0700384 if (eSIR_INFRA_AP_MODE == bssType || eSIR_IBSS_MODE == bssType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385 session_ptr->pSchProbeRspTemplate =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530386 qdf_mem_malloc(SCH_MAX_PROBE_RESP_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387 session_ptr->pSchBeaconFrameBegin =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530388 qdf_mem_malloc(SCH_MAX_BEACON_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389 session_ptr->pSchBeaconFrameEnd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530390 qdf_mem_malloc(SCH_MAX_BEACON_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800391 if ((NULL == session_ptr->pSchProbeRspTemplate)
392 || (NULL == session_ptr->pSchBeaconFrameBegin)
393 || (NULL == session_ptr->pSchBeaconFrameEnd)) {
394 lim_log(pMac, LOGE, FL("memory allocate failed!"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530395 qdf_mem_free(session_ptr->dph.dphHashTable.pHashTable);
396 qdf_mem_free(session_ptr->dph.dphHashTable.pDphNodeArray);
397 qdf_mem_free(session_ptr->gpLimPeerIdxpool);
398 qdf_mem_free(session_ptr->pSchProbeRspTemplate);
399 qdf_mem_free(session_ptr->pSchBeaconFrameBegin);
400 qdf_mem_free(session_ptr->pSchBeaconFrameEnd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401
402 session_ptr->dph.dphHashTable.pHashTable = NULL;
403 session_ptr->dph.dphHashTable.pDphNodeArray = NULL;
404 session_ptr->gpLimPeerIdxpool = NULL;
405 session_ptr->pSchProbeRspTemplate = NULL;
406 session_ptr->pSchBeaconFrameBegin = NULL;
407 session_ptr->pSchBeaconFrameEnd = NULL;
408 return NULL;
409 }
410 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800411 if (eSIR_INFRASTRUCTURE_MODE == bssType)
412 lim_ft_open(pMac, &pMac->lim.gpSession[i]);
Manjunathappa Prakash0e6e6b52016-04-21 11:48:48 -0700413
414 if (eSIR_MONITOR_MODE == bssType)
415 lim_ft_open(pMac, &pMac->lim.gpSession[i]);
416
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417 if (eSIR_INFRA_AP_MODE == bssType) {
418 session_ptr->old_protection_state = 0;
419 session_ptr->mac_ctx = (void *)pMac;
Anurag Chouhan210db072016-02-22 18:42:15 +0530420 status = qdf_mc_timer_init(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421 &session_ptr->protection_fields_reset_timer,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530422 QDF_TIMER_TYPE_SW, pe_reset_protection_callback,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423 (void *)&pMac->lim.gpSession[i]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530424 if (status == QDF_STATUS_SUCCESS) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530425 status = qdf_mc_timer_start(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800426 &session_ptr->protection_fields_reset_timer,
427 SCH_PROTECTION_RESET_TIME);
428 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530429 if (status != QDF_STATUS_SUCCESS)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530430 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
Kaushik, Sushantee3ed032016-08-04 16:40:46 +0530431 FL("cannot create or start protectionFieldsResetTimer"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432 }
Abhishek Singhcfb44482017-03-10 12:42:37 +0530433 pe_init_pmf_comeback_timer(pMac, session_ptr, *sessionId);
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -0800434
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 return &pMac->lim.gpSession[i];
436}
437
438/*--------------------------------------------------------------------------
439 \brief pe_find_session_by_bssid() - looks up the PE session given the BSSID.
440
441 This function returns the session context and the session ID if the session
442 corresponding to the given BSSID is found in the PE session table.
443
444 \param pMac - pointer to global adapter context
445 \param bssid - BSSID of the session
446 \param sessionId -session ID is returned here, if session is found.
447
448 \return tpPESession - pointer to the session context or NULL if session is not found.
449
450 \sa
451 --------------------------------------------------------------------------*/
452tpPESession pe_find_session_by_bssid(tpAniSirGlobal pMac, uint8_t *bssid,
453 uint8_t *sessionId)
454{
455 uint8_t i;
456
457 for (i = 0; i < pMac->lim.maxBssId; i++) {
458 /* If BSSID matches return corresponding tables address */
459 if ((pMac->lim.gpSession[i].valid)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530460 && (sir_compare_mac_addr(pMac->lim.gpSession[i].bssId,
461 bssid))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800462 *sessionId = i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530463 return &pMac->lim.gpSession[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800464 }
465 }
466
Kaushik, Sushantee3ed032016-08-04 16:40:46 +0530467 lim_log(pMac, LOG4, FL("Session lookup fails for BSSID:"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800468 lim_print_mac_addr(pMac, bssid, LOG4);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530469 return NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470
471}
472
473/*--------------------------------------------------------------------------
474 \brief pe_find_session_by_bss_idx() - looks up the PE session given the bssIdx.
475
476 This function returns the session context if the session
477 corresponding to the given bssIdx is found in the PE session table.
478 \param pMac - pointer to global adapter context
479 \param bssIdx - bss index of the session
480 \return tpPESession - pointer to the session context or NULL if session is not found.
481 \sa
482 --------------------------------------------------------------------------*/
483tpPESession pe_find_session_by_bss_idx(tpAniSirGlobal pMac, uint8_t bssIdx)
484{
485 uint8_t i;
486 for (i = 0; i < pMac->lim.maxBssId; i++) {
487 /* If BSSID matches return corresponding tables address */
488 if ((pMac->lim.gpSession[i].valid)
489 && (pMac->lim.gpSession[i].bssIdx == bssIdx)) {
490 return &pMac->lim.gpSession[i];
491 }
492 }
493 lim_log(pMac, LOG4, FL("Session lookup fails for bssIdx: %d"), bssIdx);
494 return NULL;
495}
496
497/*--------------------------------------------------------------------------
498 \brief pe_find_session_by_session_id() - looks up the PE session given the session ID.
499
500 This function returns the session context if the session
501 corresponding to the given session ID is found in the PE session table.
502
503 \param pMac - pointer to global adapter context
504 \param sessionId -session ID for which session context needs to be looked up.
505
506 \return tpPESession - pointer to the session context or NULL if session is not found.
507
508 \sa
509 --------------------------------------------------------------------------*/
510tpPESession pe_find_session_by_session_id(tpAniSirGlobal pMac, uint8_t sessionId)
511{
512 if (sessionId >= pMac->lim.maxBssId) {
513 lim_log(pMac, LOGE, FL("Invalid sessionId: %d \n "), sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530514 return NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800515 }
516 if ((pMac->lim.gpSession[sessionId].valid == true)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530517 return &pMac->lim.gpSession[sessionId];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800518 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530519 return NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800520
521}
522
523/**
524 * pe_find_session_by_sta_id() - looks up the PE session given staid.
525 * @mac_ctx: pointer to global adapter context
526 * @staid: StaId of the session
527 * @session_id: session ID is returned here, if session is found.
528 *
529 * This function returns the session context and the session ID if the session
530 * corresponding to the given StaId is found in the PE session table.
531 *
532 * Return: session pointer
533 */
534tpPESession
535pe_find_session_by_sta_id(tpAniSirGlobal mac_ctx,
536 uint8_t staid,
537 uint8_t *session_id)
538{
539 uint8_t i, j;
540 tpPESession session_ptr;
541 dphHashTableClass *dph_ptr;
542
543 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
544 if (!mac_ctx->lim.gpSession[i].valid)
545 continue;
546 session_ptr = &mac_ctx->lim.gpSession[i];
547 dph_ptr = &session_ptr->dph.dphHashTable;
548 for (j = 0; j < dph_ptr->size; j++) {
549 if (dph_ptr->pDphNodeArray[j].valid
550 && dph_ptr->pDphNodeArray[j].added
551 && staid == dph_ptr->pDphNodeArray[j].staIndex) {
552 *session_id = i;
553 return session_ptr;
554 }
555 }
556 }
557
558 lim_log(mac_ctx, LOG4,
Kaushik, Sushantee3ed032016-08-04 16:40:46 +0530559 FL("Session lookup fails for StaId: %d"), staid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800560 return NULL;
561}
562
563/**
564 * pe_delete_session() - deletes the PE session given the session ID.
565 * @mac_ctx: pointer to global adapter context
566 * @session: session to be deleted.
567 *
568 * Deletes the given PE session
569 *
570 * Return: void
571 */
572void pe_delete_session(tpAniSirGlobal mac_ctx, tpPESession session)
573{
574 uint16_t i = 0;
575 uint16_t n;
576 TX_TIMER *timer_ptr;
577
Krishna Kumaar Natarajan03cc3862015-12-15 17:51:19 -0800578 if (!session || (session && !session->valid)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530579 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Krishna Kumaar Natarajan03cc3862015-12-15 17:51:19 -0800580 FL("session is not valid"));
581 return;
582 }
583
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530584 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585 FL("Trying to delete PE session %d Opmode %d BssIdx %d BSSID: "MAC_ADDRESS_STR),
586 session->peSessionId, session->operMode,
587 session->bssIdx,
588 MAC_ADDR_ARRAY(session->bssId));
589 for (n = 0; n < (mac_ctx->lim.maxStation + 1); n++) {
590 timer_ptr = &mac_ctx->lim.limTimers.gpLimCnfWaitTimer[n];
591 if (session->peSessionId == timer_ptr->sessionId)
592 if (true == tx_timer_running(timer_ptr))
593 tx_timer_deactivate(timer_ptr);
594 }
595
Karthick S7a17a712015-10-14 16:12:48 +0530596 if (LIM_IS_AP_ROLE(session)) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530597 qdf_mc_timer_stop(&session->protection_fields_reset_timer);
598 qdf_mc_timer_destroy(&session->protection_fields_reset_timer);
Karthick S7a17a712015-10-14 16:12:48 +0530599 }
600
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800601 /* Delete FT related information */
602 lim_ft_cleanup(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800603 if (session->pLimStartBssReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530604 qdf_mem_free(session->pLimStartBssReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800605 session->pLimStartBssReq = NULL;
606 }
607
608 if (session->pLimJoinReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530609 qdf_mem_free(session->pLimJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610 session->pLimJoinReq = NULL;
611 }
612
613 if (session->pLimReAssocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530614 qdf_mem_free(session->pLimReAssocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615 session->pLimReAssocReq = NULL;
616 }
617
618 if (session->pLimMlmJoinReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530619 qdf_mem_free(session->pLimMlmJoinReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800620 session->pLimMlmJoinReq = NULL;
621 }
622
623 if (session->dph.dphHashTable.pHashTable != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530624 qdf_mem_free(session->dph.dphHashTable.pHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 session->dph.dphHashTable.pHashTable = NULL;
626 }
627
628 if (session->dph.dphHashTable.pDphNodeArray != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530629 qdf_mem_free(session->dph.dphHashTable.pDphNodeArray);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800630 session->dph.dphHashTable.pDphNodeArray = NULL;
631 }
632
633 if (session->gpLimPeerIdxpool != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530634 qdf_mem_free(session->gpLimPeerIdxpool);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635 session->gpLimPeerIdxpool = NULL;
636 }
637
638 if (session->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530639 qdf_mem_free(session->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640 session->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530641 session->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642 }
643
644 if (session->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530645 qdf_mem_free(session->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800646 session->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530647 session->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800648 }
649
650 if (session->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530651 qdf_mem_free(session->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800652 session->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530653 session->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800654 }
655
656 if (session->parsedAssocReq != NULL) {
657 tpSirAssocReq tmp_ptr = NULL;
658 /* Cleanup the individual allocation first */
659 for (i = 0; i < session->dph.dphHashTable.size; i++) {
660 if (session->parsedAssocReq[i] == NULL)
661 continue;
662 tmp_ptr = ((tpSirAssocReq)
663 (session->parsedAssocReq[i]));
664 if (tmp_ptr->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530665 qdf_mem_free(tmp_ptr->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800666 tmp_ptr->assocReqFrame = NULL;
667 tmp_ptr->assocReqFrameLength = 0;
668 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530669 qdf_mem_free(session->parsedAssocReq[i]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670 session->parsedAssocReq[i] = NULL;
671 }
672 /* Cleanup the whole block */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530673 qdf_mem_free(session->parsedAssocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 session->parsedAssocReq = NULL;
675 }
676 if (NULL != session->limAssocResponseData) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530677 qdf_mem_free(session->limAssocResponseData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800678 session->limAssocResponseData = NULL;
679 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680 if (NULL != session->pLimMlmReassocRetryReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530681 qdf_mem_free(session->pLimMlmReassocRetryReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 session->pLimMlmReassocRetryReq = NULL;
683 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684 if (NULL != session->pLimMlmReassocReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530685 qdf_mem_free(session->pLimMlmReassocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 session->pLimMlmReassocReq = NULL;
687 }
688
689 if (NULL != session->pSchProbeRspTemplate) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530690 qdf_mem_free(session->pSchProbeRspTemplate);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800691 session->pSchProbeRspTemplate = NULL;
692 }
693
694 if (NULL != session->pSchBeaconFrameBegin) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530695 qdf_mem_free(session->pSchBeaconFrameBegin);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 session->pSchBeaconFrameBegin = NULL;
697 }
698
699 if (NULL != session->pSchBeaconFrameEnd) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530700 qdf_mem_free(session->pSchBeaconFrameEnd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800701 session->pSchBeaconFrameEnd = NULL;
702 }
703
704 /* Must free the buffer before peSession invalid */
705 if (NULL != session->addIeParams.probeRespData_buff) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530706 qdf_mem_free(session->addIeParams.probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800707 session->addIeParams.probeRespData_buff = NULL;
708 session->addIeParams.probeRespDataLen = 0;
709 }
710 if (NULL != session->addIeParams.assocRespData_buff) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530711 qdf_mem_free(session->addIeParams.assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712 session->addIeParams.assocRespData_buff = NULL;
713 session->addIeParams.assocRespDataLen = 0;
714 }
715 if (NULL != session->addIeParams.probeRespBCNData_buff) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530716 qdf_mem_free(session->addIeParams.probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800717 session->addIeParams.probeRespBCNData_buff = NULL;
718 session->addIeParams.probeRespBCNDataLen = 0;
719 }
720#ifdef WLAN_FEATURE_11W
Anurag Chouhan210db072016-02-22 18:42:15 +0530721 if (QDF_TIMER_STATE_RUNNING ==
722 qdf_mc_timer_get_current_state(&session->pmfComebackTimer))
723 qdf_mc_timer_stop(&session->pmfComebackTimer);
724 qdf_mc_timer_destroy(&session->pmfComebackTimer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800725#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800726 session->valid = false;
727
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +0530728 if (session->access_policy_vendor_ie)
729 qdf_mem_free(session->access_policy_vendor_ie);
730
731 session->access_policy_vendor_ie = NULL;
732
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733 if (LIM_IS_AP_ROLE(session))
734 lim_check_and_reset_protection_params(mac_ctx);
735
736 return;
737}
738
739/*--------------------------------------------------------------------------
740 \brief pe_find_session_by_peer_sta() - looks up the PE session given the Station Address.
741
742 This function returns the session context and the session ID if the session
743 corresponding to the given station address is found in the PE session table.
744
745 \param pMac - pointer to global adapter context
746 \param sa - Peer STA Address of the session
747 \param sessionId -session ID is returned here, if session is found.
748
749 \return tpPESession - pointer to the session context or NULL if session is not found.
750
751 \sa
752 --------------------------------------------------------------------------*/
753
754tpPESession pe_find_session_by_peer_sta(tpAniSirGlobal pMac, uint8_t *sa,
755 uint8_t *sessionId)
756{
757 uint8_t i;
758 tpDphHashNode pSta;
759 uint16_t aid;
760
761 for (i = 0; i < pMac->lim.maxBssId; i++) {
762 if ((pMac->lim.gpSession[i].valid)) {
763 pSta =
764 dph_lookup_hash_entry(pMac, sa, &aid,
765 &pMac->lim.gpSession[i].dph.
766 dphHashTable);
767 if (pSta != NULL) {
768 *sessionId = i;
769 return &pMac->lim.gpSession[i];
770 }
771 }
772 }
773
Kaushik, Sushantee3ed032016-08-04 16:40:46 +0530774 lim_log(pMac, LOG1, FL("Session lookup fails for Peer StaId:"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800775 lim_print_mac_addr(pMac, sa, LOG1);
776 return NULL;
777}
778
779/**
780 * pe_find_session_by_sme_session_id() - looks up the PE session for given sme
781 * session id
782 * @mac_ctx: pointer to global adapter context
783 * @sme_session_id: sme session id
784 *
785 * looks up the PE session for given sme session id
786 *
787 * Return: pe session entry for given sme session if found else NULL
788 */
789tpPESession pe_find_session_by_sme_session_id(tpAniSirGlobal mac_ctx,
790 uint8_t sme_session_id)
791{
792 uint8_t i;
Srinivas Girigowda2b5d47c2017-03-29 00:28:46 -0700793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
795 if ((mac_ctx->lim.gpSession[i].valid) &&
796 (mac_ctx->lim.gpSession[i].smeSessionId ==
797 sme_session_id)) {
798 return &mac_ctx->lim.gpSession[i];
799 }
800 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 return NULL;
802}
803
804/**
805 * pe_get_active_session_count() - function to return active pe session count
806 *
807 * @mac_ctx: pointer to global mac structure
808 *
809 * returns number of active pe session count
810 *
811 * Return: 0 if there are no active sessions else return number of active
812 * sessions
813 */
814uint8_t pe_get_active_session_count(tpAniSirGlobal mac_ctx)
815{
816 uint8_t i, active_session_count = 0;
817
818 for (i = 0; i < mac_ctx->lim.maxBssId; i++)
819 if (mac_ctx->lim.gpSession[i].valid)
820 active_session_count++;
821
822 return active_session_count;
823}