blob: d6b0ef1d701ef6ca17a990725433f945b1e91df9 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala9c070ad2013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
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/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070043
Jeff Johnsone7245742012-09-05 17:12:55 -070044 \file limSessionUtils.c
45 \brief implementation for lim Session Utility APIs
Jeff Johnson295189b2012-06-20 16:38:30 -070046 \author Sunit Bhatia
47
Jeff Johnson295189b2012-06-20 16:38:30 -070048 ========================================================================*/
49
50
51/*--------------------------------------------------------------------------
52 Include Files
53 ------------------------------------------------------------------------*/
54#include "aniGlobal.h"
55#include "limDebug.h"
56#include "limSession.h"
57#include "limSessionUtils.h"
58#include "limUtils.h"
59
Jeff Johnsone7245742012-09-05 17:12:55 -070060/*--------------------------------------------------------------------------
61 \brief peGetVhtCapable() - Returns the Vht capable from a valid session.
62
63 This function itrates the session Table and returns the VHT capable from first valid session
64 if no sessions are valid/present it returns FALSE
65
66 \param pMac - pointer to global adapter context
67 \return - channel to scan from valid session else zero.
68
69 \sa
70
71 --------------------------------------------------------------------------*/
72tANI_U8 peGetVhtCapable(tpAniSirGlobal pMac)
73
74{
75#ifdef WLAN_FEATURE_11AC
76 tANI_U8 i;
77 //assumption here is that all the sessions will be on the same channel.
78 //This function will not work, once we have multiple channel support.
79 for(i =0; i < pMac->lim.maxBssId; i++)
80 {
81 if(pMac->lim.gpSession[i].valid)
82 {
83 return(pMac->lim.gpSession[i].vhtCapability);
84 }
85 }
86#endif
87 return FALSE;
88}
89/*--------------------------------------------------------------------------
90 \brief peGetCurrentChannel() - Returns the channel number for scanning,
91 from a valid session.
92 This function itrates the session Table and returns the channel number
93 from first valid session if no sessions are valid/present it returns zero
94
95 \param pMac - pointer to global adapter context
96 \return - channel to scan from valid session else zero.
97 \sa
98 --------------------------------------------------------------------------*/
99tANI_U8 peGetCurrentChannel(tpAniSirGlobal pMac)
100{
101 tANI_U8 i;
102 //assumption here is that all the sessions will be on the same channel.
103 //This function will not work, once we have multiple channel support.
104 for(i =0; i < pMac->lim.maxBssId; i++)
105 {
106 if(pMac->lim.gpSession[i].valid)
107 {
108 return(pMac->lim.gpSession[i].currentOperChannel);
109 }
110 }
111 return(HAL_INVALID_CHANNEL_ID);
112}
113
Jeff Johnson295189b2012-06-20 16:38:30 -0700114
115/*--------------------------------------------------------------------------
Jeff Johnsone7245742012-09-05 17:12:55 -0700116
Jeff Johnson295189b2012-06-20 16:38:30 -0700117 \brief peValidateJoinReq() - validates the Join request .
118
119 This function is called to validate the Join Request for a BT-AMP station. If start BSS session is present
120 this function returns TRUE else returns FALSE.
121 PE will force SME to first issue ''START_BSS' request for BTAMP_STA, before sending a JOIN request.
122
123 \param pMac - pointer to global adapter context
124 \return - return TRUE if start BSS session is present else return FALSE.
125
126 \sa
127 --------------------------------------------------------------------------*/
128
129tANI_U8 peValidateBtJoinRequest(tpAniSirGlobal pMac)
130{
131
132 tANI_U8 i;
133 for(i =0; i < pMac->lim.maxBssId; i++)
134 {
135 if( (pMac->lim.gpSession[i].valid) &&
136 (pMac->lim.gpSession[i].bssType == eSIR_BTAMP_STA_MODE) &&
137 (pMac->lim.gpSession[i].statypeForBss == STA_ENTRY_SELF))
138 {
139 return(TRUE);
140 }
141
142 }
143 return(FALSE);
144
145}
146
147/*--------------------------------------------------------------------------
148 \brief peGetValidPowerSaveSession() - Fetches the valid session for powersave .
149
150 This function is called to check the valid session for power save, if more than one session is active , this function
151 it returns NULL.
152 if there is only one valid "infrastructure" session present in "linkestablished" state this function returns sessionentry.
153 For all other cases it returns NULL.
154
155 \param pMac - pointer to global adapter context
156 \return - return session is address if valid session is present else return NULL.
157
158 \sa
159 --------------------------------------------------------------------------*/
160
161
162tpPESession peGetValidPowerSaveSession(tpAniSirGlobal pMac)
163{
164 tANI_U8 i;
165 tANI_U8 sessioncount = 0;
166 tANI_U8 sessionId = 0;
167
168 for(i = 0; i < pMac->lim.maxBssId; i++)
169 {
170 if( (pMac->lim.gpSession[i].valid == TRUE)&&
171 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_ROLE)&&
172 (pMac->lim.gpSession[i].limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)) {
173 sessioncount++;
174 sessionId = i;
175
176 if(sessioncount > 1)
177 {
178 return(NULL);
179 }
180 }
181
182 }
183
184 if( (pMac->lim.gpSession[sessionId].valid == TRUE)&&
185 (pMac->lim.gpSession[sessionId].limSystemRole == eLIM_STA_ROLE)&&
186 (pMac->lim.gpSession[sessionId].limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE))
187
188 {
189 return(&pMac->lim.gpSession[sessionId]);
190 }
191 return(NULL);
192
193}
194/*--------------------------------------------------------------------------
195 \brief peIsAnySessionActive() - checks for the active session presence .
196
197 This function returns TRUE if atleast one valid session is present else it returns FALSE
198
199 \param pMac - pointer to global adapter context
200 \return - return TRUE if atleast one session is active else return FALSE.
201
202 \sa
203 --------------------------------------------------------------------------*/
204
205
206tANI_U8 peIsAnySessionActive(tpAniSirGlobal pMac)
207{
208 tANI_U8 i;
209 for(i =0; i < pMac->lim.maxBssId; i++)
210 {
211 if(pMac->lim.gpSession[i].valid == TRUE)
212 {
213 return(TRUE);
214 }
215
216 }
217 return(FALSE);
218
219}
220
221/*--------------------------------------------------------------------------
222 \brief isLimSessionOffChannel() - Determines if the there is any other off channel
223 session.
224
225 This function returns TRUE if the session Id passed needs to be on a different
226 channel than atleast one session already active.
227
228 \param pMac - pointer to global adapter context
229 \param sessionId - session ID of the session to be verified.
230
231 \return tANI_U8 - Boolean value for off-channel operation.
232
233 \sa
234 --------------------------------------------------------------------------*/
235
236tANI_U8
237isLimSessionOffChannel(tpAniSirGlobal pMac, tANI_U8 sessionId)
238{
239 tANI_U8 i;
240
241 if(sessionId >= pMac->lim.maxBssId)
242 {
243 limLog(pMac, LOGE, FL("Invalid sessionId: %d \n "), sessionId);
244 return FALSE;
245 }
246
247 for(i =0; i < pMac->lim.maxBssId; i++)
248 {
249 if( i == sessionId )
250 {
251 //Skip the sessionId that is to be joined.
252 continue;
253 }
Jeff Johnsone7245742012-09-05 17:12:55 -0700254 //if another ession is valid and it is on different channel
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 //it is an off channel operation.
256 if( (pMac->lim.gpSession[i].valid) &&
257 (pMac->lim.gpSession[i].currentOperChannel !=
258 pMac->lim.gpSession[sessionId].currentOperChannel) )
259 {
260 return TRUE;
261 }
262 }
263
264 return FALSE;
265
266}
267
Jeff Johnsone7245742012-09-05 17:12:55 -0700268/*--------------------------------------------------------------------------
269 \brief peGetActiveSessionChannel() - Gets the operating channel of first
270 valid session. Returns 0 if there is no
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700271 valid session.
Jeff Johnsone7245742012-09-05 17:12:55 -0700272
273 \param pMac - pointer to global adapter context
274
275 \return tANI_U8 - operating channel.
276
277 \sa
278 --------------------------------------------------------------------------*/
279void
280peGetActiveSessionChannel (tpAniSirGlobal pMac, tANI_U8* resumeChannel, ePhyChanBondState* resumePhyCbState)
281{
282 tANI_U8 i;
Madan Mohan Koyyalamudi08daaa82012-10-30 16:09:11 -0700283 ePhyChanBondState prevPhyCbState = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -0700284
285 // Initialize the pointers passed to INVALID values in case we don't find a valid session
286 *resumeChannel = 0;
287 *resumePhyCbState = 0;
288 for(i =0; i < pMac->lim.maxBssId; i++)
289 {
290 if(pMac->lim.gpSession[i].valid)
291 {
292 *resumeChannel = pMac->lim.gpSession[i].currentOperChannel;
293 *resumePhyCbState = pMac->lim.gpSession[i].htSecondaryChannelOffset;
294
295#ifdef WLAN_FEATURE_11AC
296 if ((pMac->lim.gpSession[i].vhtCapability))
297 {
298 /*Get 11ac cbState from 11n cbState*/
299 *resumePhyCbState = limGet11ACPhyCBState(pMac,
300 pMac->lim.gpSession[i].currentOperChannel,
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -0700301 pMac->lim.gpSession[i].htSecondaryChannelOffset,
302 pMac->lim.gpSession[i].apCenterChan,
303 &pMac->lim.gpSession[i]);
Jeff Johnsone7245742012-09-05 17:12:55 -0700304 }
305#endif
Madan Mohan Koyyalamudi08daaa82012-10-30 16:09:11 -0700306 *resumePhyCbState = (*resumePhyCbState > prevPhyCbState )? *resumePhyCbState : prevPhyCbState;
307 prevPhyCbState = *resumePhyCbState;
Jeff Johnsone7245742012-09-05 17:12:55 -0700308 }
309 }
310 return;
311}
312
313/*--------------------------------------------------------------------------
314 \brief limIsChanSwitchRunning() - Check if channel switch is running on any
315 valid session.
316
317 \param pMac - pointer to global adapter context
318
319 \return tANI_U8 - 1 - if chann switching running.
320 0 - if chann switching is not running.
321
322 \sa
323 --------------------------------------------------------------------------*/
Jeff Johnson295189b2012-06-20 16:38:30 -0700324tANI_U8
Jeff Johnsone7245742012-09-05 17:12:55 -0700325limIsChanSwitchRunning (tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -0700326{
327 tANI_U8 i;
328
329 for(i =0; i < pMac->lim.maxBssId; i++)
330 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700331 if(pMac->lim.gpSession[i].valid &&
332 pMac->lim.gpSession[i].gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING)
Jeff Johnson295189b2012-06-20 16:38:30 -0700333 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700334 return 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700335 }
336 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700337 return 0;
Jeff Johnsone7245742012-09-05 17:12:55 -0700338}
339/*--------------------------------------------------------------------------
340 \brief limIsInQuietDuration() - Check if channel quieting is running on any
341 valid session.
Jeff Johnson295189b2012-06-20 16:38:30 -0700342
Jeff Johnsone7245742012-09-05 17:12:55 -0700343 \param pMac - pointer to global adapter context
344
345 \return tANI_U8 - 1 - if chann quiet running.
346 0 - if chann quiet is not running.
347
348 \sa
349 --------------------------------------------------------------------------*/
350tANI_U8
351limIsInQuietDuration (tpAniSirGlobal pMac)
352{
353 tANI_U8 i;
354
355 for(i =0; i < pMac->lim.maxBssId; i++)
356 {
357 if(pMac->lim.gpSession[i].valid &&
358 pMac->lim.gpSession[i].gLimSpecMgmt.quietState == eLIM_QUIET_RUNNING)
359 {
360 return 1;
361 }
362 }
363 return 0;
364}
365/*--------------------------------------------------------------------------
366 \brief limIsQuietBegin() - Check if channel quieting is begining on any
367 valid session.
368
369 \param pMac - pointer to global adapter context
370
371 \return tANI_U8 - 1 - if chann quiet running.
372 0 - if chann quiet is not running.
373
374 \sa
375 --------------------------------------------------------------------------*/
376tANI_U8
377limIsQuietBegin (tpAniSirGlobal pMac)
378{
379 tANI_U8 i;
380
381 for(i =0; i < pMac->lim.maxBssId; i++)
382 {
383 if(pMac->lim.gpSession[i].valid &&
384 pMac->lim.gpSession[i].gLimSpecMgmt.quietState == eLIM_QUIET_BEGIN)
385 {
386 return 1;
387 }
388 }
389 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700390}
391
Jeff Johnsone7245742012-09-05 17:12:55 -0700392/*--------------------------------------------------------------------------
393 \brief limIsInMCC() - Check if Device is in MCC.
394
395 \param pMac - pointer to global adapter context
396
397 \return tANI_U8 - TRUE - if in MCC.
398 FALSE - NOT in MCC.
399
400 \sa
401 --------------------------------------------------------------------------*/
402tANI_U8
403limIsInMCC (tpAniSirGlobal pMac)
404{
405 tANI_U8 i;
406 tANI_U8 chan = 0;
407
408 for(i = 0; i < pMac->lim.maxBssId; i++)
409 {
410 //if another session is valid and it is on different channel
411 //it is an off channel operation.
412 if( (pMac->lim.gpSession[i].valid) )
413 {
414 if( chan == 0 )
415 {
416 chan = pMac->lim.gpSession[i].currentOperChannel;
417 }
418 else if( chan != pMac->lim.gpSession[i].currentOperChannel)
419 {
420 return TRUE;
421 }
422 }
423 }
424 return FALSE;
425}
Gopichand Nakkala4b136bf2012-12-31 16:39:21 -0800426
427/*--------------------------------------------------------------------------
428 \brief peGetCurrentSTAsCount() - Returns total stations associated on
429 all session.
430
431 \param pMac - pointer to global adapter context
432 \return - Number of station active on all sessions.
433
434 \sa
435 --------------------------------------------------------------------------*/
436
437tANI_U8 peGetCurrentSTAsCount(tpAniSirGlobal pMac)
438{
439 tANI_U8 i;
440 tANI_U8 staCount = 0;
441 for(i =0; i < pMac->lim.maxBssId; i++)
442 {
443 if(pMac->lim.gpSession[i].valid == TRUE)
444 {
445 staCount += pMac->lim.gpSession[i].gLimNumOfCurrentSTAs;
446 }
447 }
448 return staCount;
449}
450
Srinivas Girigowda6fa58662013-02-14 16:31:48 -0800451#ifdef FEATURE_WLAN_LFR
452/*--------------------------------------------------------------------------
453 \brief limIsFastRoamEnabled() - Check LFR is enabled or not
454
455 This function returns the TRUE if LFR is enabled
456
457 \param pMac - pointer to global adapter context
458 \param sessionId - session ID is returned here, if session is found.
459
460 \return int - TRUE if enabled or else FALSE
461
462 \sa
463 --------------------------------------------------------------------------*/
464
465tANI_U8 limIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U8 sessionId)
466{
467 if(TRUE == pMac->lim.gpSession[sessionId].valid)
468 {
469 if((eSIR_INFRASTRUCTURE_MODE == pMac->lim.gpSession[sessionId].bssType) &&
470 (pMac->lim.gpSession[sessionId].isFastRoamIniFeatureEnabled))
471 {
472 return TRUE;
473 }
474 }
475
476 return FALSE;
477}
478#endif
479