blob: 32e410398e88417446c74464d923588a13813d9c [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-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/*
43 * Airgo Networks, Inc proprietary. All rights reserved.
44 * This file limUtils.cc contains the utility functions
45 * LIM uses.
46 * Author: Chandra Modumudi
47 * Date: 02/13/02
48 * History:-
49 * Date Modified by Modification Information
50 * --------------------------------------------------------------------
51 */
52
53#include "schApi.h"
54#include "limUtils.h"
55#include "limTypes.h"
56#include "limSecurityUtils.h"
57#include "limPropExtsUtils.h"
58#include "limSendMessages.h"
59#include "limSerDesUtils.h"
60#include "limAdmitControl.h"
61#include "limStaHashApi.h"
62#include "dot11f.h"
63#include "wmmApsd.h"
64#include "limTrace.h"
65#ifdef FEATURE_WLAN_DIAG_SUPPORT
66#include "vos_diag_core_event.h"
67#endif //FEATURE_WLAN_DIAG_SUPPORT
68#include "limIbssPeerMgmt.h"
69#include "limSessionUtils.h"
70#include "limSession.h"
71#include "vos_nvitem.h"
72
73/* Static global used to mark situations where pMac->lim.gLimTriggerBackgroundScanDuringQuietBss is SET
74 * and limTriggerBackgroundScanDuringQuietBss() returned failure. In this case, we will stop data
75 * traffic instead of going into scan. The recover function limProcessQuietBssTimeout() needs to have
76 * this information. */
77static tAniBool glimTriggerBackgroundScanDuringQuietBss_Status = eSIR_TRUE;
78
79/* 11A Channel list to decode RX BD channel information */
80static const tANI_U8 abChannel[]= {36,40,44,48,52,56,60,64,100,104,108,112,116,
81 120,124,128,132,136,140,149,153,157,161,165};
82
83//#define LIM_MAX_ACTIVE_SESSIONS 3 //defined temporarily for BT-AMP SUPPORT
84#define SUCCESS 1 //defined temporarily for BT-AMP
85
86/** -------------------------------------------------------------
87\fn limAssignDialogueToken
88\brief Assigns dialogue token.
89\param tpAniSirGlobal pMac
90\return tpDialogueToken - dialogueToken data structure.
91 -------------------------------------------------------------*/
92
93tpDialogueToken
94limAssignDialogueToken(tpAniSirGlobal pMac)
95{
Madan Mohan Koyyalamudidfd6aa82012-10-18 20:18:43 -070096 static tANI_U8 token;
Jeff Johnson295189b2012-06-20 16:38:30 -070097 tpDialogueToken pCurrNode;
98 if(eHAL_STATUS_SUCCESS !=
99 palAllocateMemory(pMac->hHdd, (void **) &pCurrNode, sizeof(tDialogueToken)))
100 {
101 PELOGE(limLog(pMac, LOGE, FL("palAllocateMemory failed\n"));)
102 return NULL;
103 }
104
105 palZeroMemory(pMac->hHdd, (void *) pCurrNode, sizeof(tDialogueToken));
106 //first node in the list is being added.
107 if(NULL == pMac->lim.pDialogueTokenHead)
108 {
109 pMac->lim.pDialogueTokenHead = pMac->lim.pDialogueTokenTail = pCurrNode;
110 }
111 else
112 {
113 pMac->lim.pDialogueTokenTail->next = pCurrNode;
114 pMac->lim.pDialogueTokenTail = pCurrNode;
115 }
116 //assocId and tid of the node will be filled in by caller.
117 pCurrNode->next = NULL;
118 pCurrNode->token = token++;
119 PELOG4(limLog(pMac, LOG4, FL("token assigned = %d\n"), token);)
120 return pCurrNode;
121}
122
123/** -------------------------------------------------------------
124\fn limSearchAndDeleteDialogueToken
125\brief search dialogue token in the list and deletes it if found. returns failure if not found.
126\param tpAniSirGlobal pMac
127\param tANI_U8 token
128\param tANI_U16 assocId
129\param tANI_U16 tid
130\return eSirRetStatus - status of the search
131 -------------------------------------------------------------*/
132
133
134tSirRetStatus
135limSearchAndDeleteDialogueToken(tpAniSirGlobal pMac, tANI_U8 token, tANI_U16 assocId, tANI_U16 tid)
136{
137 tpDialogueToken pCurrNode = pMac->lim.pDialogueTokenHead;
138 tpDialogueToken pPrevNode = pMac->lim.pDialogueTokenHead;
139
140 //if the list is empty
141 if(NULL == pCurrNode)
142 return eSIR_FAILURE;
143
144 // if the matching node is the first node.
145 if(pCurrNode &&
146 (assocId == pCurrNode->assocId) &&
147 (tid == pCurrNode->tid))
148 {
149 pMac->lim.pDialogueTokenHead = pCurrNode->next;
150 //there was only one node in the list. So tail pointer also needs to be adjusted.
151 if(NULL == pMac->lim.pDialogueTokenHead)
152 pMac->lim.pDialogueTokenTail = NULL;
153 palFreeMemory(pMac->hHdd, (void *) pCurrNode);
154 return eSIR_SUCCESS;
155 }
156
157 //first node did not match. so move to the next one.
158 pCurrNode = pCurrNode->next;
159 while(NULL != pCurrNode )
160 {
161 if(token == pCurrNode->token)
162 {
163 break;
164 }
165
166 pPrevNode = pCurrNode;
167 pCurrNode = pCurrNode->next;
168 }
169
170 if(pCurrNode &&
171 (assocId == pCurrNode->assocId) &&
172 (tid == pCurrNode->tid))
173 {
174 pPrevNode->next = pCurrNode->next;
175 //if the node being deleted is the last one then we also need to move the tail pointer to the prevNode.
176 if(NULL == pCurrNode->next)
177 pMac->lim.pDialogueTokenTail = pPrevNode;
178 return eSIR_SUCCESS;
179 }
180
181 PELOGW(limLog(pMac, LOGW, FL("LIM does not have matching dialogue token node\n"));)
182 return eSIR_FAILURE;
183
184}
185
186
187/** -------------------------------------------------------------
188\fn limDeleteDialogueTokenList
189\brief deletes the complete lim dialogue token linked list.
190\param tpAniSirGlobal pMac
191\return None
192 -------------------------------------------------------------*/
193void
194limDeleteDialogueTokenList(tpAniSirGlobal pMac)
195{
196 tpDialogueToken pCurrNode = pMac->lim.pDialogueTokenHead;
197
198 while(NULL != pMac->lim.pDialogueTokenHead)
199 {
200 pCurrNode = pMac->lim.pDialogueTokenHead;
201 pMac->lim.pDialogueTokenHead = pMac->lim.pDialogueTokenHead->next;
202 palFreeMemory(pMac->hHdd, (void *) pCurrNode);
203 pCurrNode = NULL;
204 }
205 pMac->lim.pDialogueTokenTail = NULL;
206}
207
208void
209limGetBssidFromBD(tpAniSirGlobal pMac, tANI_U8 * pRxPacketInfo, tANI_U8 *bssId, tANI_U32 *pIgnore)
210{
211 tpSirMacDataHdr3a pMh = WDA_GET_RX_MPDUHEADER3A(pRxPacketInfo);
212 *pIgnore = 0;
213
214 if (pMh->fc.toDS == 1 && pMh->fc.fromDS == 0)
215 {
216 palCopyMemory( pMac->hHdd, bssId, pMh->addr1, 6);
217 *pIgnore = 1;
218 }
219 else if (pMh->fc.toDS == 0 && pMh->fc.fromDS == 1)
220 {
221 palCopyMemory( pMac->hHdd, bssId, pMh->addr2, 6);
222 *pIgnore = 1;
223 }
224 else if (pMh->fc.toDS == 0 && pMh->fc.fromDS == 0)
225 {
226 palCopyMemory( pMac->hHdd, bssId, pMh->addr3, 6);
227 *pIgnore = 0;
228 }
229 else
230 {
231 palCopyMemory( pMac->hHdd, bssId, pMh->addr1, 6);
232 *pIgnore = 1;
233 }
234}
235
236char *
237limMlmStateStr(tLimMlmStates state)
238{
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 switch (state)
240 {
241 case eLIM_MLM_OFFLINE_STATE:
242 return "eLIM_MLM_OFFLINE_STATE\n";
243 case eLIM_MLM_IDLE_STATE:
244 return "eLIM_MLM_IDLE_STATE\n";
245 case eLIM_MLM_WT_PROBE_RESP_STATE:
246 return "eLIM_MLM_WT_PROBE_RESP_STATE\n";
247 case eLIM_MLM_PASSIVE_SCAN_STATE:
248 return "eLIM_MLM_PASSIVE_SCAN_STATE\n";
249 case eLIM_MLM_WT_JOIN_BEACON_STATE:
250 return "eLIM_MLM_WT_JOIN_BEACON_STATE\n";
251 case eLIM_MLM_JOINED_STATE:
252 return "eLIM_MLM_JOINED_STATE\n";
253 case eLIM_MLM_BSS_STARTED_STATE:
254 return "eLIM_MLM_BSS_STARTED_STATE\n";
255 case eLIM_MLM_WT_AUTH_FRAME2_STATE:
256 return "eLIM_MLM_WT_AUTH_FRAME2_STATE\n";
257 case eLIM_MLM_WT_AUTH_FRAME3_STATE:
258 return "eLIM_MLM_WT_AUTH_FRAME3_STATE\n";
259 case eLIM_MLM_WT_AUTH_FRAME4_STATE:
260 return "eLIM_MLM_WT_AUTH_FRAME4_STATE\n";
261 case eLIM_MLM_AUTH_RSP_TIMEOUT_STATE:
262 return "eLIM_MLM_AUTH_RSP_TIMEOUT_STATE\n";
263 case eLIM_MLM_AUTHENTICATED_STATE:
264 return "eLIM_MLM_AUTHENTICATED_STATE\n";
265 case eLIM_MLM_WT_ASSOC_RSP_STATE:
266 return "eLIM_MLM_WT_ASSOC_RSP_STATE\n";
267 case eLIM_MLM_WT_REASSOC_RSP_STATE:
268 return "eLIM_MLM_WT_REASSOC_RSP_STATE\n";
269 case eLIM_MLM_WT_FT_REASSOC_RSP_STATE:
270 return "eLIM_MLM_WT_FT_REASSOC_RSP_STATE";
271 case eLIM_MLM_WT_DEL_STA_RSP_STATE:
272 return "eLIM_MLM_WT_DEL_STA_RSP_STATE\n";
273 case eLIM_MLM_WT_DEL_BSS_RSP_STATE:
274 return "eLIM_MLM_WT_DEL_BSS_RSP_STATE\n";
275 case eLIM_MLM_WT_ADD_STA_RSP_STATE:
276 return "eLIM_MLM_WT_ADD_STA_RSP_STATE\n";
277 case eLIM_MLM_WT_ADD_BSS_RSP_STATE:
278 return "eLIM_MLM_WT_ADD_BSS_RSP_STATE\n";
279 case eLIM_MLM_REASSOCIATED_STATE:
280 return "eLIM_MLM_REASSOCIATED_STATE\n";
281 case eLIM_MLM_LINK_ESTABLISHED_STATE:
282 return "eLIM_MLM_LINK_ESTABLISHED_STATE\n";
283 case eLIM_MLM_WT_ASSOC_CNF_STATE:
284 return "eLIM_MLM_WT_ASSOC_CNF_STATE\n";
285 case eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE:
286 return "eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE\n";
287 case eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE:
288 return "eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE\n";
289 case eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE:
290 return "eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE";
291 case eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE:
292 return "eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE\n";
293 case eLIM_MLM_WT_SET_BSS_KEY_STATE:
294 return "eLIM_MLM_WT_SET_BSS_KEY_STATE\n";
295 case eLIM_MLM_WT_SET_STA_KEY_STATE:
296 return "eLIM_MLM_WT_SET_STA_KEY_STATE\n";
297 default:
298 return "INVALID MLM state\n";
299 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700300}
301
302void
303limPrintMlmState(tpAniSirGlobal pMac, tANI_U16 logLevel, tLimMlmStates state)
304{
305 limLog(pMac, logLevel, limMlmStateStr(state));
306}
307
308char *
309limSmeStateStr(tLimSmeStates state)
310{
311#ifdef FIXME_GEN6
312 switch (state)
313 {
314 case eLIM_SME_OFFLINE_STATE:
315 return "eLIM_SME_OFFLINE_STATE\n";
316 case eLIM_SME_IDLE_STATE:
317 return "eLIM_SME_IDLE_STATE\n";
318 case eLIM_SME_SUSPEND_STATE:
319 return "eLIM_SME_SUSPEND_STATE\n";
320 case eLIM_SME_WT_SCAN_STATE:
321 return "eLIM_SME_WT_SCAN_STATE\n";
322 case eLIM_SME_WT_JOIN_STATE:
323 return "eLIM_SME_WT_JOIN_STATE\n";
324 case eLIM_SME_WT_AUTH_STATE:
325 return "eLIM_SME_WT_AUTH_STATE\n";
326 case eLIM_SME_WT_ASSOC_STATE:
327 return "eLIM_SME_WT_ASSOC_STATE\n";
328 case eLIM_SME_WT_REASSOC_STATE:
329 return "eLIM_SME_WT_REASSOC_STATE\n";
330 case eLIM_SME_WT_REASSOC_LINK_FAIL_STATE:
331 return "eLIM_SME_WT_REASSOC_LINK_FAIL_STATE\n";
332 case eLIM_SME_JOIN_FAILURE_STATE:
333 return "eLIM_SME_JOIN_FAILURE_STATE\n";
334 case eLIM_SME_ASSOCIATED_STATE:
335 return "eLIM_SME_ASSOCIATED_STATE\n";
336 case eLIM_SME_REASSOCIATED_STATE:
337 return "eLIM_SME_REASSOCIATED_STATE\n";
338 case eLIM_SME_LINK_EST_STATE:
339 return "eLIM_SME_LINK_EST_STATE\n";
340 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
341 return "eLIM_SME_LINK_EST_WT_SCAN_STATE\n";
342 case eLIM_SME_WT_PRE_AUTH_STATE:
343 return "eLIM_SME_WT_PRE_AUTH_STATE\n";
344 case eLIM_SME_WT_DISASSOC_STATE:
345 return "eLIM_SME_WT_DISASSOC_STATE\n";
346 case eLIM_SME_WT_DEAUTH_STATE:
347 return "eLIM_SME_WT_DEAUTH_STATE\n";
348 case eLIM_SME_WT_START_BSS_STATE:
349 return "eLIM_SME_WT_START_BSS_STATE\n";
350 case eLIM_SME_WT_STOP_BSS_STATE:
351 return "eLIM_SME_WT_STOP_BSS_STATE\n";
352 case eLIM_SME_NORMAL_STATE:
353 return "eLIM_SME_NORMAL_STATE\n";
354 case eLIM_SME_CHANNEL_SCAN_STATE:
355 return "eLIM_SME_CHANNEL_SCAN_STATE\n";
356 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
357 return "eLIM_SME_NORMAL_CHANNEL_SCAN_STATE\n";
358 default:
359 return "INVALID SME state\n";
360 }
361#endif
362return "";
363}
364
365
366char* limDot11ModeStr(tpAniSirGlobal pMac, tANI_U8 dot11Mode)
367{
368#ifdef FIXME_GEN6
369
370 switch(dot11Mode)
371 {
372 case WNI_CFG_DOT11_MODE_ALL:
373 return "ALL\n";
374 case WNI_CFG_DOT11_MODE_11A:
375 return "11A\n";
376 case WNI_CFG_DOT11_MODE_11B:
377 return "11B\n";
378 case WNI_CFG_DOT11_MODE_11G:
379 return "11G\n";
380 case WNI_CFG_DOT11_MODE_11N:
381 return "11N\n";
382 case WNI_CFG_DOT11_MODE_POLARIS:
383 return "Polaris\n";
384 case WNI_CFG_DOT11_MODE_TITAN:
385 return "Titan\n";
386 case WNI_CFG_DOT11_MODE_TAURUS:
387 return "Taurus\n";
388 default:
389 return "Invalid Dot11 Mode\n";
390 }
391#endif
392return "";
393}
394
395
396char* limStaOpRateModeStr(tStaRateMode opRateMode)
397{
398#ifdef FIXME_GEN6
399
400 switch(opRateMode)
401 {
402 case eSTA_TAURUS:
403 return "Taurus\n";
404 case eSTA_11a:
405 return "11A\n";
406 case eSTA_11b:
407 return "11B\n";
408 case eSTA_11bg:
409 return "11G\n";
410 case eSTA_11n:
411 return "11N\n";
412 case eSTA_POLARIS:
413 return "Polaris\n";
414 case eSTA_TITAN:
415 return "Titan\n";
416 default:
417 return "Invalid Dot11 Mode\n";
418 }
419#endif
420return "";
421}
422
423char* limBssTypeStr(tSirBssType bssType)
424{
425 switch(bssType)
426 {
427 case eSIR_INFRASTRUCTURE_MODE:
428 return "eSIR_INFRASTRUCTURE_MODE";
429 case eSIR_IBSS_MODE:
430 return "eSIR_IBSS_MODE";
431 case eSIR_BTAMP_STA_MODE:
432 return "eSIR_BTAMP_STA_MODE";
433 case eSIR_BTAMP_AP_MODE:
434 return "eSIR_BTAMP_AP_MODE";
435 case eSIR_AUTO_MODE:
436 return "eSIR_AUTO_MODE";
437 default:
438 return "Invalid BSS Type";
439 }
440}
441
442void
443limPrintSmeState(tpAniSirGlobal pMac, tANI_U16 logLevel, tLimSmeStates state)
444{
445 limLog(pMac, logLevel, limSmeStateStr(state));
446}
447
448char *limMsgStr(tANI_U32 msgType)
449{
450#ifdef FIXME_GEN6
451 switch (msgType)
452 {
453 case eWNI_SME_START_REQ:
454 return "eWNI_SME_START_REQ\n";
455 case eWNI_SME_START_RSP:
456 return "eWNI_SME_START_RSP\n";
457 case eWNI_SME_SYS_READY_IND:
458 return "eWNI_SME_SYS_READY_IND\n";
459 case eWNI_SME_SCAN_REQ:
460 return "eWNI_SME_SCAN_REQ\n";
Jeff Johnsone7245742012-09-05 17:12:55 -0700461#ifdef FEATURE_OEM_DATA_SUPPORT
462 case eWNI_SME_OEM_DATA_REQ:
463 return "eWNI_SME_OEM_DATA_REQ\n";
464 case eWNI_SME_OEM_DATA_RSP:
465 return "eWNI_SME_OEM_DATA_RSP\n";
466#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 case eWNI_SME_SCAN_RSP:
468 return "eWNI_SME_SCAN_RSP\n";
469 case eWNI_SME_JOIN_REQ:
470 return "eWNI_SME_JOIN_REQ\n";
471 case eWNI_SME_JOIN_RSP:
472 return "eWNI_SME_JOIN_RSP\n";
473 case eWNI_SME_SETCONTEXT_REQ:
474 return "eWNI_SME_SETCONTEXT_REQ\n";
475 case eWNI_SME_SETCONTEXT_RSP:
476 return "eWNI_SME_SETCONTEXT_RSP\n";
477 case eWNI_SME_REASSOC_REQ:
478 return "eWNI_SME_REASSOC_REQ\n";
479 case eWNI_SME_REASSOC_RSP:
480 return "eWNI_SME_REASSOC_RSP\n";
481 case eWNI_SME_AUTH_REQ:
482 return "eWNI_SME_AUTH_REQ\n";
483 case eWNI_SME_AUTH_RSP:
484 return "eWNI_SME_AUTH_RSP\n";
485 case eWNI_SME_DISASSOC_REQ:
486 return "eWNI_SME_DISASSOC_REQ\n";
487 case eWNI_SME_DISASSOC_RSP:
488 return "eWNI_SME_DISASSOC_RSP\n";
489 case eWNI_SME_DISASSOC_IND:
490 return "eWNI_SME_DISASSOC_IND\n";
491 case eWNI_SME_DISASSOC_CNF:
492 return "eWNI_SME_DISASSOC_CNF\n";
493 case eWNI_SME_DEAUTH_REQ:
494 return "eWNI_SME_DEAUTH_REQ\n";
495 case eWNI_SME_DEAUTH_RSP:
496 return "eWNI_SME_DEAUTH_RSP\n";
497 case eWNI_SME_DEAUTH_IND:
498 return "eWNI_SME_DEAUTH_IND\n";
499 case eWNI_SME_WM_STATUS_CHANGE_NTF:
500 return "eWNI_SME_WM_STATUS_CHANGE_NTF\n";
501 case eWNI_SME_START_BSS_REQ:
502 return "eWNI_SME_START_BSS_REQ\n";
503 case eWNI_SME_START_BSS_RSP:
504 return "eWNI_SME_START_BSS_RSP\n";
505 case eWNI_SME_AUTH_IND:
506 return "eWNI_SME_AUTH_IND\n";
507 case eWNI_SME_ASSOC_IND:
508 return "eWNI_SME_ASSOC_IND\n";
509 case eWNI_SME_ASSOC_CNF:
510 return "eWNI_SME_ASSOC_CNF\n";
511 case eWNI_SME_REASSOC_IND:
512 return "eWNI_SME_REASSOC_IND\n";
513 case eWNI_SME_REASSOC_CNF:
514 return "eWNI_SME_REASSOC_CNF\n";
515 case eWNI_SME_SWITCH_CHL_REQ:
516 return "eWNI_SME_SWITCH_CHL_REQ\n";
517 case eWNI_SME_SWITCH_CHL_RSP:
518 return "eWNI_SME_SWITCH_CHL_RSP\n";
519 case eWNI_SME_SWITCH_CHL_CB_PRIMARY_REQ:
520 return "eWNI_SME_SWITCH_CHL_CB_PRIMARY_REQ\n";
521 case eWNI_SME_SWITCH_CHL_CB_SECONDARY_REQ:
522 return "eWNI_SME_SWITCH_CHL_CB_SECONDARY_REQ\n";
523 case eWNI_SME_STOP_BSS_REQ:
524 return "eWNI_SME_STOP_BSS_REQ\n";
525 case eWNI_SME_STOP_BSS_RSP:
526 return "eWNI_SME_STOP_BSS_RSP\n";
527 case eWNI_SME_PROMISCUOUS_MODE_REQ:
528 return "eWNI_SME_PROMISCUOUS_MODE_REQ\n";
529 case eWNI_SME_PROMISCUOUS_MODE_RSP:
530 return "eWNI_SME_PROMISCUOUS_MODE_RSP\n";
531 case eWNI_SME_NEIGHBOR_BSS_IND:
532 return "eWNI_SME_NEIGHBOR_BSS_IND\n";
533 case eWNI_SME_MEASUREMENT_REQ:
534 return "eWNI_SME_MEASUREMENT_REQ\n";
535 case eWNI_SME_MEASUREMENT_RSP:
536 return "eWNI_SME_MEASUREMENT_RSP\n";
537 case eWNI_SME_MEASUREMENT_IND:
538 return "eWNI_SME_MEASUREMENT_IND\n";
539 case eWNI_SME_SET_WDS_INFO_REQ:
540 return "eWNI_SME_SET_WDS_INFO_REQ\n";
541 case eWNI_SME_SET_WDS_INFO_RSP:
542 return "eWNI_SME_SET_WDS_INFO_RSP\n";
543 case eWNI_SME_WDS_INFO_IND:
544 return "eWNI_SME_WDS_INFO_IND\n";
545 case eWNI_SME_DEAUTH_CNF:
546 return "eWNI_SME_DEAUTH_CNF\n";
547 case eWNI_SME_MIC_FAILURE_IND:
548 return "eWNI_SME_MIC_FAILURE_IND\n";
549 case eWNI_SME_ADDTS_REQ:
550 return "eWNI_SME_ADDTS_REQ\n";
551 case eWNI_SME_ADDTS_RSP:
552 return "eWNI_SME_ADDTS_RSP\n";
553 case eWNI_SME_ADDTS_CNF:
554 return "eWNI_SME_ADDTS_CNF\n";
555 case eWNI_SME_ADDTS_IND:
556 return "eWNI_SME_ADDTS_IND\n";
557 case eWNI_SME_DELTS_REQ:
558 return "eWNI_SME_DELTS_REQ\n";
559 case eWNI_SME_DELTS_RSP:
560 return "eWNI_SME_DELTS_RSP\n";
561 case eWNI_SME_DELTS_IND:
562 return "eWNI_SME_DELTS_IND\n";
563
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 case WDA_SUSPEND_ACTIVITY_RSP:
565 return "WDA_SUSPEND_ACTIVITY_RSP\n";
566 case SIR_LIM_RETRY_INTERRUPT_MSG:
567 return "SIR_LIM_RETRY_INTERRUPT_MSG\n";
568 case SIR_BB_XPORT_MGMT_MSG:
569 return "SIR_BB_XPORT_MGMT_MSG\n";
570 case SIR_LIM_INV_KEY_INTERRUPT_MSG:
571 return "SIR_LIM_INV_KEY_INTERRUPT_MSG\n";
572 case SIR_LIM_KEY_ID_INTERRUPT_MSG:
573 return "SIR_LIM_KEY_ID_INTERRUPT_MSG\n";
574 case SIR_LIM_REPLAY_THRES_INTERRUPT_MSG:
575 return "SIR_LIM_REPLAY_THRES_INTERRUPT_MSG\n";
576 case SIR_LIM_MIN_CHANNEL_TIMEOUT:
577 return "SIR_LIM_MIN_CHANNEL_TIMEOUT\n";
578 case SIR_LIM_MAX_CHANNEL_TIMEOUT:
579 return "SIR_LIM_MAX_CHANNEL_TIMEOUT\n";
580 case SIR_LIM_JOIN_FAIL_TIMEOUT:
581 return "SIR_LIM_JOIN_FAIL_TIMEOUT\n";
582 case SIR_LIM_AUTH_FAIL_TIMEOUT:
583 return "SIR_LIM_AUTH_FAIL_TIMEOUT\n";
584 case SIR_LIM_AUTH_RSP_TIMEOUT:
585 return "SIR_LIM_AUTH_RSP_TIMEOUT\n";
586 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
587 return "SIR_LIM_ASSOC_FAIL_TIMEOUT\n";
588 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
589 return "SIR_LIM_REASSOC_FAIL_TIMEOUT\n";
590 case SIR_LIM_HEART_BEAT_TIMEOUT:
591 return "SIR_LIM_HEART_BEAT_TIMEOUT\n";
Jeff Johnson295189b2012-06-20 16:38:30 -0700592 case SIR_LIM_ADDTS_RSP_TIMEOUT:
593 return "SIR_LIM_ADDTS_RSP_TIMEOUT\n";
594 case SIR_LIM_CHANNEL_SCAN_TIMEOUT:
595 return "SIR_LIM_CHANNEL_SCAN_TIMEOUT\n";
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 case SIR_LIM_LINK_TEST_DURATION_TIMEOUT:
597 return "SIR_LIM_LINK_TEST_DURATION_TIMEOUT\n";
598 case SIR_LIM_HASH_MISS_THRES_TIMEOUT:
599 return "SIR_LIM_HASH_MISS_THRES_TIMEOUT\n";
600 case SIR_LIM_KEEPALIVE_TIMEOUT:
601 return "SIR_LIM_KEEPALIVE_TIMEOUT\n";
602 case SIR_LIM_UPDATE_OLBC_CACHEL_TIMEOUT:
603 return "SIR_LIM_UPDATE_OLBC_CACHEL_TIMEOUT\n";
604 case SIR_LIM_CNF_WAIT_TIMEOUT:
605 return "SIR_LIM_CNF_WAIT_TIMEOUT\n";
606 case SIR_LIM_RADAR_DETECT_IND:
607 return "SIR_LIM_RADAR_DETECT_IND\n";
608#ifdef WLAN_FEATURE_VOWIFI_11R
609 case SIR_LIM_FT_PREAUTH_RSP_TIMEOUT:
610 return "SIR_LIM_FT_PREAUTH_RSP_TIMEOUT\n";
611#endif
612
613 case SIR_HAL_APP_SETUP_NTF:
614 return "SIR_HAL_APP_SETUP_NTF\n";
615 case SIR_HAL_INITIAL_CAL_FAILED_NTF:
616 return "SIR_HAL_INITIAL_CAL_FAILED_NTF\n";
617 case SIR_HAL_NIC_OPER_NTF:
618 return "SIR_HAL_NIC_OPER_NTF\n";
619 case SIR_HAL_INIT_START_REQ:
620 return "SIR_HAL_INIT_START_REQ\n";
621 case SIR_HAL_SHUTDOWN_REQ:
622 return "SIR_HAL_SHUTDOWN_REQ\n";
623 case SIR_HAL_SHUTDOWN_CNF:
624 return "SIR_HAL_SHUTDOWN_CNF\n";
625 case SIR_HAL_RESET_REQ:
626 return "SIR_HAL_RESET_REQ\n";
627 case SIR_HAL_RESET_CNF:
628 return "SIR_HAL_RESET_CNF\n";
629 case SIR_WRITE_TO_TD:
630 return "SIR_WRITE_TO_TD\n";
631
632 case WNI_CFG_PARAM_UPDATE_IND:
633 return "WNI_CFG_PARAM_UPDATE_IND\n";
634 case WNI_CFG_DNLD_REQ:
635 return "WNI_CFG_DNLD_REQ\n";
636 case WNI_CFG_DNLD_CNF:
637 return "WNI_CFG_DNLD_CNF\n";
638 case WNI_CFG_GET_RSP:
639 return "WNI_CFG_GET_RSP\n";
640 case WNI_CFG_SET_CNF:
641 return "WNI_CFG_SET_CNF\n";
642 case WNI_CFG_GET_ATTRIB_RSP:
643 return "WNI_CFG_GET_ATTRIB_RSP\n";
644 case WNI_CFG_ADD_GRP_ADDR_CNF:
645 return "WNI_CFG_ADD_GRP_ADDR_CNF\n";
646 case WNI_CFG_DEL_GRP_ADDR_CNF:
647 return "WNI_CFG_DEL_GRP_ADDR_CNF\n";
648 case ANI_CFG_GET_RADIO_STAT_RSP:
649 return "ANI_CFG_GET_RADIO_STAT_RSP\n";
650 case ANI_CFG_GET_PER_STA_STAT_RSP:
651 return "ANI_CFG_GET_PER_STA_STAT_RSP\n";
652 case ANI_CFG_GET_AGG_STA_STAT_RSP:
653 return "ANI_CFG_GET_AGG_STA_STAT_RSP\n";
654 case ANI_CFG_CLEAR_STAT_RSP:
655 return "ANI_CFG_CLEAR_STAT_RSP\n";
656 case WNI_CFG_DNLD_RSP:
657 return "WNI_CFG_DNLD_RSP\n";
658 case WNI_CFG_GET_REQ:
659 return "WNI_CFG_GET_REQ\n";
660 case WNI_CFG_SET_REQ:
661 return "WNI_CFG_SET_REQ\n";
662 case WNI_CFG_SET_REQ_NO_RSP:
663 return "WNI_CFG_SET_REQ_NO_RSP\n";
664 case eWNI_PMC_ENTER_IMPS_RSP:
665 return "eWNI_PMC_ENTER_IMPS_RSP\n";
666 case eWNI_PMC_EXIT_IMPS_RSP:
667 return "eWNI_PMC_EXIT_IMPS_RSP\n";
668 case eWNI_PMC_ENTER_BMPS_RSP:
669 return "eWNI_PMC_ENTER_BMPS_RSP\n";
670 case eWNI_PMC_EXIT_BMPS_RSP:
671 return "eWNI_PMC_EXIT_BMPS_RSP\n";
672 case eWNI_PMC_EXIT_BMPS_IND:
673 return "eWNI_PMC_EXIT_BMPS_IND\n";
Yathish9f22e662012-12-10 14:21:35 -0800674 case eWNI_SME_SET_BCN_FILTER_REQ:
675 return "eWNI_SME_SET_BCN_FILTER_REQ\n";
Jeff Johnson295189b2012-06-20 16:38:30 -0700676 default:
677 return "INVALID SME message\n";
678 }
679#endif
680return "";
681}
682
683
684
685char *limResultCodeStr(tSirResultCodes resultCode)
686{
Jeff Johnson295189b2012-06-20 16:38:30 -0700687 switch (resultCode)
688 {
689 case eSIR_SME_SUCCESS:
690 return "eSIR_SME_SUCCESS\n";
691 case eSIR_EOF_SOF_EXCEPTION:
692 return "eSIR_EOF_SOF_EXCEPTION\n";
693 case eSIR_BMU_EXCEPTION:
694 return "eSIR_BMU_EXCEPTION\n";
695 case eSIR_LOW_PDU_EXCEPTION:
696 return "eSIR_LOW_PDU_EXCEPTION\n";
697 case eSIR_USER_TRIG_RESET:
698 return"eSIR_USER_TRIG_RESET\n";
699 case eSIR_LOGP_EXCEPTION:
700 return "eSIR_LOGP_EXCEPTION\n";
701 case eSIR_CP_EXCEPTION:
702 return "eSIR_CP_EXCEPTION\n";
703 case eSIR_STOP_BSS:
704 return "eSIR_STOP_BSS\n";
705 case eSIR_AHB_HANG_EXCEPTION:
706 return "eSIR_AHB_HANG_EXCEPTION\n";
707 case eSIR_DPU_EXCEPTION:
708 return "eSIR_DPU_EXCEPTION\n";
709 case eSIR_RXP_EXCEPTION:
710 return "eSIR_RXP_EXCEPTION\n";
711 case eSIR_MCPU_EXCEPTION:
712 return "eSIR_MCPU_EXCEPTION\n";
713 case eSIR_MCU_EXCEPTION:
714 return "eSIR_MCU_EXCEPTION\n";
715 case eSIR_MTU_EXCEPTION:
716 return "eSIR_MTU_EXCEPTION\n";
717 case eSIR_MIF_EXCEPTION:
718 return "eSIR_MIF_EXCEPTION\n";
719 case eSIR_FW_EXCEPTION:
720 return "eSIR_FW_EXCEPTION\n";
721 case eSIR_MAILBOX_SANITY_CHK_FAILED:
722 return "eSIR_MAILBOX_SANITY_CHK_FAILED\n";
723 case eSIR_RADIO_HW_SWITCH_STATUS_IS_OFF:
724 return "eSIR_RADIO_HW_SWITCH_STATUS_IS_OFF\n";
725 case eSIR_CFB_FLAG_STUCK_EXCEPTION:
726 return "eSIR_CFB_FLAG_STUCK_EXCEPTION\n";
727 case eSIR_SME_BASIC_RATES_NOT_SUPPORTED_STATUS:
728 return "eSIR_SME_BASIC_RATES_NOT_SUPPORTED_STATUS\n";
729 case eSIR_SME_INVALID_PARAMETERS:
730 return "eSIR_SME_INVALID_PARAMETERS\n";
731 case eSIR_SME_UNEXPECTED_REQ_RESULT_CODE:
732 return "eSIR_SME_UNEXPECTED_REQ_RESULT_CODE\n";
733 case eSIR_SME_RESOURCES_UNAVAILABLE:
734 return "eSIR_SME_RESOURCES_UNAVAILABLE\n";
735 case eSIR_SME_SCAN_FAILED:
736 return "eSIR_SME_SCAN_FAILED\n";
737 case eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED:
738 return "eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED\n";
739 case eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE:
740 return "eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE\n";
741 case eSIR_SME_REFUSED:
742 return "eSIR_SME_REFUSED\n";
743 case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE:
744 return "eSIR_SME_JOIN_TIMEOUT_RESULT_CODE\n";
745 case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE:
746 return "eSIR_SME_AUTH_TIMEOUT_RESULT_CODE\n";
747 case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE:
748 return "eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE\n";
749 case eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE:
750 return "eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE\n";
751 case eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED:
752 return "eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED\n";
753 case eSIR_SME_AUTH_REFUSED:
754 return "eSIR_SME_AUTH_REFUSED\n";
755 case eSIR_SME_INVALID_WEP_DEFAULT_KEY:
756 return "eSIR_SME_INVALID_WEP_DEFAULT_KEY\n";
757 case eSIR_SME_ASSOC_REFUSED:
758 return "eSIR_SME_ASSOC_REFUSED\n";
759 case eSIR_SME_REASSOC_REFUSED:
760 return "eSIR_SME_REASSOC_REFUSED\n";
761 case eSIR_SME_STA_NOT_AUTHENTICATED:
762 return "eSIR_SME_STA_NOT_AUTHENTICATED\n";
763 case eSIR_SME_STA_NOT_ASSOCIATED:
764 return "eSIR_SME_STA_NOT_ASSOCIATED\n";
765 case eSIR_SME_STA_DISASSOCIATED:
766 return "eSIR_SME_STA_DISASSOCIATED\n";
767 case eSIR_SME_ALREADY_JOINED_A_BSS:
768 return "eSIR_SME_ALREADY_JOINED_A_BSS\n";
769 case eSIR_ULA_COMPLETED:
770 return "eSIR_ULA_COMPLETED\n";
771 case eSIR_ULA_FAILURE:
772 return "eSIR_ULA_FAILURE\n";
773 case eSIR_SME_LINK_ESTABLISHED:
774 return "eSIR_SME_LINK_ESTABLISHED\n";
775 case eSIR_SME_UNABLE_TO_PERFORM_MEASUREMENTS:
776 return "eSIR_SME_UNABLE_TO_PERFORM_MEASUREMENTS\n";
777 case eSIR_SME_UNABLE_TO_PERFORM_DFS:
778 return "eSIR_SME_UNABLE_TO_PERFORM_DFS\n";
779 case eSIR_SME_DFS_FAILED:
780 return "eSIR_SME_DFS_FAILED\n";
781 case eSIR_SME_TRANSFER_STA:
782 return "eSIR_SME_TRANSFER_STA\n";
783 case eSIR_SME_INVALID_LINK_TEST_PARAMETERS:
784 return "eSIR_SME_INVALID_LINK_TEST_PARAMETERS\n";
785 case eSIR_SME_LINK_TEST_MAX_EXCEEDED:
786 return "eSIR_SME_LINK_TEST_MAX_EXCEEDED\n";
787 case eSIR_SME_UNSUPPORTED_RATE:
788 return "eSIR_SME_UNSUPPORTED_RATE\n";
789 case eSIR_SME_LINK_TEST_TIMEOUT:
790 return "eSIR_SME_LINK_TEST_TIMEOUT\n";
791 case eSIR_SME_LINK_TEST_COMPLETE:
792 return "eSIR_SME_LINK_TEST_COMPLETE\n";
793 case eSIR_SME_LINK_TEST_INVALID_STATE:
794 return "eSIR_SME_LINK_TEST_INVALID_STATE\n";
795 case eSIR_SME_LINK_TEST_INVALID_ADDRESS:
796 return "eSIR_SME_LINK_TEST_INVALID_ADDRESS\n";
797 case eSIR_SME_POLARIS_RESET:
798 return "eSIR_SME_POLARIS_RESET\n";
799 case eSIR_SME_SETCONTEXT_FAILED:
800 return "eSIR_SME_SETCONTEXT_FAILED\n";
801 case eSIR_SME_BSS_RESTART:
802 return "eSIR_SME_BSS_RESTART\n";
803 case eSIR_SME_MORE_SCAN_RESULTS_FOLLOW:
804 return "eSIR_SME_MORE_SCAN_RESULTS_FOLLOW\n";
805 case eSIR_SME_INVALID_ASSOC_RSP_RXED:
806 return "eSIR_SME_INVALID_ASSOC_RSP_RXED\n";
807 case eSIR_SME_MIC_COUNTER_MEASURES:
808 return "eSIR_SME_MIC_COUNTER_MEASURES\n";
809 case eSIR_SME_ADDTS_RSP_TIMEOUT:
810 return "eSIR_SME_ADDTS_RSP_TIMEOUT\n";
811 case eSIR_SME_RECEIVED:
812 return "eSIR_SME_RECEIVED\n";
813 case eSIR_SME_CHANNEL_SWITCH_FAIL:
814 return "eSIR_SME_CHANNEL_SWITCH_FAIL\n";
815#ifdef GEN4_SCAN
816 case eSIR_SME_CHANNEL_SWITCH_DISABLED:
817 return "eSIR_SME_CHANNEL_SWITCH_DISABLED\n";
818 case eSIR_SME_HAL_SCAN_INIT_FAILED:
819 return "eSIR_SME_HAL_SCAN_INIT_FAILED\n";
820 case eSIR_SME_HAL_SCAN_START_FAILED:
821 return "eSIR_SME_HAL_SCAN_START_FAILED\n";
822 case eSIR_SME_HAL_SCAN_END_FAILED:
823 return "eSIR_SME_HAL_SCAN_END_FAILED\n";
824 case eSIR_SME_HAL_SCAN_FINISH_FAILED:
825 return "eSIR_SME_HAL_SCAN_FINISH_FAILED\n";
826 case eSIR_SME_HAL_SEND_MESSAGE_FAIL:
827 return "eSIR_SME_HAL_SEND_MESSAGE_FAIL\n";
828#else // GEN4_SCAN
829 case eSIR_SME_CHANNEL_SWITCH_DISABLED:
830 return "eSIR_SME_CHANNEL_SWITCH_DISABLED\n";
831 case eSIR_SME_HAL_SEND_MESSAGE_FAIL:
832 return "eSIR_SME_HAL_SEND_MESSAGE_FAIL\n";
833#endif // GEN4_SCAN
834
835 default:
836 return "INVALID resultCode\n";
837 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700838}
839
840void
841limPrintMsgName(tpAniSirGlobal pMac, tANI_U16 logLevel, tANI_U32 msgType)
842{
843 limLog(pMac, logLevel, limMsgStr(msgType));
844}
845
846
847#if defined(ANI_MIPS) || defined(ANI_ARM)
848#define LINK 0
849#else
850#define LINK 1
851#endif
852
853void
854limPrintMsgInfo(tpAniSirGlobal pMac, tANI_U16 logLevel, tSirMsgQ *msg)
855{
856 //tSirMacFrameCtl fc; // FIXME_GEN4 - ASAP!!
857#if defined (ANI_OS_TYPE_LINUX) || defined (ANI_OS_TYPE_OSX)
858 tANI_U32 *pRxPacketInfo;
859#endif
860 if (logLevel <= pMac->utils.gLogDbgLevel[SIR_LIM_MODULE_ID - LOG_FIRST_MODULE_ID])
861 {
862 switch (msg->type)
863 {
864 case SIR_BB_XPORT_MGMT_MSG:
865#if defined (ANI_OS_TYPE_LINUX) || defined (ANI_OS_TYPE_OSX)
866#ifndef GEN6_ONWARDS //PAL does not provide this API GEN6 onwards.
867 palGetPacketDataPtr( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, (void *) msg->bodyptr, (void **) &pRxPacketInfo );
868#endif //GEN6_ONWARDS
869#else
870 limPrintMsgName(pMac, logLevel,msg->type);
871#endif
872 break;
873 default:
874 limPrintMsgName(pMac, logLevel,msg->type);
875 break;
876 }
877 }
878}
879
880/**
881 * limInitMlm()
882 *
883 *FUNCTION:
884 * This function is called by limProcessSmeMessages() to
885 * initialize MLM state machine on STA
886 *
887 *PARAMS:
888 *
889 *LOGIC:
890 *
891 *ASSUMPTIONS:
892 * NA
893 *
894 *NOTE:
895 * NA
896 *
897 * @param pMac Pointer to Global MAC structure
898 * @return None
899 */
900void
901limInitMlm(tpAniSirGlobal pMac)
902{
Madan Mohan Koyyalamudi694f8d72012-10-11 16:32:55 -0700903 tANI_U32 retVal;
904
905 pMac->lim.gLimTimersCreated = 0;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700906
Jeff Johnsone7245742012-09-05 17:12:55 -0700907 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700908
909 /// Initialize scan result hash table
910 limReInitScanResults(pMac); //sep26th review
911
912
913 /// Initialize number of pre-auth contexts
914 pMac->lim.gLimNumPreAuthContexts = 0;
915
916 /// Initialize MAC based Authentication STA list
917 limInitPreAuthList(pMac);
918
919 //pMac->lim.gpLimMlmJoinReq = NULL;
920
921 if (pMac->lim.gLimTimersCreated)
922 return;
923
924 // Create timers used by LIM
Madan Mohan Koyyalamudi694f8d72012-10-11 16:32:55 -0700925 retVal = limCreateTimers(pMac);
926 if(retVal == TX_SUCCESS)
927 {
928 pMac->lim.gLimTimersCreated = 1;
929 }
930 else
931 {
932 limLog(pMac, LOGP, FL(" limCreateTimers Failed to create lim timers \n"));
933 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700934} /*** end limInitMlm() ***/
935
936
937
938/**
939 * limCleanupMlm()
940 *
941 *FUNCTION:
942 * This function is called to cleanup any resources
943 * allocated by the MLM state machine.
944 *
945 *PARAMS:
946 *
947 *LOGIC:
948 *
949 *ASSUMPTIONS:
950 * NA
951 *
952 *NOTE:
953 * It is assumed that BSS is already informed that we're leaving it
954 * before this function is called.
955 *
956 * @param pMac Pointer to Global MAC structure
957 * @param None
958 * @return None
959 */
960void
961limCleanupMlm(tpAniSirGlobal pMac)
962{
963 tANI_U32 n;
964 tLimPreAuthNode *pAuthNode;
965
966 if (pMac->lim.gLimTimersCreated == 1)
967 {
968 // Deactivate and delete MIN/MAX channel timers.
969 tx_timer_deactivate(&pMac->lim.limTimers.gLimMinChannelTimer);
970 tx_timer_delete(&pMac->lim.limTimers.gLimMinChannelTimer);
971 tx_timer_deactivate(&pMac->lim.limTimers.gLimMaxChannelTimer);
972 tx_timer_delete(&pMac->lim.limTimers.gLimMaxChannelTimer);
973 tx_timer_deactivate(&pMac->lim.limTimers.gLimPeriodicProbeReqTimer);
974 tx_timer_delete(&pMac->lim.limTimers.gLimPeriodicProbeReqTimer);
975
976
977 // Deactivate and delete channel switch timer.
978 tx_timer_deactivate(&pMac->lim.limTimers.gLimChannelSwitchTimer);
979 tx_timer_delete(&pMac->lim.limTimers.gLimChannelSwitchTimer);
980
981
982 // Deactivate and delete addts response timer.
983 tx_timer_deactivate(&pMac->lim.limTimers.gLimAddtsRspTimer);
984 tx_timer_delete(&pMac->lim.limTimers.gLimAddtsRspTimer);
985
986 // Deactivate and delete Join failure timer.
987 tx_timer_deactivate(&pMac->lim.limTimers.gLimJoinFailureTimer);
988 tx_timer_delete(&pMac->lim.limTimers.gLimJoinFailureTimer);
989
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -0800990 // Deactivate and delete Periodic Join Probe Request timer.
991 tx_timer_deactivate(&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer);
992 tx_timer_delete(&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer);
993
Jeff Johnson295189b2012-06-20 16:38:30 -0700994 // Deactivate and delete Association failure timer.
995 tx_timer_deactivate(&pMac->lim.limTimers.gLimAssocFailureTimer);
996 tx_timer_delete(&pMac->lim.limTimers.gLimAssocFailureTimer);
997
998 // Deactivate and delete Reassociation failure timer.
999 tx_timer_deactivate(&pMac->lim.limTimers.gLimReassocFailureTimer);
1000 tx_timer_delete(&pMac->lim.limTimers.gLimReassocFailureTimer);
1001
1002 // Deactivate and delete Authentication failure timer.
1003 tx_timer_deactivate(&pMac->lim.limTimers.gLimAuthFailureTimer);
1004 tx_timer_delete(&pMac->lim.limTimers.gLimAuthFailureTimer);
1005
1006 // Deactivate and delete Heartbeat timer.
1007 tx_timer_deactivate(&pMac->lim.limTimers.gLimHeartBeatTimer);
1008 tx_timer_delete(&pMac->lim.limTimers.gLimHeartBeatTimer);
1009
1010 // Deactivate and delete wait-for-probe-after-Heartbeat timer.
1011 tx_timer_deactivate(&pMac->lim.limTimers.gLimProbeAfterHBTimer);
1012 tx_timer_delete(&pMac->lim.limTimers.gLimProbeAfterHBTimer);
1013
1014 // Deactivate and delete Quiet timer.
1015 tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietTimer);
1016 tx_timer_delete(&pMac->lim.limTimers.gLimQuietTimer);
1017
1018 // Deactivate and delete Quiet BSS timer.
1019 tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietBssTimer);
1020 tx_timer_delete(&pMac->lim.limTimers.gLimQuietBssTimer);
1021
Jeff Johnson295189b2012-06-20 16:38:30 -07001022 // Deactivate and delete LIM background scan timer.
1023 tx_timer_deactivate(&pMac->lim.limTimers.gLimBackgroundScanTimer);
1024 tx_timer_delete(&pMac->lim.limTimers.gLimBackgroundScanTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07001025
1026
1027 // Deactivate and delete cnf wait timer
1028 for (n = 0; n < pMac->lim.maxStation; n++)
1029 {
1030 tx_timer_deactivate(&pMac->lim.limTimers.gpLimCnfWaitTimer[n]);
1031 tx_timer_delete(&pMac->lim.limTimers.gpLimCnfWaitTimer[n]);
1032 }
1033
1034 // Deactivate and delete keepalive timer
1035 tx_timer_deactivate(&pMac->lim.limTimers.gLimKeepaliveTimer);
1036 tx_timer_delete(&pMac->lim.limTimers.gLimKeepaliveTimer);
1037
1038 pAuthNode = pMac->lim.gLimPreAuthTimerTable.pTable;
1039
1040 //Deactivate any Authentication response timers
1041 limDeletePreAuthList(pMac);
1042
1043 for (n = 0; n < pMac->lim.gLimPreAuthTimerTable.numEntry; n++,pAuthNode++)
1044 {
1045 // Delete any Authentication response
1046 // timers, which might have been started.
1047 tx_timer_delete(&pAuthNode->timer);
1048 }
1049
Jeff Johnson295189b2012-06-20 16:38:30 -07001050
1051
1052 // Deactivate and delete Hash Miss throttle timer
1053 tx_timer_deactivate(&pMac->lim.limTimers.gLimSendDisassocFrameThresholdTimer);
1054 tx_timer_delete(&pMac->lim.limTimers.gLimSendDisassocFrameThresholdTimer);
1055
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 tx_timer_deactivate(&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer);
1057 tx_timer_delete(&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer);
1058 tx_timer_deactivate(&pMac->lim.limTimers.gLimPreAuthClnupTimer);
1059 tx_timer_delete(&pMac->lim.limTimers.gLimPreAuthClnupTimer);
1060
1061#if 0 // The WPS PBC clean up timer is disabled
1062 if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE)
1063 {
1064 if(pMac->lim.limTimers.gLimWPSOverlapTimerObj.isTimerCreated == eANI_BOOLEAN_TRUE)
1065 {
1066 tx_timer_deactivate(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer);
1067 tx_timer_delete(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer);
1068 pMac->lim.limTimers.gLimWPSOverlapTimerObj.isTimerCreated = eANI_BOOLEAN_FALSE;
1069 }
1070 }
1071#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001072#ifdef WLAN_FEATURE_VOWIFI_11R
1073 // Deactivate and delete FT Preauth response timer
1074 tx_timer_deactivate(&pMac->lim.limTimers.gLimFTPreAuthRspTimer);
1075 tx_timer_delete(&pMac->lim.limTimers.gLimFTPreAuthRspTimer);
1076#endif
1077
1078#ifdef WLAN_FEATURE_P2P
1079 // Deactivate and delete remain on channel timer
1080 tx_timer_deactivate(&pMac->lim.limTimers.gLimRemainOnChannelTimer);
1081 tx_timer_delete(&pMac->lim.limTimers.gLimRemainOnChannelTimer);
1082#endif
1083
1084#ifdef FEATURE_WLAN_CCX
1085 // Deactivate and delete TSM
1086 tx_timer_deactivate(&pMac->lim.limTimers.gLimCcxTsmTimer);
1087 tx_timer_delete(&pMac->lim.limTimers.gLimCcxTsmTimer);
1088#endif
1089
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08001090 tx_timer_deactivate(&pMac->lim.limTimers.gLimDisassocAckTimer);
1091 tx_timer_delete(&pMac->lim.limTimers.gLimDisassocAckTimer);
1092
1093 tx_timer_deactivate(&pMac->lim.limTimers.gLimDeauthAckTimer);
1094 tx_timer_delete(&pMac->lim.limTimers.gLimDeauthAckTimer);
1095
Hoonki Leef63df0d2013-01-16 19:29:14 -08001096#ifdef WLAN_FEATURE_P2P
1097 tx_timer_deactivate(&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer);
1098 tx_timer_delete(&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer);
1099#endif
1100
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 pMac->lim.gLimTimersCreated = 0;
1102 }
1103
1104 /// Cleanup cached scan list
1105 limReInitScanResults(pMac);
1106
1107} /*** end limCleanupMlm() ***/
1108
1109
1110
1111/**
1112 * limCleanupLmm()
1113 *
1114 *FUNCTION:
1115 * This function is called to cleanup any resources
1116 * allocated by LMM sub-module.
1117 *
1118 *PARAMS:
1119 *
1120 *LOGIC:
1121 *
1122 *ASSUMPTIONS:
1123 * NA
1124 *
1125 *NOTE:
1126 * NA
1127 *
1128 * @param pMac Pointer to Global MAC structure
1129 * @return None
1130 */
1131
1132void
1133limCleanupLmm(tpAniSirGlobal pMac)
1134{
Jeff Johnson295189b2012-06-20 16:38:30 -07001135} /*** end limCleanupLmm() ***/
1136
1137
1138
1139/**
1140 * limIsAddrBC()
1141 *
1142 *FUNCTION:
1143 * This function is called in various places within LIM code
1144 * to determine whether passed MAC address is a broadcast or not
1145 *
1146 *LOGIC:
1147 *
1148 *ASSUMPTIONS:
1149 * NA
1150 *
1151 *NOTE:
1152 * NA
1153 *
1154 * @param macAddr Indicates MAC address that need to be determined
1155 * whether it is Broadcast address or not
1156 *
1157 * @return true if passed address is Broadcast address else false
1158 */
1159
1160tANI_U8
1161limIsAddrBC(tSirMacAddr macAddr)
1162{
1163 int i;
1164 for (i = 0; i < 6; i++)
1165 {
1166 if ((macAddr[i] & 0xFF) != 0xFF)
1167 return false;
1168 }
1169
1170 return true;
1171} /****** end limIsAddrBC() ******/
1172
1173
1174
1175/**
1176 * limIsGroupAddr()
1177 *
1178 *FUNCTION:
1179 * This function is called in various places within LIM code
1180 * to determine whether passed MAC address is a group address or not
1181 *
1182 *LOGIC:
1183 * If least significant bit of first octet of the MAC address is
1184 * set to 1, it is a Group address.
1185 *
1186 *ASSUMPTIONS:
1187 * NA
1188 *
1189 *NOTE:
1190 * NA
1191 *
1192 * @param macAddr Indicates MAC address that need to be determined
1193 * whether it is Group address or not
1194 *
1195 * @return true if passed address is Group address else false
1196 */
1197
1198tANI_U8
1199limIsGroupAddr(tSirMacAddr macAddr)
1200{
1201 if ((macAddr[0] & 0x01) == 0x01)
1202 return true;
1203 else
1204 return false;
1205} /****** end limIsGroupAddr() ******/
1206
1207/**
1208 * limPostMsgApiNoWait()
1209 *
1210 *FUNCTION:
1211 * This function is called from other thread while posting a
1212 * message to LIM message Queue gSirLimMsgQ with NO_WAIT option
1213 *
1214 *LOGIC:
1215 * NA
1216 *
1217 *ASSUMPTIONS:
1218 * NA
1219 *
1220 *NOTE:
1221 * NA
1222 *
1223 * @param pMsg - Pointer to the Global MAC structure
1224 * @param pMsg - Pointer to the message structure
1225 * @return None
1226 */
1227
1228tANI_U32
1229limPostMsgApiNoWait(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1230{
1231#ifdef ANI_OS_TYPE_WINDOWS
1232 tANI_U32 retCode;
1233
1234 if ((retCode = tx_queue_send(&pMac->sys.gSirLimMsgQ, pMsg, TX_NO_WAIT))
1235 != TX_SUCCESS)
1236 {
1237 // Failure in sending DFS duration timeout indication
1238 // to LIM thread
1239
1240 // Log error
1241 limLog(pMac, LOGP,
1242 FL("could not post a message %X to LIM msgq, status=%d\n"),
1243 pMsg->type, retCode);
1244 }
1245
1246 return retCode;
1247#else
1248 limProcessMessages(pMac, pMsg);
1249 return TX_SUCCESS;
1250#endif
1251} /*** end limPostMsgApiNoWait() ***/
1252
1253
1254
1255/**
1256 * limPrintMacAddr()
1257 *
1258 *FUNCTION:
1259 * This function is called to print passed MAC address
1260 * in : format.
1261 *
1262 *LOGIC:
1263 *
1264 *ASSUMPTIONS:
1265 * NA
1266 *
1267 *NOTE:
1268 * @param macAddr - MacAddr to be printed
1269 * @param logLevel - Loglevel to be used
1270 *
1271 * @return None.
1272 */
1273
1274void
1275limPrintMacAddr(tpAniSirGlobal pMac, tSirMacAddr macAddr, tANI_U8 logLevel)
1276{
1277 limLog(pMac, logLevel,
1278 FL("%X:%X:%X:%X:%X:%X\n"),
1279 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
1280 macAddr[5]);
1281} /****** end limPrintMacAddr() ******/
1282
1283
1284
1285
1286
1287
1288/*
1289 * limResetDeferredMsgQ()
1290 *
1291 *FUNCTION:
1292 * This function resets the deferred message queue parameters.
1293 *
1294 *PARAMS:
1295 * @param pMac - Pointer to Global MAC structure
1296 *
1297 *LOGIC:
1298 *
1299 *ASSUMPTIONS:
1300 * NA
1301 *
1302 *NOTE:
1303 * NA
1304 *
1305 *RETURNS:
1306 * None
1307 */
1308
1309void limResetDeferredMsgQ(tpAniSirGlobal pMac)
1310{
1311 pMac->lim.gLimDeferredMsgQ.size =
1312 pMac->lim.gLimDeferredMsgQ.write =
1313 pMac->lim.gLimDeferredMsgQ.read = 0;
1314
1315}
1316
1317
1318#define LIM_DEFERRED_Q_CHECK_THRESHOLD (MAX_DEFERRED_QUEUE_LEN/2)
1319#define LIM_MAX_NUM_MGMT_FRAME_DEFERRED (MAX_DEFERRED_QUEUE_LEN/2)
1320
1321/*
1322 * limWriteDeferredMsgQ()
1323 *
1324 *FUNCTION:
1325 * This function queues up a deferred message for later processing on the
1326 * STA side.
1327 *
1328 *PARAMS:
1329 * @param pMac - Pointer to Global MAC structure
1330 * @param limMsg - a LIM message
1331 *
1332 *LOGIC:
1333 *
1334 *ASSUMPTIONS:
1335 * NA
1336 *
1337 *NOTE:
1338 * NA
1339 *
1340 *RETURNS:
1341 * None
1342 */
1343
1344tANI_U8 limWriteDeferredMsgQ(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
1345{
1346 PELOG1(limLog(pMac, LOG1,
1347 FL("** Queue a deferred message (size %d, write %d) - type 0x%x **\n"),
1348 pMac->lim.gLimDeferredMsgQ.size, pMac->lim.gLimDeferredMsgQ.write,
1349 limMsg->type);)
1350
1351 /*
1352 ** check if the deferred message queue is full
1353 **/
1354 if (pMac->lim.gLimDeferredMsgQ.size >= MAX_DEFERRED_QUEUE_LEN)
1355 {
1356 PELOGE(limLog(pMac, LOGE, FL("Deferred Message Queue is full. Msg: %d\n"), limMsg->type);)
1357 return TX_QUEUE_FULL;
1358 }
1359
1360 /*
1361 ** In the application, there should not be more than 1 message get
1362 ** queued up. If happens, flags a warning. In the future, this can
1363 ** happen.
1364 **/
1365 if (pMac->lim.gLimDeferredMsgQ.size > 0)
1366 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001367 PELOGW(limLog(pMac, LOGW, FL("%d Deferred messages (type 0x%x, scan %d, global sme %d, global mlme %d, addts %d)\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 pMac->lim.gLimDeferredMsgQ.size, limMsg->type,
1369 limIsSystemInScanState(pMac),
1370 pMac->lim.gLimSmeState, pMac->lim.gLimMlmState,
1371 pMac->lim.gLimAddtsSent);)
1372 }
1373
1374 /*
1375 ** To prevent the deferred Q is full of management frames, only give them certain space
1376 **/
1377 if( SIR_BB_XPORT_MGMT_MSG == limMsg->type )
1378 {
1379 if( LIM_DEFERRED_Q_CHECK_THRESHOLD < pMac->lim.gLimDeferredMsgQ.size )
1380 {
1381 tANI_U16 idx, count = 0;
1382 for(idx = 0; idx < pMac->lim.gLimDeferredMsgQ.size; idx++)
1383 {
1384 if( SIR_BB_XPORT_MGMT_MSG == pMac->lim.gLimDeferredMsgQ.deferredQueue[idx].type )
1385 {
1386 count++;
1387 }
1388 }
1389 if( LIM_MAX_NUM_MGMT_FRAME_DEFERRED < count )
1390 {
1391 //We reach the quota for management frames, drop this one
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07001392 PELOGW(limLog(pMac, LOGW, FL("Cannot deferred. Msg: %d Too many (count=%d) already"), limMsg->type, count);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001393 //Return error, caller knows what to do
1394 return TX_QUEUE_FULL;
1395 }
1396 }
1397 }
1398
1399 ++pMac->lim.gLimDeferredMsgQ.size;
1400
1401 /*
1402 ** if the write pointer hits the end of the queue, rewind it
1403 **/
1404 if (pMac->lim.gLimDeferredMsgQ.write >= MAX_DEFERRED_QUEUE_LEN)
1405 pMac->lim.gLimDeferredMsgQ.write = 0;
1406
1407 /*
1408 ** save the message to the queue and advanced the write pointer
1409 **/
1410 palCopyMemory(pMac->hHdd,
1411 (tANI_U8 *)&pMac->lim.gLimDeferredMsgQ.deferredQueue[pMac->lim.gLimDeferredMsgQ.write++],
1412 (tANI_U8 *)limMsg,
1413 sizeof(tSirMsgQ));
1414 return TX_SUCCESS;
1415
1416}
1417
1418/*
1419 * limReadDeferredMsgQ()
1420 *
1421 *FUNCTION:
1422 * This function dequeues a deferred message for processing on the
1423 * STA side.
1424 *
1425 *PARAMS:
1426 * @param pMac - Pointer to Global MAC structure
1427 *
1428 *LOGIC:
1429 *
1430 *ASSUMPTIONS:
1431 * NA
1432 *
1433 *NOTE:
1434 *
1435 *
1436 *RETURNS:
1437 * Returns the message at the head of the deferred message queue
1438 */
1439
1440tSirMsgQ* limReadDeferredMsgQ(tpAniSirGlobal pMac)
1441{
1442 tSirMsgQ *msg;
1443
1444 /*
1445 ** check any messages left. If no, return
1446 **/
1447 if (pMac->lim.gLimDeferredMsgQ.size <= 0)
1448 return NULL;
1449
1450 /*
1451 ** decrement the queue size
1452 **/
1453 pMac->lim.gLimDeferredMsgQ.size--;
1454
1455 /*
1456 ** retrieve the message from the head of the queue
1457 **/
1458 msg = &pMac->lim.gLimDeferredMsgQ.deferredQueue[pMac->lim.gLimDeferredMsgQ.read];
1459
1460 /*
1461 ** advance the read pointer
1462 **/
1463 pMac->lim.gLimDeferredMsgQ.read++;
1464
1465 /*
1466 ** if the read pointer hits the end of the queue, rewind it
1467 **/
1468 if (pMac->lim.gLimDeferredMsgQ.read >= MAX_DEFERRED_QUEUE_LEN)
1469 pMac->lim.gLimDeferredMsgQ.read = 0;
1470
1471 PELOG1(limLog(pMac, LOG1,
1472 FL("** DeQueue a deferred message (size %d read %d) - type 0x%x **\n"),
1473 pMac->lim.gLimDeferredMsgQ.size, pMac->lim.gLimDeferredMsgQ.read,
1474 msg->type);)
1475
Jeff Johnsone7245742012-09-05 17:12:55 -07001476 PELOG1(limLog(pMac, LOG1, FL("DQ msg -- scan %d, global sme %d, global mlme %d, addts %d\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 limIsSystemInScanState(pMac),
1478 pMac->lim.gLimSmeState, pMac->lim.gLimMlmState,
1479 pMac->lim.gLimAddtsSent);)
1480
1481 return(msg);
1482}
1483
1484tSirRetStatus
1485limSysProcessMmhMsgApi(tpAniSirGlobal pMac,
1486 tSirMsgQ *pMsg,
1487 tANI_U8 qType)
1488{
1489// FIXME
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 SysProcessMmhMsg(pMac, pMsg);
1491 return eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001492}
1493
1494char *limFrameStr(tANI_U32 type, tANI_U32 subType)
1495{
1496#ifdef FIXME_GEN6
1497
1498 if (type == SIR_MAC_MGMT_FRAME)
1499 {
1500 switch (subType)
1501 {
1502 case SIR_MAC_MGMT_ASSOC_REQ:
1503 return "MAC_MGMT_ASSOC_REQ";
1504 case SIR_MAC_MGMT_ASSOC_RSP:
1505 return "MAC_MGMT_ASSOC_RSP";
1506 case SIR_MAC_MGMT_REASSOC_REQ:
1507 return "MAC_MGMT_REASSOC_REQ";
1508 case SIR_MAC_MGMT_REASSOC_RSP:
1509 return "MAC_MGMT_REASSOC_RSP";
1510 case SIR_MAC_MGMT_PROBE_REQ:
1511 return "MAC_MGMT_PROBE_REQ";
1512 case SIR_MAC_MGMT_PROBE_RSP:
1513 return "MAC_MGMT_PROBE_RSP";
1514 case SIR_MAC_MGMT_BEACON:
1515 return "MAC_MGMT_BEACON";
1516 case SIR_MAC_MGMT_ATIM:
1517 return "MAC_MGMT_ATIM";
1518 case SIR_MAC_MGMT_DISASSOC:
1519 return "MAC_MGMT_DISASSOC";
1520 case SIR_MAC_MGMT_AUTH:
1521 return "MAC_MGMT_AUTH";
1522 case SIR_MAC_MGMT_DEAUTH:
1523 return "MAC_MGMT_DEAUTH";
1524 case SIR_MAC_MGMT_ACTION:
1525 return "MAC_MGMT_ACTION";
1526 case SIR_MAC_MGMT_RESERVED15:
1527 return "MAC_MGMT_RESERVED15";
1528 default:
1529 return "Unknown MGMT Frame";
1530 }
1531 }
1532
1533 else if (type == SIR_MAC_CTRL_FRAME)
1534 {
1535 switch (subType)
1536 {
1537 case SIR_MAC_CTRL_RR:
1538 return "MAC_CTRL_RR";
1539 case SIR_MAC_CTRL_BAR:
1540 return "MAC_CTRL_BAR";
1541 case SIR_MAC_CTRL_BA:
1542 return "MAC_CTRL_BA";
1543 case SIR_MAC_CTRL_PS_POLL:
1544 return "MAC_CTRL_PS_POLL";
1545 case SIR_MAC_CTRL_RTS:
1546 return "MAC_CTRL_RTS";
1547 case SIR_MAC_CTRL_CTS:
1548 return "MAC_CTRL_CTS";
1549 case SIR_MAC_CTRL_ACK:
1550 return "MAC_CTRL_ACK";
1551 case SIR_MAC_CTRL_CF_END:
1552 return "MAC_CTRL_CF_END";
1553 case SIR_MAC_CTRL_CF_END_ACK:
1554 return "MAC_CTRL_CF_END_ACK";
1555 default:
1556 return "Unknown CTRL Frame";
1557 }
1558 }
1559
1560 else if (type == SIR_MAC_DATA_FRAME)
1561 {
1562 switch (subType)
1563 {
1564 case SIR_MAC_DATA_DATA:
1565 return "MAC_DATA_DATA";
1566 case SIR_MAC_DATA_DATA_ACK:
1567 return "MAC_DATA_DATA_ACK";
1568 case SIR_MAC_DATA_DATA_POLL:
1569 return "MAC_DATA_DATA_POLL";
1570 case SIR_MAC_DATA_DATA_ACK_POLL:
1571 return "MAC_DATA_DATA_ACK_POLL";
1572 case SIR_MAC_DATA_NULL:
1573 return "MAC_DATA_NULL";
1574 case SIR_MAC_DATA_NULL_ACK:
1575 return "MAC_DATA_NULL_ACK";
1576 case SIR_MAC_DATA_NULL_POLL:
1577 return "MAC_DATA_NULL_POLL";
1578 case SIR_MAC_DATA_NULL_ACK_POLL:
1579 return "MAC_DATA_NULL_ACK_POLL";
1580 case SIR_MAC_DATA_QOS_DATA:
1581 return "MAC_DATA_QOS_DATA";
1582 case SIR_MAC_DATA_QOS_DATA_ACK:
1583 return "MAC_DATA_QOS_DATA_ACK";
1584 case SIR_MAC_DATA_QOS_DATA_POLL:
1585 return "MAC_DATA_QOS_DATA_POLL";
1586 case SIR_MAC_DATA_QOS_DATA_ACK_POLL:
1587 return "MAC_DATA_QOS_DATA_ACK_POLL";
1588 case SIR_MAC_DATA_QOS_NULL:
1589 return "MAC_DATA_QOS_NULL";
1590 case SIR_MAC_DATA_QOS_NULL_ACK:
1591 return "MAC_DATA_QOS_NULL_ACK";
1592 case SIR_MAC_DATA_QOS_NULL_POLL:
1593 return "MAC_DATA_QOS_NULL_POLL";
1594 case SIR_MAC_DATA_QOS_NULL_ACK_POLL:
1595 return "MAC_DATA_QOS_NULL_ACK_POLL";
1596 default:
1597 return "Unknown Data Frame";
1598 }
1599 }
1600 else
1601 return "Unknown";
1602#endif
1603return "";
1604}
1605
Jeff Johnson295189b2012-06-20 16:38:30 -07001606void limHandleUpdateOlbcCache(tpAniSirGlobal pMac)
1607{
1608 int i;
1609 static int enable;
1610 tUpdateBeaconParams beaconParams;
1611
1612 tpPESession psessionEntry = limIsApSessionActive(pMac);
1613
1614 if (psessionEntry == NULL)
Madan Mohan Koyyalamudi788b4ee2012-09-25 10:42:09 -07001615 {
1616 PELOGE(limLog(pMac, LOGE, FL(" Session not found\n"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 return;
Madan Mohan Koyyalamudi788b4ee2012-09-25 10:42:09 -07001618 }
Pratik Bhalgatb44ea3f2012-11-22 16:41:39 +05301619
Madan Mohan Koyyalamudib2733142012-10-31 13:59:17 -07001620 palZeroMemory( pMac->hHdd, ( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams) );
1621 beaconParams.bssIdx = psessionEntry->bssIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001622
1623 beaconParams.paramChangeBitmap = 0;
1624 /*
1625 ** This is doing a 2 pass check. The first pass is to invalidate
1626 ** all the cache entries. The second pass is to decide whether to
1627 ** disable protection.
1628 **/
1629 if (!enable)
1630 {
1631
1632 PELOG2(limLog(pMac, LOG2, FL("Resetting OLBC cache\n"));)
1633 psessionEntry->gLimOlbcParams.numSta = 0;
1634 psessionEntry->gLimOverlap11gParams.numSta = 0;
1635 psessionEntry->gLimOverlapHt20Params.numSta = 0;
1636 psessionEntry->gLimNonGfParams.numSta = 0;
1637 psessionEntry->gLimLsigTxopParams.numSta = 0;
1638
1639 for (i=0; i < LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
1640 pMac->lim.protStaOverlapCache[i].active = false;
1641
1642 enable = 1;
1643 }
1644 else
1645 {
1646
Madan Mohan Koyyalamudi788b4ee2012-09-25 10:42:09 -07001647 if (!psessionEntry->gLimOlbcParams.numSta)
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 {
1649 if (psessionEntry->gLimOlbcParams.protectionEnabled)
1650 {
1651 if (!psessionEntry->gLim11bParams.protectionEnabled)
1652 {
1653 PELOG1(limLog(pMac, LOG1, FL("Overlap cache all clear and no 11B STA detected\n"));)
1654 limEnable11gProtection(pMac, false, true, &beaconParams, psessionEntry);
1655 }
1656 }
1657 }
1658
1659 if (!psessionEntry->gLimOverlap11gParams.numSta)
1660 {
1661 if (psessionEntry->gLimOverlap11gParams.protectionEnabled)
1662 {
1663 if (!psessionEntry->gLim11gParams.protectionEnabled)
1664 {
1665 PELOG1(limLog(pMac, LOG1, FL("Overlap cache all clear and no 11G STA detected\n"));)
1666 limEnableHtProtectionFrom11g(pMac, false, true, &beaconParams,psessionEntry);
1667 }
1668 }
1669 }
1670
1671 if (!psessionEntry->gLimOverlapHt20Params.numSta)
1672 {
1673 if (psessionEntry->gLimOverlapHt20Params.protectionEnabled)
1674 {
1675 if (!psessionEntry->gLimHt20Params.protectionEnabled)
1676 {
1677 PELOG1(limLog(pMac, LOG1, FL("Overlap cache all clear and no HT20 STA detected\n"));)
1678 limEnable11gProtection(pMac, false, true, &beaconParams,psessionEntry);
1679 }
1680 }
1681 }
1682
1683 enable = 0;
1684 }
1685
1686 if(beaconParams.paramChangeBitmap)
1687 {
1688 schSetFixedBeaconFields(pMac,psessionEntry);
1689 limSendBeaconParams(pMac, &beaconParams, psessionEntry);
1690 }
1691
1692 // Start OLBC timer
1693 if (tx_timer_activate(&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer) != TX_SUCCESS)
1694 {
1695 limLog(pMac, LOGE, FL("tx_timer_activate failed\n"));
1696 }
1697}
Jeff Johnson295189b2012-06-20 16:38:30 -07001698
1699/**
1700 * limIsNullSsid()
1701 *
1702 *FUNCTION:
1703 * This function checks if Ssid supplied is Null SSID
1704 *
1705 *
1706 *LOGIC:
1707 *
1708 *ASSUMPTIONS:
1709 * NA
1710 *
1711 *NOTE:
1712 * NA
1713 *
1714 * @param tSirMacSSid *
1715 *
1716 *
1717 * @return true if SSID is Null SSID else false
1718 */
1719
1720tANI_U8
1721limIsNullSsid( tSirMacSSid *pSsid )
1722{
1723 tANI_U8 fNullSsid = false;
1724 tANI_U32 SsidLength;
1725 tANI_U8 *pSsidStr;
1726
1727 do
1728 {
1729 if ( 0 == pSsid->length )
1730 {
1731 fNullSsid = true;
1732 break;
1733 }
1734
1735#define ASCII_SPACE_CHARACTER 0x20
1736 /* If the first charactes is space, then check if all characters in
1737 * SSID are spaces to consider it as NULL SSID*/
1738 if( ASCII_SPACE_CHARACTER == pSsid->ssId[0])
1739 {
1740 SsidLength = pSsid->length;
1741 pSsidStr = pSsid->ssId;
1742 /* check if all the charactes in SSID are spaces*/
1743 while ( SsidLength )
1744 {
1745 if( ASCII_SPACE_CHARACTER != *pSsidStr )
1746 break;
1747
1748 pSsidStr++;
1749 SsidLength--;
1750 }
1751
1752 if( 0 == SsidLength )
1753 {
1754 fNullSsid = true;
1755 break;
1756 }
1757 }
1758 else
1759 {
1760 /* check if all the charactes in SSID are NULL*/
1761 SsidLength = pSsid->length;
1762 pSsidStr = pSsid->ssId;
1763
1764 while ( SsidLength )
1765 {
1766 if( *pSsidStr )
1767 break;
1768
1769 pSsidStr++;
1770 SsidLength--;
1771 }
1772
1773 if( 0 == SsidLength )
1774 {
1775 fNullSsid = true;
1776 break;
1777 }
1778 }
1779 }
1780 while( 0 );
1781
1782 return fNullSsid;
1783} /****** end limIsNullSsid() ******/
1784
1785
1786
Jeff Johnson295189b2012-06-20 16:38:30 -07001787
1788/** -------------------------------------------------------------
1789\fn limUpdateProtStaParams
1790\brief updates protection related counters.
1791\param tpAniSirGlobal pMac
1792\param tSirMacAddr peerMacAddr
1793\param tLimProtStaCacheType protStaCacheType
1794\param tHalBitVal gfSupported
1795\param tHalBitVal lsigTxopSupported
1796\return None
1797 -------------------------------------------------------------*/
1798void
1799limUpdateProtStaParams(tpAniSirGlobal pMac,
1800tSirMacAddr peerMacAddr, tLimProtStaCacheType protStaCacheType,
1801tHalBitVal gfSupported, tHalBitVal lsigTxopSupported,
1802tpPESession psessionEntry)
1803{
1804 tANI_U32 i;
1805
1806 PELOG1(limLog(pMac,LOG1, FL("A STA is associated:"));
1807 limLog(pMac,LOG1, FL("Addr : "));
1808 limPrintMacAddr(pMac, peerMacAddr, LOG1);)
1809
1810 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1811 {
1812 if (psessionEntry->protStaCache[i].active)
1813 {
1814 PELOG1(limLog(pMac, LOG1, FL("Addr: "));)
1815 PELOG1(limPrintMacAddr(pMac, psessionEntry->protStaCache[i].addr, LOG1);)
1816
1817 if (palEqualMemory( pMac->hHdd,
1818 psessionEntry->protStaCache[i].addr,
1819 peerMacAddr, sizeof(tSirMacAddr)))
1820 {
1821 PELOG1(limLog(pMac, LOG1, FL("matching cache entry at %d already active.\n"), i);)
1822 return;
1823 }
1824 }
1825 }
1826
1827 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1828 {
1829 if (!psessionEntry->protStaCache[i].active)
1830 break;
1831 }
1832
1833 if (i >= LIM_PROT_STA_CACHE_SIZE)
1834 {
1835 PELOGE(limLog(pMac, LOGE, FL("No space in ProtStaCache\n"));)
1836 return;
1837 }
1838
1839 palCopyMemory( pMac->hHdd, psessionEntry->protStaCache[i].addr,
1840 peerMacAddr,
1841 sizeof(tSirMacAddr));
1842
1843 psessionEntry->protStaCache[i].protStaCacheType = protStaCacheType;
1844 psessionEntry->protStaCache[i].active = true;
1845 if(eLIM_PROT_STA_CACHE_TYPE_llB == protStaCacheType)
1846 {
1847 psessionEntry->gLim11bParams.numSta++;
1848 limLog(pMac,LOG1, FL("11B, "));
1849 }
1850 else if(eLIM_PROT_STA_CACHE_TYPE_llG == protStaCacheType)
1851 {
1852 psessionEntry->gLim11gParams.numSta++;
1853 limLog(pMac,LOG1, FL("11G, "));
1854 }
1855 else if(eLIM_PROT_STA_CACHE_TYPE_HT20 == protStaCacheType)
1856 {
1857 psessionEntry->gLimHt20Params.numSta++;
1858 limLog(pMac,LOG1, FL("HT20, "));
1859 }
1860
1861 if(!gfSupported)
1862 {
1863 psessionEntry->gLimNonGfParams.numSta++;
1864 limLog(pMac,LOG1, FL("NonGf, "));
1865 }
1866 if(!lsigTxopSupported)
1867 {
1868 psessionEntry->gLimLsigTxopParams.numSta++;
1869 limLog(pMac,LOG1, FL("!lsigTxopSupported\n"));
1870 }
1871}// ---------------------------------------------------------------------
1872
1873/** -------------------------------------------------------------
1874\fn limDecideApProtection
1875\brief Decides all the protection related staiton coexistence and also sets
1876\ short preamble and short slot appropriately. This function will be called
1877\ when AP is ready to send assocRsp tp the station joining right now.
1878\param tpAniSirGlobal pMac
1879\param tSirMacAddr peerMacAddr
1880\return None
1881 -------------------------------------------------------------*/
1882void
1883limDecideApProtection(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1884{
1885 tANI_U16 tmpAid;
1886 tpDphHashNode pStaDs;
1887 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1888 tANI_U32 phyMode;
1889 tLimProtStaCacheType protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_INVALID;
1890 tHalBitVal gfSupported = eHAL_SET, lsigTxopSupported = eHAL_SET;
1891
1892 pBeaconParams->paramChangeBitmap = 0;
1893 // check whether to enable protection or not
1894 pStaDs = dphLookupHashEntry(pMac, peerMacAddr, &tmpAid, &psessionEntry->dph.dphHashTable);
1895 if(NULL == pStaDs)
1896 {
1897 PELOG1(limLog(pMac, LOG1, FL("pStaDs is NULL\n"));)
1898 return;
1899 }
1900 limGetRfBand(pMac, &rfBand, psessionEntry);
1901 //if we are in 5 GHZ band
1902 if(SIR_BAND_5_GHZ == rfBand)
1903 {
1904 //We are 11N. we need to protect from 11A and Ht20. we don't need any other protection in 5 GHZ.
1905 //HT20 case is common between both the bands and handled down as common code.
Jeff Johnsone7245742012-09-05 17:12:55 -07001906 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 {
1908 //we are 11N and 11A station is joining.
1909 //protection from 11A required.
1910 if(false == pStaDs->mlmStaContext.htCapability)
1911 {
1912 limEnable11aProtection(pMac, true, false, pBeaconParams,psessionEntry);
1913 return;
1914 }
1915 }
1916 }
1917 else if(SIR_BAND_2_4_GHZ== rfBand)
1918 {
1919 limGetPhyMode(pMac, &phyMode, psessionEntry);
1920
1921 //We are 11G. Check if we need protection from 11b Stations.
1922 if ((phyMode == WNI_CFG_PHY_MODE_11G) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001923 (false == psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 {
1925
1926 if (pStaDs->erpEnabled== eHAL_CLEAR)
1927 {
1928 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llB;
1929 // enable protection
1930 PELOG3(limLog(pMac, LOG3, FL("Enabling protection from 11B\n"));)
1931 limEnable11gProtection(pMac, true, false, pBeaconParams,psessionEntry);
1932 }
1933 }
1934
1935 //HT station.
Jeff Johnsone7245742012-09-05 17:12:55 -07001936 if (true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 {
1938 //check if we need protection from 11b station
1939 if ((pStaDs->erpEnabled == eHAL_CLEAR) &&
1940 (!pStaDs->mlmStaContext.htCapability))
1941 {
1942 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llB;
1943 // enable protection
1944 PELOG3(limLog(pMac, LOG3, FL("Enabling protection from 11B\n"));)
1945 limEnable11gProtection(pMac, true, false, pBeaconParams, psessionEntry);
1946 }
1947 //station being joined is non-11b and non-ht ==> 11g device
1948 else if(!pStaDs->mlmStaContext.htCapability)
1949 {
1950 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llG;
1951 //enable protection
1952 limEnableHtProtectionFrom11g(pMac, true, false, pBeaconParams, psessionEntry);
1953 }
1954 //ERP mode is enabled for the latest station joined
1955 //latest station joined is HT capable
1956 //This case is being handled in common code (commn between both the bands) below.
1957 }
1958 }
1959
1960 //we are HT and HT station is joining. This code is common for both the bands.
Jeff Johnsone7245742012-09-05 17:12:55 -07001961 if((true == psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 (true == pStaDs->mlmStaContext.htCapability))
1963 {
1964 if(!pStaDs->htGreenfield)
1965 {
1966 limEnableHTNonGfProtection(pMac, true, false, pBeaconParams, psessionEntry);
1967 gfSupported = eHAL_CLEAR;
1968 }
1969 //Station joining is HT 20Mhz
1970 if(eHT_CHANNEL_WIDTH_20MHZ == pStaDs->htSupportedChannelWidthSet)
1971 {
1972 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_HT20;
1973 limEnableHT20Protection(pMac, true, false, pBeaconParams, psessionEntry);
1974 }
1975 //Station joining does not support LSIG TXOP Protection
1976 if(!pStaDs->htLsigTXOPProtection)
1977 {
1978 limEnableHTLsigTxopProtection(pMac, false, false, pBeaconParams,psessionEntry);
1979 lsigTxopSupported = eHAL_CLEAR;
1980 }
1981 }
1982
1983 limUpdateProtStaParams(pMac, peerMacAddr, protStaCacheType,
1984 gfSupported, lsigTxopSupported, psessionEntry);
1985
1986 return;
1987}
Jeff Johnson295189b2012-06-20 16:38:30 -07001988
1989
1990/** -------------------------------------------------------------
1991\fn limEnableOverlap11gProtection
1992\brief wrapper function for setting overlap 11g protection.
1993\param tpAniSirGlobal pMac
1994\param tpUpdateBeaconParams pBeaconParams
1995\param tpSirMacMgmtHdr pMh
1996\return None
1997 -------------------------------------------------------------*/
1998void
1999limEnableOverlap11gProtection(tpAniSirGlobal pMac,
2000tpUpdateBeaconParams pBeaconParams, tpSirMacMgmtHdr pMh,tpPESession psessionEntry)
2001{
2002 limUpdateOverlapStaParam(pMac, pMh->bssId, &(psessionEntry->gLimOlbcParams));
2003
2004 if (psessionEntry->gLimOlbcParams.numSta &&
2005 !psessionEntry->gLimOlbcParams.protectionEnabled)
2006 {
2007 // enable protection
2008 PELOG1(limLog(pMac, LOG1, FL("OLBC happens!!!\n"));)
2009 limEnable11gProtection(pMac, true, true, pBeaconParams,psessionEntry);
2010 }
2011}
2012
2013
2014/** -------------------------------------------------------------
2015\fn limUpdateShortPreamble
2016\brief Updates short preamble if needed when a new station joins.
2017\param tpAniSirGlobal pMac
2018\param tSirMacAddr peerMacAddr
2019\param tpUpdateBeaconParams pBeaconParams
2020\return None
2021 -------------------------------------------------------------*/
2022void
2023limUpdateShortPreamble(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2024 tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
2025{
2026 tANI_U16 tmpAid;
2027 tpDphHashNode pStaDs;
2028 tANI_U32 phyMode;
2029 tANI_U16 i;
2030
2031 // check whether to enable protection or not
2032 pStaDs = dphLookupHashEntry(pMac, peerMacAddr, &tmpAid, &psessionEntry->dph.dphHashTable);
2033
2034 limGetPhyMode(pMac, &phyMode, psessionEntry);
2035
2036 if (pStaDs != NULL && phyMode == WNI_CFG_PHY_MODE_11G)
2037
2038 {
2039 if (pStaDs->shortPreambleEnabled == eHAL_CLEAR)
2040 {
2041 PELOG1(limLog(pMac,LOG1,FL("Short Preamble is not enabled in Assoc Req from "));
2042 limPrintMacAddr(pMac, peerMacAddr, LOG1);)
2043
2044 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
2045 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
2047 psessionEntry->gLimNoShortParams.staNoShortCache[i].active)
2048 {
2049 if (palEqualMemory( pMac->hHdd,
2050 psessionEntry->gLimNoShortParams.staNoShortCache[i].addr,
2051 peerMacAddr, sizeof(tSirMacAddr)))
2052 return;
2053 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 {
2055 if (pMac->lim.gLimNoShortParams.staNoShortCache[i].active)
2056 {
2057 if (palEqualMemory( pMac->hHdd,
2058 pMac->lim.gLimNoShortParams.staNoShortCache[i].addr,
2059 peerMacAddr, sizeof(tSirMacAddr)))
2060 return;
2061 }
2062 }
2063 }
2064
2065
2066 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
2067 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002068 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
2069 !psessionEntry->gLimNoShortParams.staNoShortCache[i].active)
2070 break;
2071 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 {
2073 if (!pMac->lim.gLimNoShortParams.staNoShortCache[i].active)
2074 break;
2075 }
2076 }
2077
2078 if (i >= LIM_PROT_STA_CACHE_SIZE)
2079 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002080 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
2081 limLog(pMac, LOGE, FL("No space in Short cache (#active %d, #sta %d) for sta "),
2082 i, psessionEntry->gLimNoShortParams.numNonShortPreambleSta);
2083 limPrintMacAddr(pMac, peerMacAddr, LOGE);
2084 return;
2085 }
2086 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002087 {
2088 limLog(pMac, LOGE, FL("No space in Short cache (#active %d, #sta %d) for sta "),
2089 i, pMac->lim.gLimNoShortParams.numNonShortPreambleSta);
2090 limPrintMacAddr(pMac, peerMacAddr, LOGE);
2091 return;
2092 }
2093
2094 }
2095
2096
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
2098 palCopyMemory( pMac->hHdd, psessionEntry->gLimNoShortParams.staNoShortCache[i].addr,
2099 peerMacAddr, sizeof(tSirMacAddr));
2100 psessionEntry->gLimNoShortParams.staNoShortCache[i].active = true;
2101 psessionEntry->gLimNoShortParams.numNonShortPreambleSta++;
2102 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 {
2104 palCopyMemory( pMac->hHdd, pMac->lim.gLimNoShortParams.staNoShortCache[i].addr,
2105 peerMacAddr, sizeof(tSirMacAddr));
2106 pMac->lim.gLimNoShortParams.staNoShortCache[i].active = true;
2107 pMac->lim.gLimNoShortParams.numNonShortPreambleSta++;
2108 }
2109
2110
2111 // enable long preamble
2112 PELOG1(limLog(pMac, LOG1, FL("Disabling short preamble\n"));)
2113
Jeff Johnson295189b2012-06-20 16:38:30 -07002114 if (limEnableShortPreamble(pMac, false, pBeaconParams, psessionEntry) != eSIR_SUCCESS)
2115 PELOGE(limLog(pMac, LOGE, FL("Cannot enable long preamble\n"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002116 }
2117 }
2118}
2119
2120/** -------------------------------------------------------------
2121\fn limUpdateShortSlotTime
2122\brief Updates short slot time if needed when a new station joins.
2123\param tpAniSirGlobal pMac
2124\param tSirMacAddr peerMacAddr
2125\param tpUpdateBeaconParams pBeaconParams
2126\return None
2127 -------------------------------------------------------------*/
2128
2129void
2130limUpdateShortSlotTime(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2131 tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
2132{
2133 tANI_U16 tmpAid;
2134 tpDphHashNode pStaDs;
2135 tANI_U32 phyMode;
2136 tANI_U32 val;
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 tANI_U16 i;
2138
2139 // check whether to enable protection or not
2140 pStaDs = dphLookupHashEntry(pMac, peerMacAddr, &tmpAid, &psessionEntry->dph.dphHashTable);
2141 limGetPhyMode(pMac, &phyMode, psessionEntry);
2142
Jeff Johnsone7245742012-09-05 17:12:55 -07002143 /* Only in case of softap in 11g mode, slot time might change depending on the STA being added. In 11a case, it should
2144 * be always 1 and in 11b case, it should be always 0
2145 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 if (pStaDs != NULL && phyMode == WNI_CFG_PHY_MODE_11G)
2147 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002148 /* Only when the new STA has short slot time disabled, we need to change softap's overall slot time settings
2149 * else the default for softap is always short slot enabled. When the last long slot STA leaves softAP, we take care of
2150 * it in limDecideShortSlot
2151 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002152 if (pStaDs->shortSlotTimeEnabled == eHAL_CLEAR)
2153 {
2154 PELOG1(limLog(pMac, LOG1, FL("Short Slot Time is not enabled in Assoc Req from "));
2155 limPrintMacAddr(pMac, peerMacAddr, LOG1);)
2156 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
2157 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
2159 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active)
2160 {
2161 if (palEqualMemory( pMac->hHdd,
2162 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
2163 peerMacAddr, sizeof(tSirMacAddr)))
2164 return;
2165 }
2166 else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 {
2168 if (pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active)
2169 {
2170 if (palEqualMemory( pMac->hHdd,
2171 pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
2172 peerMacAddr, sizeof(tSirMacAddr)))
2173 return;
2174 }
2175 }
2176 }
2177
2178 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
2179 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002180 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
2181 !psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active)
2182 break;
2183 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 {
2185 if (!pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active)
2186 break;
2187 }
2188 }
2189
2190 if (i >= LIM_PROT_STA_CACHE_SIZE)
2191 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
2193 limLog(pMac, LOGE, FL("No space in ShortSlot cache (#active %d, #sta %d) for sta "),
2194 i, psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta);
2195 limPrintMacAddr(pMac, peerMacAddr, LOGE);
2196 return;
2197 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 {
2199 limLog(pMac, LOGE, FL("No space in ShortSlot cache (#active %d, #sta %d) for sta "),
2200 i, pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta);
2201 limPrintMacAddr(pMac, peerMacAddr, LOGE);
2202 return;
2203 }
2204 }
2205
2206
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
2208 palCopyMemory( pMac->hHdd, psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
2209 peerMacAddr, sizeof(tSirMacAddr));
2210 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active = true;
2211 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta++;
2212 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 {
2214 palCopyMemory( pMac->hHdd, pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
2215 peerMacAddr, sizeof(tSirMacAddr));
2216 pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active = true;
2217 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta++;
2218 }
2219 wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val);
2220
Jeff Johnsone7245742012-09-05 17:12:55 -07002221 /* Here we check if we are AP role and short slot enabled (both admin and oper modes) but we have atleast one STA connected with
2222 * only long slot enabled, we need to change our beacon/pb rsp to broadcast short slot disabled
2223 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002224 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07002225 (val && psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta && psessionEntry->shortSlotTimeSupported))
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 {
2227 // enable long slot time
2228 pBeaconParams->fShortSlotTime = false;
2229 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
2230 PELOG1(limLog(pMac, LOG1, FL("Disable short slot time. Enable long slot time.\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002231 psessionEntry->shortSlotTimeSupported = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 }
2233 else if ( psessionEntry->limSystemRole != eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002235 if (val && pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta && psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07002236 {
2237 // enable long slot time
2238 pBeaconParams->fShortSlotTime = false;
2239 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
2240 PELOG1(limLog(pMac, LOG1, FL("Disable short slot time. Enable long slot time.\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002241 psessionEntry->shortSlotTimeSupported = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 }
2243 }
2244 }
2245 }
2246}
2247
Jeff Johnson295189b2012-06-20 16:38:30 -07002248
2249/** -------------------------------------------------------------
2250\fn limDecideStaProtectionOnAssoc
2251\brief Decide protection related settings on Sta while association.
2252\param tpAniSirGlobal pMac
2253\param tpSchBeaconStruct pBeaconStruct
2254\return None
2255 -------------------------------------------------------------*/
2256void
2257limDecideStaProtectionOnAssoc(tpAniSirGlobal pMac,
2258 tpSchBeaconStruct pBeaconStruct, tpPESession psessionEntry)
2259{
2260 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
2261 tANI_U32 phyMode = WNI_CFG_PHY_MODE_NONE;
2262
2263 limGetRfBand(pMac, &rfBand, psessionEntry);
2264 limGetPhyMode(pMac, &phyMode, psessionEntry);
2265
2266 if(SIR_BAND_5_GHZ == rfBand)
2267 {
2268 if((eSIR_HT_OP_MODE_MIXED == pBeaconStruct->HTInfo.opMode) ||
2269 (eSIR_HT_OP_MODE_OVERLAP_LEGACY == pBeaconStruct->HTInfo.opMode))
2270 {
2271 if(pMac->lim.cfgProtection.fromlla)
2272 psessionEntry->beaconParams.llaCoexist = true;
2273 }
2274 else if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == pBeaconStruct->HTInfo.opMode)
2275 {
2276 if(pMac->lim.cfgProtection.ht20)
2277 psessionEntry->beaconParams.ht20Coexist = true;
2278 }
2279
2280 }
2281 else if(SIR_BAND_2_4_GHZ == rfBand)
2282 {
2283 //spec 7.3.2.13
2284 //UseProtection will be set when nonERP STA is associated.
2285 //NonERPPresent bit will be set when:
2286 //--nonERP Sta is associated OR
2287 //--nonERP Sta exists in overlapping BSS
2288 //when useProtection is not set then protection from nonERP stations is optional.
2289
2290 //CFG protection from 11b is enabled and
2291 //11B device in the BSS
2292 /* TODO, This is not sessionized */
2293 if (phyMode != WNI_CFG_PHY_MODE_11B)
2294 {
2295 if (pMac->lim.cfgProtection.fromllb &&
2296 pBeaconStruct->erpPresent &&
2297 (pBeaconStruct->erpIEInfo.useProtection ||
2298 pBeaconStruct->erpIEInfo.nonErpPresent))
2299 {
2300 psessionEntry->beaconParams.llbCoexist = true;
2301 }
2302 //AP has no 11b station associated.
2303 else
2304 {
2305 psessionEntry->beaconParams.llbCoexist = false;
2306 }
2307 }
2308 //following code block is only for HT station.
Jeff Johnsone7245742012-09-05 17:12:55 -07002309 if((psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002310 (pBeaconStruct->HTInfo.present))
2311 {
2312 tDot11fIEHTInfo htInfo = pBeaconStruct->HTInfo;
2313
2314 //Obss Non HT STA present mode
2315 psessionEntry->beaconParams.gHTObssMode = (tANI_U8)htInfo.obssNonHTStaPresent;
2316
2317
2318 //CFG protection from 11G is enabled and
2319 //our AP has at least one 11G station associated.
2320 if(pMac->lim.cfgProtection.fromllg &&
2321 ((eSIR_HT_OP_MODE_MIXED == htInfo.opMode) ||
2322 (eSIR_HT_OP_MODE_OVERLAP_LEGACY == htInfo.opMode))&&
2323 (!psessionEntry->beaconParams.llbCoexist))
2324 {
2325 if(pMac->lim.cfgProtection.fromllg)
2326 psessionEntry->beaconParams.llgCoexist = true;
2327 }
2328
2329 //AP has only HT stations associated and at least one station is HT 20
2330 //disable protection from any non-HT devices.
2331 //decision for disabling protection from 11b has already been taken above.
2332 if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == htInfo.opMode)
2333 {
2334 //Disable protection from 11G station.
2335 psessionEntry->beaconParams.llgCoexist = false;
2336 //CFG protection from HT 20 is enabled.
2337 if(pMac->lim.cfgProtection.ht20)
2338 psessionEntry->beaconParams.ht20Coexist = true;
2339 }
2340 //Disable protection from non-HT and HT20 devices.
2341 //decision for disabling protection from 11b has already been taken above.
2342 if(eSIR_HT_OP_MODE_PURE == htInfo.opMode)
2343 {
2344 psessionEntry->beaconParams.llgCoexist = false;
2345 psessionEntry->beaconParams.ht20Coexist = false;
2346 }
2347
2348 }
2349 }
2350
2351 //protection related factors other than HT operating mode. Applies to 2.4 GHZ as well as 5 GHZ.
Jeff Johnsone7245742012-09-05 17:12:55 -07002352 if((psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 (pBeaconStruct->HTInfo.present))
2354 {
2355 tDot11fIEHTInfo htInfo = pBeaconStruct->HTInfo;
2356 psessionEntry->beaconParams.fRIFSMode =
2357 ( tANI_U8 ) htInfo.rifsMode;
2358 psessionEntry->beaconParams.llnNonGFCoexist =
2359 ( tANI_U8 )htInfo.nonGFDevicesPresent;
2360 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport =
2361 ( tANI_U8 )htInfo.lsigTXOPProtectionFullSupport;
2362 }
2363}
2364
2365
2366/** -------------------------------------------------------------
2367\fn limDecideStaProtection
2368\brief Decides protection related settings on Sta while processing beacon.
2369\param tpAniSirGlobal pMac
2370\param tpUpdateBeaconParams pBeaconParams
2371\return None
2372 -------------------------------------------------------------*/
2373void
2374limDecideStaProtection(tpAniSirGlobal pMac,
2375 tpSchBeaconStruct pBeaconStruct, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
2376{
2377
2378 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
2379 tANI_U32 phyMode = WNI_CFG_PHY_MODE_NONE;
2380
2381 limGetRfBand(pMac, &rfBand, psessionEntry);
2382 limGetPhyMode(pMac, &phyMode, psessionEntry);
2383
2384 if(SIR_BAND_5_GHZ == rfBand)
2385 {
2386 //we are HT capable.
Jeff Johnsone7245742012-09-05 17:12:55 -07002387 if((true == psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 (pBeaconStruct->HTInfo.present))
2389 {
2390 //we are HT capable, AP's HT OPMode is mixed / overlap legacy ==> need protection from 11A.
2391 if((eSIR_HT_OP_MODE_MIXED == pBeaconStruct->HTInfo.opMode) ||
2392 (eSIR_HT_OP_MODE_OVERLAP_LEGACY == pBeaconStruct->HTInfo.opMode))
2393 {
2394 limEnable11aProtection(pMac, true, false, pBeaconParams,psessionEntry);
2395 }
2396 //we are HT capable, AP's HT OPMode is HT20 ==> disable protection from 11A if enabled. enabled
2397 //protection from HT20 if needed.
2398 else if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT== pBeaconStruct->HTInfo.opMode)
2399 {
2400 limEnable11aProtection(pMac, false, false, pBeaconParams,psessionEntry);
2401 limEnableHT20Protection(pMac, true, false, pBeaconParams,psessionEntry);
2402 }
2403 else if(eSIR_HT_OP_MODE_PURE == pBeaconStruct->HTInfo.opMode)
2404 {
2405 limEnable11aProtection(pMac, false, false, pBeaconParams,psessionEntry);
2406 limEnableHT20Protection(pMac, false, false, pBeaconParams,psessionEntry);
2407 }
2408 }
2409 }
2410 else if(SIR_BAND_2_4_GHZ == rfBand)
2411 {
2412 /* spec 7.3.2.13
2413 * UseProtection will be set when nonERP STA is associated.
2414 * NonERPPresent bit will be set when:
2415 * --nonERP Sta is associated OR
2416 * --nonERP Sta exists in overlapping BSS
2417 * when useProtection is not set then protection from nonERP stations is optional.
2418 */
2419
2420 if (phyMode != WNI_CFG_PHY_MODE_11B)
2421 {
2422 if (pBeaconStruct->erpPresent &&
2423 (pBeaconStruct->erpIEInfo.useProtection ||
2424 pBeaconStruct->erpIEInfo.nonErpPresent))
2425 {
2426 limEnable11gProtection(pMac, true, false, pBeaconParams, psessionEntry);
2427 }
2428 //AP has no 11b station associated.
2429 else
2430 {
2431 //disable protection from 11b station
2432 limEnable11gProtection(pMac, false, false, pBeaconParams, psessionEntry);
2433 }
2434 }
2435
2436 //following code block is only for HT station.
Jeff Johnsone7245742012-09-05 17:12:55 -07002437 if((psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 (pBeaconStruct->HTInfo.present))
2439 {
2440
2441 tDot11fIEHTInfo htInfo = pBeaconStruct->HTInfo;
2442 //AP has at least one 11G station associated.
2443 if(((eSIR_HT_OP_MODE_MIXED == htInfo.opMode) ||
2444 (eSIR_HT_OP_MODE_OVERLAP_LEGACY == htInfo.opMode))&&
2445 (!psessionEntry->beaconParams.llbCoexist))
2446 {
2447 limEnableHtProtectionFrom11g(pMac, true, false, pBeaconParams,psessionEntry);
2448
2449 }
2450
2451 //no HT operating mode change ==> no change in protection settings except for MIXED_MODE/Legacy Mode.
2452 //in Mixed mode/legacy Mode even if there is no change in HT operating mode, there might be change in 11bCoexist
2453 //or 11gCoexist. that is why this check is being done after mixed/legacy mode check.
2454 if ( pMac->lim.gHTOperMode != ( tSirMacHTOperatingMode )htInfo.opMode )
2455 {
2456 pMac->lim.gHTOperMode = ( tSirMacHTOperatingMode )htInfo.opMode;
2457
2458 //AP has only HT stations associated and at least one station is HT 20
2459 //disable protection from any non-HT devices.
2460 //decision for disabling protection from 11b has already been taken above.
2461 if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == htInfo.opMode)
2462 {
2463 //Disable protection from 11G station.
2464 limEnableHtProtectionFrom11g(pMac, false, false, pBeaconParams,psessionEntry);
2465
2466 limEnableHT20Protection(pMac, true, false, pBeaconParams,psessionEntry);
2467 }
2468 //Disable protection from non-HT and HT20 devices.
2469 //decision for disabling protection from 11b has already been taken above.
2470 else if(eSIR_HT_OP_MODE_PURE == htInfo.opMode)
2471 {
2472 limEnableHtProtectionFrom11g(pMac, false, false, pBeaconParams,psessionEntry);
2473 limEnableHT20Protection(pMac, false, false, pBeaconParams,psessionEntry);
2474
2475 }
2476 }
2477 }
2478 }
2479
2480 //following code block is only for HT station. ( 2.4 GHZ as well as 5 GHZ)
Jeff Johnsone7245742012-09-05 17:12:55 -07002481 if((psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002482 (pBeaconStruct->HTInfo.present))
2483 {
2484 tDot11fIEHTInfo htInfo = pBeaconStruct->HTInfo;
2485 //Check for changes in protection related factors other than HT operating mode.
2486 //Check for changes in RIFS mode, nonGFDevicesPresent, lsigTXOPProtectionFullSupport.
2487 if ( psessionEntry->beaconParams.fRIFSMode !=
2488 ( tANI_U8 ) htInfo.rifsMode )
2489 {
2490 pBeaconParams->fRIFSMode =
2491 psessionEntry->beaconParams.fRIFSMode =
2492 ( tANI_U8 ) htInfo.rifsMode;
2493 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
2494 }
2495
2496 if ( psessionEntry->beaconParams.llnNonGFCoexist !=
2497 htInfo.nonGFDevicesPresent )
2498 {
2499 pBeaconParams->llnNonGFCoexist =
2500 psessionEntry->beaconParams.llnNonGFCoexist =
2501 ( tANI_U8 )htInfo.nonGFDevicesPresent;
2502 pBeaconParams->paramChangeBitmap |=
2503 PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
2504 }
2505
2506 if ( psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport !=
2507 ( tANI_U8 )htInfo.lsigTXOPProtectionFullSupport )
2508 {
2509 pBeaconParams->fLsigTXOPProtectionFullSupport =
2510 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport =
2511 ( tANI_U8 )htInfo.lsigTXOPProtectionFullSupport;
2512 pBeaconParams->paramChangeBitmap |=
2513 PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
2514 }
2515
2516 // For Station just update the global lim variable, no need to send message to HAL
2517 // Station already taking care of HT OPR Mode=01, meaning AP is seeing legacy
2518 //stations in overlapping BSS.
2519 if ( psessionEntry->beaconParams.gHTObssMode != ( tANI_U8 )htInfo.obssNonHTStaPresent )
2520 psessionEntry->beaconParams.gHTObssMode = ( tANI_U8 )htInfo.obssNonHTStaPresent ;
2521
2522 }
2523}
2524
2525
2526/**
2527 * limProcessChannelSwitchTimeout()
2528 *
2529 *FUNCTION:
2530 * This function is invoked when Channel Switch Timer expires at
2531 * the STA. Now, STA must stop traffic, and then change/disable
2532 * primary or secondary channel.
2533 *
2534 *
2535 *NOTE:
2536 * @param pMac - Pointer to Global MAC structure
2537 * @return None
2538 */
2539void limProcessChannelSwitchTimeout(tpAniSirGlobal pMac)
2540{
2541 tpPESession psessionEntry = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07002542 tANI_U8 channel; // This is received and stored from channelSwitch Action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07002543
2544 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimChannelSwitchTimer.sessionId))== NULL)
2545 {
2546 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
2547 return;
2548 }
2549
2550 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
2551 {
2552 PELOGW(limLog(pMac, LOGW, "Channel switch can be done only in STA role, Current Role = %d\n", psessionEntry->limSystemRole);)
2553 return;
2554 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002555 channel = psessionEntry->gLimChannelSwitch.primaryChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07002556 /*
2557 * This potentially can create issues if the function tries to set
2558 * channel while device is in power-save, hence putting an extra check
2559 * to verify if the device is in power-save or not
2560 */
2561 if(!limIsSystemInActiveState(pMac))
2562 {
2563 PELOGW(limLog(pMac, LOGW, FL("Device is not in active state, cannot switch channel\n"));)
2564 return;
2565 }
2566
2567 // Restore Channel Switch parameters to default
Jeff Johnsone7245742012-09-05 17:12:55 -07002568 psessionEntry->gLimChannelSwitch.switchTimeoutValue = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002569
2570 /* Channel-switch timeout has occurred. reset the state */
Jeff Johnsone7245742012-09-05 17:12:55 -07002571 psessionEntry->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_END;
Jeff Johnson295189b2012-06-20 16:38:30 -07002572
2573 /* Check if the AP is switching to a channel that we support.
2574 * Else, just don't bother to switch. Indicate HDD to look for a
2575 * better AP to associate
2576 */
2577 if(!limIsChannelValidForChannelSwitch(pMac, channel))
2578 {
2579 /* We need to restore pre-channelSwitch state on the STA */
2580 if(limRestorePreChannelSwitchState(pMac, psessionEntry) != eSIR_SUCCESS)
2581 {
2582 limLog(pMac, LOGP, FL("Could not restore pre-channelSwitch (11h) state, resetting the system\n"));
2583 return;
2584 }
2585
2586 /* If the channel-list that AP is asking us to switch is invalid,
2587 * then we cannot switch the channel. Just disassociate from AP.
2588 * We will find a better AP !!!
2589 */
2590 limTearDownLinkWithAp(pMac,
2591 pMac->lim.limTimers.gLimChannelSwitchTimer.sessionId,
2592 eSIR_MAC_UNSPEC_FAILURE_REASON);
2593 return;
2594 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002595 switch(psessionEntry->gLimChannelSwitch.state)
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 {
2597 case eLIM_CHANNEL_SWITCH_PRIMARY_ONLY:
2598 PELOGW(limLog(pMac, LOGW, FL("CHANNEL_SWITCH_PRIMARY_ONLY \n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002599 limSwitchPrimaryChannel(pMac, psessionEntry->gLimChannelSwitch.primaryChannel,psessionEntry);
2600 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 break;
2602
2603 case eLIM_CHANNEL_SWITCH_SECONDARY_ONLY:
2604 PELOGW(limLog(pMac, LOGW, FL("CHANNEL_SWITCH_SECONDARY_ONLY \n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002605 limSwitchPrimarySecondaryChannel(pMac, psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 psessionEntry->currentOperChannel,
Jeff Johnsone7245742012-09-05 17:12:55 -07002607 psessionEntry->gLimChannelSwitch.secondarySubBand);
2608 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 break;
2610
2611 case eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY:
2612 PELOGW(limLog(pMac, LOGW, FL("CHANNEL_SWITCH_PRIMARY_AND_SECONDARY\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002613 limSwitchPrimarySecondaryChannel(pMac, psessionEntry,
2614 psessionEntry->gLimChannelSwitch.primaryChannel,
2615 psessionEntry->gLimChannelSwitch.secondarySubBand);
2616 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 break;
2618
2619 case eLIM_CHANNEL_SWITCH_IDLE:
2620 default:
2621 PELOGE(limLog(pMac, LOGE, FL("incorrect state \n"));)
2622 if(limRestorePreChannelSwitchState(pMac, psessionEntry) != eSIR_SUCCESS)
2623 {
2624 limLog(pMac, LOGP, FL("Could not restore pre-channelSwitch (11h) state, resetting the system\n"));
2625 }
2626 return; /* Please note, this is 'return' and not 'break' */
2627 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002628}
Jeff Johnson295189b2012-06-20 16:38:30 -07002629
2630/**
2631 * limUpdateChannelSwitch()
2632 *
2633 *FUNCTION:
2634 * This function is invoked whenever Station receives
2635 * either 802.11h channel switch IE or airgo proprietary
2636 * channel switch IE.
2637 *
2638 *NOTE:
2639 * @param pMac - Pointer to Global MAC structure
2640 * @return tpSirProbeRespBeacon - Pointer to Beacon/Probe Rsp
2641 * @param psessionentry
2642 */
2643void
2644limUpdateChannelSwitch(struct sAniSirGlobal *pMac, tpSirProbeRespBeacon pBeacon, tpPESession psessionEntry)
2645{
2646
2647 tANI_U16 beaconPeriod;
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 tChannelSwitchPropIEStruct *pPropChnlSwitch;
2649 tDot11fIEChanSwitchAnn *pChnlSwitch;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002650#ifdef WLAN_FEATURE_11AC
2651 tDot11fIEWiderBWChanSwitchAnn *pWiderChnlSwitch;
2652#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002653
Jeff Johnsone7245742012-09-05 17:12:55 -07002654 beaconPeriod = psessionEntry->beaconParams.beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002655
2656 /* STA either received proprietary channel switch IE or 802.11h
2657 * standard channel switch IE.
2658 */
2659 if (pBeacon->propIEinfo.propChannelSwitchPresent)
2660 {
2661 pPropChnlSwitch = &(pBeacon->propIEinfo.channelSwitch);
2662
2663 /* Add logic to determine which change this is: */
2664 /* primary, secondary, both. For now assume both. */
Jeff Johnsone7245742012-09-05 17:12:55 -07002665 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2666 psessionEntry->gLimChannelSwitch.primaryChannel = pPropChnlSwitch->primaryChannel;
2667 psessionEntry->gLimChannelSwitch.secondarySubBand = (ePhyChanBondState)pPropChnlSwitch->subBand;
2668 psessionEntry->gLimChannelSwitch.switchCount = pPropChnlSwitch->channelSwitchCount;
2669 psessionEntry->gLimChannelSwitch.switchTimeoutValue =
Jeff Johnson295189b2012-06-20 16:38:30 -07002670 SYS_MS_TO_TICKS(beaconPeriod)* (pPropChnlSwitch->channelSwitchCount);
Jeff Johnsone7245742012-09-05 17:12:55 -07002671 psessionEntry->gLimChannelSwitch.switchMode = pPropChnlSwitch->mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 }
2673 else
2674 {
2675 pChnlSwitch = &(pBeacon->channelSwitchIE);
Jeff Johnsone7245742012-09-05 17:12:55 -07002676 psessionEntry->gLimChannelSwitch.primaryChannel = pChnlSwitch->newChannel;
2677 psessionEntry->gLimChannelSwitch.switchCount = pChnlSwitch->switchCount;
2678 psessionEntry->gLimChannelSwitch.switchTimeoutValue =
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 SYS_MS_TO_TICKS(beaconPeriod)* (pChnlSwitch->switchCount);
Jeff Johnsone7245742012-09-05 17:12:55 -07002680 psessionEntry->gLimChannelSwitch.switchMode = pChnlSwitch->switchMode;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002681#ifdef WLAN_FEATURE_11AC
2682 pWiderChnlSwitch = &(pBeacon->WiderBWChanSwitchAnn);
2683 if(pBeacon->WiderBWChanSwitchAnnPresent)
2684 {
2685 psessionEntry->gLimWiderBWChannelSwitch.newChanWidth = pWiderChnlSwitch->newChanWidth;
2686 psessionEntry->gLimWiderBWChannelSwitch.newCenterChanFreq0 = pWiderChnlSwitch->newCenterChanFreq0;
2687 psessionEntry->gLimWiderBWChannelSwitch.newCenterChanFreq1 = pWiderChnlSwitch->newCenterChanFreq1;
2688 }
2689#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002690
2691 /* Only primary channel switch element is present */
Jeff Johnsone7245742012-09-05 17:12:55 -07002692 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2693 psessionEntry->gLimChannelSwitch.secondarySubBand = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07002694
2695 /* Do not bother to look and operate on extended channel switch element
2696 * if our own channel-bonding state is not enabled
2697 */
Jeff Johnsone7245742012-09-05 17:12:55 -07002698 if (psessionEntry->htSupportedChannelWidthSet)
Jeff Johnson295189b2012-06-20 16:38:30 -07002699 {
2700 if (pBeacon->extChannelSwitchPresent)
2701 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002702 if ((pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_LOW_PRIMARY) ||
2703 (pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY))
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002705 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2706 psessionEntry->gLimChannelSwitch.secondarySubBand = pBeacon->extChannelSwitchIE.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002707 }
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002708#ifdef WLAN_FEATURE_11AC
2709 if(psessionEntry->vhtCapability && pBeacon->WiderBWChanSwitchAnnPresent)
2710 {
2711 if (pWiderChnlSwitch->newChanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
2712 {
2713 if(pBeacon->extChannelSwitchPresent)
2714 {
2715 if ((pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_LOW_PRIMARY) ||
2716 (pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY))
2717 {
2718 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2719 psessionEntry->gLimChannelSwitch.secondarySubBand = limGet11ACPhyCBState(pMac,
2720 psessionEntry->gLimChannelSwitch.primaryChannel,
2721 pBeacon->extChannelSwitchIE.secondaryChannelOffset,
2722 pWiderChnlSwitch->newCenterChanFreq0,
2723 psessionEntry);
2724 }
2725 }
2726 }
2727 }
2728#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002729 }
2730 }
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002731 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 if (eSIR_SUCCESS != limStartChannelSwitch(pMac, psessionEntry))
2733 {
2734 PELOGW(limLog(pMac, LOGW, FL("Could not start Channel Switch\n"));)
2735 }
2736
2737 limLog(pMac, LOGW,
Jeff Johnsone7245742012-09-05 17:12:55 -07002738 FL("session %d primary chl %d, subband %d, count %d (%d ticks) \n"),
2739 psessionEntry->peSessionId,
2740 psessionEntry->gLimChannelSwitch.primaryChannel,
2741 psessionEntry->gLimChannelSwitch.secondarySubBand,
2742 psessionEntry->gLimChannelSwitch.switchCount,
2743 psessionEntry->gLimChannelSwitch.switchTimeoutValue);
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 return;
2745}
2746
2747/**
2748 * limCancelDot11hChannelSwitch
2749 *
2750 *FUNCTION:
2751 * This function is called when STA does not send updated channel-swith IE
2752 * after indicating channel-switch start. This will cancel the channel-swith
2753 * timer which is already running.
2754 *
2755 *LOGIC:
2756 *
2757 *ASSUMPTIONS:
2758 *
2759 *NOTE:
2760 *
2761 * @param pMac - Pointer to Global MAC structure
2762 *
2763 * @return None
2764 */
2765void limCancelDot11hChannelSwitch(tpAniSirGlobal pMac, tpPESession psessionEntry)
2766{
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
2768 return;
2769
2770 PELOGW(limLog(pMac, LOGW, FL("Received a beacon without channel switch IE\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002771 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_CHANNEL_SWITCH_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002772
2773 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimChannelSwitchTimer) != eSIR_SUCCESS)
2774 {
2775 PELOGE(limLog(pMac, LOGE, FL("tx_timer_deactivate failed!\n"));)
2776 }
2777
2778 /* We need to restore pre-channelSwitch state on the STA */
2779 if (limRestorePreChannelSwitchState(pMac, psessionEntry) != eSIR_SUCCESS)
2780 {
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002781 PELOGE(limLog(pMac, LOGE, FL("LIM: Could not restore pre-channelSwitch (11h) state, resetting the system\n"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002782
2783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002784}
2785
2786/**----------------------------------------------
2787\fn limCancelDot11hQuiet
2788\brief Cancel the quieting on Station if latest
2789 beacon doesn't contain quiet IE in it.
2790
2791\param pMac
2792\return NONE
2793-----------------------------------------------*/
2794void limCancelDot11hQuiet(tpAniSirGlobal pMac, tpPESession psessionEntry)
2795{
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
2797 return;
2798
Jeff Johnsone7245742012-09-05 17:12:55 -07002799 if (psessionEntry->gLimSpecMgmt.quietState == eLIM_QUIET_BEGIN)
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002801 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_QUIET_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002802 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietTimer) != TX_SUCCESS)
2803 {
2804 PELOGE(limLog(pMac, LOGE, FL("tx_timer_deactivate failed\n"));)
2805 }
2806 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002807 else if (psessionEntry->gLimSpecMgmt.quietState == eLIM_QUIET_RUNNING)
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002809 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_QUIET_BSS_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietBssTimer) != TX_SUCCESS)
2811 {
2812 PELOGE(limLog(pMac, LOGE, FL("tx_timer_deactivate failed\n"));)
2813 }
2814 /**
2815 * If the channel switch is already running in silent mode, dont resume the
2816 * transmission. Channel switch timer when timeout, transmission will be resumed.
2817 */
Jeff Johnsone7245742012-09-05 17:12:55 -07002818 if(!((psessionEntry->gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING) &&
2819 (psessionEntry->gLimChannelSwitch.switchMode == eSIR_CHANSW_MODE_SILENT)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002820 {
2821 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
Jeff Johnsone7245742012-09-05 17:12:55 -07002822 limRestorePreQuietState(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002823 }
2824 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002825 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002826}
2827
2828/**
2829 * limProcessQuietTimeout
2830 *
2831 * FUNCTION:
2832 * This function is active only on the STA.
2833 * Handles SIR_LIM_QUIET_TIMEOUT
2834 *
2835 * LOGIC:
2836 * This timeout can occur under only one circumstance:
2837 *
2838 * 1) When gLimQuietState = eLIM_QUIET_BEGIN
2839 * This indicates that the timeout "interval" has
2840 * expired. This is a trigger for the STA to now
2841 * shut-off Tx/Rx for the specified gLimQuietDuration
2842 * -> The TIMER object gLimQuietBssTimer is
2843 * activated
2844 * -> With timeout = gLimQuietDuration
2845 * -> gLimQuietState is set to eLIM_QUIET_RUNNING
2846 *
2847 * ASSUMPTIONS:
2848 * Using two TIMER objects -
2849 * gLimQuietTimer & gLimQuietBssTimer
2850 *
2851 * NOTE:
2852 *
2853 * @param pMac - Pointer to Global MAC structure
2854 *
2855 * @return None
2856 */
2857void limProcessQuietTimeout(tpAniSirGlobal pMac)
2858{
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 //fetch the sessionEntry based on the sessionId
2860 //priority - MEDIUM
Jeff Johnsone7245742012-09-05 17:12:55 -07002861 tpPESession psessionEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07002862
Jeff Johnsone7245742012-09-05 17:12:55 -07002863 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimQuietTimer.sessionId))== NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002864 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002865 limLog(pMac, LOGE,FL("Session Does not exist for given sessionID\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 return;
2867 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002868
Jeff Johnsone7245742012-09-05 17:12:55 -07002869 PELOG1(limLog(pMac, LOG1, FL("quietState = %d\n"), psessionEntry->gLimSpecMgmt.quietState);)
2870 switch( psessionEntry->gLimSpecMgmt.quietState )
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 {
2872 case eLIM_QUIET_BEGIN:
2873 // Time to Stop data traffic for quietDuration
Jeff Johnsone7245742012-09-05 17:12:55 -07002874 //limDeactivateAndChangeTimer(pMac, eLIM_QUIET_BSS_TIMER);
2875 if (TX_SUCCESS !=
2876 tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietBssTimer))
2877 {
2878 limLog( pMac, LOGE,
2879 FL("Unable to de-activate gLimQuietBssTimer! Will attempt to activate anyway...\n"));
2880 }
2881
2882 // gLimQuietDuration appears to be in units of ticks
2883 // Use it as is
2884 if (TX_SUCCESS !=
2885 tx_timer_change( &pMac->lim.limTimers.gLimQuietBssTimer,
2886 psessionEntry->gLimSpecMgmt.quietDuration,
2887 0))
2888 {
2889 limLog( pMac, LOGE,
2890 FL("Unable to change gLimQuietBssTimer! Will still attempt to activate anyway...\n"));
2891 }
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002892 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, pMac->lim.limTimers.gLimQuietTimer.sessionId, eLIM_QUIET_BSS_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002893#ifdef GEN6_TODO
2894 /* revisit this piece of code to assign the appropriate sessionId below
2895 * priority - HIGH
2896 */
2897 pMac->lim.limTimers.gLimQuietBssTimer.sessionId = sessionId;
2898#endif
2899 if( TX_SUCCESS !=
2900 tx_timer_activate( &pMac->lim.limTimers.gLimQuietBssTimer ))
2901 {
2902 limLog( pMac, LOGW,
2903 FL("Unable to activate gLimQuietBssTimer! The STA will be unable to honor Quiet BSS...\n"));
2904 }
2905 else
2906 {
2907 // Transition to eLIM_QUIET_RUNNING
Jeff Johnsone7245742012-09-05 17:12:55 -07002908 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_RUNNING;
Jeff Johnson295189b2012-06-20 16:38:30 -07002909
2910 /* If we have sta bk scan triggered and trigger bk scan actually started successfully, */
2911 /* print message, otherwise, stop data traffic and stay quiet */
2912 if( pMac->lim.gLimTriggerBackgroundScanDuringQuietBss &&
2913 (eSIR_TRUE == (glimTriggerBackgroundScanDuringQuietBss_Status = limTriggerBackgroundScanDuringQuietBss( pMac ))) )
2914 {
2915 limLog( pMac, LOG2,
2916 FL("Attempting to trigger a background scan...\n"));
2917 }
2918 else
2919 {
2920 // Shut-off Tx/Rx for gLimSpecMgmt.quietDuration
2921 /* freeze the transmission */
2922 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_STOP_TX);
2923
2924 limLog( pMac, LOG2,
2925 FL("Quiet BSS: STA shutting down for %d ticks\n"),
Jeff Johnsone7245742012-09-05 17:12:55 -07002926 psessionEntry->gLimSpecMgmt.quietDuration );
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 }
2928 }
2929 break;
2930
2931 case eLIM_QUIET_RUNNING:
2932 case eLIM_QUIET_INIT:
2933 case eLIM_QUIET_END:
2934 default:
2935 //
2936 // As of now, nothing to be done
2937 //
2938 break;
2939 }
2940}
2941
2942/**
2943 * limProcessQuietBssTimeout
2944 *
2945 * FUNCTION:
2946 * This function is active on the AP and STA.
2947 * Handles SIR_LIM_QUIET_BSS_TIMEOUT
2948 *
2949 * LOGIC:
2950 * On the AP -
2951 * When the SIR_LIM_QUIET_BSS_TIMEOUT is triggered, it is
2952 * an indication for the AP to START sending out the
2953 * Quiet BSS IE.
2954 * If 802.11H is enabled, the Quiet BSS IE is sent as per
2955 * the 11H spec
2956 * If 802.11H is not enabled, the Quiet BSS IE is sent as
2957 * a Proprietary IE. This will be understood by all the
2958 * TITAN STA's
2959 * Transitioning gLimQuietState to eLIM_QUIET_BEGIN will
2960 * initiate the SCH to include the Quiet BSS IE in all
2961 * its subsequent Beacons/PR's.
2962 * The Quiet BSS IE will be included in all the Beacons
2963 * & PR's until the next DTIM period
2964 *
2965 * On the STA -
2966 * When gLimQuietState = eLIM_QUIET_RUNNING
2967 * This indicates that the STA was successfully shut-off
2968 * for the specified gLimQuietDuration. This is a trigger
2969 * for the STA to now resume data traffic.
2970 * -> gLimQuietState is set to eLIM_QUIET_INIT
2971 *
2972 * ASSUMPTIONS:
2973 *
2974 * NOTE:
2975 *
2976 * @param pMac - Pointer to Global MAC structure
2977 *
2978 * @return None
2979 */
2980void limProcessQuietBssTimeout( tpAniSirGlobal pMac )
2981{
Jeff Johnsone7245742012-09-05 17:12:55 -07002982 tpPESession psessionEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07002983
Jeff Johnsone7245742012-09-05 17:12:55 -07002984 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimQuietBssTimer.sessionId))== NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 {
2986 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
2987 return;
2988 }
2989
Jeff Johnsone7245742012-09-05 17:12:55 -07002990 PELOG1(limLog(pMac, LOG1, FL("quietState = %d\n"), psessionEntry->gLimSpecMgmt.quietState);)
2991 if (eLIM_AP_ROLE == psessionEntry->limSystemRole)
Jeff Johnson295189b2012-06-20 16:38:30 -07002992 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002993 }
2994 else
2995 {
2996 // eLIM_STA_ROLE
Jeff Johnsone7245742012-09-05 17:12:55 -07002997 switch( psessionEntry->gLimSpecMgmt.quietState )
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 {
2999 case eLIM_QUIET_RUNNING:
3000 // Transition to eLIM_QUIET_INIT
Jeff Johnsone7245742012-09-05 17:12:55 -07003001 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003002
3003 if( !pMac->lim.gLimTriggerBackgroundScanDuringQuietBss || (glimTriggerBackgroundScanDuringQuietBss_Status == eSIR_FALSE) )
3004 {
3005 // Resume data traffic only if channel switch is not running in silent mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07003006 if (!((psessionEntry->gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING) &&
3007 (psessionEntry->gLimChannelSwitch.switchMode == eSIR_CHANSW_MODE_SILENT)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 {
3009 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
Jeff Johnsone7245742012-09-05 17:12:55 -07003010 limRestorePreQuietState(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 }
3012
3013 /* Reset status flag */
3014 if(glimTriggerBackgroundScanDuringQuietBss_Status == eSIR_FALSE)
3015 glimTriggerBackgroundScanDuringQuietBss_Status = eSIR_TRUE;
3016
3017 limLog( pMac, LOG2,
3018 FL("Quiet BSS: Resuming traffic...\n"));
3019 }
3020 else
3021 {
3022 //
3023 // Nothing specific to be done in this case
3024 // A background scan that was triggered during
3025 // SIR_LIM_QUIET_TIMEOUT will complete on its own
3026 //
3027 limLog( pMac, LOG2,
3028 FL("Background scan should be complete now...\n"));
3029 }
3030 break;
3031
3032 case eLIM_QUIET_INIT:
3033 case eLIM_QUIET_BEGIN:
3034 case eLIM_QUIET_END:
3035 PELOG2(limLog(pMac, LOG2, FL("Quiet state not in RUNNING\n"));)
3036 /* If the quiet period has ended, then resume the frame transmission */
3037 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
Jeff Johnsone7245742012-09-05 17:12:55 -07003038 limRestorePreQuietState(pMac, psessionEntry);
3039 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003040 break;
3041
3042 default:
3043 //
3044 // As of now, nothing to be done
3045 //
3046 break;
3047 }
3048 }
3049}
Jeff Johnson295189b2012-06-20 16:38:30 -07003050/**
3051 * limProcessWPSOverlapTimeout
3052 *
3053 * FUNCTION: This function call limWPSPBCTimeout() to clean WPS PBC probe request entries
3054 *
3055 * LOGIC:
3056 *
3057 * ASSUMPTIONS:
3058 *
3059 * NOTE:
3060 *
3061 * @param pMac - Pointer to Global MAC structure
3062 *
3063 * @return None
3064 */
3065#if 0
3066void limProcessWPSOverlapTimeout(tpAniSirGlobal pMac)
3067{
3068
3069 tpPESession psessionEntry;
3070 tANI_U32 sessionId;
3071
3072 if (tx_timer_activate(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer) != TX_SUCCESS)
3073 {
3074 limLog(pMac, LOGP, FL("tx_timer_activate failed\n"));
3075 }
3076
3077 sessionId = pMac->lim.limTimers.gLimWPSOverlapTimerObj.sessionId;
3078
3079 PELOGE(limLog(pMac, LOGE, FL("WPS overlap timeout, sessionId=%d\n"), sessionId);)
3080
3081 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId)) == NULL)
3082 {
3083 PELOGE(limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));)
3084 return;
3085 }
3086
3087 limWPSPBCTimeout(pMac, psessionEntry);
3088}
3089#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003090
Jeff Johnson295189b2012-06-20 16:38:30 -07003091/**----------------------------------------------
3092\fn limStartQuietTimer
3093\brief Starts the quiet timer.
3094
3095\param pMac
3096\return NONE
3097-----------------------------------------------*/
3098void limStartQuietTimer(tpAniSirGlobal pMac, tANI_U8 sessionId)
3099{
3100 tpPESession psessionEntry;
3101 psessionEntry = peFindSessionBySessionId(pMac , sessionId);
3102
3103 if(psessionEntry == NULL) {
3104 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
3105 return;
3106 }
3107
Jeff Johnson295189b2012-06-20 16:38:30 -07003108
3109 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3110 return;
3111 // First, de-activate Timer, if its already active
3112 limCancelDot11hQuiet(pMac, psessionEntry);
3113
Jeff Johnsone7245742012-09-05 17:12:55 -07003114 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, sessionId, eLIM_QUIET_TIMER));
3115 if( TX_SUCCESS != tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietTimer))
3116 {
3117 limLog( pMac, LOGE,
3118 FL( "Unable to deactivate gLimQuietTimer! Will still attempt to re-activate anyway...\n" ));
3119 }
3120
3121 // Set the NEW timeout value, in ticks
3122 if( TX_SUCCESS != tx_timer_change( &pMac->lim.limTimers.gLimQuietTimer,
3123 SYS_MS_TO_TICKS(psessionEntry->gLimSpecMgmt.quietTimeoutValue), 0))
3124 {
3125 limLog( pMac, LOGE,
3126 FL( "Unable to change gLimQuietTimer! Will still attempt to re-activate anyway...\n" ));
3127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003128
3129 pMac->lim.limTimers.gLimQuietTimer.sessionId = sessionId;
3130 if( TX_SUCCESS != tx_timer_activate(&pMac->lim.limTimers.gLimQuietTimer))
3131 {
3132 limLog( pMac, LOGE,
3133 FL("Unable to activate gLimQuietTimer! STA cannot honor Quiet BSS!\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003134 limRestorePreQuietState(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003135
Jeff Johnsone7245742012-09-05 17:12:55 -07003136 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 return;
3138 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003139}
3140
Jeff Johnson295189b2012-06-20 16:38:30 -07003141
3142/** ------------------------------------------------------------------------ **/
3143/**
3144 * keep track of the number of ANI peers associated in the BSS
3145 * For the first and last ANI peer, we have to update EDCA params as needed
3146 *
3147 * When the first ANI peer joins the BSS, we notify SCH
3148 * When the last ANI peer leaves the BSS, we notfiy SCH
3149 */
3150void
3151limUtilCountStaAdd(
3152 tpAniSirGlobal pMac,
3153 tpDphHashNode pSta,
3154 tpPESession psessionEntry)
3155{
3156
3157 if ((! pSta) || (! pSta->valid) || (! pSta->aniPeer) || (pSta->fAniCount))
3158 return;
3159
3160 pSta->fAniCount = 1;
3161
3162 if (pMac->lim.gLimNumOfAniSTAs++ != 0)
3163 return;
3164
3165 // get here only if this is the first ANI peer in the BSS
3166 schEdcaProfileUpdate(pMac, psessionEntry);
3167}
3168
3169void
3170limUtilCountStaDel(
3171 tpAniSirGlobal pMac,
3172 tpDphHashNode pSta,
3173 tpPESession psessionEntry)
3174{
3175
3176 if ((pSta == NULL) || (pSta->aniPeer == eHAL_CLEAR) || (! pSta->fAniCount))
3177 return;
3178
3179 /* Only if sta is invalid and the validInDummyState bit is set to 1,
3180 * then go ahead and update the count and profiles. This ensures
3181 * that the "number of ani station" count is properly incremented/decremented.
3182 */
3183 if (pSta->valid == 1)
3184 return;
3185
3186 pSta->fAniCount = 0;
3187
3188 if (pMac->lim.gLimNumOfAniSTAs <= 0)
3189 {
3190 limLog(pMac, LOGE, FL("CountStaDel: ignoring Delete Req when AniPeer count is %d\n"),
3191 pMac->lim.gLimNumOfAniSTAs);
3192 return;
3193 }
3194
3195 pMac->lim.gLimNumOfAniSTAs--;
3196
3197 if (pMac->lim.gLimNumOfAniSTAs != 0)
3198 return;
3199
3200 // get here only if this is the last ANI peer in the BSS
3201 schEdcaProfileUpdate(pMac, psessionEntry);
3202}
3203
Jeff Johnson295189b2012-06-20 16:38:30 -07003204/**
3205 * limSwitchChannelCback()
3206 *
3207 *FUNCTION:
3208 * This is the callback function registered while requesting to switch channel
3209 * after AP indicates a channel switch for spectrum management (11h).
3210 *
3211 *NOTE:
3212 * @param pMac Pointer to Global MAC structure
3213 * @param status Status of channel switch request
3214 * @param data User data
3215 * @param psessionEntry Session information
3216 * @return NONE
3217 */
3218void limSwitchChannelCback(tpAniSirGlobal pMac, eHalStatus status,
3219 tANI_U32 *data, tpPESession psessionEntry)
3220{
3221 tSirMsgQ mmhMsg = {0};
3222 tSirSmeSwitchChannelInd *pSirSmeSwitchChInd;
3223
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 psessionEntry->currentOperChannel = psessionEntry->currentReqChannel;
3225
3226 /* We need to restore pre-channelSwitch state on the STA */
3227 if (limRestorePreChannelSwitchState(pMac, psessionEntry) != eSIR_SUCCESS)
3228 {
3229 limLog(pMac, LOGP, FL("Could not restore pre-channelSwitch (11h) state, resetting the system\n"));
3230 return;
3231 }
3232
3233 mmhMsg.type = eWNI_SME_SWITCH_CHL_REQ;
3234 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pSirSmeSwitchChInd, sizeof(tSirSmeSwitchChannelInd)))
3235 {
3236 limLog(pMac, LOGP, FL("Failed to allocate buffer for buffer descriptor\n"));
3237 return;
3238 }
3239
3240 pSirSmeSwitchChInd->messageType = eWNI_SME_SWITCH_CHL_REQ;
3241 pSirSmeSwitchChInd->length = sizeof(tSirSmeSwitchChannelInd);
Jeff Johnsone7245742012-09-05 17:12:55 -07003242 pSirSmeSwitchChInd->newChannelId = psessionEntry->gLimChannelSwitch.primaryChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 pSirSmeSwitchChInd->sessionId = psessionEntry->smeSessionId;
3244 //BSS ID
3245 palCopyMemory( pMac->hHdd, pSirSmeSwitchChInd->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
3246 mmhMsg.bodyptr = pSirSmeSwitchChInd;
3247 mmhMsg.bodyval = 0;
3248
Jeff Johnsone7245742012-09-05 17:12:55 -07003249 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003250
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 SysProcessMmhMsg(pMac, &mmhMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -07003252}
3253
3254/**
3255 * limSwitchPrimaryChannel()
3256 *
3257 *FUNCTION:
3258 * This function changes the current operating channel
3259 * and sets the new new channel ID in WNI_CFG_CURRENT_CHANNEL.
3260 *
3261 *NOTE:
3262 * @param pMac Pointer to Global MAC structure
3263 * @param newChannel new chnannel ID
3264 * @return NONE
3265 */
3266void limSwitchPrimaryChannel(tpAniSirGlobal pMac, tANI_U8 newChannel,tpPESession psessionEntry)
3267{
3268#if !defined WLAN_FEATURE_VOWIFI
3269 tANI_U32 localPwrConstraint;
3270#endif
3271
3272 PELOG3(limLog(pMac, LOG3, FL("limSwitchPrimaryChannel: old chnl %d --> new chnl %d \n"),
3273 psessionEntry->currentOperChannel, newChannel);)
3274 psessionEntry->currentReqChannel = newChannel;
3275 psessionEntry->limRFBand = limGetRFBand(newChannel);
3276
3277 psessionEntry->channelChangeReasonCode=LIM_SWITCH_CHANNEL_OPERATION;
3278
3279 pMac->lim.gpchangeChannelCallback = limSwitchChannelCback;
3280 pMac->lim.gpchangeChannelData = NULL;
3281
3282#if defined WLAN_FEATURE_VOWIFI
Jeff Johnsone7245742012-09-05 17:12:55 -07003283 limSendSwitchChnlParams(pMac, newChannel, PHY_SINGLE_CHANNEL_CENTERED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 psessionEntry->maxTxPower, psessionEntry->peSessionId);
3285#else
3286 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS)
3287 {
3288 limLog( pMac, LOGP, FL( "Unable to read Local Power Constraint from cfg\n" ));
3289 return;
3290 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003291 limSendSwitchChnlParams(pMac, newChannel, PHY_SINGLE_CHANNEL_CENTERED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 (tPowerdBm)localPwrConstraint, psessionEntry->peSessionId);
3293#endif
3294 return;
3295}
3296
3297/**
3298 * limSwitchPrimarySecondaryChannel()
3299 *
3300 *FUNCTION:
3301 * This function changes the primary and secondary channel.
3302 * If 11h is enabled and user provides a "new channel ID"
3303 * that is different from the current operating channel,
3304 * then we must set this new channel in WNI_CFG_CURRENT_CHANNEL,
3305 * assign notify LIM of such change.
3306 *
3307 *NOTE:
3308 * @param pMac Pointer to Global MAC structure
3309 * @param newChannel New chnannel ID (or current channel ID)
3310 * @param subband CB secondary info:
3311 * - eANI_CB_SECONDARY_NONE
3312 * - eANI_CB_SECONDARY_UP
3313 * - eANI_CB_SECONDARY_DOWN
3314 * @return NONE
3315 */
Jeff Johnsone7245742012-09-05 17:12:55 -07003316void limSwitchPrimarySecondaryChannel(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 newChannel, ePhyChanBondState subband)
Jeff Johnson295189b2012-06-20 16:38:30 -07003317{
3318#if !defined WLAN_FEATURE_VOWIFI
3319 tANI_U32 localPwrConstraint;
3320#endif
3321
Jeff Johnson295189b2012-06-20 16:38:30 -07003322#if !defined WLAN_FEATURE_VOWIFI
3323 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
3324 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg\n" ));
3325 return;
3326 }
3327#endif
3328
Jeff Johnson295189b2012-06-20 16:38:30 -07003329#if defined WLAN_FEATURE_VOWIFI
Jeff Johnsone7245742012-09-05 17:12:55 -07003330 limSendSwitchChnlParams(pMac, newChannel, subband, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003331#else
Jeff Johnsone7245742012-09-05 17:12:55 -07003332 limSendSwitchChnlParams(pMac, newChannel, subband, (tPowerdBm)localPwrConstraint, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003333#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003334
Jeff Johnsone7245742012-09-05 17:12:55 -07003335 // Store the new primary and secondary channel in session entries if different
3336 if (psessionEntry->currentOperChannel != newChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 {
3338 limLog(pMac, LOGW,
3339 FL("switch old chnl %d --> new chnl %d \n"),
3340 psessionEntry->currentOperChannel, newChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 psessionEntry->currentOperChannel = newChannel;
3342 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003343 if (psessionEntry->htSecondaryChannelOffset != subband)
3344 {
3345 limLog(pMac, LOGW,
3346 FL("switch old sec chnl %d --> new sec chnl %d \n"),
3347 psessionEntry->htSecondaryChannelOffset, subband);
3348 psessionEntry->htSecondaryChannelOffset = subband;
3349 if (psessionEntry->htSecondaryChannelOffset == PHY_SINGLE_CHANNEL_CENTERED)
3350 {
3351 psessionEntry->htSupportedChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3352 }
3353 else
3354 {
3355 psessionEntry->htSupportedChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
3356 }
3357 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
3358 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003359
3360 return;
3361}
3362
3363
3364/**
3365 * limActiveScanAllowed()
3366 *
3367 *FUNCTION:
3368 * Checks if active scans are permitted on the given channel
3369 *
3370 *LOGIC:
3371 * The config variable SCAN_CONTROL_LIST contains pairs of (channelNum, activeScanAllowed)
3372 * Need to check if the channelNum matches, then depending on the corresponding
3373 * scan flag, return true (for activeScanAllowed==1) or false (otherwise).
3374 *
3375 *ASSUMPTIONS:
3376 *
3377 *NOTE:
3378 *
3379 * @param pMac Pointer to Global MAC structure
3380 * @param channelNum channel number
3381 * @return None
3382 */
3383
3384tANI_U8 limActiveScanAllowed(
3385 tpAniSirGlobal pMac,
3386 tANI_U8 channelNum)
3387{
3388 tANI_U32 i;
3389 tANI_U8 channelPair[WNI_CFG_SCAN_CONTROL_LIST_LEN];
3390 tANI_U32 len = WNI_CFG_SCAN_CONTROL_LIST_LEN;
3391 if (wlan_cfgGetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, channelPair, &len)
3392 != eSIR_SUCCESS)
3393 {
3394 PELOGE(limLog(pMac, LOGE, FL("Unable to get scan control list\n"));)
3395 return false;
3396 }
3397
3398 if (len > WNI_CFG_SCAN_CONTROL_LIST_LEN)
3399 {
3400 limLog(pMac, LOGE, FL("Invalid scan control list length:%d\n"),
3401 len);
3402 return false;
3403 }
3404
3405 for (i=0; (i+1) < len; i+=2)
3406 {
3407 if (channelPair[i] == channelNum)
3408 return ((channelPair[i+1] == eSIR_ACTIVE_SCAN) ? true : false);
3409 }
3410 return false;
3411}
3412
3413/**
3414 * limTriggerBackgroundScanDuringQuietBss()
3415 *
3416 *FUNCTION:
3417 * This function is applicable to the STA only.
3418 * This function is called by limProcessQuietTimeout(),
3419 * when it is time to honor the Quiet BSS IE from the AP.
3420 *
3421 *LOGIC:
3422 * If 11H is enabled:
3423 * We cannot trigger a background scan. The STA needs to
3424 * shut-off Tx/Rx.
3425 * If 11 is not enabled:
3426 * Determine if the next channel that we are going to
3427 * scan is NOT the same channel (or not) on which the
3428 * Quiet BSS was requested.
3429 * If yes, then we cannot trigger a background scan on
3430 * this channel. Return with a false.
3431 * If no, then trigger a background scan. Return with
3432 * a true.
3433 *
3434 *ASSUMPTIONS:
3435 *
3436 *NOTE:
3437 * This API is redundant if the existing API,
3438 * limTriggerBackgroundScan(), were to return a valid
3439 * response instead of returning void.
3440 * If possible, try to revisit this API
3441 *
3442 * @param pMac Pointer to Global MAC structure
3443 * @return eSIR_TRUE, if a background scan was attempted
3444 * eSIR_FALSE, if not
3445 */
3446tAniBool limTriggerBackgroundScanDuringQuietBss( tpAniSirGlobal pMac )
3447{
3448 tAniBool bScanTriggered = eSIR_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003449
3450
3451
3452 //TBD-RAJESH HOW TO GET sessionEntry?????
3453 tpPESession psessionEntry = &pMac->lim.gpSession[0];
3454
3455 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3456 return bScanTriggered;
3457
Jeff Johnsone7245742012-09-05 17:12:55 -07003458 if( !psessionEntry->lim11hEnable )
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 {
3460 tSirMacChanNum bgScanChannelList[WNI_CFG_BG_SCAN_CHANNEL_LIST_LEN];
3461 tANI_U32 len = WNI_CFG_BG_SCAN_CHANNEL_LIST_LEN;
3462
3463 // Determine the next scan channel
3464
3465 // Get background scan channel list from CFG
3466 if( eSIR_SUCCESS == wlan_cfgGetStr( pMac,
3467 WNI_CFG_BG_SCAN_CHANNEL_LIST,
3468 (tANI_U8 *) bgScanChannelList,
3469 (tANI_U32 *) &len ))
3470 {
3471 // Ensure that we do not go off scanning on the same
3472 // channel on which the Quiet BSS was requested
3473 if( psessionEntry->currentOperChannel!=
3474 bgScanChannelList[pMac->lim.gLimBackgroundScanChannelId] )
3475 {
3476 // For now, try and attempt a background scan. It will
3477 // be ideal if this API actually returns a success or
3478 // failure instead of having a void return type
3479 limTriggerBackgroundScan( pMac );
3480
3481 bScanTriggered = eSIR_TRUE;
3482 }
3483 else
3484 {
3485 limLog( pMac, LOGW,
3486 FL("The next SCAN channel is the current operating channel on which a Quiet BSS is requested.! A background scan will not be triggered during this Quiet BSS period...\n"));
3487 }
3488 }
3489 else
3490 {
3491 limLog( pMac, LOGW,
3492 FL("Unable to retrieve WNI_CFG_VALID_CHANNEL_LIST from CFG! A background scan will not be triggered during this Quiet BSS period...\n"));
3493 }
3494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 return bScanTriggered;
3496}
3497
3498
3499/**
3500 * limGetHTCapability()
3501 *
3502 *FUNCTION:
3503 * A utility function that returns the "current HT capability state" for the HT
3504 * capability of interest (as requested in the API)
3505 *
3506 *LOGIC:
3507 * This routine will return with the "current" setting of a requested HT
3508 * capability. This state info could be retrieved from -
3509 * a) CFG (for static entries)
3510 * b) Run time info
3511 * - Dynamic state maintained by LIM
3512 * - Configured at radio init time by SME
3513 *
3514 *
3515 *ASSUMPTIONS:
3516 * NA
3517 *
3518 *NOTE:
3519 *
3520 * @param pMac Pointer to Global MAC structure
3521 * @param htCap The HT capability being queried
3522 * @return tANI_U8 The current state of the requested HT capability is returned in a
3523 * tANI_U8 variable
3524 */
3525
Jeff Johnson295189b2012-06-20 16:38:30 -07003526tANI_U8 limGetHTCapability( tpAniSirGlobal pMac,
3527 tANI_U32 htCap, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003528{
3529tANI_U8 retVal = 0;
3530tANI_U8 *ptr;
3531tANI_U32 cfgValue;
3532tSirMacHTCapabilityInfo macHTCapabilityInfo = {0};
3533tSirMacExtendedHTCapabilityInfo macExtHTCapabilityInfo = {0};
3534tSirMacTxBFCapabilityInfo macTxBFCapabilityInfo = {0};
3535tSirMacASCapabilityInfo macASCapabilityInfo = {0};
3536
3537 //
3538 // Determine which CFG to read from. Not ALL of the HT
3539 // related CFG's need to be read each time this API is
3540 // accessed
3541 //
3542 if( htCap >= eHT_ANTENNA_SELECTION &&
3543 htCap < eHT_SI_GRANULARITY )
3544 {
3545 // Get Antenna Seletion HT Capabilities
3546 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_AS_CAP, &cfgValue ))
3547 cfgValue = 0;
3548 ptr = (tANI_U8 *) &macASCapabilityInfo;
3549 *((tANI_U8 *)ptr) = (tANI_U8) (cfgValue & 0xff);
3550 }
3551 else
3552 {
3553 if( htCap >= eHT_TX_BEAMFORMING &&
3554 htCap < eHT_ANTENNA_SELECTION )
3555 {
3556 // Get Transmit Beam Forming HT Capabilities
3557 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_TX_BF_CAP, &cfgValue ))
3558 cfgValue = 0;
3559 ptr = (tANI_U8 *) &macTxBFCapabilityInfo;
3560 *((tANI_U32 *)ptr) = (tANI_U32) (cfgValue);
3561 }
3562 else
3563 {
3564 if( htCap >= eHT_PCO &&
3565 htCap < eHT_TX_BEAMFORMING )
3566 {
3567 // Get Extended HT Capabilities
3568 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_EXT_HT_CAP_INFO, &cfgValue ))
3569 cfgValue = 0;
3570 ptr = (tANI_U8 *) &macExtHTCapabilityInfo;
3571 *((tANI_U16 *)ptr) = (tANI_U16) (cfgValue & 0xffff);
3572 }
3573 else
3574 {
3575 if( htCap < eHT_MAX_RX_AMPDU_FACTOR )
3576 {
3577 // Get HT Capabilities
3578 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_HT_CAP_INFO, &cfgValue ))
3579 cfgValue = 0;
3580 ptr = (tANI_U8 *) &macHTCapabilityInfo;
3581 // CR 265282 MDM SoftAP 2.4PL: SoftAP boot up crash in 2.4 PL builds while same WLAN SU is working on 2.1 PL
3582 *ptr++ = cfgValue & 0xff;
3583 *ptr = (cfgValue >> 8) & 0xff;
3584 }
3585 }
3586 }
3587 }
3588
3589 switch( htCap )
3590 {
3591 case eHT_LSIG_TXOP_PROTECTION:
3592 retVal = pMac->lim.gHTLsigTXOPProtection;
3593 break;
3594
3595 case eHT_STBC_CONTROL_FRAME:
3596 retVal = (tANI_U8) macHTCapabilityInfo.stbcControlFrame;
3597 break;
3598
3599 case eHT_PSMP:
3600 retVal = pMac->lim.gHTPSMPSupport;
3601 break;
3602
3603 case eHT_DSSS_CCK_MODE_40MHZ:
3604 retVal = pMac->lim.gHTDsssCckRate40MHzSupport;
3605 break;
3606
3607 case eHT_MAX_AMSDU_LENGTH:
3608 retVal = (tANI_U8) macHTCapabilityInfo.maximalAMSDUsize;
3609 break;
3610
3611 case eHT_DELAYED_BA:
3612 retVal = (tANI_U8) macHTCapabilityInfo.delayedBA;
3613 break;
3614
3615 case eHT_RX_STBC:
3616 retVal = (tANI_U8) macHTCapabilityInfo.rxSTBC;
3617 break;
3618
3619 case eHT_TX_STBC:
3620 retVal = (tANI_U8) macHTCapabilityInfo.txSTBC;
3621 break;
3622
3623 case eHT_SHORT_GI_40MHZ:
3624 retVal = (tANI_U8) macHTCapabilityInfo.shortGI40MHz;
3625 break;
3626
3627 case eHT_SHORT_GI_20MHZ:
3628 retVal = (tANI_U8) macHTCapabilityInfo.shortGI20MHz;
3629 break;
3630
3631 case eHT_GREENFIELD:
3632 retVal = (tANI_U8) macHTCapabilityInfo.greenField;
3633 break;
3634
3635 case eHT_MIMO_POWER_SAVE:
3636 retVal = (tANI_U8) pMac->lim.gHTMIMOPSState;
3637 break;
3638
3639 case eHT_SUPPORTED_CHANNEL_WIDTH_SET:
Jeff Johnsone7245742012-09-05 17:12:55 -07003640 retVal = (tANI_U8) psessionEntry->htSupportedChannelWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 break;
3642
3643 case eHT_ADVANCED_CODING:
3644 retVal = (tANI_U8) macHTCapabilityInfo.advCodingCap;
3645 break;
3646
3647 case eHT_MAX_RX_AMPDU_FACTOR:
3648 retVal = pMac->lim.gHTMaxRxAMpduFactor;
3649 break;
3650
3651 case eHT_MPDU_DENSITY:
3652 retVal = pMac->lim.gHTAMpduDensity;
3653 break;
3654
3655 case eHT_PCO:
3656 retVal = (tANI_U8) macExtHTCapabilityInfo.pco;
3657 break;
3658
3659 case eHT_TRANSITION_TIME:
3660 retVal = (tANI_U8) macExtHTCapabilityInfo.transitionTime;
3661 break;
3662
3663 case eHT_MCS_FEEDBACK:
3664 retVal = (tANI_U8) macExtHTCapabilityInfo.mcsFeedback;
3665 break;
3666
3667 case eHT_TX_BEAMFORMING:
3668 retVal = (tANI_U8) macTxBFCapabilityInfo.txBF;
3669 break;
3670
3671 case eHT_ANTENNA_SELECTION:
3672 retVal = (tANI_U8) macASCapabilityInfo.antennaSelection;
3673 break;
3674
3675 case eHT_SI_GRANULARITY:
3676 retVal = pMac->lim.gHTServiceIntervalGranularity;
3677 break;
3678
3679 case eHT_CONTROLLED_ACCESS:
3680 retVal = pMac->lim.gHTControlledAccessOnly;
3681 break;
3682
3683 case eHT_RIFS_MODE:
3684 retVal = psessionEntry->beaconParams.fRIFSMode;
3685 break;
3686
3687 case eHT_RECOMMENDED_TX_WIDTH_SET:
Jeff Johnsone7245742012-09-05 17:12:55 -07003688 retVal = psessionEntry->htRecommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 break;
3690
3691 case eHT_EXTENSION_CHANNEL_OFFSET:
Jeff Johnsone7245742012-09-05 17:12:55 -07003692 retVal = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07003693 break;
3694
3695 case eHT_OP_MODE:
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 if(psessionEntry->limSystemRole == eLIM_AP_ROLE )
3697 retVal = psessionEntry->htOperMode;
3698 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003699 retVal = pMac->lim.gHTOperMode;
3700 break;
3701
3702 case eHT_BASIC_STBC_MCS:
3703 retVal = pMac->lim.gHTSTBCBasicMCS;
3704 break;
3705
3706 case eHT_DUAL_CTS_PROTECTION:
3707 retVal = pMac->lim.gHTDualCTSProtection;
3708 break;
3709
3710 case eHT_LSIG_TXOP_PROTECTION_FULL_SUPPORT:
3711 retVal = psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport;
3712 break;
3713
3714 case eHT_PCO_ACTIVE:
3715 retVal = pMac->lim.gHTPCOActive;
3716 break;
3717
3718 case eHT_PCO_PHASE:
3719 retVal = pMac->lim.gHTPCOPhase;
3720 break;
3721
3722 default:
3723 break;
3724 }
3725
3726 return retVal;
3727}
3728
Jeff Johnson295189b2012-06-20 16:38:30 -07003729void limGetMyMacAddr(tpAniSirGlobal pMac, tANI_U8 *mac)
3730{
3731 palCopyMemory( pMac->hHdd, mac, pMac->lim.gLimMyMacAddr, sizeof(tSirMacAddr));
3732 return;
3733}
3734
3735
3736
3737
3738/** -------------------------------------------------------------
3739\fn limEnable11aProtection
3740\brief based on config setting enables\disables 11a protection.
3741\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
3742\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
3743\param tpUpdateBeaconParams pBeaconParams
3744\return None
3745 -------------------------------------------------------------*/
3746tSirRetStatus
3747limEnable11aProtection(tpAniSirGlobal pMac, tANI_U8 enable,
3748 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
3749{
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07003750 if(NULL == psessionEntry)
3751 {
3752 PELOG3(limLog(pMac, LOG3, FL("psessionEntry is NULL\n"));)
3753 return eSIR_FAILURE;
3754 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003755 //overlapping protection configuration check.
3756 if(overlap)
3757 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003758 }
3759 else
3760 {
3761 //normal protection config check
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07003762 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07003763 (!psessionEntry->cfgProtection.fromlla))
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 {
3765 // protection disabled.
3766 PELOG3(limLog(pMac, LOG3, FL("protection from 11a is disabled\n"));)
3767 return eSIR_SUCCESS;
3768 }
3769 }
3770
3771 if (enable)
3772 {
3773 //If we are AP and HT capable, we need to set the HT OP mode
3774 //appropriately.
3775 if(((eLIM_AP_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole))&&
Jeff Johnsone7245742012-09-05 17:12:55 -07003776 (true == psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 {
3778 if(overlap)
3779 {
3780 pMac->lim.gLimOverlap11aParams.protectionEnabled = true;
3781 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
3782 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
3783 {
3784 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
3785 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
3786 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3787 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3788 }
3789 }
3790 else
3791 {
3792 psessionEntry->gLim11aParams.protectionEnabled = true;
3793 if(eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode)
3794 {
3795 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_MIXED;
Jeff Johnsone7245742012-09-05 17:12:55 -07003796 psessionEntry->htOperMode = eSIR_HT_OP_MODE_MIXED;
Jeff Johnson295189b2012-06-20 16:38:30 -07003797 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3798 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3799
3800 }
3801 }
3802 }
3803
3804 //This part is common for staiton as well.
3805 if(false == psessionEntry->beaconParams.llaCoexist)
3806 {
3807 PELOG1(limLog(pMac, LOG1, FL(" => protection from 11A Enabled\n"));)
3808 pBeaconParams->llaCoexist = psessionEntry->beaconParams.llaCoexist = true;
3809 pBeaconParams->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
3810 }
3811 }
3812 else if (true == psessionEntry->beaconParams.llaCoexist)
3813 {
3814 //for AP role.
3815 //we need to take care of HT OP mode change if needed.
3816 //We need to take care of Overlap cases.
3817 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
3818 {
3819 if(overlap)
3820 {
3821 //Overlap Legacy protection disabled.
3822 pMac->lim.gLimOverlap11aParams.protectionEnabled = false;
3823
3824 //We need to take care of HT OP mode iff we are HT AP.
Jeff Johnsone7245742012-09-05 17:12:55 -07003825 if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07003826 {
3827 // no HT op mode change if any of the overlap protection enabled.
3828 if(!(pMac->lim.gLimOverlap11aParams.protectionEnabled ||
3829 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
3830 pMac->lim.gLimOverlapNonGfParams.protectionEnabled))
3831
3832 {
3833 //Check if there is a need to change HT OP mode.
3834 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
3835 {
3836 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
3837 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
3838
3839 if(psessionEntry->gLimHt20Params.protectionEnabled)
3840 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
3841 else
3842 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
3843 }
3844 }
3845 }
3846 }
3847 else
3848 {
3849 //Disable protection from 11A stations.
3850 psessionEntry->gLim11aParams.protectionEnabled = false;
3851 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
3852
3853 //Check if any other non-HT protection enabled.
3854 //Right now we are in HT OP Mixed mode.
3855 //Change HT op mode appropriately.
3856
3857 //Change HT OP mode to 01 if any overlap protection enabled
3858 if(pMac->lim.gLimOverlap11aParams.protectionEnabled ||
3859 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
3860 pMac->lim.gLimOverlapNonGfParams.protectionEnabled)
3861
3862 {
3863 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
Jeff Johnsone7245742012-09-05 17:12:55 -07003864 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3866 }
3867 else if(psessionEntry->gLimHt20Params.protectionEnabled)
3868 {
3869 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003870 psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
3872 }
3873 else
3874 {
3875 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003876 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003877 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
3878 }
3879 }
3880 if(!pMac->lim.gLimOverlap11aParams.protectionEnabled &&
3881 !psessionEntry->gLim11aParams.protectionEnabled)
3882 {
3883 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11A Disabled\n"));)
3884 pBeaconParams->llaCoexist = psessionEntry->beaconParams.llaCoexist = false;
3885 pBeaconParams->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
3886 }
3887 }
3888 //for station role
3889 else
3890 {
3891 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11A Disabled\n"));)
3892 pBeaconParams->llaCoexist = psessionEntry->beaconParams.llaCoexist = false;
3893 pBeaconParams->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
3894 }
3895 }
3896
3897 return eSIR_SUCCESS;
3898}
3899
3900/** -------------------------------------------------------------
3901\fn limEnable11gProtection
3902\brief based on config setting enables\disables 11g protection.
3903\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
3904\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
3905\param tpUpdateBeaconParams pBeaconParams
3906\return None
3907 -------------------------------------------------------------*/
3908
3909tSirRetStatus
3910limEnable11gProtection(tpAniSirGlobal pMac, tANI_U8 enable,
3911 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
3912{
3913
3914 //overlapping protection configuration check.
3915 if(overlap)
3916 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 }
3918 else
3919 {
3920 //normal protection config check
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
3922 !psessionEntry->cfgProtection.fromllb)
3923 {
3924 // protection disabled.
3925 PELOG1(limLog(pMac, LOG1, FL("protection from 11b is disabled\n"));)
3926 return eSIR_SUCCESS;
3927 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 {
3929 if(!pMac->lim.cfgProtection.fromllb)
3930 {
3931 // protection disabled.
3932 PELOG1(limLog(pMac, LOG1, FL("protection from 11b is disabled\n"));)
3933 return eSIR_SUCCESS;
3934 }
3935 }
3936 }
3937
3938 if (enable)
3939 {
3940 //If we are AP and HT capable, we need to set the HT OP mode
3941 //appropriately.
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
3943 {
3944 if(overlap)
3945 {
3946 psessionEntry->gLimOlbcParams.protectionEnabled = true;
3947 PELOGE(limLog(pMac, LOGE, FL("protection from olbc is enabled\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07003948 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 {
3950 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != psessionEntry->htOperMode) &&
3951 (eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode))
3952 {
3953 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
3954 }
3955 //CR-263021: OBSS bit is not switching back to 0 after disabling the overlapping legacy BSS
3956 // This fixes issue of OBSS bit not set after 11b, 11g station leaves
3957 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3958 //Not processing OBSS bit from other APs, as we are already taking care
3959 //of Protection from overlapping BSS based on erp IE or useProtection bit
3960 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams, psessionEntry);
3961 }
3962 }
3963 else
3964 {
3965 psessionEntry->gLim11bParams.protectionEnabled = true;
3966 PELOGE(limLog(pMac, LOGE, FL("protection from 11b is enabled\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07003967 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07003968 {
3969 if(eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode)
3970 {
3971 psessionEntry->htOperMode = eSIR_HT_OP_MODE_MIXED;
3972 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3973 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3974 }
3975 }
3976 }
3977 }else if ((eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07003978 (true == psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 {
3980 if(overlap)
3981 {
3982 psessionEntry->gLimOlbcParams.protectionEnabled = true;
3983 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
3984 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
3985 {
3986 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
3987 }
3988 //CR-263021: OBSS bit is not switching back to 0 after disabling the overlapping legacy BSS
3989 // This fixes issue of OBSS bit not set after 11b, 11g station leaves
3990 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3991 //Not processing OBSS bit from other APs, as we are already taking care
3992 //of Protection from overlapping BSS based on erp IE or useProtection bit
3993 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams, psessionEntry);
3994 }
3995 else
3996 {
3997 psessionEntry->gLim11bParams.protectionEnabled = true;
3998 if(eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode)
3999 {
4000 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_MIXED;
4001 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4002 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4003 }
4004 }
4005 }
4006
4007 //This part is common for staiton as well.
4008 if(false == psessionEntry->beaconParams.llbCoexist)
4009 {
4010 PELOG1(limLog(pMac, LOG1, FL("=> 11G Protection Enabled\n"));)
4011 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = true;
4012 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4013 }
4014 }
4015 else if (true == psessionEntry->beaconParams.llbCoexist)
4016 {
4017 //for AP role.
4018 //we need to take care of HT OP mode change if needed.
4019 //We need to take care of Overlap cases.
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4021 {
4022 if(overlap)
4023 {
4024 //Overlap Legacy protection disabled.
4025 psessionEntry->gLimOlbcParams.protectionEnabled = false;
4026
4027 //We need to take care of HT OP mode if we are HT AP.
Jeff Johnsone7245742012-09-05 17:12:55 -07004028 if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 {
4030 // no HT op mode change if any of the overlap protection enabled.
4031 if(!(psessionEntry->gLimOverlap11gParams.protectionEnabled ||
4032 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4033 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
4034 {
4035 //Check if there is a need to change HT OP mode.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004036 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == psessionEntry->htOperMode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 {
4038 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4039 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4040 if(psessionEntry->gLimHt20Params.protectionEnabled){
4041 //Commenting out beacuse of CR 258588 WFA cert
4042 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4043 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4044 }
4045 else
4046 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4047 }
4048 }
4049 }
4050 }
4051 else
4052 {
4053 //Disable protection from 11B stations.
4054 psessionEntry->gLim11bParams.protectionEnabled = false;
4055 PELOGE(limLog(pMac, LOGE, FL("===> 11B Protection Disabled\n"));)
4056 //Check if any other non-HT protection enabled.
4057 if(!psessionEntry->gLim11gParams.protectionEnabled)
4058 {
4059 //Right now we are in HT OP Mixed mode.
4060 //Change HT op mode appropriately.
4061 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4062
4063 //Change HT OP mode to 01 if any overlap protection enabled
4064 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4065 psessionEntry->gLimOverlap11gParams.protectionEnabled ||
4066 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4067 psessionEntry->gLimOverlapNonGfParams.protectionEnabled)
4068 {
4069 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4070 PELOGE(limLog(pMac, LOGE, FL("===> 11G Protection Disabled\n"));)
4071 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4072 }
4073 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4074 {
4075 //Commenting because of CR 258588 WFA cert
4076 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4077 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4078 PELOGE(limLog(pMac, LOGE, FL("===> 11G Protection Disabled\n"));)
4079 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4080 }
4081 else
4082 {
4083 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4084 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4085 }
4086 }
4087 }
4088 if(!psessionEntry->gLimOlbcParams.protectionEnabled &&
4089 !psessionEntry->gLim11bParams.protectionEnabled)
4090 {
4091 PELOGE(limLog(pMac, LOGE, FL("===> 11G Protection Disabled\n"));)
4092 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
4093 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4094 }
4095 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 {
4097 if(overlap)
4098 {
4099 //Overlap Legacy protection disabled.
4100 psessionEntry->gLimOlbcParams.protectionEnabled = false;
4101
4102 //We need to take care of HT OP mode iff we are HT AP.
Jeff Johnsone7245742012-09-05 17:12:55 -07004103 if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 {
4105 // no HT op mode change if any of the overlap protection enabled.
4106 if(!(pMac->lim.gLimOverlap11gParams.protectionEnabled ||
4107 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4108 pMac->lim.gLimOverlapNonGfParams.protectionEnabled))
4109
4110 {
4111 //Check if there is a need to change HT OP mode.
4112 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
4113 {
4114 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4115 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4116 if(psessionEntry->gLimHt20Params.protectionEnabled)
4117 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4118 else
4119 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4120 }
4121 }
4122 }
4123 }
4124 else
4125 {
4126 //Disable protection from 11B stations.
4127 psessionEntry->gLim11bParams.protectionEnabled = false;
4128 //Check if any other non-HT protection enabled.
4129 if(!psessionEntry->gLim11gParams.protectionEnabled)
4130 {
4131 //Right now we are in HT OP Mixed mode.
4132 //Change HT op mode appropriately.
4133 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4134
4135 //Change HT OP mode to 01 if any overlap protection enabled
4136 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4137 pMac->lim.gLimOverlap11gParams.protectionEnabled ||
4138 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4139 pMac->lim.gLimOverlapNonGfParams.protectionEnabled)
4140
4141 {
4142 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4143 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4144 }
4145 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4146 {
4147 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4148 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4149 }
4150 else
4151 {
4152 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4153 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4154 }
4155 }
4156 }
4157 if(!psessionEntry->gLimOlbcParams.protectionEnabled &&
4158 !psessionEntry->gLim11bParams.protectionEnabled)
4159 {
4160 PELOG1(limLog(pMac, LOG1, FL("===> 11G Protection Disabled\n"));)
4161 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
4162 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4163 }
4164 }
4165 //for station role
4166 else
4167 {
4168 PELOG1(limLog(pMac, LOG1, FL("===> 11G Protection Disabled\n"));)
4169 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
4170 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4171 }
4172 }
4173 return eSIR_SUCCESS;
4174}
4175
4176/** -------------------------------------------------------------
4177\fn limEnableHtProtectionFrom11g
4178\brief based on cofig enables\disables protection from 11g.
4179\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4180\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4181\param tpUpdateBeaconParams pBeaconParams
4182\return None
4183 -------------------------------------------------------------*/
4184tSirRetStatus
4185limEnableHtProtectionFrom11g(tpAniSirGlobal pMac, tANI_U8 enable,
4186 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4187{
Jeff Johnsone7245742012-09-05 17:12:55 -07004188 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004189 return eSIR_SUCCESS; // protection from 11g is only for HT stations.
4190
4191 //overlapping protection configuration check.
4192 if(overlap)
4193 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) && (!psessionEntry->cfgProtection.overlapFromllg))
4195 {
4196 // protection disabled.
4197 PELOG3(limLog(pMac, LOG3, FL("overlap protection from 11g is disabled\n")););
4198 return eSIR_SUCCESS;
4199 }else if ((psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) && (!pMac->lim.cfgProtection.overlapFromllg))
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 {
4201 // protection disabled.
4202 PELOG3(limLog(pMac, LOG3, FL("overlap protection from 11g is disabled\n")););
4203 return eSIR_SUCCESS;
4204 }
4205 }
4206 else
4207 {
4208 //normal protection config check
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
4210 !psessionEntry->cfgProtection.fromllg){
4211 // protection disabled.
4212 PELOG3(limLog(pMac, LOG3, FL("protection from 11g is disabled\n"));)
4213 return eSIR_SUCCESS;
4214 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 {
4216 if(!pMac->lim.cfgProtection.fromllg)
4217 {
4218 // protection disabled.
4219 PELOG3(limLog(pMac, LOG3, FL("protection from 11g is disabled\n"));)
4220 return eSIR_SUCCESS;
4221 }
4222 }
4223 }
4224 if (enable)
4225 {
4226 //If we are AP and HT capable, we need to set the HT OP mode
4227 //appropriately.
4228
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4230 {
4231 if(overlap)
4232 {
4233 psessionEntry->gLimOverlap11gParams.protectionEnabled = true;
4234 //11g exists in overlap BSS.
4235 //need not to change the operating mode to overlap_legacy
4236 //if higher or same protection operating mode is enabled right now.
4237 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != psessionEntry->htOperMode) &&
4238 (eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode))
4239 {
4240 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4241 }
4242 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4243 limEnableHtOBSSProtection(pMac, true , overlap, pBeaconParams, psessionEntry);
4244 }
4245 else
4246 {
4247 //11g is associated to an AP operating in 11n mode.
4248 //Change the HT operating mode to 'mixed mode'.
4249 psessionEntry->gLim11gParams.protectionEnabled = true;
4250 if(eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode)
4251 {
4252 psessionEntry->htOperMode = eSIR_HT_OP_MODE_MIXED;
4253 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4254 limEnableHtOBSSProtection(pMac, true , overlap, pBeaconParams,psessionEntry);
4255 }
4256 }
4257 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
Jeff Johnson295189b2012-06-20 16:38:30 -07004258 {
4259 if(overlap)
4260 {
4261 pMac->lim.gLimOverlap11gParams.protectionEnabled = true;
4262 //11g exists in overlap BSS.
4263 //need not to change the operating mode to overlap_legacy
4264 //if higher or same protection operating mode is enabled right now.
4265 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
4266 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
4267 {
4268 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4269 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4270 }
4271 }
4272 else
4273 {
4274 //11g is associated to an AP operating in 11n mode.
4275 //Change the HT operating mode to 'mixed mode'.
4276 psessionEntry->gLim11gParams.protectionEnabled = true;
4277 if(eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode)
4278 {
4279 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_MIXED;
4280 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4281 limEnableHtOBSSProtection(pMac, true , overlap, pBeaconParams,psessionEntry);
4282 }
4283 }
4284 }
4285
4286 //This part is common for staiton as well.
4287 if(false == psessionEntry->beaconParams.llgCoexist)
4288 {
4289 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = true;
4290 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 else if (true == psessionEntry->gLimOverlap11gParams.protectionEnabled)
4293 {
4294 // As operating mode changed after G station assoc some way to update beacon
4295 // This addresses the issue of mode not changing to - 11 in beacon when OBSS overlap is enabled
4296 //pMac->sch.schObject.fBeaconChanged = 1;
4297 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4298 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 }
4300 else if (true == psessionEntry->beaconParams.llgCoexist)
4301 {
4302 //for AP role.
4303 //we need to take care of HT OP mode change if needed.
4304 //We need to take care of Overlap cases.
4305
Jeff Johnson295189b2012-06-20 16:38:30 -07004306 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4307 {
4308 if(overlap)
4309 {
4310 //Overlap Legacy protection disabled.
4311 if (psessionEntry->gLim11gParams.numSta == 0)
4312 psessionEntry->gLimOverlap11gParams.protectionEnabled = false;
4313
4314 // no HT op mode change if any of the overlap protection enabled.
4315 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
4316 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4317 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
4318 {
4319 //Check if there is a need to change HT OP mode.
4320 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == psessionEntry->htOperMode)
4321 {
4322 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4323 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4324
4325 if(psessionEntry->gLimHt20Params.protectionEnabled){
4326 //Commenting because of CR 258588 WFA cert
4327 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4328 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4329 }
4330 else
4331 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4332 }
4333 }
4334 }
4335 else
4336 {
4337 //Disable protection from 11G stations.
4338 psessionEntry->gLim11gParams.protectionEnabled = false;
4339 //Check if any other non-HT protection enabled.
4340 if(!psessionEntry->gLim11bParams.protectionEnabled)
4341 {
4342
4343 //Right now we are in HT OP Mixed mode.
4344 //Change HT op mode appropriately.
4345 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4346
4347 //Change HT OP mode to 01 if any overlap protection enabled
4348 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4349 psessionEntry->gLimOverlap11gParams.protectionEnabled ||
4350 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4351 psessionEntry->gLimOverlapNonGfParams.protectionEnabled)
4352
4353 {
4354 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4355 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4356 }
4357 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4358 {
4359 //Commenting because of CR 258588 WFA cert
4360 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4361 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4362 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4363 }
4364 else
4365 {
4366 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4367 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4368 }
4369 }
4370 }
4371 if(!psessionEntry->gLimOverlap11gParams.protectionEnabled &&
4372 !psessionEntry->gLim11gParams.protectionEnabled)
4373 {
4374 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11G Disabled\n"));)
4375 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = false;
4376 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4377 }
4378 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 {
4380 if(overlap)
4381 {
4382 //Overlap Legacy protection disabled.
4383 pMac->lim.gLimOverlap11gParams.protectionEnabled = false;
4384
4385 // no HT op mode change if any of the overlap protection enabled.
4386 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
4387 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4388 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
4389 {
4390 //Check if there is a need to change HT OP mode.
4391 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
4392 {
4393 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4394 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4395
4396 if(psessionEntry->gLimHt20Params.protectionEnabled)
4397 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4398 else
4399 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4400 }
4401 }
4402 }
4403 else
4404 {
4405 //Disable protection from 11G stations.
4406 psessionEntry->gLim11gParams.protectionEnabled = false;
4407 //Check if any other non-HT protection enabled.
4408 if(!psessionEntry->gLim11bParams.protectionEnabled)
4409 {
4410
4411 //Right now we are in HT OP Mixed mode.
4412 //Change HT op mode appropriately.
4413 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4414
4415 //Change HT OP mode to 01 if any overlap protection enabled
4416 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4417 pMac->lim.gLimOverlap11gParams.protectionEnabled ||
4418 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4419 pMac->lim.gLimOverlapNonGfParams.protectionEnabled)
4420
4421 {
4422 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4423 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4424 }
4425 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4426 {
4427 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4428 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4429 }
4430 else
4431 {
4432 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4433 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4434 }
4435 }
4436 }
4437 if(!pMac->lim.gLimOverlap11gParams.protectionEnabled &&
4438 !psessionEntry->gLim11gParams.protectionEnabled)
4439 {
4440 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11G Disabled\n"));)
4441 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = false;
4442 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4443 }
4444 }
4445 //for station role
4446 else
4447 {
4448 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11G Disabled\n"));)
4449 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = false;
4450 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4451 }
4452 }
4453 return eSIR_SUCCESS;
4454}
4455//FIXME_PROTECTION : need to check for no APSD whenever we want to enable this protection.
4456//This check will be done at the caller.
4457
4458/** -------------------------------------------------------------
4459\fn limEnableHtObssProtection
4460\brief based on cofig enables\disables obss protection.
4461\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4462\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4463\param tpUpdateBeaconParams pBeaconParams
4464\return None
4465 -------------------------------------------------------------*/
4466tSirRetStatus
4467limEnableHtOBSSProtection(tpAniSirGlobal pMac, tANI_U8 enable,
4468 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4469{
4470
4471
Jeff Johnsone7245742012-09-05 17:12:55 -07004472 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 return eSIR_SUCCESS; // this protection is only for HT stations.
4474
4475 //overlapping protection configuration check.
4476 if(overlap)
4477 {
4478 //overlapping protection configuration check.
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 }
4480 else
4481 {
4482 //normal protection config check
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 if((psessionEntry->limSystemRole == eLIM_AP_ROLE) && !psessionEntry->cfgProtection.obss)
4484 { //ToDo Update this field
4485 // protection disabled.
4486 PELOG1(limLog(pMac, LOG1, FL("protection from Obss is disabled\n"));)
4487 return eSIR_SUCCESS;
4488 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004489 {
4490 if(!pMac->lim.cfgProtection.obss)
4491 { //ToDo Update this field
4492 // protection disabled.
4493 PELOG1(limLog(pMac, LOG1, FL("protection from Obss is disabled\n"));)
4494 return eSIR_SUCCESS;
4495 }
4496 }
4497 }
4498
4499
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 if (eLIM_AP_ROLE == psessionEntry->limSystemRole){
4501 if ((enable) && (false == psessionEntry->beaconParams.gHTObssMode) )
4502 {
4503 PELOG1(limLog(pMac, LOG1, FL("=>obss protection enabled\n"));)
4504 psessionEntry->beaconParams.gHTObssMode = true;
4505 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED; // UPDATE AN ENUM FOR OBSS MODE <todo>
4506
4507 }
4508 else if (!enable && (true == psessionEntry->beaconParams.gHTObssMode))
4509 {
4510 PELOG1(limLog(pMac, LOG1, FL("===> obss Protection disabled\n"));)
4511 psessionEntry->beaconParams.gHTObssMode = false;
4512 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED;
4513
4514 }
4515//CR-263021: OBSS bit is not switching back to 0 after disabling the overlapping legacy BSS
4516 if (!enable && !overlap)
4517 {
4518 psessionEntry->gLimOverlap11gParams.protectionEnabled = false;
4519 }
4520 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 {
4522 if ((enable) && (false == psessionEntry->beaconParams.gHTObssMode) )
4523 {
4524 PELOG1(limLog(pMac, LOG1, FL("=>obss protection enabled\n"));)
4525 psessionEntry->beaconParams.gHTObssMode = true;
4526 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED; // UPDATE AN ENUM FOR OBSS MODE <todo>
4527
4528 }
4529 else if (!enable && (true == psessionEntry->beaconParams.gHTObssMode))
4530 {
4531
4532 PELOG1(limLog(pMac, LOG1, FL("===> obss Protection disabled\n"));)
4533 psessionEntry->beaconParams.gHTObssMode = false;
4534 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED;
4535
4536 }
4537 }
4538 return eSIR_SUCCESS;
4539}
4540/** -------------------------------------------------------------
4541\fn limEnableHT20Protection
4542\brief based on cofig enables\disables protection from Ht20.
4543\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4544\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4545\param tpUpdateBeaconParams pBeaconParams
4546\return None
4547 -------------------------------------------------------------*/
4548tSirRetStatus
4549limEnableHT20Protection(tpAniSirGlobal pMac, tANI_U8 enable,
4550 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4551{
Jeff Johnsone7245742012-09-05 17:12:55 -07004552 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 return eSIR_SUCCESS; // this protection is only for HT stations.
4554
4555 //overlapping protection configuration check.
4556 if(overlap)
4557 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 }
4559 else
4560 {
4561 //normal protection config check
Jeff Johnson295189b2012-06-20 16:38:30 -07004562 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
4563 !psessionEntry->cfgProtection.ht20)
4564 {
4565 // protection disabled.
4566 PELOG3(limLog(pMac, LOG3, FL("protection from HT20 is disabled\n"));)
4567 return eSIR_SUCCESS;
4568 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 {
4570 if(!pMac->lim.cfgProtection.ht20)
4571 {
4572 // protection disabled.
4573 PELOG3(limLog(pMac, LOG3, FL("protection from HT20 is disabled\n"));)
4574 return eSIR_SUCCESS;
4575 }
4576 }
4577 }
4578
4579 if (enable)
4580 {
4581 //If we are AP and HT capable, we need to set the HT OP mode
4582 //appropriately.
4583
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 if(eLIM_AP_ROLE == psessionEntry->limSystemRole){
4585 if(overlap)
4586 {
4587 psessionEntry->gLimOverlapHt20Params.protectionEnabled = true;
4588 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != psessionEntry->htOperMode) &&
4589 (eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode))
4590 {
4591 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4592 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4593 }
4594 }
4595 else
4596 {
4597 psessionEntry->gLimHt20Params.protectionEnabled = true;
4598 if(eSIR_HT_OP_MODE_PURE == psessionEntry->htOperMode)
4599 {
4600 //Commenting because of CR 258588 WFA cert
4601 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4602 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4603 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4604 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4605 }
4606 }
4607 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 {
4609 if(overlap)
4610 {
4611 pMac->lim.gLimOverlapHt20Params.protectionEnabled = true;
4612 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
4613 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
4614 {
4615 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4616 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4617 }
4618 }
4619 else
4620 {
4621 psessionEntry->gLimHt20Params.protectionEnabled = true;
4622 if(eSIR_HT_OP_MODE_PURE == pMac->lim.gHTOperMode)
4623 {
4624 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4625 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4626 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4627 }
4628 }
4629 }
4630
4631 //This part is common for staiton as well.
4632 if(false == psessionEntry->beaconParams.ht20Coexist)
4633 {
4634 PELOG1(limLog(pMac, LOG1, FL("=> Prtection from HT20 Enabled\n"));)
4635 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = true;
4636 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
4637 }
4638 }
4639 else if (true == psessionEntry->beaconParams.ht20Coexist)
4640 {
4641 //for AP role.
4642 //we need to take care of HT OP mode change if needed.
4643 //We need to take care of Overlap cases.
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 if(eLIM_AP_ROLE == psessionEntry->limSystemRole){
4645 if(overlap)
4646 {
4647 //Overlap Legacy protection disabled.
4648 psessionEntry->gLimOverlapHt20Params.protectionEnabled = false;
4649
4650 // no HT op mode change if any of the overlap protection enabled.
4651 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
4652 psessionEntry->gLimOverlap11gParams.protectionEnabled ||
4653 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4654 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
4655 {
4656
4657 //Check if there is a need to change HT OP mode.
4658 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == psessionEntry->htOperMode)
4659 {
4660 if(psessionEntry->gLimHt20Params.protectionEnabled)
4661 {
4662 //Commented beacuse of CR 258588 for WFA Cert
4663 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4664 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4665 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4666 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4667 }
4668 else
4669 {
4670 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4671 }
4672 }
4673 }
4674 }
4675 else
4676 {
4677 //Disable protection from 11G stations.
4678 psessionEntry->gLimHt20Params.protectionEnabled = false;
4679
4680 //Change HT op mode appropriately.
4681 if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == psessionEntry->htOperMode)
4682 {
4683 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4684 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4685 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4686 }
4687 }
4688 PELOG1(limLog(pMac, LOG1, FL("===> Protection from HT 20 Disabled\n"));)
4689 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = false;
4690 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
4691 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 {
4693 if(overlap)
4694 {
4695 //Overlap Legacy protection disabled.
4696 pMac->lim.gLimOverlapHt20Params.protectionEnabled = false;
4697
4698 // no HT op mode change if any of the overlap protection enabled.
4699 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
4700 pMac->lim.gLimOverlap11gParams.protectionEnabled ||
4701 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4702 pMac->lim.gLimOverlapNonGfParams.protectionEnabled))
4703 {
4704
4705 //Check if there is a need to change HT OP mode.
4706 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
4707 {
4708 if(psessionEntry->gLimHt20Params.protectionEnabled)
4709 {
4710 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4711 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4712 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4713 }
4714 else
4715 {
4716 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4717 }
4718 }
4719 }
4720 }
4721 else
4722 {
4723 //Disable protection from 11G stations.
4724 psessionEntry->gLimHt20Params.protectionEnabled = false;
4725
4726 //Change HT op mode appropriately.
4727 if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == pMac->lim.gHTOperMode)
4728 {
4729 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4730 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4731 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4732 }
4733 }
4734 PELOG1(limLog(pMac, LOG1, FL("===> Protection from HT 20 Disabled\n"));)
4735 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = false;
4736 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
4737 }
4738 //for station role
4739 else
4740 {
4741 PELOG1(limLog(pMac, LOG1, FL("===> Protection from HT20 Disabled\n"));)
4742 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = false;
4743 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
4744 }
4745 }
4746
4747 return eSIR_SUCCESS;
4748}
4749
4750/** -------------------------------------------------------------
4751\fn limEnableHTNonGfProtection
4752\brief based on cofig enables\disables protection from NonGf.
4753\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4754\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4755\param tpUpdateBeaconParams pBeaconParams
4756\return None
4757 -------------------------------------------------------------*/
4758tSirRetStatus
4759limEnableHTNonGfProtection(tpAniSirGlobal pMac, tANI_U8 enable,
4760 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4761{
Jeff Johnsone7245742012-09-05 17:12:55 -07004762 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 return eSIR_SUCCESS; // this protection is only for HT stations.
4764
4765 //overlapping protection configuration check.
4766 if(overlap)
4767 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 }
4769 else
4770 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 //normal protection config check
4772 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
4773 !psessionEntry->cfgProtection.nonGf)
4774 {
4775 // protection disabled.
4776 PELOG3(limLog(pMac, LOG3, FL("protection from NonGf is disabled\n"));)
4777 return eSIR_SUCCESS;
4778 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004779 {
4780 //normal protection config check
4781 if(!pMac->lim.cfgProtection.nonGf)
4782 {
4783 // protection disabled.
4784 PELOG3(limLog(pMac, LOG3, FL("protection from NonGf is disabled\n"));)
4785 return eSIR_SUCCESS;
4786 }
4787 }
4788 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
4790 if ((enable) && (false == psessionEntry->beaconParams.llnNonGFCoexist))
4791 {
4792 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from non GF Enabled\n"));)
4793 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = true;
4794 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
4795 }
4796 else if (!enable && (true == psessionEntry->beaconParams.llnNonGFCoexist))
4797 {
4798 PELOG1(limLog(pMac, LOG1, FL("===> Protection from Non GF Disabled\n"));)
4799 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = false;
4800 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
4801 }
4802 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 {
4804 if ((enable) && (false == psessionEntry->beaconParams.llnNonGFCoexist))
4805 {
4806 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from non GF Enabled\n"));)
4807 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = true;
4808 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
4809 }
4810 else if (!enable && (true == psessionEntry->beaconParams.llnNonGFCoexist))
4811 {
4812 PELOG1(limLog(pMac, LOG1, FL("===> Protection from Non GF Disabled\n"));)
4813 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = false;
4814 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
4815 }
4816 }
4817
4818 return eSIR_SUCCESS;
4819}
4820
4821/** -------------------------------------------------------------
4822\fn limEnableHTLsigTxopProtection
4823\brief based on cofig enables\disables LsigTxop protection.
4824\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4825\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4826\param tpUpdateBeaconParams pBeaconParams
4827\return None
4828 -------------------------------------------------------------*/
4829tSirRetStatus
4830limEnableHTLsigTxopProtection(tpAniSirGlobal pMac, tANI_U8 enable,
4831 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4832{
Jeff Johnsone7245742012-09-05 17:12:55 -07004833 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004834 return eSIR_SUCCESS; // this protection is only for HT stations.
4835
4836 //overlapping protection configuration check.
4837 if(overlap)
4838 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 }
4840 else
4841 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 //normal protection config check
4843 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
4844 !psessionEntry->cfgProtection.lsigTxop)
4845 {
4846 // protection disabled.
4847 PELOG3(limLog(pMac, LOG3, FL(" protection from LsigTxop not supported is disabled\n"));)
4848 return eSIR_SUCCESS;
4849 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004850 {
4851 //normal protection config check
4852 if(!pMac->lim.cfgProtection.lsigTxop)
4853 {
4854 // protection disabled.
4855 PELOG3(limLog(pMac, LOG3, FL(" protection from LsigTxop not supported is disabled\n"));)
4856 return eSIR_SUCCESS;
4857 }
4858 }
4859 }
4860
4861
Jeff Johnson295189b2012-06-20 16:38:30 -07004862 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
4863 if ((enable) && (false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
4864 {
4865 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from LsigTxop Enabled\n"));)
4866 pBeaconParams->fLsigTXOPProtectionFullSupport = psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = true;
4867 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
4868 }
4869 else if (!enable && (true == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
4870 {
4871 PELOG1(limLog(pMac, LOG1, FL("===> Protection from LsigTxop Disabled\n"));)
4872 pBeaconParams->fLsigTXOPProtectionFullSupport= psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = false;
4873 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
4874 }
4875 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 {
4877 if ((enable) && (false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
4878 {
4879 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from LsigTxop Enabled\n"));)
4880 pBeaconParams->fLsigTXOPProtectionFullSupport = psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = true;
4881 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
4882 }
4883 else if (!enable && (true == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
4884 {
4885 PELOG1(limLog(pMac, LOG1, FL("===> Protection from LsigTxop Disabled\n"));)
4886 pBeaconParams->fLsigTXOPProtectionFullSupport= psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = false;
4887 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
4888 }
4889 }
4890 return eSIR_SUCCESS;
4891}
4892//FIXME_PROTECTION : need to check for no APSD whenever we want to enable this protection.
4893//This check will be done at the caller.
4894/** -------------------------------------------------------------
4895\fn limEnableHtRifsProtection
4896\brief based on cofig enables\disables Rifs protection.
4897\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4898\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4899\param tpUpdateBeaconParams pBeaconParams
4900\return None
4901 -------------------------------------------------------------*/
4902tSirRetStatus
4903limEnableHtRifsProtection(tpAniSirGlobal pMac, tANI_U8 enable,
4904 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4905{
Jeff Johnsone7245742012-09-05 17:12:55 -07004906 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 return eSIR_SUCCESS; // this protection is only for HT stations.
4908
4909
4910 //overlapping protection configuration check.
4911 if(overlap)
4912 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 }
4914 else
4915 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 //normal protection config check
4917 if((psessionEntry->limSystemRole == eLIM_AP_ROLE) &&
4918 !psessionEntry->cfgProtection.rifs)
4919 {
4920 // protection disabled.
4921 PELOG3(limLog(pMac, LOG3, FL(" protection from Rifs is disabled\n"));)
4922 return eSIR_SUCCESS;
4923 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 {
4925 //normal protection config check
4926 if(!pMac->lim.cfgProtection.rifs)
4927 {
4928 // protection disabled.
4929 PELOG3(limLog(pMac, LOG3, FL(" protection from Rifs is disabled\n"));)
4930 return eSIR_SUCCESS;
4931 }
4932 }
4933 }
4934
Jeff Johnson295189b2012-06-20 16:38:30 -07004935 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
4936 // Disabling the RIFS Protection means Enable the RIFS mode of operation in the BSS
4937 if ((!enable) && (false == psessionEntry->beaconParams.fRIFSMode))
4938 {
4939 PELOG1(limLog(pMac, LOG1, FL(" => Rifs protection Disabled\n"));)
4940 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = true;
4941 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
4942 }
4943 // Enabling the RIFS Protection means Disable the RIFS mode of operation in the BSS
4944 else if (enable && (true == psessionEntry->beaconParams.fRIFSMode))
4945 {
4946 PELOG1(limLog(pMac, LOG1, FL("===> Rifs Protection Enabled\n"));)
4947 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = false;
4948 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
4949 }
4950 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 {
4952 // Disabling the RIFS Protection means Enable the RIFS mode of operation in the BSS
4953 if ((!enable) && (false == psessionEntry->beaconParams.fRIFSMode))
4954 {
4955 PELOG1(limLog(pMac, LOG1, FL(" => Rifs protection Disabled\n"));)
4956 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = true;
4957 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
4958 }
4959 // Enabling the RIFS Protection means Disable the RIFS mode of operation in the BSS
4960 else if (enable && (true == psessionEntry->beaconParams.fRIFSMode))
4961 {
4962 PELOG1(limLog(pMac, LOG1, FL("===> Rifs Protection Enabled\n"));)
4963 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = false;
4964 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
4965 }
4966 }
4967 return eSIR_SUCCESS;
4968}
4969
4970// ---------------------------------------------------------------------
4971/**
4972 * limEnableShortPreamble
4973 *
4974 * FUNCTION:
4975 * Enable/Disable short preamble
4976 *
4977 * LOGIC:
4978 *
4979 * ASSUMPTIONS:
4980 *
4981 * NOTE:
4982 *
4983 * @param enable Flag to enable/disable short preamble
4984 * @return None
4985 */
4986
4987tSirRetStatus
4988limEnableShortPreamble(tpAniSirGlobal pMac, tANI_U8 enable, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
4989{
4990 tANI_U32 val;
4991
4992 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val) != eSIR_SUCCESS)
4993 {
4994 /* Could not get short preamble enabled flag from CFG. Log error. */
4995 limLog(pMac, LOGP, FL("could not retrieve short preamble flag\n"));
4996 return eSIR_FAILURE;
4997 }
4998
4999 if (!val)
5000 return eSIR_SUCCESS;
5001
5002 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_PREAMBLE_ENABLED, &val) != eSIR_SUCCESS)
5003 {
5004 limLog(pMac, LOGP, FL("could not retrieve 11G short preamble switching enabled flag\n"));
5005 return eSIR_FAILURE;
5006 }
5007
5008 if (!val) // 11G short preamble switching is disabled.
5009 return eSIR_SUCCESS;
5010
5011 if ( psessionEntry->limSystemRole == eLIM_AP_ROLE )
5012 {
5013 if (enable && (psessionEntry->beaconParams.fShortPreamble == 0))
5014 {
5015 PELOG1(limLog(pMac, LOG1, FL("===> Short Preamble Enabled\n"));)
5016 psessionEntry->beaconParams.fShortPreamble = true;
5017 pBeaconParams->fShortPreamble = (tANI_U8) psessionEntry->beaconParams.fShortPreamble;
5018 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_PREAMBLE_CHANGED;
5019 }
5020 else if (!enable && (psessionEntry->beaconParams.fShortPreamble == 1))
5021 {
5022 PELOG1(limLog(pMac, LOG1, FL("===> Short Preamble Disabled\n"));)
5023 psessionEntry->beaconParams.fShortPreamble = false;
5024 pBeaconParams->fShortPreamble = (tANI_U8) psessionEntry->beaconParams.fShortPreamble;
5025 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_PREAMBLE_CHANGED;
5026 }
5027 }
5028
5029 return eSIR_SUCCESS;
5030 }
5031
5032/**
5033 * limTxComplete
5034 *
5035 * Function:
5036 * This is LIM's very own "TX MGMT frame complete" completion routine.
5037 *
5038 * Logic:
5039 * LIM wants to send a MGMT frame (broadcast or unicast)
5040 * LIM allocates memory using palPktAlloc( ..., **pData, **pPacket )
5041 * LIM transmits the MGMT frame using the API:
5042 * halTxFrame( ... pPacket, ..., (void *) limTxComplete, pData )
5043 * HDD, via halTxFrame/DXE, "transfers" the packet over to BMU
5044 * HDD, if it determines that a TX completion routine (in this case
5045 * limTxComplete) has been provided, will invoke this callback
5046 * LIM will try to free the TX MGMT packet that was earlier allocated, in order
5047 * to send this MGMT frame, using the PAL API palPktFree( ... pData, pPacket )
5048 *
5049 * Assumptions:
5050 * Presently, this is ONLY being used for MGMT frames/packets
5051 * TODO:
5052 * Would it do good for LIM to have some sort of "signature" validation to
5053 * ensure that the pData argument passed in was a buffer that was actually
5054 * allocated by LIM and/or is not corrupted?
5055 *
5056 * Note: FIXME and TODO
5057 * Looks like palPktFree() is interested in pPacket. But, when this completion
5058 * routine is called, only pData is made available to LIM!!
5059 *
5060 * @param void A pointer to pData. Shouldn't it be pPacket?!
5061 *
5062 * @return none
5063 */
5064void limTxComplete( tHalHandle hHal, void *pData )
5065{
5066 tpAniSirGlobal pMac;
5067 pMac = (tpAniSirGlobal)hHal;
5068
5069#ifdef FIXME_PRIMA
5070 /* the trace logic needs to be fixed for Prima. Refer to CR 306075 */
5071#ifdef TRACE_RECORD
5072 {
5073 tpSirMacMgmtHdr mHdr;
5074 v_U8_t *pRxBd;
5075 vos_pkt_t *pVosPkt;
5076 VOS_STATUS vosStatus;
5077
5078
5079
5080 pVosPkt = (vos_pkt_t *)pData;
5081 vosStatus = vos_pkt_peek_data( pVosPkt, 0, (v_PVOID_t *)&pRxBd, WLANHAL_RX_BD_HEADER_SIZE);
5082
5083 if(VOS_IS_STATUS_SUCCESS(vosStatus))
5084 {
5085 mHdr = WDA_GET_RX_MAC_HEADER(pRxBd);
Jeff Johnsone7245742012-09-05 17:12:55 -07005086 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE, NO_SESSION, mHdr->fc.subType);)
Jeff Johnson295189b2012-06-20 16:38:30 -07005087
5088 }
5089 }
5090#endif
5091#endif
5092
5093 palPktFree( pMac->hHdd,
5094 HAL_TXRX_FRM_802_11_MGMT,
5095 (void *) NULL, // this is ignored and will likely be removed from this API
5096 (void *) pData ); // lim passed in pPacket in the pData pointer that is given in this completion routine
5097}
5098
5099/**
5100 * \brief This function updates lim global structure, if CB parameters in the BSS
5101 * have changed, and sends an indication to HAL also with the
5102 * updated HT Parameters.
5103 * This function does not detect the change in the primary channel, that is done as part
5104 * of channel Swtich IE processing.
5105 * If STA is configured with '20Mhz only' mode, then this function does not do anything
5106 * This function changes the CB mode, only if the self capability is set to '20 as well as 40Mhz'
5107 *
5108 *
5109 * \param pMac Pointer to global MAC structure
5110 *
5111 * \param pRcvdHTInfo Pointer to HT Info IE obtained from a Beacon or
5112 * Probe Response
5113 *
5114 * \param bssIdx BSS Index of the Bss to which Station is associated.
5115 *
5116 *
5117 */
5118
5119void limUpdateStaRunTimeHTSwitchChnlParams( tpAniSirGlobal pMac,
5120 tDot11fIEHTInfo *pHTInfo,
5121 tANI_U8 bssIdx,
5122 tpPESession psessionEntry)
5123{
Jeff Johnsone7245742012-09-05 17:12:55 -07005124 ePhyChanBondState secondaryChnlOffset = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07005125#if !defined WLAN_FEATURE_VOWIFI
5126 tANI_U32 localPwrConstraint;
5127#endif
5128
5129 //If self capability is set to '20Mhz only', then do not change the CB mode.
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 if( !limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005131 return;
5132
5133#if !defined WLAN_FEATURE_VOWIFI
5134 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
5135 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg\n" ));
5136 return;
5137 }
5138#endif
5139
Jeff Johnsone7245742012-09-05 17:12:55 -07005140 if ( psessionEntry->htSecondaryChannelOffset != ( tANI_U8 ) pHTInfo->secondaryChannelOffset ||
5141 psessionEntry->htRecommendedTxWidthSet != ( tANI_U8 ) pHTInfo->recommendedTxWidthSet )
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005143 psessionEntry->htSecondaryChannelOffset = ( ePhyChanBondState ) pHTInfo->secondaryChannelOffset;
5144 psessionEntry->htRecommendedTxWidthSet = ( tANI_U8 ) pHTInfo->recommendedTxWidthSet;
5145 if ( eHT_CHANNEL_WIDTH_40MHZ == psessionEntry->htRecommendedTxWidthSet )
5146 secondaryChnlOffset = (ePhyChanBondState)pHTInfo->secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07005147
5148 // Notify HAL
5149 limLog( pMac, LOGW, FL( "Channel Information in HT IE change"
5150 "d; sending notification to HAL.\n" ) );
5151 limLog( pMac, LOGW, FL( "Primary Channel: %d, Secondary Chan"
5152 "nel Offset: %d, Channel Width: %d\n" ),
5153 pHTInfo->primaryChannel, secondaryChnlOffset,
Jeff Johnsone7245742012-09-05 17:12:55 -07005154 psessionEntry->htRecommendedTxWidthSet );
Madan Mohan Koyyalamudifd322a02012-10-05 12:01:26 -07005155 psessionEntry->channelChangeReasonCode=LIM_SWITCH_CHANNEL_OPERATION;
5156 pMac->lim.gpchangeChannelCallback = NULL;
5157 pMac->lim.gpchangeChannelData = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005158
5159#if defined WLAN_FEATURE_VOWIFI
5160 limSendSwitchChnlParams( pMac, ( tANI_U8 ) pHTInfo->primaryChannel,
5161 secondaryChnlOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
5162#else
5163 limSendSwitchChnlParams( pMac, ( tANI_U8 ) pHTInfo->primaryChannel,
5164 secondaryChnlOffset, (tPowerdBm)localPwrConstraint, psessionEntry->peSessionId);
5165#endif
5166
5167 //In case of IBSS, if STA should update HT Info IE in its beacons.
5168 if (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole)
5169 {
5170 schSetFixedBeaconFields(pMac,psessionEntry);
5171 }
5172
5173 }
5174} // End limUpdateStaRunTimeHTParams.
5175
5176/**
5177 * \brief This function updates the lim global structure, if any of the
5178 * HT Capabilities have changed.
5179 *
5180 *
5181 * \param pMac Pointer to Global MAC structure
5182 *
5183 * \param pHTCapability Pointer to HT Capability Information Element
5184 * obtained from a Beacon or Probe Response
5185 *
5186 *
5187 *
5188 */
5189
5190void limUpdateStaRunTimeHTCapability( tpAniSirGlobal pMac,
5191 tDot11fIEHTCaps *pHTCaps )
5192{
5193
5194 if ( pMac->lim.gHTLsigTXOPProtection != ( tANI_U8 ) pHTCaps->lsigTXOPProtection )
5195 {
5196 pMac->lim.gHTLsigTXOPProtection = ( tANI_U8 ) pHTCaps->lsigTXOPProtection;
5197 // Send change notification to HAL
5198 }
5199
5200 if ( pMac->lim.gHTAMpduDensity != ( tANI_U8 ) pHTCaps->mpduDensity )
5201 {
5202 pMac->lim.gHTAMpduDensity = ( tANI_U8 ) pHTCaps->mpduDensity;
5203 // Send change notification to HAL
5204 }
5205
5206 if ( pMac->lim.gHTMaxRxAMpduFactor != ( tANI_U8 ) pHTCaps->maxRxAMPDUFactor )
5207 {
5208 pMac->lim.gHTMaxRxAMpduFactor = ( tANI_U8 ) pHTCaps->maxRxAMPDUFactor;
5209 // Send change notification to HAL
5210 }
5211
5212
5213} // End limUpdateStaRunTimeHTCapability.
5214
5215/**
5216 * \brief This function updates lim global structure, if any of the HT
5217 * Info Parameters have changed.
5218 *
5219 *
5220 * \param pMac Pointer to the global MAC structure
5221 *
5222 * \param pHTInfo Pointer to the HT Info IE obtained from a Beacon or
5223 * Probe Response
5224 *
5225 *
5226 */
5227
5228void limUpdateStaRunTimeHTInfo( tpAniSirGlobal pMac,
5229 tDot11fIEHTInfo *pHTInfo , tpPESession psessionEntry)
5230{
Jeff Johnsone7245742012-09-05 17:12:55 -07005231 if ( psessionEntry->htRecommendedTxWidthSet != ( tANI_U8 )pHTInfo->recommendedTxWidthSet )
Jeff Johnson295189b2012-06-20 16:38:30 -07005232 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005233 psessionEntry->htRecommendedTxWidthSet = ( tANI_U8 )pHTInfo->recommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 // Send change notification to HAL
5235 }
5236
5237 if ( psessionEntry->beaconParams.fRIFSMode != ( tANI_U8 )pHTInfo->rifsMode )
5238 {
5239 psessionEntry->beaconParams.fRIFSMode = ( tANI_U8 )pHTInfo->rifsMode;
5240 // Send change notification to HAL
5241 }
5242
5243 if ( pMac->lim.gHTServiceIntervalGranularity != ( tANI_U8 )pHTInfo->serviceIntervalGranularity )
5244 {
5245 pMac->lim.gHTServiceIntervalGranularity = ( tANI_U8 )pHTInfo->serviceIntervalGranularity;
5246 // Send change notification to HAL
5247 }
5248
5249 if ( pMac->lim.gHTOperMode != ( tSirMacHTOperatingMode )pHTInfo->opMode )
5250 {
5251 pMac->lim.gHTOperMode = ( tSirMacHTOperatingMode )pHTInfo->opMode;
5252 // Send change notification to HAL
5253 }
5254
5255 if ( psessionEntry->beaconParams.llnNonGFCoexist != pHTInfo->nonGFDevicesPresent )
5256 {
5257 psessionEntry->beaconParams.llnNonGFCoexist = ( tANI_U8 )pHTInfo->nonGFDevicesPresent;
5258 }
5259
5260 if ( pMac->lim.gHTSTBCBasicMCS != ( tANI_U8 )pHTInfo->basicSTBCMCS )
5261 {
5262 pMac->lim.gHTSTBCBasicMCS = ( tANI_U8 )pHTInfo->basicSTBCMCS;
5263 // Send change notification to HAL
5264 }
5265
5266 if ( pMac->lim.gHTDualCTSProtection != ( tANI_U8 )pHTInfo->dualCTSProtection )
5267 {
5268 pMac->lim.gHTDualCTSProtection = ( tANI_U8 )pHTInfo->dualCTSProtection;
5269 // Send change notification to HAL
5270 }
5271
5272 if ( pMac->lim.gHTSecondaryBeacon != ( tANI_U8 )pHTInfo->secondaryBeacon )
5273 {
5274 pMac->lim.gHTSecondaryBeacon = ( tANI_U8 )pHTInfo->secondaryBeacon;
5275 // Send change notification to HAL
5276 }
5277
5278 if ( psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport != ( tANI_U8 )pHTInfo->lsigTXOPProtectionFullSupport )
5279 {
5280 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = ( tANI_U8 )pHTInfo->lsigTXOPProtectionFullSupport;
5281 // Send change notification to HAL
5282 }
5283
5284 if ( pMac->lim.gHTPCOActive != ( tANI_U8 )pHTInfo->pcoActive )
5285 {
5286 pMac->lim.gHTPCOActive = ( tANI_U8 )pHTInfo->pcoActive;
5287 // Send change notification to HAL
5288 }
5289
5290 if ( pMac->lim.gHTPCOPhase != ( tANI_U8 )pHTInfo->pcoPhase )
5291 {
5292 pMac->lim.gHTPCOPhase = ( tANI_U8 )pHTInfo->pcoPhase;
5293 // Send change notification to HAL
5294 }
5295
5296} // End limUpdateStaRunTimeHTInfo.
5297
5298
5299/** -------------------------------------------------------------
5300\fn limProcessHalIndMessages
5301\brief callback function for HAL indication
5302\param tpAniSirGlobal pMac
5303\param tANI_U32 mesgId
5304\param void *mesgParam
5305\return tSirRetStatu - status
5306 -------------------------------------------------------------*/
5307
5308tSirRetStatus limProcessHalIndMessages(tpAniSirGlobal pMac, tANI_U32 msgId, void *msgParam )
5309{
5310 //its PE's responsibility to free msgparam when its done extracting the message parameters.
5311 tSirMsgQ msg;
5312
5313 switch(msgId)
5314 {
5315 case SIR_LIM_DEL_TS_IND:
5316 case SIR_LIM_ADD_BA_IND:
5317 case SIR_LIM_DEL_BA_ALL_IND:
5318 case SIR_LIM_DELETE_STA_CONTEXT_IND:
5319 case SIR_LIM_BEACON_GEN_IND:
5320 msg.type = (tANI_U16) msgId;
5321 msg.bodyptr = msgParam;
5322 msg.bodyval = 0;
5323 break;
5324
5325 default:
5326 palFreeMemory(pMac->hHdd, msgParam);
5327 limLog(pMac, LOGP, FL("invalid message id = %d received\n"), msgId);
5328 return eSIR_FAILURE;
5329 }
5330
5331 if (limPostMsgApi(pMac, &msg) != eSIR_SUCCESS)
5332 {
5333 palFreeMemory(pMac->hHdd, msgParam);
5334 limLog(pMac, LOGP, FL("limPostMsgApi failed for msgid = %d"), msg.type);
5335 return eSIR_FAILURE;
5336 }
5337 return eSIR_SUCCESS;
5338}
5339
5340/** -------------------------------------------------------------
5341\fn limValidateDeltsReq
5342\brief Validates DelTs req originated by SME or by HAL and also sends halMsg_DelTs to HAL
5343\param tpAniSirGlobal pMac
5344\param tpSirDeltsReq pDeltsReq
5345\param tSirMacAddr peerMacAddr
5346\return eSirRetStatus - status
5347 -------------------------------------------------------------*/
5348
5349tSirRetStatus
5350limValidateDeltsReq(tpAniSirGlobal pMac, tpSirDeltsReq pDeltsReq, tSirMacAddr peerMacAddr,tpPESession psessionEntry)
5351{
5352 tpDphHashNode pSta;
5353 tANI_U8 tsStatus;
5354 tSirMacTSInfo *tsinfo;
5355 tANI_U32 i;
5356 tANI_U8 tspecIdx;
5357 /* if sta
5358 * - verify assoc state
5359 * - del tspec locally
5360 * if ap,
5361 * - verify sta is in assoc state
5362 * - del sta tspec locally
5363 */
5364 if(pDeltsReq == NULL)
5365 {
5366 PELOGE(limLog(pMac, LOGE, FL("Delete TS request pointer is NULL\n"));)
5367 return eSIR_FAILURE;
5368 }
5369
5370 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
5371 {
5372 tANI_U32 val;
5373
5374 // station always talks to the AP
5375 pSta = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
5376
5377 val = sizeof(tSirMacAddr);
5378 #if 0
5379 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMacAddr, &val) != eSIR_SUCCESS)
5380 {
5381 /// Could not get BSSID from CFG. Log error.
5382 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
5383 return eSIR_FAILURE;
5384 }
5385 #endif// TO SUPPORT BT-AMP
5386 sirCopyMacAddr(peerMacAddr,psessionEntry->bssId);
5387
5388 }
5389 else
5390 {
5391 tANI_U16 assocId;
5392 tANI_U8 *macaddr = (tANI_U8 *) peerMacAddr;
5393
5394 assocId = pDeltsReq->aid;
5395 if (assocId != 0)
5396 pSta = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
5397 else
5398 pSta = dphLookupHashEntry(pMac, pDeltsReq->macAddr, &assocId, &psessionEntry->dph.dphHashTable);
5399
5400 if (pSta != NULL)
5401 // TBD: check sta assoc state as well
5402 for (i =0; i < sizeof(tSirMacAddr); i++)
5403 macaddr[i] = pSta->staAddr[i];
5404 }
5405
5406 if (pSta == NULL)
5407 {
5408 PELOGE(limLog(pMac, LOGE, "Cannot find station context for delts req\n");)
5409 return eSIR_FAILURE;
5410 }
5411
5412 if ((! pSta->valid) ||
5413 (pSta->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE))
5414 {
5415 PELOGE(limLog(pMac, LOGE, "Invalid Sta (or state) for DelTsReq\n");)
5416 return eSIR_FAILURE;
5417 }
5418
5419 pDeltsReq->req.wsmTspecPresent = 0;
5420 pDeltsReq->req.wmeTspecPresent = 0;
5421 pDeltsReq->req.lleTspecPresent = 0;
5422
5423 if ((pSta->wsmEnabled) &&
5424 (pDeltsReq->req.tspec.tsinfo.traffic.accessPolicy != SIR_MAC_ACCESSPOLICY_EDCA))
5425 pDeltsReq->req.wsmTspecPresent = 1;
5426 else if (pSta->wmeEnabled)
5427 pDeltsReq->req.wmeTspecPresent = 1;
5428 else if (pSta->lleEnabled)
5429 pDeltsReq->req.lleTspecPresent = 1;
5430 else
5431 {
5432 PELOGW(limLog(pMac, LOGW, FL("DELTS_REQ ignore - qos is disabled\n"));)
5433 return eSIR_FAILURE;
5434 }
5435
5436 tsinfo = pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.tsinfo
5437 : &pDeltsReq->req.tsinfo;
5438 PELOG1(limLog(pMac, LOG1,
5439 FL("received DELTS_REQ message (wmeTspecPresent = %d, lleTspecPresent = %d, wsmTspecPresent = %d, tsid %d, up %d, direction = %d)\n"),
5440 pDeltsReq->req.wmeTspecPresent, pDeltsReq->req.lleTspecPresent, pDeltsReq->req.wsmTspecPresent,
5441 tsinfo->traffic.tsid, tsinfo->traffic.userPrio, tsinfo->traffic.direction);)
5442
5443 // if no Access Control, ignore the request
Jeff Johnson295189b2012-06-20 16:38:30 -07005444
5445 if (limAdmitControlDeleteTS(pMac, pSta->assocId, tsinfo, &tsStatus, &tspecIdx)
5446 != eSIR_SUCCESS)
5447 {
5448 PELOGE(limLog(pMac, LOGE, "ERROR DELTS request for sta assocId %d (tsid %d, up %d)\n",
5449 pSta->assocId, tsinfo->traffic.tsid, tsinfo->traffic.userPrio);)
5450 return eSIR_FAILURE;
5451 }
5452 else if ((tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
5453 (tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH))
5454 {
5455 //edca only now.
5456 }
5457 else
5458 {
5459 if((tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_EDCA) &&
5460 psessionEntry->gLimEdcaParams[upToAc(tsinfo->traffic.userPrio)].aci.acm)
5461 {
5462 //send message to HAL to delete TS
Jeff Johnsone7245742012-09-05 17:12:55 -07005463 if(eSIR_SUCCESS != limSendHalMsgDelTs(pMac, pSta->staIndex, tspecIdx, pDeltsReq->req, psessionEntry->peSessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 {
5465 limLog(pMac, LOGW, FL("DelTs with UP %d failed in limSendHalMsgDelTs - ignoring request\n"),
5466 tsinfo->traffic.userPrio);
5467 return eSIR_FAILURE;
5468 }
5469 }
5470 }
5471 return eSIR_SUCCESS;
5472}
5473
5474/** -------------------------------------------------------------
5475\fn limRegisterHalIndCallBack
5476\brief registers callback function to HAL for any indication.
5477\param tpAniSirGlobal pMac
5478\return none.
5479 -------------------------------------------------------------*/
5480void
5481limRegisterHalIndCallBack(tpAniSirGlobal pMac)
5482{
5483 tSirMsgQ msg;
5484 tpHalIndCB pHalCB;
5485
5486 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pHalCB, sizeof(tHalIndCB)))
5487 {
5488 limLog(pMac, LOGP, FL("palAllocateMemory() failed\n"));
5489 return;
5490 }
5491
5492 pHalCB->pHalIndCB = limProcessHalIndMessages;
5493
5494 msg.type = WDA_REGISTER_PE_CALLBACK;
5495 msg.bodyptr = pHalCB;
5496 msg.bodyval = 0;
5497
Jeff Johnsone7245742012-09-05 17:12:55 -07005498 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07005499 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5500 {
5501 palFreeMemory(pMac->hHdd, pHalCB);
5502 limLog(pMac, LOGP, FL("wdaPostCtrlMsg() failed\n"));
5503 }
5504
5505 return;
5506}
5507
5508
5509/** -------------------------------------------------------------
5510\fn limProcessAddBaInd
5511
5512\brief handles the BA activity check timeout indication coming from HAL.
5513 Validates the request, posts request for sending addBaReq message for every candidate in the list.
5514\param tpAniSirGlobal pMac
5515\param tSirMsgQ limMsg
5516\return None
5517-------------------------------------------------------------*/
5518void
5519limProcessAddBaInd(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
5520{
5521 tANI_U8 i;
5522 tANI_U8 tid;
5523 tANI_U16 assocId;
5524 tpDphHashNode pSta;
5525 tpAddBaCandidate pBaCandidate;
5526 tANI_U32 baCandidateCnt;
5527 tpBaActivityInd pBaActivityInd;
5528 tpPESession psessionEntry;
5529 tANI_U8 sessionId;
5530
5531
5532
5533 if(limMsg->bodyptr == NULL)
5534 return;
5535
5536 pBaActivityInd = (tpBaActivityInd)limMsg->bodyptr;
5537 baCandidateCnt = pBaActivityInd->baCandidateCnt;
5538
5539 if((psessionEntry = peFindSessionByBssid(pMac,pBaActivityInd->bssId,&sessionId))== NULL)
5540 {
5541 limLog(pMac, LOGE,FL("session does not exist for given BSSId\n"));
5542 palFreeMemory(pMac->hHdd, limMsg->bodyptr);
5543 return;
5544 }
5545
5546 //if we are not HT capable we don't need to handle BA timeout indication from HAL.
Jeff Johnsone7245742012-09-05 17:12:55 -07005547 if( (baCandidateCnt > pMac->lim.maxStation) || !psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 {
5549 palFreeMemory(pMac->hHdd, limMsg->bodyptr);
5550 return;
5551 }
5552
5553 //delete the complete dialoguetoken linked list
5554 limDeleteDialogueTokenList(pMac);
5555 pBaCandidate = (tpAddBaCandidate) (((tANI_U8*)pBaActivityInd) + sizeof(tBaActivityInd));
5556
5557 for(i=0; i<baCandidateCnt; i++, pBaCandidate++)
5558 {
5559 pSta = dphLookupHashEntry(pMac, pBaCandidate->staAddr, &assocId, &psessionEntry->dph.dphHashTable);
5560 if( (NULL == pSta) || (!pSta->valid))
5561 continue;
5562
5563 for (tid=0; tid<STACFG_MAX_TC; tid++)
5564 {
5565 if( (eBA_DISABLE == pSta->tcCfg[tid].fUseBATx) &&
5566 (pBaCandidate->baInfo[tid].fBaEnable))
5567 {
5568 PELOG2(limLog(pMac, LOG2, FL("BA setup for staId = %d, TID: %d, SSN:%d.\n"),
5569 pSta->staIndex, tid, pBaCandidate->baInfo[tid].startingSeqNum);)
5570 limPostMlmAddBAReq(pMac, pSta, tid, pBaCandidate->baInfo[tid].startingSeqNum,psessionEntry);
5571 }
5572 }
5573 }
5574 palFreeMemory(pMac->hHdd, limMsg->bodyptr);
5575 return;
5576}
5577
5578
5579/** -------------------------------------------------------------
5580\fn limDelAllBASessions
5581\brief Deletes all the exisitng BA sessions.
5582\ Note : This API is provided for Mac OSx only. The reason for this is that Mac OSx may not
5583\ restart after CFG update.
5584\param tpAniSirGlobal pMac
5585\return None
5586-------------------------------------------------------------*/
5587
5588void
5589limDelAllBASessions(tpAniSirGlobal pMac)
5590{
5591 tANI_U32 i;
5592 tANI_U8 tid;
5593 tpDphHashNode pSta;
5594
5595 tpPESession psessionEntry = &pMac->lim.gpSession[0]; //TBD-RAJESH HOW TO GET sessionEntry?????
5596 for(tid = 0; tid < STACFG_MAX_TC; tid++)
5597 {
5598 if((eLIM_AP_ROLE == psessionEntry->limSystemRole) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)||
5599 (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole))
5600 {
5601 for(i = 0; i < pMac->lim.maxStation; i++)
5602 {
5603 pSta = psessionEntry->dph.dphHashTable.pDphNodeArray + i;
5604 if (pSta && pSta->added)
5605 {
5606 if(eBA_ENABLE == pSta->tcCfg[tid].fUseBATx)
5607 {
5608 limPostMlmDelBAReq(pMac, pSta, eBA_INITIATOR, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
5609 }
5610 else if(eBA_ENABLE == pSta->tcCfg[tid].fUseBARx)
5611 {
5612 limPostMlmDelBAReq(pMac, pSta, eBA_RECIPIENT, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
5613 }
5614 }
5615 }
5616 }
5617 else if((eLIM_STA_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_STA_ROLE == psessionEntry->limSystemRole))
5618 {
5619 pSta = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
5620 if (pSta && pSta->added)
5621 {
5622 if(eBA_ENABLE == pSta->tcCfg[tid].fUseBATx)
5623 {
5624 limPostMlmDelBAReq(pMac, pSta, eBA_INITIATOR, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
5625 }
5626 if(eBA_ENABLE == pSta->tcCfg[tid].fUseBARx)
5627 {
5628 limPostMlmDelBAReq(pMac, pSta, eBA_RECIPIENT, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
5629 }
5630 }
5631 }
5632 }
5633}
5634/** -------------------------------------------------------------
5635\fn limProcessDelTsInd
5636\brief handles the DeleteTS indication coming from HAL or generated by PE itself in some error cases.
5637 Validates the request, sends the DelTs action frame to the Peer and sends DelTs indicatoin to HDD.
5638\param tpAniSirGlobal pMac
5639\param tSirMsgQ limMsg
5640\return None
5641-------------------------------------------------------------*/
5642void
5643limProcessDelTsInd(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
5644{
5645 tpDphHashNode pSta;
5646 tpDelTsParams pDelTsParam = (tpDelTsParams) (limMsg->bodyptr);
5647 tpSirDeltsReq pDelTsReq = NULL;
5648 tSirMacAddr peerMacAddr;
5649 tpSirDeltsReqInfo pDelTsReqInfo;
5650 tpLimTspecInfo pTspecInfo;
5651 tpPESession psessionEntry;
5652 tANI_U8 sessionId;
5653
5654if((psessionEntry = peFindSessionByBssid(pMac,pDelTsParam->bssId,&sessionId))== NULL)
5655 {
5656 limLog(pMac, LOGE,FL("session does not exist for given BssId\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07005657 palFreeMemory(pMac->hHdd, (void *)(limMsg->bodyptr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 return;
5659 }
5660
5661 pTspecInfo = &(pMac->lim.tspecInfo[pDelTsParam->tspecIdx]);
5662 if(pTspecInfo->inuse == false)
5663 {
5664 PELOGE(limLog(pMac, LOGE, FL("tspec entry with index %d is not in use\n"), pDelTsParam->tspecIdx);)
5665 goto error1;
5666 }
5667
5668 pSta = dphGetHashEntry(pMac, pTspecInfo->assocId, &psessionEntry->dph.dphHashTable);
5669 if(pSta == NULL)
5670 {
5671 limLog(pMac, LOGE, FL("Could not find entry in DPH table for assocId = %d\n"),
5672 pTspecInfo->assocId);
5673 goto error1;
5674 }
5675
5676 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pDelTsReq, sizeof(tSirDeltsReq)))
5677 {
5678 PELOGE(limLog(pMac, LOGE, FL("palAllocateMemory() failed\n"));)
5679 goto error1;
5680 }
5681
5682 palZeroMemory( pMac->hHdd, (tANI_U8 *)pDelTsReq, sizeof(tSirDeltsReq));
5683
5684 if(pSta->wmeEnabled)
5685 palCopyMemory(pMac->hHdd, &(pDelTsReq->req.tspec), &(pTspecInfo->tspec), sizeof(tSirMacTspecIE));
5686 else
5687 palCopyMemory(pMac->hHdd, &(pDelTsReq->req.tsinfo), &(pTspecInfo->tspec.tsinfo), sizeof(tSirMacTSInfo));
5688
5689
5690 //validate the req
5691 if (eSIR_SUCCESS != limValidateDeltsReq(pMac, pDelTsReq, peerMacAddr,psessionEntry))
5692 {
5693 PELOGE(limLog(pMac, LOGE, FL("limValidateDeltsReq failed\n"));)
5694 goto error2;
5695 }
5696 PELOG1(limLog(pMac, LOG1, "Sent DELTS request to station with assocId = %d MacAddr = %x:%x:%x:%x:%x:%x\n",
5697 pDelTsReq->aid, peerMacAddr[0], peerMacAddr[1], peerMacAddr[2],
5698 peerMacAddr[3], peerMacAddr[4], peerMacAddr[5]);)
5699
5700 limSendDeltsReqActionFrame(pMac, peerMacAddr, pDelTsReq->req.wmeTspecPresent, &pDelTsReq->req.tsinfo, &pDelTsReq->req.tspec,
5701 psessionEntry);
5702
5703 // prepare and send an sme indication to HDD
5704 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pDelTsReqInfo, sizeof(tSirDeltsReqInfo)))
5705 {
5706 PELOGE(limLog(pMac, LOGE, FL("palAllocateMemory() failed\n"));)
5707 goto error3;
5708 }
5709 palZeroMemory( pMac->hHdd, (tANI_U8 *)pDelTsReqInfo, sizeof(tSirDeltsReqInfo));
5710
5711 if(pSta->wmeEnabled)
5712 palCopyMemory(pMac->hHdd, &(pDelTsReqInfo->tspec), &(pTspecInfo->tspec), sizeof(tSirMacTspecIE));
5713 else
5714 palCopyMemory(pMac->hHdd, &(pDelTsReqInfo->tsinfo), &(pTspecInfo->tspec.tsinfo), sizeof(tSirMacTSInfo));
5715
5716 limSendSmeDeltsInd(pMac, pDelTsReqInfo, pDelTsReq->aid,psessionEntry);
5717
5718error3:
5719 palFreeMemory(pMac->hHdd, (void *) pDelTsReqInfo);
5720error2:
5721 palFreeMemory(pMac->hHdd, (void *) pDelTsReq);
5722error1:
5723 palFreeMemory(pMac->hHdd, (void *)(limMsg->bodyptr));
5724 return;
5725}
5726
5727/**
5728 * \brief Setup an A-MPDU/BA session
5729 *
5730 * \sa limPostMlmAddBAReq
5731 *
5732 * \param pMac The global tpAniSirGlobal object
5733 *
5734 * \param pStaDs DPH Hash Node object of peer STA
5735 *
5736 * \param tid TID for which a BA is being setup.
5737 * If this is set to 0xFFFF, then we retrieve
5738 * the default TID from the CFG
5739 *
5740 * \return eSIR_SUCCESS if setup completes successfully
5741 * eSIR_FAILURE is some problem is encountered
5742 */
5743tSirRetStatus limPostMlmAddBAReq( tpAniSirGlobal pMac,
5744 tpDphHashNode pStaDs,
5745 tANI_U8 tid, tANI_U16 startingSeqNum,tpPESession psessionEntry)
5746{
5747 tSirRetStatus status = eSIR_SUCCESS;
5748 tpLimMlmAddBAReq pMlmAddBAReq;
5749 tpDialogueToken dialogueTokenNode;
5750 tANI_U32 val = 0;
5751
5752 // Check if the peer is a 11n capable STA
5753 // FIXME - Need a 11n peer indication in DPH.
5754 // For now, using the taurusPeer attribute
5755 //if( 0 == pStaDs->taurusPeer == )
5756 //return eSIR_SUCCESS;
5757
5758 // Allocate for LIM_MLM_ADDBA_REQ
5759 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
5760 (void **) &pMlmAddBAReq,
5761 sizeof( tLimMlmAddBAReq )))
5762 {
5763 limLog( pMac, LOGP, FL("palAllocateMemory failed\n"));
5764 status = eSIR_MEM_ALLOC_FAILED;
5765 goto returnFailure;
5766 }
5767
5768 palZeroMemory( pMac->hHdd, (void *) pMlmAddBAReq, sizeof( tLimMlmAddBAReq ));
5769
5770 // Copy the peer MAC
5771 palCopyMemory( pMac->hHdd,
5772 pMlmAddBAReq->peerMacAddr,
5773 pStaDs->staAddr,
5774 sizeof( tSirMacAddr ));
5775
5776 // Update the TID
5777 pMlmAddBAReq->baTID = tid;
5778
5779 // Determine the supported BA policy of local STA
5780 // for the TID of interest
5781 pMlmAddBAReq->baPolicy = (pStaDs->baPolicyFlag >> tid) & 0x1;
5782
5783 // BA Buffer Size
5784 // Requesting the ADDBA recipient to populate the size.
5785 // If ADDBA is accepted, a non-zero buffer size should
5786 // be returned in the ADDBA Rsp
5787 pMlmAddBAReq->baBufferSize = 0;
5788
5789 limLog( pMac, LOGW,
5790 FL( "Requesting an ADDBA to setup a %s BA session with STA %d for TID %d\n" ),
5791 (pMlmAddBAReq->baPolicy ? "Immediate": "Delayed"),
5792 pStaDs->staIndex,
5793 tid );
5794
5795 // BA Timeout
5796 // pMlmAddBAReq->baTimeout = pMac->hal.halMac.baTimeout; // In TU's
5797 if (wlan_cfgGetInt(pMac, WNI_CFG_BA_TIMEOUT, &val) != eSIR_SUCCESS)
5798 {
5799 limLog(pMac, LOGE, FL("could not retrieve BA TIME OUT Param CFG\n"));
5800 status = eSIR_FAILURE;
5801 goto returnFailure;
5802 }
5803 pMlmAddBAReq->baTimeout = val; // In TU's
5804
5805 // ADDBA Failure Timeout
5806 // FIXME_AMPDU - Need to retrieve this from CFG.
5807 //right now we are not checking for response timeout. so this field is dummy just to be compliant with the spec.
5808 pMlmAddBAReq->addBAFailureTimeout = 2000; // In TU's
5809
5810 // BA Starting Sequence Number
5811 pMlmAddBAReq->baSSN = startingSeqNum;
5812
5813 /* Update PE session Id*/
5814 pMlmAddBAReq->sessionId = psessionEntry->peSessionId;
5815
5816 LIM_SET_STA_BA_STATE(pStaDs, tid, eLIM_BA_STATE_WT_ADD_RSP);
5817
5818 if( NULL == (dialogueTokenNode = limAssignDialogueToken(pMac)))
5819 goto returnFailure;
5820
5821 pMlmAddBAReq->baDialogToken = dialogueTokenNode->token;
5822 //set assocId and tid information in the lim linked list
5823 dialogueTokenNode->assocId = pStaDs->assocId;
5824 dialogueTokenNode->tid = tid;
5825 // Send ADDBA Req to MLME
5826 limPostMlmMessage( pMac,
5827 LIM_MLM_ADDBA_REQ,
5828 (tANI_U32 *) pMlmAddBAReq );
5829
5830returnFailure:
5831
5832 return status;
5833}
5834
5835/**
5836 * \brief Post LIM_MLM_ADDBA_RSP to MLME. MLME
5837 * will then send an ADDBA Rsp to peer MAC entity
5838 * with the appropriate ADDBA status code
5839 *
5840 * \sa limPostMlmAddBARsp
5841 *
5842 * \param pMac The global tpAniSirGlobal object
5843 *
5844 * \param peerMacAddr MAC address of peer entity that will
5845 * be the recipient of this ADDBA Rsp
5846 *
5847 * \param baStatusCode ADDBA Rsp status code
5848 *
5849 * \param baDialogToken ADDBA Rsp dialog token
5850 *
5851 * \param baTID TID of interest
5852 *
5853 * \param baPolicy The BA policy
5854 *
5855 * \param baBufferSize The BA buffer size
5856 *
5857 * \param baTimeout BA timeout in TU's
5858 *
5859 * \return eSIR_SUCCESS if setup completes successfully
5860 * eSIR_FAILURE is some problem is encountered
5861 */
5862tSirRetStatus limPostMlmAddBARsp( tpAniSirGlobal pMac,
5863 tSirMacAddr peerMacAddr,
5864 tSirMacStatusCodes baStatusCode,
5865 tANI_U8 baDialogToken,
5866 tANI_U8 baTID,
5867 tANI_U8 baPolicy,
5868 tANI_U16 baBufferSize,
5869 tANI_U16 baTimeout,
5870 tpPESession psessionEntry)
5871{
5872tSirRetStatus status = eSIR_SUCCESS;
5873tpLimMlmAddBARsp pMlmAddBARsp;
5874
5875 // Allocate for LIM_MLM_ADDBA_RSP
5876 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
5877 (void **) &pMlmAddBARsp,
5878 sizeof( tLimMlmAddBARsp )))
5879 {
5880 limLog( pMac, LOGE,
5881 FL("palAllocateMemory failed with error code %d\n"),
5882 status );
5883
5884 status = eSIR_MEM_ALLOC_FAILED;
5885 goto returnFailure;
5886 }
5887
5888 palZeroMemory( pMac->hHdd, (void *) pMlmAddBARsp, sizeof( tLimMlmAddBARsp ));
5889
5890 // Copy the peer MAC
5891 palCopyMemory( pMac->hHdd,
5892 pMlmAddBARsp->peerMacAddr,
5893 peerMacAddr,
5894 sizeof( tSirMacAddr ));
5895
5896 pMlmAddBARsp->baDialogToken = baDialogToken;
5897 pMlmAddBARsp->addBAResultCode = baStatusCode;
5898 pMlmAddBARsp->baTID = baTID;
5899 pMlmAddBARsp->baPolicy = baPolicy;
5900 pMlmAddBARsp->baBufferSize = baBufferSize;
5901 pMlmAddBARsp->baTimeout = baTimeout;
5902
5903 /* UPdate PE session ID*/
5904 pMlmAddBARsp->sessionId = psessionEntry->peSessionId;
5905
5906 // Send ADDBA Rsp to MLME
5907 limPostMlmMessage( pMac,
5908 LIM_MLM_ADDBA_RSP,
5909 (tANI_U32 *) pMlmAddBARsp );
5910
5911returnFailure:
5912
5913 return status;
5914}
5915
5916/**
5917 * \brief Post LIM_MLM_DELBA_REQ to MLME. MLME
5918 * will then send an DELBA Ind to peer MAC entity
5919 * with the appropriate DELBA status code
5920 *
5921 * \sa limPostMlmDelBAReq
5922 *
5923 * \param pMac The global tpAniSirGlobal object
5924 *
5925 * \param pSta DPH Hash Node object of peer MAC entity
5926 * for which the BA session is being deleted
5927 *
5928 * \param baDirection DELBA direction
5929 *
5930 * \param baTID TID for which the BA session is being deleted
5931 *
5932 * \param baReasonCode DELBA Req reason code
5933 *
5934 * \return eSIR_SUCCESS if setup completes successfully
5935 * eSIR_FAILURE is some problem is encountered
5936 */
5937tSirRetStatus limPostMlmDelBAReq( tpAniSirGlobal pMac,
5938 tpDphHashNode pSta,
5939 tANI_U8 baDirection,
5940 tANI_U8 baTID,
5941 tSirMacReasonCodes baReasonCode,
5942 tpPESession psessionEntry)
5943{
5944tSirRetStatus status = eSIR_SUCCESS;
5945tpLimMlmDelBAReq pMlmDelBAReq;
5946tLimBAState curBaState;
5947
5948if(NULL == pSta)
5949 return eSIR_FAILURE;
5950
5951LIM_GET_STA_BA_STATE(pSta, baTID, &curBaState);
5952
5953 // Need to validate the current BA State.
5954 if( eLIM_BA_STATE_IDLE != curBaState)
5955 {
5956 limLog( pMac, LOGE,
5957 FL( "Received unexpected DELBA REQ when STA BA state for tid = %d is %d\n" ),
5958 baTID,
5959 curBaState);
5960
5961 status = eSIR_FAILURE;
5962 goto returnFailure;
5963 }
5964
5965 // Allocate for LIM_MLM_DELBA_REQ
5966 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
5967 (void **) &pMlmDelBAReq,
5968 sizeof( tLimMlmDelBAReq )))
5969 {
5970 limLog( pMac, LOGE,
5971 FL("palAllocateMemory failed with error code %d\n"),
5972 status );
5973
5974 status = eSIR_MEM_ALLOC_FAILED;
5975 goto returnFailure;
5976 }
5977
5978 palZeroMemory( pMac->hHdd, (void *) pMlmDelBAReq, sizeof( tLimMlmDelBAReq ));
5979
5980 // Copy the peer MAC
5981 palCopyMemory( pMac->hHdd,
5982 pMlmDelBAReq->peerMacAddr,
5983 pSta->staAddr,
5984 sizeof( tSirMacAddr ));
5985
5986 pMlmDelBAReq->baDirection = baDirection;
5987 pMlmDelBAReq->baTID = baTID;
5988 pMlmDelBAReq->delBAReasonCode = baReasonCode;
5989
5990 /* Update PE session ID*/
5991 pMlmDelBAReq->sessionId = psessionEntry->peSessionId;
5992
5993 //we don't have valid BA session for the given direction.
5994 // HDD wants to get the BA session deleted on PEER in this case.
5995 // in this case we just need to send DelBA to the peer.
5996 if(((eBA_RECIPIENT == baDirection) && (eBA_DISABLE == pSta->tcCfg[baTID].fUseBARx)) ||
5997 ((eBA_INITIATOR == baDirection) && (eBA_DISABLE == pSta->tcCfg[baTID].fUseBATx)))
5998 {
5999 // Send DELBA Ind over the air
6000 if( eSIR_SUCCESS !=
6001 (status = limSendDelBAInd( pMac, pMlmDelBAReq,psessionEntry)))
6002 status = eSIR_FAILURE;
6003
6004 palFreeMemory(pMac->hHdd, (void*) pMlmDelBAReq);
6005 return status;
6006 }
6007
6008
6009 // Update the BA state in STA
6010 LIM_SET_STA_BA_STATE(pSta, pMlmDelBAReq->baTID, eLIM_BA_STATE_WT_DEL_RSP);
6011
6012 // Send DELBA Req to MLME
6013 limPostMlmMessage( pMac,
6014 LIM_MLM_DELBA_REQ,
6015 (tANI_U32 *) pMlmDelBAReq );
6016
6017returnFailure:
6018
6019 return status;
6020}
6021
6022/**
6023 * \brief Send WDA_ADDBA_REQ to HAL, in order
6024 * to setup a new BA session with a peer
6025 *
6026 * \sa limPostMsgAddBAReq
6027 *
6028 * \param pMac The global tpAniSirGlobal object
6029 *
6030 * \param pSta Runtime, STA-related configuration cached
6031 * in the HashNode object
6032 *
6033 * \param baDialogToken The Action Frame dialog token
6034 *
6035 * \param baTID TID for which the BA session is being setup
6036 *
6037 * \param baPolicy BA Policy
6038 *
6039 * \param baBufferSize The requested BA buffer size
6040 *
6041 * \param baTimeout BA Timeout. 0 indicates no BA timeout enforced
6042 *
6043 * \param baSSN Starting Sequence Number for this BA session
6044 *
6045 * \param baDirection BA Direction: 1 - Initiator, 0 - Recipient
6046 *
6047 * \return none
6048 *
6049 */
6050tSirRetStatus limPostMsgAddBAReq( tpAniSirGlobal pMac,
6051 tpDphHashNode pSta,
6052 tANI_U8 baDialogToken,
6053 tANI_U8 baTID,
6054 tANI_U8 baPolicy,
6055 tANI_U16 baBufferSize,
6056 tANI_U16 baTimeout,
6057 tANI_U16 baSSN,
6058 tANI_U8 baDirection,
6059 tpPESession psessionEntry)
6060{
6061tpAddBAParams pAddBAParams = NULL;
6062tSirRetStatus retCode = eSIR_SUCCESS;
6063eHalStatus status;
6064tSirMsgQ msgQ;
6065
6066#ifdef WLAN_SOFTAP_VSTA_FEATURE
6067 // we can only do BA on "hard" STAs
6068 if (!(IS_HWSTA_IDX(pSta->staIndex)))
6069 {
6070 retCode = eHAL_STATUS_FAILURE;
6071 goto returnFailure;
6072 }
6073#endif //WLAN_SOFTAP_VSTA_FEATURE
6074
6075 // Allocate for WDA_ADDBA_REQ
6076 if( eHAL_STATUS_SUCCESS !=
6077 (status = palAllocateMemory( pMac->hHdd,
6078 (void **) &pAddBAParams,
6079 sizeof( tAddBAParams ))))
6080 {
6081 limLog( pMac, LOGE,
6082 FL("palAllocateMemory failed with error code %d\n"),
6083 status );
6084
6085 retCode = eSIR_MEM_ALLOC_FAILED;
6086 goto returnFailure;
6087 }
6088
6089 palZeroMemory( pMac->hHdd, (void *) pAddBAParams, sizeof( tAddBAParams ));
6090
6091 // Copy the peer MAC address
6092 palCopyMemory( pMac->hHdd,
6093 (void *) pAddBAParams->peerMacAddr,
6094 (void *) pSta->staAddr,
6095 sizeof( tSirMacAddr ));
6096
6097 // Populate the REQ parameters
6098 pAddBAParams->staIdx = pSta->staIndex;
6099 pAddBAParams->baDialogToken = baDialogToken;
6100 pAddBAParams->baTID = baTID;
6101 pAddBAParams->baPolicy = baPolicy;
6102 pAddBAParams->baBufferSize = baBufferSize;
6103 pAddBAParams->baTimeout = baTimeout;
6104 pAddBAParams->baSSN = baSSN;
6105 pAddBAParams->baDirection = baDirection;
6106 pAddBAParams->respReqd = 1;
6107
6108 /* UPdate PE session ID */
6109 pAddBAParams->sessionId = psessionEntry->peSessionId;
6110
6111 // Post WDA_ADDBA_REQ to HAL.
6112 msgQ.type = WDA_ADDBA_REQ;
6113 //
6114 // FIXME_AMPDU
6115 // A global counter (dialog token) is required to keep track of
6116 // all PE <-> HAL communication(s)
6117 //
6118 msgQ.reserved = 0;
6119 msgQ.bodyptr = pAddBAParams;
6120 msgQ.bodyval = 0;
6121
6122 limLog( pMac, LOGW,
6123 FL( "Sending WDA_ADDBA_REQ..." ));
6124
6125 //defer any other message until we get response back.
6126 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
6127
Jeff Johnsone7245742012-09-05 17:12:55 -07006128 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006129#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
6130 limDiagEventReport(pMac, WLAN_PE_DIAG_HAL_ADDBA_REQ_EVENT, psessionEntry, 0, 0);
6131#endif //FEATURE_WLAN_DIAG_SUPPORT
6132
6133 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
6134 limLog( pMac, LOGE,
6135 FL("Posting WDA_ADDBA_REQ to HAL failed! Reason = %d\n"),
6136 retCode );
6137 else
6138 return retCode;
6139
6140returnFailure:
6141
6142 // Clean-up...
6143 if( NULL != pAddBAParams )
6144 palFreeMemory( pMac->hHdd, (void *) pAddBAParams );
6145
6146 return retCode;
6147
6148}
6149
6150/**
6151 * \brief Send WDA_DELBA_IND to HAL, in order
6152 * to delete an existing BA session with peer
6153 *
6154 * \sa limPostMsgDelBAInd
6155 *
6156 * \param pMac The global tpAniSirGlobal object
6157 *
6158 * \param pSta Runtime, STA-related configuration cached
6159 * in the HashNode object
6160 *
6161 * \param baTID TID for which the BA session is being setup
6162 *
6163 * \param baDirection Identifies whether the DELBA Ind was
6164 * sent by the BA initiator or recipient
6165 *
6166 * \return none
6167 *
6168 */
6169tSirRetStatus limPostMsgDelBAInd( tpAniSirGlobal pMac,
6170 tpDphHashNode pSta,
6171 tANI_U8 baTID,
6172 tANI_U8 baDirection,
6173 tpPESession psessionEntry)
6174{
6175tpDelBAParams pDelBAParams = NULL;
6176tSirRetStatus retCode = eSIR_SUCCESS;
6177eHalStatus status;
6178tSirMsgQ msgQ;
6179
6180 // Allocate for SIR_HAL_DELBA_IND
6181 if( eHAL_STATUS_SUCCESS !=
6182 (status = palAllocateMemory( pMac->hHdd,
6183 (void **) &pDelBAParams,
6184 sizeof( tDelBAParams ))))
6185 {
6186 limLog( pMac, LOGE,
6187 FL("palAllocateMemory failed with error code %d\n"),
6188 status );
6189
6190 retCode = eSIR_MEM_ALLOC_FAILED;
6191 goto returnFailure;
6192 }
6193
6194 palZeroMemory( pMac->hHdd, (void *) pDelBAParams, sizeof( tDelBAParams ));
6195
6196 // Populate the REQ parameters
6197 pDelBAParams->staIdx = pSta->staIndex;
6198 pDelBAParams->baTID = baTID;
6199 pDelBAParams->baDirection = baDirection;
6200
6201 /* Update PE session ID */
6202
6203
6204 //TBD-RAJESH Updating of the session ID is requird for SIR_HAL_DELBA_IND?????
6205 //pDelBAParams->sessionId = psessionEntry->peSessionId;
6206
6207 // Post WDA_DELBA_IND to HAL.
6208 msgQ.type = WDA_DELBA_IND;
6209 //
6210 // FIXME:
6211 // A global counter (dialog token) is required to keep track of
6212 // all PE <-> HAL communication(s)
6213 //
6214 msgQ.reserved = 0;
6215 msgQ.bodyptr = pDelBAParams;
6216 msgQ.bodyval = 0;
6217
6218 limLog( pMac, LOGW,
6219 FL( "Sending SIR_HAL_DELBA_IND..." ));
6220
Jeff Johnsone7245742012-09-05 17:12:55 -07006221 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006222#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
6223 limDiagEventReport(pMac, WLAN_PE_DIAG_HAL_DELBA_IND_EVENT, psessionEntry, 0, 0);
6224#endif //FEATURE_WLAN_DIAG_SUPPORT
6225
6226 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
6227 limLog( pMac, LOGE,
6228 FL("Posting WDA_DELBA_IND to HAL failed! Reason = %d\n"),
6229 retCode );
6230 else
6231 {
6232 // Update LIM's internal cache...
6233 if( eBA_INITIATOR == baDirection)
6234 {
6235 pSta->tcCfg[baTID].fUseBATx = 0;
6236 pSta->tcCfg[baTID].txBufSize = 0;
6237 }
6238 else
6239 {
6240 pSta->tcCfg[baTID].fUseBARx = 0;
6241 pSta->tcCfg[baTID].rxBufSize = 0;
6242 }
6243
6244 return retCode;
6245 }
6246
6247returnFailure:
6248
6249 // Clean-up...
6250 if( NULL != pDelBAParams )
6251 palFreeMemory( pMac->hHdd, (void *) pDelBAParams );
6252
6253 return retCode;
6254
6255}
6256
6257/**
6258 * @function : limPostSMStateUpdate()
6259 *
6260 * @brief : This function Updates the HAL and Softmac about the change in the STA's SMPS state.
6261 *
6262 * LOGIC:
6263 *
6264 * ASSUMPTIONS:
6265 * NA
6266 *
6267 * NOTE:
6268 * NA
6269 *
6270 * @param pMac - Pointer to Global MAC structure
6271 * @param limMsg - Lim Message structure object with the MimoPSparam in body
6272 * @return None
6273 */
6274tSirRetStatus
6275limPostSMStateUpdate(tpAniSirGlobal pMac,
6276 tANI_U16 staIdx, tSirMacHTMIMOPowerSaveState state)
6277{
6278 tSirRetStatus retCode = eSIR_SUCCESS;
6279 tSirMsgQ msgQ;
6280 eHalStatus status;
6281 tpSetMIMOPS pMIMO_PSParams;
6282
6283 msgQ.reserved = 0;
6284 msgQ.type = WDA_SET_MIMOPS_REQ;
6285
6286 // Allocate for WDA_SET_MIMOPS_REQ
6287 status = palAllocateMemory( pMac->hHdd, (void **) &pMIMO_PSParams, sizeof( tSetMIMOPS));
6288 if( eHAL_STATUS_SUCCESS != status) {
6289 limLog( pMac, LOGP,FL(" palAllocateMemory failed with error code %d\n"), status );
6290 return eSIR_MEM_ALLOC_FAILED;
6291 }
6292
6293 pMIMO_PSParams->htMIMOPSState = state;
6294 pMIMO_PSParams->staIdx = staIdx;
6295 pMIMO_PSParams->fsendRsp = true;
6296 msgQ.bodyptr = pMIMO_PSParams;
6297 msgQ.bodyval = 0;
6298
6299 limLog( pMac, LOG2, FL( "Sending WDA_SET_MIMOPS_REQ..." ));
6300
Jeff Johnsone7245742012-09-05 17:12:55 -07006301 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006302 retCode = wdaPostCtrlMsg( pMac, &msgQ );
6303 if (eSIR_SUCCESS != retCode)
6304 {
6305 limLog( pMac, LOGP, FL("Posting WDA_SET_MIMOPS_REQ to HAL failed! Reason = %d\n"), retCode );
6306 palFreeMemory(pMac->hHdd, (void *) pMIMO_PSParams);
6307 return retCode;
6308 }
6309
6310 return retCode;
6311}
6312
6313void limPktFree (
6314 tpAniSirGlobal pMac,
6315 eFrameType frmType,
6316 tANI_U8 *pRxPacketInfo,
6317 void *pBody)
6318{
6319 (void) pMac; (void) frmType; (void) pRxPacketInfo; (void) pBody;
6320#if defined ANI_OS_TYPE_LINUX || defined ANI_OS_TYPE_OSX
6321 // Free up allocated SK BUF
6322 palPktFree( pMac->hHdd, frmType, pRxPacketInfo, pBody) ;
6323#endif
6324}
6325
6326/**
6327 * limGetBDfromRxPacket()
6328 *
6329 *FUNCTION:
6330 * This function is called to get pointer to Polaris
6331 * Buffer Descriptor containing MAC header & other control
6332 * info from the body of the message posted to LIM.
6333 *
6334 *LOGIC:
6335 * NA
6336 *
6337 *ASSUMPTIONS:
6338 * NA
6339 *
6340 *NOTE:
6341 * NA
6342 *
6343 * @param body - Received message body
6344 * @param pRxPacketInfo - Pointer to received BD
6345 * @return None
6346 */
6347
6348void
6349limGetBDfromRxPacket(tpAniSirGlobal pMac, void *body, tANI_U32 **pRxPacketInfo)
6350{
6351#if defined (ANI_OS_TYPE_LINUX) || defined (ANI_OS_TYPE_OSX)
6352#ifndef GEN6_ONWARDS
6353 palGetPacketDataPtr( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, (void *) body, (void **) pRxPacketInfo );
6354#endif //GEN6_ONWARDS
6355#else
6356 *pRxPacketInfo = (tANI_U32 *) body;
6357#endif
6358} /*** end limGetBDfromRxPacket() ***/
6359
6360
6361
6362
6363
6364void limRessetScanChannelInfo(tpAniSirGlobal pMac)
6365{
6366 palZeroMemory(pMac->hHdd, &pMac->lim.scanChnInfo, sizeof(tLimScanChnInfo));
6367}
6368
6369
6370void limAddScanChannelInfo(tpAniSirGlobal pMac, tANI_U8 channelId)
6371{
6372 tANI_U8 i;
6373 tANI_BOOLEAN fFound = eANI_BOOLEAN_FALSE;
6374
6375 for(i = 0; i < pMac->lim.scanChnInfo.numChnInfo; i++)
6376 {
6377 if(pMac->lim.scanChnInfo.scanChn[i].channelId == channelId)
6378 {
6379 pMac->lim.scanChnInfo.scanChn[i].numTimeScan++;
6380 fFound = eANI_BOOLEAN_TRUE;
6381 break;
6382 }
6383 }
6384 if(eANI_BOOLEAN_FALSE == fFound)
6385 {
6386 if(pMac->lim.scanChnInfo.numChnInfo < SIR_MAX_SUPPORTED_CHANNEL_LIST)
6387 {
6388 pMac->lim.scanChnInfo.scanChn[pMac->lim.scanChnInfo.numChnInfo].channelId = channelId;
6389 pMac->lim.scanChnInfo.scanChn[pMac->lim.scanChnInfo.numChnInfo++].numTimeScan = 1;
6390 }
6391 else
6392 {
6393 PELOGW(limLog(pMac, LOGW, FL(" -- number of channels exceed mac\n"));)
6394 }
6395 }
6396}
6397
6398
6399/**
6400 * @function : limIsChannelValidForChannelSwitch()
6401 *
6402 * @brief : This function checks if the channel to which AP
6403 * is expecting us to switch, is a valid channel for us.
6404 * LOGIC:
6405 *
6406 * ASSUMPTIONS:
6407 * NA
6408 *
6409 * NOTE:
6410 * NA
6411 *
6412 * @param pMac - Pointer to Global MAC structure
6413 * @param channel - New channel to which we are expected to move
6414 * @return None
6415 */
6416tAniBool
6417limIsChannelValidForChannelSwitch(tpAniSirGlobal pMac, tANI_U8 channel)
6418{
6419 tANI_U8 index;
6420 tANI_U32 validChannelListLen = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6421 tSirMacChanNum validChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6422
6423 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
6424 (tANI_U8 *)validChannelList,
6425 (tANI_U32 *)&validChannelListLen) != eSIR_SUCCESS)
6426 {
6427 PELOGE(limLog(pMac, LOGE, FL("could not retrieve valid channel list\n"));)
6428 return (eSIR_FALSE);
6429 }
6430
6431 for(index = 0; index < validChannelListLen; index++)
6432 {
6433 if(validChannelList[index] == channel)
6434 return (eSIR_TRUE);
6435 }
6436
6437 /* channel does not belong to list of valid channels */
6438 return (eSIR_FALSE);
6439}
6440
6441/**------------------------------------------------------
6442\fn __limFillTxControlParams
6443\brief Fill the message for stopping/resuming tx.
6444
6445\param pMac
6446\param pTxCtrlMsg - Pointer to tx control message.
6447\param type - Which way we want to stop/ resume tx.
6448\param mode - To stop/resume.
6449 -------------------------------------------------------*/
6450static eHalStatus
6451__limFillTxControlParams(tpAniSirGlobal pMac, tpTxControlParams pTxCtrlMsg,
6452 tLimQuietTxMode type, tLimControlTx mode)
6453{
6454
6455 //TBD-RAJESH HOW TO GET sessionEntry?????
6456 tpPESession psessionEntry = &pMac->lim.gpSession[0];
6457
6458 if (mode == eLIM_STOP_TX)
6459 pTxCtrlMsg->stopTx = eANI_BOOLEAN_TRUE;
6460 else
6461 pTxCtrlMsg->stopTx = eANI_BOOLEAN_FALSE;
6462
6463 switch (type)
6464 {
6465 case eLIM_TX_ALL:
6466 /** Stops/resumes transmission completely */
6467 pTxCtrlMsg->fCtrlGlobal = 1;
6468 break;
6469
6470 case eLIM_TX_BSS_BUT_BEACON:
6471 /** Stops/resumes transmission on a particular BSS. Stopping BSS, doesnt
6472 * stop beacon transmission.
6473 */
6474 pTxCtrlMsg->ctrlBss = 1;
6475 pTxCtrlMsg->bssBitmap |= (1 << psessionEntry->bssIdx);
6476 break;
6477
6478 case eLIM_TX_STA:
6479 /** Memory for station bitmap is allocated dynamically in caller of this
6480 * so decode properly here and fill the bitmap. Now not implemented,
6481 * fall through.
6482 */
6483 case eLIM_TX_BSS:
6484 //Fall thru...
6485 default:
6486 PELOGW(limLog(pMac, LOGW, FL("Invalid case: Not Handled\n"));)
6487 return eHAL_STATUS_FAILURE;
6488 }
6489
6490 return eHAL_STATUS_SUCCESS;
6491}
6492
6493/**
6494 * @function : limFrameTransmissionControl()
6495 *
6496 * @brief : This API is called by the user to halt/resume any frame
6497 * transmission from the device. If stopped, all frames will be
6498 * queued starting from hardware. Then back-pressure
6499 * is built till the driver.
6500 * LOGIC:
6501 *
6502 * ASSUMPTIONS:
6503 * NA
6504 *
6505 * NOTE:
6506 * NA
6507 *
6508 * @param pMac - Pointer to Global MAC structure
6509 * @return None
6510 */
6511void limFrameTransmissionControl(tpAniSirGlobal pMac, tLimQuietTxMode type, tLimControlTx mode)
6512{
6513
6514 eHalStatus status = eHAL_STATUS_FAILURE;
6515 tpTxControlParams pTxCtrlMsg;
6516 tSirMsgQ msgQ;
6517 tANI_U8 nBytes = 0; // No of bytes required for station bitmap.
6518
6519 /** Allocate only required number of bytes for station bitmap
6520 * Make it to align to 4 byte boundary */
6521 nBytes = (tANI_U8)HALMSG_NUMBYTES_STATION_BITMAP(pMac->lim.maxStation);
6522
6523 status = palAllocateMemory(pMac->hHdd, (void **) &pTxCtrlMsg,
6524 (sizeof(*pTxCtrlMsg) + nBytes));
6525 if (status != eHAL_STATUS_SUCCESS)
6526 {
6527 limLog(pMac, LOGP, FL("palAllocateMemory() failed\n"));
6528 return;
6529 }
6530
6531 status = palZeroMemory(pMac->hHdd, (void *) pTxCtrlMsg,
6532 (sizeof(*pTxCtrlMsg) + nBytes));
6533 if (status != eHAL_STATUS_SUCCESS)
6534 {
6535 palFreeMemory(pMac->hHdd, (void *) pTxCtrlMsg);
6536 limLog(pMac, LOGP, FL("palZeroMemory() failed, status = %d\n"), status);
6537 return;
6538 }
6539
6540 status = __limFillTxControlParams(pMac, pTxCtrlMsg, type, mode);
6541 if (status != eHAL_STATUS_SUCCESS)
6542 {
6543 palFreeMemory(pMac->hHdd, (void *) pTxCtrlMsg);
6544 limLog(pMac, LOGP, FL("__limFillTxControlParams failed, status = %d\n"), status);
6545 return;
6546 }
6547
6548 msgQ.bodyptr = (void *) pTxCtrlMsg;
6549 msgQ.bodyval = 0;
6550 msgQ.reserved = 0;
6551 msgQ.type = WDA_TRANSMISSION_CONTROL_IND;
6552
Jeff Johnsone7245742012-09-05 17:12:55 -07006553 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006554 if(wdaPostCtrlMsg( pMac, &msgQ) != eSIR_SUCCESS)
6555 {
6556 palFreeMemory(pMac->hHdd, (void *) pTxCtrlMsg);
6557 limLog( pMac, LOGP, FL("Posting Message to HAL failed\n"));
6558 return;
6559 }
6560
6561 if (mode == eLIM_STOP_TX)
6562 {
6563 PELOG1(limLog(pMac, LOG1, FL("Stopping the transmission of all packets, indicated softmac\n"));)
6564 }
6565 else
6566 {
6567 PELOG1(limLog(pMac, LOG1, FL("Resuming the transmission of all packets, indicated softmac\n"));)
6568 }
6569 return;
6570}
6571
6572
6573/**
6574 * @function : limRestorePreChannelSwitchState()
6575 *
6576 * @brief : This API is called by the user to undo any
6577 * specific changes done on the device during
6578 * channel switch.
6579 * LOGIC:
6580 *
6581 * ASSUMPTIONS:
6582 * NA
6583 *
6584 * NOTE:
6585 * NA
6586 *
6587 * @param pMac - Pointer to Global MAC structure
6588 * @return None
6589 */
6590
6591tSirRetStatus
6592limRestorePreChannelSwitchState(tpAniSirGlobal pMac, tpPESession psessionEntry)
6593{
6594
6595 tSirRetStatus retCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 tANI_U32 val = 0;
6597
6598 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
6599 return retCode;
6600
6601 /* Channel switch should be ready for the next time */
Jeff Johnsone7245742012-09-05 17:12:55 -07006602 psessionEntry->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07006603
6604 /* Restore the frame transmission, all the time. */
6605 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
6606
6607 /* Free to enter BMPS */
6608 limSendSmePostChannelSwitchInd(pMac);
6609
6610 //Background scan is now enabled by SME
6611 if(pMac->lim.gLimBackgroundScanTerminate == FALSE)
6612 {
6613 /* Enable background scan if already enabled, else don't bother */
6614 if ((retCode = wlan_cfgGetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD,
6615 &val)) != eSIR_SUCCESS)
6616
6617 {
6618 limLog(pMac, LOGP, FL("could not retrieve Background scan period value\n"));
6619 return (retCode);
6620 }
6621
6622 if (val > 0 && TX_TIMER_VALID(pMac->lim.limTimers.gLimBackgroundScanTimer))
6623 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006624 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_BACKGROUND_SCAN_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 if(tx_timer_activate(&pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
6626 {
6627 limLog(pMac, LOGP, FL("Could not restart background scan timer, doing LOGP"));
6628 return (eSIR_FAILURE);
6629 }
6630
6631 }
6632 }
6633
6634 /* Enable heartbeat timer */
6635 if (TX_TIMER_VALID(pMac->lim.limTimers.gLimHeartBeatTimer))
6636 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006637 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_HEART_BEAT_TIMER));
Yathish9f22e662012-12-10 14:21:35 -08006638 if((limActivateHearBeatTimer(pMac) != TX_SUCCESS) && (!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 {
6640 limLog(pMac, LOGP, FL("Could not restart heartbeat timer, doing LOGP"));
6641 return (eSIR_FAILURE);
6642 }
6643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006644 return (retCode);
6645}
6646
6647
6648/**--------------------------------------------
6649\fn limRestorePreQuietState
6650\brief Restore the pre quiet state
6651
6652\param pMac
6653\return NONE
6654---------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07006655tSirRetStatus limRestorePreQuietState(tpAniSirGlobal pMac, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07006656{
6657
6658 tSirRetStatus retCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006659 tANI_U32 val = 0;
6660
6661 if (pMac->lim.gLimSystemRole != eLIM_STA_ROLE)
6662 return retCode;
6663
6664 /* Quiet should be ready for the next time */
Jeff Johnsone7245742012-09-05 17:12:55 -07006665 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07006666
6667 /* Restore the frame transmission, all the time. */
Jeff Johnsone7245742012-09-05 17:12:55 -07006668 if (psessionEntry->gLimSpecMgmt.quietState == eLIM_QUIET_RUNNING)
Jeff Johnson295189b2012-06-20 16:38:30 -07006669 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
6670
6671
6672 //Background scan is now enabled by SME
6673 if(pMac->lim.gLimBackgroundScanTerminate == FALSE)
6674 {
6675 /* Enable background scan if already enabled, else don't bother */
6676 if ((retCode = wlan_cfgGetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD,
6677 &val)) != eSIR_SUCCESS)
6678
6679 {
6680 limLog(pMac, LOGP, FL("could not retrieve Background scan period value\n"));
6681 return (retCode);
6682 }
6683
6684 if (val > 0 && TX_TIMER_VALID(pMac->lim.limTimers.gLimBackgroundScanTimer))
6685 {
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08006686 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_BACKGROUND_SCAN_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07006687 if(tx_timer_activate(&pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
6688 {
6689 limLog(pMac, LOGP, FL("Could not restart background scan timer, doing LOGP"));
6690 return (eSIR_FAILURE);
6691 }
6692
6693 }
6694 }
6695
6696 /* Enable heartbeat timer */
6697 if (TX_TIMER_VALID(pMac->lim.limTimers.gLimHeartBeatTimer))
6698 {
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08006699 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_HEART_BEAT_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 if(limActivateHearBeatTimer(pMac) != TX_SUCCESS)
6701 {
6702 limLog(pMac, LOGP, FL("Could not restart heartbeat timer, doing LOGP"));
6703 return (eSIR_FAILURE);
6704 }
6705 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006706 return (retCode);
6707}
6708
6709
6710/**
6711 * @function: limPrepareFor11hChannelSwitch()
6712 *
6713 * @brief : This API is called by the user to prepare for
6714 * 11h channel switch. As of now, the API does
6715 * very minimal work. User can add more into the
6716 * same API if needed.
6717 * LOGIC:
6718 *
6719 * ASSUMPTIONS:
6720 * NA
6721 *
6722 * NOTE:
6723 * NA
6724 *
6725 * @param pMac - Pointer to Global MAC structure
6726 * @param psessionEntry
6727 * @return None
6728 */
6729void
6730limPrepareFor11hChannelSwitch(tpAniSirGlobal pMac, tpPESession psessionEntry)
6731{
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
6733 return;
6734
6735 /* Flag to indicate 11h channel switch in progress */
Jeff Johnsone7245742012-09-05 17:12:55 -07006736 psessionEntry->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_RUNNING;
Jeff Johnson295189b2012-06-20 16:38:30 -07006737
6738 /* Disable, Stop background scan if enabled and running */
6739 limDeactivateAndChangeTimer(pMac, eLIM_BACKGROUND_SCAN_TIMER);
6740
6741 /* Stop heart-beat timer to stop heartbeat disassociation */
6742 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
6743
6744 if(pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE ||
6745 pMac->lim.gLimSmeState == eLIM_SME_CHANNEL_SCAN_STATE)
6746 {
6747 PELOGE(limLog(pMac, LOGE, FL("Posting finish scan as we are in scan state\n"));)
6748 /* Stop ongoing scanning if any */
6749 if (GET_LIM_PROCESS_DEFD_MESGS(pMac))
6750 {
6751 //Set the resume channel to Any valid channel (invalid).
6752 //This will instruct HAL to set it to any previous valid channel.
6753 peSetResumeChannel(pMac, 0, 0);
6754 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
6755 }
6756 else
6757 {
6758 limRestorePreChannelSwitchState(pMac, psessionEntry);
6759 }
6760 return;
6761 }
6762 else
6763 {
6764 PELOGE(limLog(pMac, LOGE, FL("Not in scan state, start channel switch timer\n"));)
6765 /** We are safe to switch channel at this point */
6766 limStopTxAndSwitchChannel(pMac, psessionEntry->peSessionId);
6767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006768}
6769
6770
6771
6772/**----------------------------------------------------
6773\fn limGetNwType
6774
6775\brief Get type of the network from data packet or beacon
6776\param pMac
6777\param channelNum - Channel number
6778\param type - Type of packet.
6779\param pBeacon - Pointer to beacon or probe response
6780
6781\return Network type a/b/g.
6782-----------------------------------------------------*/
6783tSirNwType limGetNwType(tpAniSirGlobal pMac, tANI_U8 channelNum, tANI_U32 type, tpSchBeaconStruct pBeacon)
6784{
6785 tSirNwType nwType = eSIR_11B_NW_TYPE;
6786
6787 if (type == SIR_MAC_DATA_FRAME)
6788 {
6789 if ((channelNum > 0) && (channelNum < 15))
6790 {
6791 nwType = eSIR_11G_NW_TYPE;
6792 }
6793 else
6794 {
6795 nwType = eSIR_11A_NW_TYPE;
6796 }
6797 }
6798 else
6799 {
6800 if ((channelNum > 0) && (channelNum < 15))
6801 {
6802 int i;
6803 // 11b or 11g packet
6804 // 11g iff extended Rate IE is present or
6805 // if there is an A rate in suppRate IE
6806 for (i = 0; i < pBeacon->supportedRates.numRates; i++)
6807 {
6808 if (sirIsArate(pBeacon->supportedRates.rate[i] & 0x7f))
6809 {
6810 nwType = eSIR_11G_NW_TYPE;
6811 break;
6812 }
6813 }
6814 if (pBeacon->extendedRatesPresent)
6815 {
6816 PELOG3(limLog(pMac, LOG3, FL("Beacon, nwtype=G\n"));)
6817 nwType = eSIR_11G_NW_TYPE;
6818 }
6819 }
6820 else
6821 {
6822 // 11a packet
6823 PELOG3(limLog(pMac, LOG3,FL("Beacon, nwtype=A\n"));)
6824 nwType = eSIR_11A_NW_TYPE;
6825 }
6826 }
6827 return nwType;
6828}
6829
6830
6831/**---------------------------------------------------------
6832\fn limGetChannelFromBeacon
6833\brief To extract channel number from beacon
6834
6835\param pMac
6836\param pBeacon - Pointer to beacon or probe rsp
6837\return channel number
6838-----------------------------------------------------------*/
6839tANI_U8 limGetChannelFromBeacon(tpAniSirGlobal pMac, tpSchBeaconStruct pBeacon)
6840{
6841 tANI_U8 channelNum = 0;
6842
6843 if (pBeacon->dsParamsPresent)
6844 channelNum = pBeacon->channelNumber;
6845 else if(pBeacon->HTInfo.present)
6846 channelNum = pBeacon->HTInfo.primaryChannel;
6847 else
6848 channelNum = pBeacon->channelNumber;
6849
6850 return channelNum;
6851}
6852
6853
6854/** ---------------------------------------------------------
6855\fn limSetTspecUapsdMask
6856\brief This function sets the PE global variable:
6857\ 1) gUapsdPerAcTriggerEnableMask and
6858\ 2) gUapsdPerAcDeliveryEnableMask
6859\ based on the user priority field and direction field
6860\ in the TS Info Fields.
6861\
6862\ An AC is a trigger-enabled AC if the PSB subfield
6863\ is set to 1 in the uplink direction.
6864\ An AC is a delivery-enabled AC if the PSB subfield
6865\ is set to 1 in the down-link direction.
6866\
6867\param tpAniSirGlobal pMac
6868\param tSirMacTSInfo pTsInfo
6869\param tANI_U32 action
6870\return None
6871 ------------------------------------------------------------*/
6872void limSetTspecUapsdMask(tpAniSirGlobal pMac, tSirMacTSInfo *pTsInfo, tANI_U32 action)
6873{
6874 tANI_U8 userPrio = (tANI_U8)pTsInfo->traffic.userPrio;
6875 tANI_U16 direction = pTsInfo->traffic.direction;
6876 tANI_U8 ac = upToAc(userPrio);
6877
6878 PELOG1(limLog(pMac, LOG1, FL(" Set UAPSD mask for AC %d, direction %d, action=%d (1=set,0=clear) \n"),ac, direction, action );)
6879
6880 /* Converting AC to appropriate Uapsd Bit Mask
6881 * AC_BE(0) --> UAPSD_BITOFFSET_ACVO(3)
6882 * AC_BK(1) --> UAPSD_BITOFFSET_ACVO(2)
6883 * AC_VI(2) --> UAPSD_BITOFFSET_ACVO(1)
6884 * AC_VO(3) --> UAPSD_BITOFFSET_ACVO(0)
6885 */
6886 ac = ((~ac) & 0x3);
6887
6888 if (action == CLEAR_UAPSD_MASK)
6889 {
6890 if (direction == SIR_MAC_DIRECTION_UPLINK)
6891 pMac->lim.gUapsdPerAcTriggerEnableMask &= ~(1 << ac);
6892 else if (direction == SIR_MAC_DIRECTION_DNLINK)
6893 pMac->lim.gUapsdPerAcDeliveryEnableMask &= ~(1 << ac);
6894 else if (direction == SIR_MAC_DIRECTION_BIDIR)
6895 {
6896 pMac->lim.gUapsdPerAcTriggerEnableMask &= ~(1 << ac);
6897 pMac->lim.gUapsdPerAcDeliveryEnableMask &= ~(1 << ac);
6898 }
6899 }
6900 else if (action == SET_UAPSD_MASK)
6901 {
6902 if (direction == SIR_MAC_DIRECTION_UPLINK)
6903 pMac->lim.gUapsdPerAcTriggerEnableMask |= (1 << ac);
6904 else if (direction == SIR_MAC_DIRECTION_DNLINK)
6905 pMac->lim.gUapsdPerAcDeliveryEnableMask |= (1 << ac);
6906 else if (direction == SIR_MAC_DIRECTION_BIDIR)
6907 {
6908 pMac->lim.gUapsdPerAcTriggerEnableMask |= (1 << ac);
6909 pMac->lim.gUapsdPerAcDeliveryEnableMask |= (1 << ac);
6910 }
6911 }
6912
6913 limLog(pMac, LOGE, FL("New pMac->lim.gUapsdPerAcTriggerEnableMask = 0x%x \n"), pMac->lim.gUapsdPerAcTriggerEnableMask );
6914 limLog(pMac, LOGE, FL("New pMac->lim.gUapsdPerAcDeliveryEnableMask = 0x%x \n"), pMac->lim.gUapsdPerAcDeliveryEnableMask );
6915
6916 return;
6917}
6918
6919
6920
6921void limHandleHeartBeatTimeout(tpAniSirGlobal pMac )
6922{
6923
6924 tANI_U8 i;
6925 for(i =0;i < pMac->lim.maxBssId;i++)
6926 {
6927 if(pMac->lim.gpSession[i].valid == TRUE )
6928 {
6929 if(pMac->lim.gpSession[i].bssType == eSIR_IBSS_MODE)
6930 {
6931 limIbssHeartBeatHandle(pMac,&pMac->lim.gpSession[i]);
6932 break;
6933 }
6934
6935 if((pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) &&
6936 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_ROLE))
6937 {
6938 limHandleHeartBeatFailure(pMac,&pMac->lim.gpSession[i]);
6939 }
6940 }
6941 }
6942 for(i=0; i< pMac->lim.maxBssId; i++)
6943 {
6944 if(pMac->lim.gpSession[i].valid == TRUE )
6945 {
6946 if((pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) &&
6947 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_ROLE))
6948 {
6949 if(pMac->lim.gpSession[i].LimHBFailureStatus == eANI_BOOLEAN_TRUE)
6950 {
6951 /* Activate Probe After HeartBeat Timer incase HB Failure detected */
6952 PELOGW(limLog(pMac, LOGW,FL("Sending Probe for Session: %d\n"),
6953 i);)
6954 limDeactivateAndChangeTimer(pMac, eLIM_PROBE_AFTER_HB_TIMER);
6955 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0, eLIM_PROBE_AFTER_HB_TIMER));
6956 if (tx_timer_activate(&pMac->lim.limTimers.gLimProbeAfterHBTimer) != TX_SUCCESS)
6957 {
6958 limLog(pMac, LOGP, FL("Fail to re-activate Probe-after-heartbeat timer\n"));
6959 limReactivateHeartBeatTimer(pMac, &pMac->lim.gpSession[i]);
6960 }
6961 break;
6962 }
6963 }
6964 }
6965 }
6966}
6967
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08006968void limHandleHeartBeatTimeoutForSession(tpAniSirGlobal pMac, tpPESession psessionEntry)
6969{
6970 if(psessionEntry->valid == TRUE )
6971 {
6972 if(psessionEntry->bssType == eSIR_IBSS_MODE)
6973 {
6974 limIbssHeartBeatHandle(pMac,psessionEntry);
6975 }
6976 if((psessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE) &&
6977 (psessionEntry->limSystemRole == eLIM_STA_ROLE))
6978 {
6979 limHandleHeartBeatFailure(pMac,psessionEntry);
6980 }
6981 }
6982 /* In the function limHandleHeartBeatFailure things can change so check for the session entry valid
6983 and the other things again */
6984 if(psessionEntry->valid == TRUE )
6985 {
6986 if((psessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE) &&
6987 (psessionEntry->limSystemRole == eLIM_STA_ROLE))
6988 {
6989 if(psessionEntry->LimHBFailureStatus == eANI_BOOLEAN_TRUE)
6990 {
6991 /* Activate Probe After HeartBeat Timer incase HB Failure detected */
6992 PELOGW(limLog(pMac, LOGW,FL("Sending Probe for Session: %d"),
6993 psessionEntry->bssIdx);)
6994 limDeactivateAndChangeTimer(pMac, eLIM_PROBE_AFTER_HB_TIMER);
6995 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0, eLIM_PROBE_AFTER_HB_TIMER));
6996 if (tx_timer_activate(&pMac->lim.limTimers.gLimProbeAfterHBTimer) != TX_SUCCESS)
6997 {
6998 limLog(pMac, LOGP, FL("Fail to re-activate Probe-after-heartbeat timer"));
6999 limReactivateHeartBeatTimer(pMac, psessionEntry);
7000 }
7001 }
7002 }
7003 }
7004}
7005
7006
Jeff Johnson295189b2012-06-20 16:38:30 -07007007tANI_U8 limGetCurrentOperatingChannel(tpAniSirGlobal pMac)
7008{
7009 tANI_U8 i;
7010 for(i =0;i < pMac->lim.maxBssId;i++)
7011 {
7012 if(pMac->lim.gpSession[i].valid == TRUE )
7013 {
7014 if((pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) &&
7015 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_ROLE))
7016 {
7017 return pMac->lim.gpSession[i].currentOperChannel;
7018 }
7019 }
7020 }
7021 return 0;
7022}
7023
7024void limProcessAddStaRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ)
7025{
7026
7027 tpPESession psessionEntry;
7028// tANI_U8 sessionId;
7029 tpAddStaParams pAddStaParams;
7030
7031 pAddStaParams = (tpAddStaParams)limMsgQ->bodyptr;
7032
7033 if((psessionEntry = peFindSessionBySessionId(pMac,pAddStaParams->sessionId))==NULL)
7034 {
7035 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07007036 palFreeMemory(pMac, pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07007037 return;
7038 }
7039 if (psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
7040 (void) limIbssAddStaRsp(pMac, limMsgQ->bodyptr,psessionEntry);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007041#ifdef FEATURE_WLAN_TDLS
7042 else if(pMac->lim.gLimAddStaTdls)
7043 {
7044 limProcessTdlsAddStaRsp(pMac, limMsgQ->bodyptr, psessionEntry) ;
7045 pMac->lim.gLimAddStaTdls = FALSE ;
7046 }
7047#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007048 else
7049 limProcessMlmAddStaRsp(pMac, limMsgQ,psessionEntry);
7050
7051}
7052
7053
7054void limUpdateBeacon(tpAniSirGlobal pMac)
7055{
7056 tANI_U8 i;
7057
7058 for(i =0;i < pMac->lim.maxBssId;i++)
7059 {
7060 if(pMac->lim.gpSession[i].valid == TRUE )
7061 {
7062 if( ( (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) ||
7063 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_IN_IBSS_ROLE) )
7064 && (eLIM_SME_NORMAL_STATE == pMac->lim.gpSession[i].limSmeState)
7065 )
7066 {
7067 schSetFixedBeaconFields(pMac,&pMac->lim.gpSession[i]);
7068 limSendBeaconInd(pMac, &pMac->lim.gpSession[i]);
7069 }
7070 else
7071 {
7072 if( (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)||
7073 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE))
7074 {
7075
7076 if(pMac->lim.gpSession[i].statypeForBss == STA_ENTRY_SELF)
7077 {
7078 schSetFixedBeaconFields(pMac,&pMac->lim.gpSession[i]);
7079 }
7080 }
7081 }
7082 }
7083 }
7084}
7085
7086void limHandleHeartBeatFailureTimeout(tpAniSirGlobal pMac)
7087{
7088 tANI_U8 i;
7089 tpPESession psessionEntry;
7090 /* Probe response is not received after HB failure. This is handled by LMM sub module. */
7091 for(i =0; i < pMac->lim.maxBssId; i++)
7092 {
7093 if(pMac->lim.gpSession[i].valid == TRUE)
7094 {
7095 psessionEntry = &pMac->lim.gpSession[i];
7096 if(psessionEntry->LimHBFailureStatus == eANI_BOOLEAN_TRUE)
7097 {
7098 limLog(pMac, LOGE, FL("Probe_hb_failure: SME %d, MLME %d, HB-Count %d\n"),psessionEntry->limSmeState,
7099 psessionEntry->limMlmState, psessionEntry->LimRxedBeaconCntDuringHB);
7100 if (psessionEntry->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)
7101 {
7102 if (!LIM_IS_CONNECTION_ACTIVE(psessionEntry))
7103 {
7104 limLog(pMac, LOGE, FL("Probe_hb_failure: for session:%d \n" ),psessionEntry->peSessionId);
7105 /* AP did not respond to Probe Request. Tear down link with it.*/
7106 limTearDownLinkWithAp(pMac,
7107 psessionEntry->peSessionId,
7108 eSIR_BEACON_MISSED);
7109 pMac->lim.gLimProbeFailureAfterHBfailedCnt++ ;
7110 }
7111 else // restart heartbeat timer
7112 {
7113 limReactivateHeartBeatTimer(pMac, psessionEntry);
7114 }
7115 }
7116 else
7117 {
7118 limLog(pMac, LOGE, FL("Unexpected wt-probe-timeout in state \n"));
7119 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
7120 limReactivateHeartBeatTimer(pMac, psessionEntry);
7121 }
7122
7123 }
7124 }
7125 }
7126 /* Deactivate Timer ProbeAfterHB Timer -> As its a oneshot timer, need not deactivate the timer */
7127 // tx_timer_deactivate(&pMac->lim.limTimers.gLimProbeAfterHBTimer);
7128}
7129
7130
7131/*
7132* This function assumes there will not be more than one IBSS session active at any time.
7133*/
7134tpPESession limIsIBSSSessionActive(tpAniSirGlobal pMac)
7135{
7136 tANI_U8 i;
7137
7138 for(i =0;i < pMac->lim.maxBssId;i++)
7139 {
7140 if( (pMac->lim.gpSession[i].valid) &&
7141 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_IN_IBSS_ROLE))
7142 return (&pMac->lim.gpSession[i]);
7143 }
7144
7145 return NULL;
7146}
7147
7148tpPESession limIsApSessionActive(tpAniSirGlobal pMac)
7149{
7150 tANI_U8 i;
7151
7152 for(i =0;i < pMac->lim.maxBssId;i++)
7153 {
7154 if( (pMac->lim.gpSession[i].valid) &&
7155 ( (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) ||
7156 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)))
7157 return (&pMac->lim.gpSession[i]);
7158 }
7159
7160 return NULL;
7161}
7162
7163/**---------------------------------------------------------
7164\fn limHandleDeferMsgError
7165\brief handles error scenario, when the msg can not be deferred.
7166\param pMac
7167\param pLimMsg LIM msg, which could not be deferred.
7168\return void
7169-----------------------------------------------------------*/
7170
7171void limHandleDeferMsgError(tpAniSirGlobal pMac, tpSirMsgQ pLimMsg)
7172{
7173 if(SIR_BB_XPORT_MGMT_MSG == pLimMsg->type)
7174 {
7175 vos_pkt_return_packet((vos_pkt_t*)pLimMsg->bodyptr);
7176 }
7177 else if(pLimMsg->bodyptr != NULL)
7178 palFreeMemory( pMac->hHdd, (tANI_U8 *) pLimMsg->bodyptr);
7179
7180}
7181
7182
7183#ifdef FEATURE_WLAN_DIAG_SUPPORT
7184/**---------------------------------------------------------
7185\fn limDiagEventReport
7186\brief This function reports Diag event
7187\param pMac
7188\param eventType
7189\param bssid
7190\param status
7191\param reasonCode
7192\return void
7193-----------------------------------------------------------*/
7194void limDiagEventReport(tpAniSirGlobal pMac, tANI_U16 eventType, tpPESession pSessionEntry, tANI_U16 status, tANI_U16 reasonCode)
7195{
7196 tSirMacAddr nullBssid = { 0, 0, 0, 0, 0, 0 };
7197 WLAN_VOS_DIAG_EVENT_DEF(peEvent, vos_event_wlan_pe_payload_type);
7198
7199 palZeroMemory(pMac->hHdd, &peEvent, sizeof(vos_event_wlan_pe_payload_type));
7200
7201 if (NULL == pSessionEntry)
7202 {
7203 palCopyMemory(pMac->hHdd, peEvent.bssid, nullBssid, sizeof(tSirMacAddr));
7204 peEvent.sme_state = (tANI_U16)pMac->lim.gLimSmeState;
7205 peEvent.mlm_state = (tANI_U16)pMac->lim.gLimMlmState;
7206
7207 }
7208 else
7209 {
7210 palCopyMemory(pMac->hHdd, peEvent.bssid, pSessionEntry->bssId, sizeof(tSirMacAddr));
7211 peEvent.sme_state = (tANI_U16)pSessionEntry->limSmeState;
7212 peEvent.mlm_state = (tANI_U16)pSessionEntry->limMlmState;
7213 }
7214 peEvent.event_type = eventType;
7215 peEvent.status = status;
7216 peEvent.reason_code = reasonCode;
7217
7218 WLAN_VOS_DIAG_EVENT_REPORT(&peEvent, EVENT_WLAN_PE);
7219 return;
7220}
7221
7222#endif /* FEATURE_WLAN_DIAG_SUPPORT */
7223
7224void limProcessAddStaSelfRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ)
7225{
7226
7227 tpAddStaSelfParams pAddStaSelfParams;
7228 tSirMsgQ mmhMsg;
7229 tpSirSmeAddStaSelfRsp pRsp;
7230
7231
7232 pAddStaSelfParams = (tpAddStaSelfParams)limMsgQ->bodyptr;
7233
7234 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pRsp, sizeof(tSirSmeAddStaSelfRsp)))
7235 {
7236 /// Buffer not available. Log error
7237 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for Add Sta self RSP\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07007238 palFreeMemory( pMac->hHdd, (tANI_U8 *)pAddStaSelfParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07007239 return;
7240 }
7241
7242 palZeroMemory(pMac, (tANI_U8*)pRsp, sizeof(tSirSmeAddStaSelfRsp));
7243
7244 pRsp->mesgType = eWNI_SME_ADD_STA_SELF_RSP;
7245 pRsp->mesgLen = (tANI_U16) sizeof(tSirSmeAddStaSelfRsp);
7246 pRsp->status = pAddStaSelfParams->status;
7247
7248 palCopyMemory( pMac->hHdd, pRsp->selfMacAddr, pAddStaSelfParams->selfMacAddr, sizeof(tSirMacAddr) );
7249
7250 palFreeMemory( pMac->hHdd, (tANI_U8 *)pAddStaSelfParams);
7251
7252 mmhMsg.type = eWNI_SME_ADD_STA_SELF_RSP;
7253 mmhMsg.bodyptr = pRsp;
7254 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007255 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07007256 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
7257
7258}
7259
7260void limProcessDelStaSelfRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ)
7261{
7262
7263 tpDelStaSelfParams pDelStaSelfParams;
7264 tSirMsgQ mmhMsg;
7265 tpSirSmeDelStaSelfRsp pRsp;
7266
7267
7268 pDelStaSelfParams = (tpDelStaSelfParams)limMsgQ->bodyptr;
7269
7270 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pRsp, sizeof(tSirSmeDelStaSelfRsp)))
7271 {
7272 /// Buffer not available. Log error
7273 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for Add Sta self RSP\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07007274 palFreeMemory( pMac->hHdd, (tANI_U8 *)pDelStaSelfParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07007275 return;
7276 }
7277
7278 palZeroMemory(pMac, (tANI_U8*)pRsp, sizeof(tSirSmeDelStaSelfRsp));
7279
7280 pRsp->mesgType = eWNI_SME_DEL_STA_SELF_RSP;
7281 pRsp->mesgLen = (tANI_U16) sizeof(tSirSmeDelStaSelfRsp);
7282 pRsp->status = pDelStaSelfParams->status;
7283
7284 palCopyMemory( pMac->hHdd, pRsp->selfMacAddr, pDelStaSelfParams->selfMacAddr, sizeof(tSirMacAddr) );
7285
7286 palFreeMemory( pMac->hHdd, (tANI_U8 *)pDelStaSelfParams);
7287
7288 mmhMsg.type = eWNI_SME_DEL_STA_SELF_RSP;
7289 mmhMsg.bodyptr = pRsp;
7290 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007291 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07007292 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
7293
7294}
7295
7296/***************************************************************
7297* tANI_U8 limUnmapChannel(tANI_U8 mapChannel)
7298* To unmap the channel to reverse the effect of mapping
7299* a band channel in hal .Mapping was done hal to overcome the
7300* limitation of the rxbd which use only 4 bit for channel number.
7301*****************************************************************/
7302tANI_U8 limUnmapChannel(tANI_U8 mapChannel)
7303{
7304 if( mapChannel > 0 && mapChannel < 25 )
7305 return abChannel[mapChannel -1];
7306 else
7307 return 0;
7308}
7309
7310
7311v_U8_t* limGetIEPtr(tpAniSirGlobal pMac, v_U8_t *pIes, int length, v_U8_t eid,eSizeOfLenField size_of_len_field)
7312{
7313 int left = length;
7314 v_U8_t *ptr = pIes;
7315 v_U8_t elem_id;
7316 v_U16_t elem_len;
7317
7318 while(left >= (size_of_len_field+1))
7319 {
7320 elem_id = ptr[0];
7321 if (size_of_len_field == TWO_BYTE)
7322 {
7323 elem_len = ((v_U16_t) ptr[1]) | (ptr[2]<<8);
7324 }
7325 else
7326 {
7327 elem_len = ptr[1];
7328 }
7329
7330
7331 left -= (size_of_len_field+1);
7332 if(elem_len > left)
7333 {
7334 limLog(pMac, LOGE,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007335 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 eid,elem_len,left);
7337 return NULL;
7338 }
7339 if (elem_id == eid)
7340 {
7341 return ptr;
7342 }
7343
7344 left -= elem_len;
7345 ptr += (elem_len + (size_of_len_field+1));
7346 }
7347 return NULL;
7348}
7349
7350/* return NULL if oui is not found in ie
7351 return !NULL pointer to vendor IE (starting from 0xDD) if oui is found
7352 */
7353v_U8_t* limGetVendorIEOuiPtr(tpAniSirGlobal pMac, tANI_U8 *oui, tANI_U8 oui_size, tANI_U8 *ie, tANI_U16 ie_len)
7354{
7355 int left = ie_len;
7356 v_U8_t *ptr = ie;
7357 v_U8_t elem_id, elem_len;
7358
7359 while(left >= 2)
7360 {
7361 elem_id = ptr[0];
7362 elem_len = ptr[1];
7363 left -= 2;
7364 if(elem_len > left)
7365 {
7366 limLog( pMac, LOGE,
7367 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****\n"),
7368 elem_id,elem_len,left);
7369 return NULL;
7370 }
7371 if (SIR_MAC_EID_VENDOR == elem_id)
7372 {
7373 if(memcmp(&ptr[2], oui, oui_size)==0)
7374 return ptr;
7375 }
7376
7377 left -= elem_len;
7378 ptr += (elem_len + 2);
7379 }
7380 return NULL;
7381}
7382
7383#ifdef WLAN_FEATURE_P2P
7384//Returns length of P2P stream and Pointer ie passed to this function is filled with noa stream
7385
7386v_U8_t limBuildP2pIe(tpAniSirGlobal pMac, tANI_U8 *ie, tANI_U8 *data, tANI_U8 ie_len)
7387{
7388 int length = 0;
7389 tANI_U8 *ptr = ie;
7390
7391 ptr[length++] = SIR_MAC_EID_VENDOR;
7392 ptr[length++] = ie_len + SIR_MAC_P2P_OUI_SIZE;
7393 palCopyMemory( pMac->hHdd, &ptr[length], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
7394 palCopyMemory( pMac->hHdd, &ptr[length + SIR_MAC_P2P_OUI_SIZE], data, ie_len);
7395 return (ie_len + SIR_P2P_IE_HEADER_LEN);
7396}
7397
7398//Returns length of NoA stream and Pointer pNoaStream passed to this function is filled with noa stream
7399
7400v_U8_t limGetNoaAttrStreamInMultP2pIes(tpAniSirGlobal pMac,v_U8_t* noaStream,v_U8_t noaLen,v_U8_t overFlowLen)
7401{
7402 v_U8_t overFlowP2pStream[SIR_MAX_NOA_ATTR_LEN];
7403 palCopyMemory( pMac->hHdd, overFlowP2pStream, noaStream + noaLen - overFlowLen, overFlowLen);
7404 noaStream[noaLen - overFlowLen] = SIR_MAC_EID_VENDOR;
7405 noaStream[noaLen - overFlowLen+1] = overFlowLen + SIR_MAC_P2P_OUI_SIZE;
7406 palCopyMemory( pMac->hHdd, noaStream+ noaLen - overFlowLen+2,SIR_MAC_P2P_OUI,SIR_MAC_P2P_OUI_SIZE);
7407
7408 palCopyMemory( pMac->hHdd, noaStream+ noaLen - overFlowLen+2+SIR_MAC_P2P_OUI_SIZE,overFlowP2pStream,overFlowLen);
7409 return (noaLen + SIR_P2P_IE_HEADER_LEN);
7410
7411}
7412
7413//Returns length of NoA stream and Pointer pNoaStream passed to this function is filled with noa stream
7414v_U8_t limGetNoaAttrStream(tpAniSirGlobal pMac, v_U8_t*pNoaStream,tpPESession psessionEntry)
7415{
7416 v_U8_t len=0;
7417
7418 v_U8_t *pBody = pNoaStream;
7419
7420
7421 if ( (psessionEntry != NULL) && (psessionEntry->valid) &&
7422 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
7423 {
7424 if ((!(psessionEntry->p2pGoPsUpdate.uNoa1Duration)) && (!(psessionEntry->p2pGoPsUpdate.uNoa2Duration))
7425 && (!psessionEntry->p2pGoPsUpdate.oppPsFlag)
7426 )
7427 return 0; //No NoA Descriptor then return 0
7428
7429
7430 pBody[0] = SIR_P2P_NOA_ATTR;
7431
7432 pBody[3] = psessionEntry->p2pGoPsUpdate.index;
7433 pBody[4] = psessionEntry->p2pGoPsUpdate.ctWin | (psessionEntry->p2pGoPsUpdate.oppPsFlag<<7);
7434 len = 5;
7435 pBody += len;
7436
7437
7438 if (psessionEntry->p2pGoPsUpdate.uNoa1Duration)
7439 {
7440 *pBody = psessionEntry->p2pGoPsUpdate.uNoa1IntervalCnt;
7441 pBody += 1;
7442 len +=1;
7443
7444 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa1Duration);
7445 pBody += sizeof(tANI_U32);
7446 len +=4;
7447
7448 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa1Interval);
7449 pBody += sizeof(tANI_U32);
7450 len +=4;
7451
7452 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa1StartTime);
7453 pBody += sizeof(tANI_U32);
7454 len +=4;
7455
7456 }
7457
7458 if (psessionEntry->p2pGoPsUpdate.uNoa2Duration)
7459 {
7460 *pBody = psessionEntry->p2pGoPsUpdate.uNoa2IntervalCnt;
7461 pBody += 1;
7462 len +=1;
7463
7464 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa2Duration);
7465 pBody += sizeof(tANI_U32);
7466 len +=4;
7467
7468 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa2Interval);
7469 pBody += sizeof(tANI_U32);
7470 len +=4;
7471
7472 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa2StartTime);
7473 pBody += sizeof(tANI_U32);
7474 len +=4;
7475
7476 }
7477
7478
7479 pBody = pNoaStream + 1;
7480 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(len-3);/*one byte for Attr and 2 bytes for length*/
7481
7482 return (len);
7483
7484 }
7485 return 0;
7486
7487}
Jeff Johnsone7245742012-09-05 17:12:55 -07007488
7489void peSetResumeChannel(tpAniSirGlobal pMac, tANI_U16 channel, ePhyChanBondState phyCbState)
Jeff Johnson295189b2012-06-20 16:38:30 -07007490{
7491
7492 pMac->lim.gResumeChannel = channel;
Jeff Johnsone7245742012-09-05 17:12:55 -07007493 pMac->lim.gResumePhyCbState = phyCbState;
Jeff Johnson295189b2012-06-20 16:38:30 -07007494}
Jeff Johnsone7245742012-09-05 17:12:55 -07007495
Jeff Johnson295189b2012-06-20 16:38:30 -07007496/*--------------------------------------------------------------------------
7497
7498 \brief peGetResumeChannel() - Returns the channel number for scanning, from a valid session.
7499
Jeff Johnsone7245742012-09-05 17:12:55 -07007500 This function returns the channel to resume to during link resume. channel id of 0 means HAL will
7501 resume to previous channel before link suspend
Jeff Johnson295189b2012-06-20 16:38:30 -07007502
7503 \param pMac - pointer to global adapter context
7504 \return - channel to scan from valid session else zero.
7505
7506 \sa
7507
7508 --------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07007509void peGetResumeChannel(tpAniSirGlobal pMac, tANI_U8* resumeChannel, ePhyChanBondState* resumePhyCbState)
Jeff Johnson295189b2012-06-20 16:38:30 -07007510{
7511
7512 //Rationale - this could be the suspend/resume for assoc and it is essential that
7513 //the new BSS is active for some time. Other BSS was anyway suspended.
7514 //TODO: Comeup with a better alternative. Sending NULL with PM=0 on other BSS means
7515 //there will be trouble. But since it is sent on current channel, it will be missed by peer
Jeff Johnsone7245742012-09-05 17:12:55 -07007516 //and hence should be ok. Need to discuss this further
7517 if( !limIsInMCC(pMac) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007518 {
7519 //Get current active session channel
Jeff Johnsone7245742012-09-05 17:12:55 -07007520 peGetActiveSessionChannel(pMac, resumeChannel, resumePhyCbState);
Jeff Johnson295189b2012-06-20 16:38:30 -07007521 }
7522 else
7523 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007524 *resumeChannel = pMac->lim.gResumeChannel;
7525 *resumePhyCbState = pMac->lim.gResumePhyCbState;
Jeff Johnson295189b2012-06-20 16:38:30 -07007526 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007527 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007528}
7529
Viral Modid86bde22012-12-10 13:09:21 -08007530tANI_BOOLEAN limIsNOAInsertReqd(tpAniSirGlobal pMac)
7531{
7532 tANI_U8 i;
7533 for(i =0; i < pMac->lim.maxBssId; i++)
7534 {
7535 if(pMac->lim.gpSession[i].valid == TRUE)
7536 {
7537 if( (eLIM_AP_ROLE == pMac->lim.gpSession[i].limSystemRole )
7538 && ( VOS_P2P_GO_MODE == pMac->lim.gpSession[i].pePersona )
7539 )
7540 {
7541 return TRUE;
7542 }
7543 }
7544 }
7545 return FALSE;
7546}
Jeff Johnsone7245742012-09-05 17:12:55 -07007547
Jeff Johnson295189b2012-06-20 16:38:30 -07007548#endif
7549
7550tANI_BOOLEAN limIsconnectedOnDFSChannel(tANI_U8 currentChannel)
7551{
7552 if(NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(currentChannel))
7553 {
7554 return eANI_BOOLEAN_TRUE;
7555 }
7556 else
7557 {
7558 return eANI_BOOLEAN_FALSE;
7559 }
7560}
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07007561
Mohit Khanna4a70d262012-09-11 16:30:12 -07007562#ifdef WLAN_FEATURE_11AC
7563tANI_BOOLEAN limCheckVHTOpModeChange( tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 chanWidth, tANI_U8 staId)
7564{
7565 tUpdateVHTOpMode tempParam;
7566
7567 tempParam.opMode = chanWidth;
7568 tempParam.staId = staId;
7569
7570 limSendModeUpdate( pMac, &tempParam, psessionEntry );
7571
7572 return eANI_BOOLEAN_TRUE;
7573}
Madan Mohan Koyyalamudi6db7ad12012-10-29 16:14:41 -07007574#endif
7575
7576tANI_U8 limGetShortSlotFromPhyMode(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U32 phyMode)
7577{
7578 tANI_U8 val=0;
7579
7580 if (phyMode == WNI_CFG_PHY_MODE_11A)
7581 {
7582 // 11a mode always uses short slot
7583 // Check this since some APs in 11a mode broadcast long slot in their beacons. As per standard, always use what PHY mandates.
7584 val = true;
7585 }
7586 else if (phyMode == WNI_CFG_PHY_MODE_11G)
7587 {
7588 if ((psessionEntry->pePersona == VOS_STA_SAP_MODE) ||
7589 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
7590 {
7591 val = true;
7592 }
7593
7594 // Program Polaris based on AP capability
7595
7596 if (psessionEntry->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE)
7597 // Joining BSS.
7598 val = SIR_MAC_GET_SHORT_SLOT_TIME( psessionEntry->limCurrentBssCaps);
7599 else if (psessionEntry->limMlmState == eLIM_MLM_WT_REASSOC_RSP_STATE)
7600 // Reassociating with AP.
7601 val = SIR_MAC_GET_SHORT_SLOT_TIME( psessionEntry->limReassocBssCaps);
7602 }
7603 else // if (phyMode == WNI_CFG_PHY_MODE_11B) - use this if another phymode is added later ON
7604 {
7605 // Will reach here in 11b case
7606 val = false;
7607 }
7608 limLog(pMac, LOG1, FL("phyMode = %u shortslotsupported = %u\n"), phyMode, val);
7609 return val;
7610}