blob: 51e27bccea0fcb4ed9869202aa14effd63bf4009 [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"
Jeff Johnson77165482013-03-07 08:15:44 -080065#ifdef FEATURE_WLAN_DIAG_SUPPORT
Jeff Johnson295189b2012-06-20 16:38:30 -070066#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";
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -0800563#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_CCX || defined(FEATURE_WLAN_LFR)
564 case eWNI_SME_GET_ROAM_RSSI_REQ:
565 return "eWNI_SME_GET_ROAM_RSSI_REQ\n";
566 case eWNI_SME_GET_ROAM_RSSI_RSP:
567 return "eWNI_SME_GET_ROAM_RSSI_RSP\n";
568#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700569
Jeff Johnson295189b2012-06-20 16:38:30 -0700570 case WDA_SUSPEND_ACTIVITY_RSP:
571 return "WDA_SUSPEND_ACTIVITY_RSP\n";
572 case SIR_LIM_RETRY_INTERRUPT_MSG:
573 return "SIR_LIM_RETRY_INTERRUPT_MSG\n";
574 case SIR_BB_XPORT_MGMT_MSG:
575 return "SIR_BB_XPORT_MGMT_MSG\n";
576 case SIR_LIM_INV_KEY_INTERRUPT_MSG:
577 return "SIR_LIM_INV_KEY_INTERRUPT_MSG\n";
578 case SIR_LIM_KEY_ID_INTERRUPT_MSG:
579 return "SIR_LIM_KEY_ID_INTERRUPT_MSG\n";
580 case SIR_LIM_REPLAY_THRES_INTERRUPT_MSG:
581 return "SIR_LIM_REPLAY_THRES_INTERRUPT_MSG\n";
582 case SIR_LIM_MIN_CHANNEL_TIMEOUT:
583 return "SIR_LIM_MIN_CHANNEL_TIMEOUT\n";
584 case SIR_LIM_MAX_CHANNEL_TIMEOUT:
585 return "SIR_LIM_MAX_CHANNEL_TIMEOUT\n";
586 case SIR_LIM_JOIN_FAIL_TIMEOUT:
587 return "SIR_LIM_JOIN_FAIL_TIMEOUT\n";
588 case SIR_LIM_AUTH_FAIL_TIMEOUT:
589 return "SIR_LIM_AUTH_FAIL_TIMEOUT\n";
590 case SIR_LIM_AUTH_RSP_TIMEOUT:
591 return "SIR_LIM_AUTH_RSP_TIMEOUT\n";
592 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
593 return "SIR_LIM_ASSOC_FAIL_TIMEOUT\n";
594 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
595 return "SIR_LIM_REASSOC_FAIL_TIMEOUT\n";
596 case SIR_LIM_HEART_BEAT_TIMEOUT:
597 return "SIR_LIM_HEART_BEAT_TIMEOUT\n";
Jeff Johnson295189b2012-06-20 16:38:30 -0700598 case SIR_LIM_ADDTS_RSP_TIMEOUT:
599 return "SIR_LIM_ADDTS_RSP_TIMEOUT\n";
600 case SIR_LIM_CHANNEL_SCAN_TIMEOUT:
601 return "SIR_LIM_CHANNEL_SCAN_TIMEOUT\n";
Jeff Johnson295189b2012-06-20 16:38:30 -0700602 case SIR_LIM_LINK_TEST_DURATION_TIMEOUT:
603 return "SIR_LIM_LINK_TEST_DURATION_TIMEOUT\n";
604 case SIR_LIM_HASH_MISS_THRES_TIMEOUT:
605 return "SIR_LIM_HASH_MISS_THRES_TIMEOUT\n";
606 case SIR_LIM_KEEPALIVE_TIMEOUT:
607 return "SIR_LIM_KEEPALIVE_TIMEOUT\n";
608 case SIR_LIM_UPDATE_OLBC_CACHEL_TIMEOUT:
609 return "SIR_LIM_UPDATE_OLBC_CACHEL_TIMEOUT\n";
610 case SIR_LIM_CNF_WAIT_TIMEOUT:
611 return "SIR_LIM_CNF_WAIT_TIMEOUT\n";
612 case SIR_LIM_RADAR_DETECT_IND:
613 return "SIR_LIM_RADAR_DETECT_IND\n";
614#ifdef WLAN_FEATURE_VOWIFI_11R
615 case SIR_LIM_FT_PREAUTH_RSP_TIMEOUT:
616 return "SIR_LIM_FT_PREAUTH_RSP_TIMEOUT\n";
617#endif
618
619 case SIR_HAL_APP_SETUP_NTF:
620 return "SIR_HAL_APP_SETUP_NTF\n";
621 case SIR_HAL_INITIAL_CAL_FAILED_NTF:
622 return "SIR_HAL_INITIAL_CAL_FAILED_NTF\n";
623 case SIR_HAL_NIC_OPER_NTF:
624 return "SIR_HAL_NIC_OPER_NTF\n";
625 case SIR_HAL_INIT_START_REQ:
626 return "SIR_HAL_INIT_START_REQ\n";
627 case SIR_HAL_SHUTDOWN_REQ:
628 return "SIR_HAL_SHUTDOWN_REQ\n";
629 case SIR_HAL_SHUTDOWN_CNF:
630 return "SIR_HAL_SHUTDOWN_CNF\n";
631 case SIR_HAL_RESET_REQ:
632 return "SIR_HAL_RESET_REQ\n";
633 case SIR_HAL_RESET_CNF:
634 return "SIR_HAL_RESET_CNF\n";
635 case SIR_WRITE_TO_TD:
636 return "SIR_WRITE_TO_TD\n";
637
638 case WNI_CFG_PARAM_UPDATE_IND:
639 return "WNI_CFG_PARAM_UPDATE_IND\n";
640 case WNI_CFG_DNLD_REQ:
641 return "WNI_CFG_DNLD_REQ\n";
642 case WNI_CFG_DNLD_CNF:
643 return "WNI_CFG_DNLD_CNF\n";
644 case WNI_CFG_GET_RSP:
645 return "WNI_CFG_GET_RSP\n";
646 case WNI_CFG_SET_CNF:
647 return "WNI_CFG_SET_CNF\n";
648 case WNI_CFG_GET_ATTRIB_RSP:
649 return "WNI_CFG_GET_ATTRIB_RSP\n";
650 case WNI_CFG_ADD_GRP_ADDR_CNF:
651 return "WNI_CFG_ADD_GRP_ADDR_CNF\n";
652 case WNI_CFG_DEL_GRP_ADDR_CNF:
653 return "WNI_CFG_DEL_GRP_ADDR_CNF\n";
654 case ANI_CFG_GET_RADIO_STAT_RSP:
655 return "ANI_CFG_GET_RADIO_STAT_RSP\n";
656 case ANI_CFG_GET_PER_STA_STAT_RSP:
657 return "ANI_CFG_GET_PER_STA_STAT_RSP\n";
658 case ANI_CFG_GET_AGG_STA_STAT_RSP:
659 return "ANI_CFG_GET_AGG_STA_STAT_RSP\n";
660 case ANI_CFG_CLEAR_STAT_RSP:
661 return "ANI_CFG_CLEAR_STAT_RSP\n";
662 case WNI_CFG_DNLD_RSP:
663 return "WNI_CFG_DNLD_RSP\n";
664 case WNI_CFG_GET_REQ:
665 return "WNI_CFG_GET_REQ\n";
666 case WNI_CFG_SET_REQ:
667 return "WNI_CFG_SET_REQ\n";
668 case WNI_CFG_SET_REQ_NO_RSP:
669 return "WNI_CFG_SET_REQ_NO_RSP\n";
670 case eWNI_PMC_ENTER_IMPS_RSP:
671 return "eWNI_PMC_ENTER_IMPS_RSP\n";
672 case eWNI_PMC_EXIT_IMPS_RSP:
673 return "eWNI_PMC_EXIT_IMPS_RSP\n";
674 case eWNI_PMC_ENTER_BMPS_RSP:
675 return "eWNI_PMC_ENTER_BMPS_RSP\n";
676 case eWNI_PMC_EXIT_BMPS_RSP:
677 return "eWNI_PMC_EXIT_BMPS_RSP\n";
678 case eWNI_PMC_EXIT_BMPS_IND:
679 return "eWNI_PMC_EXIT_BMPS_IND\n";
Yathish9f22e662012-12-10 14:21:35 -0800680 case eWNI_SME_SET_BCN_FILTER_REQ:
681 return "eWNI_SME_SET_BCN_FILTER_REQ\n";
Jeff Johnson295189b2012-06-20 16:38:30 -0700682 default:
683 return "INVALID SME message\n";
684 }
685#endif
686return "";
687}
688
689
690
691char *limResultCodeStr(tSirResultCodes resultCode)
692{
Jeff Johnson295189b2012-06-20 16:38:30 -0700693 switch (resultCode)
694 {
695 case eSIR_SME_SUCCESS:
696 return "eSIR_SME_SUCCESS\n";
697 case eSIR_EOF_SOF_EXCEPTION:
698 return "eSIR_EOF_SOF_EXCEPTION\n";
699 case eSIR_BMU_EXCEPTION:
700 return "eSIR_BMU_EXCEPTION\n";
701 case eSIR_LOW_PDU_EXCEPTION:
702 return "eSIR_LOW_PDU_EXCEPTION\n";
703 case eSIR_USER_TRIG_RESET:
704 return"eSIR_USER_TRIG_RESET\n";
705 case eSIR_LOGP_EXCEPTION:
706 return "eSIR_LOGP_EXCEPTION\n";
707 case eSIR_CP_EXCEPTION:
708 return "eSIR_CP_EXCEPTION\n";
709 case eSIR_STOP_BSS:
710 return "eSIR_STOP_BSS\n";
711 case eSIR_AHB_HANG_EXCEPTION:
712 return "eSIR_AHB_HANG_EXCEPTION\n";
713 case eSIR_DPU_EXCEPTION:
714 return "eSIR_DPU_EXCEPTION\n";
715 case eSIR_RXP_EXCEPTION:
716 return "eSIR_RXP_EXCEPTION\n";
717 case eSIR_MCPU_EXCEPTION:
718 return "eSIR_MCPU_EXCEPTION\n";
719 case eSIR_MCU_EXCEPTION:
720 return "eSIR_MCU_EXCEPTION\n";
721 case eSIR_MTU_EXCEPTION:
722 return "eSIR_MTU_EXCEPTION\n";
723 case eSIR_MIF_EXCEPTION:
724 return "eSIR_MIF_EXCEPTION\n";
725 case eSIR_FW_EXCEPTION:
726 return "eSIR_FW_EXCEPTION\n";
727 case eSIR_MAILBOX_SANITY_CHK_FAILED:
728 return "eSIR_MAILBOX_SANITY_CHK_FAILED\n";
729 case eSIR_RADIO_HW_SWITCH_STATUS_IS_OFF:
730 return "eSIR_RADIO_HW_SWITCH_STATUS_IS_OFF\n";
731 case eSIR_CFB_FLAG_STUCK_EXCEPTION:
732 return "eSIR_CFB_FLAG_STUCK_EXCEPTION\n";
733 case eSIR_SME_BASIC_RATES_NOT_SUPPORTED_STATUS:
734 return "eSIR_SME_BASIC_RATES_NOT_SUPPORTED_STATUS\n";
735 case eSIR_SME_INVALID_PARAMETERS:
736 return "eSIR_SME_INVALID_PARAMETERS\n";
737 case eSIR_SME_UNEXPECTED_REQ_RESULT_CODE:
738 return "eSIR_SME_UNEXPECTED_REQ_RESULT_CODE\n";
739 case eSIR_SME_RESOURCES_UNAVAILABLE:
740 return "eSIR_SME_RESOURCES_UNAVAILABLE\n";
741 case eSIR_SME_SCAN_FAILED:
742 return "eSIR_SME_SCAN_FAILED\n";
743 case eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED:
744 return "eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED\n";
745 case eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE:
746 return "eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE\n";
747 case eSIR_SME_REFUSED:
748 return "eSIR_SME_REFUSED\n";
749 case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE:
750 return "eSIR_SME_JOIN_TIMEOUT_RESULT_CODE\n";
751 case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE:
752 return "eSIR_SME_AUTH_TIMEOUT_RESULT_CODE\n";
753 case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE:
754 return "eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE\n";
755 case eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE:
756 return "eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE\n";
757 case eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED:
758 return "eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED\n";
759 case eSIR_SME_AUTH_REFUSED:
760 return "eSIR_SME_AUTH_REFUSED\n";
761 case eSIR_SME_INVALID_WEP_DEFAULT_KEY:
762 return "eSIR_SME_INVALID_WEP_DEFAULT_KEY\n";
763 case eSIR_SME_ASSOC_REFUSED:
764 return "eSIR_SME_ASSOC_REFUSED\n";
765 case eSIR_SME_REASSOC_REFUSED:
766 return "eSIR_SME_REASSOC_REFUSED\n";
767 case eSIR_SME_STA_NOT_AUTHENTICATED:
768 return "eSIR_SME_STA_NOT_AUTHENTICATED\n";
769 case eSIR_SME_STA_NOT_ASSOCIATED:
770 return "eSIR_SME_STA_NOT_ASSOCIATED\n";
771 case eSIR_SME_STA_DISASSOCIATED:
772 return "eSIR_SME_STA_DISASSOCIATED\n";
773 case eSIR_SME_ALREADY_JOINED_A_BSS:
774 return "eSIR_SME_ALREADY_JOINED_A_BSS\n";
775 case eSIR_ULA_COMPLETED:
776 return "eSIR_ULA_COMPLETED\n";
777 case eSIR_ULA_FAILURE:
778 return "eSIR_ULA_FAILURE\n";
779 case eSIR_SME_LINK_ESTABLISHED:
780 return "eSIR_SME_LINK_ESTABLISHED\n";
781 case eSIR_SME_UNABLE_TO_PERFORM_MEASUREMENTS:
782 return "eSIR_SME_UNABLE_TO_PERFORM_MEASUREMENTS\n";
783 case eSIR_SME_UNABLE_TO_PERFORM_DFS:
784 return "eSIR_SME_UNABLE_TO_PERFORM_DFS\n";
785 case eSIR_SME_DFS_FAILED:
786 return "eSIR_SME_DFS_FAILED\n";
787 case eSIR_SME_TRANSFER_STA:
788 return "eSIR_SME_TRANSFER_STA\n";
789 case eSIR_SME_INVALID_LINK_TEST_PARAMETERS:
790 return "eSIR_SME_INVALID_LINK_TEST_PARAMETERS\n";
791 case eSIR_SME_LINK_TEST_MAX_EXCEEDED:
792 return "eSIR_SME_LINK_TEST_MAX_EXCEEDED\n";
793 case eSIR_SME_UNSUPPORTED_RATE:
794 return "eSIR_SME_UNSUPPORTED_RATE\n";
795 case eSIR_SME_LINK_TEST_TIMEOUT:
796 return "eSIR_SME_LINK_TEST_TIMEOUT\n";
797 case eSIR_SME_LINK_TEST_COMPLETE:
798 return "eSIR_SME_LINK_TEST_COMPLETE\n";
799 case eSIR_SME_LINK_TEST_INVALID_STATE:
800 return "eSIR_SME_LINK_TEST_INVALID_STATE\n";
801 case eSIR_SME_LINK_TEST_INVALID_ADDRESS:
802 return "eSIR_SME_LINK_TEST_INVALID_ADDRESS\n";
803 case eSIR_SME_POLARIS_RESET:
804 return "eSIR_SME_POLARIS_RESET\n";
805 case eSIR_SME_SETCONTEXT_FAILED:
806 return "eSIR_SME_SETCONTEXT_FAILED\n";
807 case eSIR_SME_BSS_RESTART:
808 return "eSIR_SME_BSS_RESTART\n";
809 case eSIR_SME_MORE_SCAN_RESULTS_FOLLOW:
810 return "eSIR_SME_MORE_SCAN_RESULTS_FOLLOW\n";
811 case eSIR_SME_INVALID_ASSOC_RSP_RXED:
812 return "eSIR_SME_INVALID_ASSOC_RSP_RXED\n";
813 case eSIR_SME_MIC_COUNTER_MEASURES:
814 return "eSIR_SME_MIC_COUNTER_MEASURES\n";
815 case eSIR_SME_ADDTS_RSP_TIMEOUT:
816 return "eSIR_SME_ADDTS_RSP_TIMEOUT\n";
817 case eSIR_SME_RECEIVED:
818 return "eSIR_SME_RECEIVED\n";
819 case eSIR_SME_CHANNEL_SWITCH_FAIL:
820 return "eSIR_SME_CHANNEL_SWITCH_FAIL\n";
821#ifdef GEN4_SCAN
822 case eSIR_SME_CHANNEL_SWITCH_DISABLED:
823 return "eSIR_SME_CHANNEL_SWITCH_DISABLED\n";
824 case eSIR_SME_HAL_SCAN_INIT_FAILED:
825 return "eSIR_SME_HAL_SCAN_INIT_FAILED\n";
826 case eSIR_SME_HAL_SCAN_START_FAILED:
827 return "eSIR_SME_HAL_SCAN_START_FAILED\n";
828 case eSIR_SME_HAL_SCAN_END_FAILED:
829 return "eSIR_SME_HAL_SCAN_END_FAILED\n";
830 case eSIR_SME_HAL_SCAN_FINISH_FAILED:
831 return "eSIR_SME_HAL_SCAN_FINISH_FAILED\n";
832 case eSIR_SME_HAL_SEND_MESSAGE_FAIL:
833 return "eSIR_SME_HAL_SEND_MESSAGE_FAIL\n";
834#else // GEN4_SCAN
835 case eSIR_SME_CHANNEL_SWITCH_DISABLED:
836 return "eSIR_SME_CHANNEL_SWITCH_DISABLED\n";
837 case eSIR_SME_HAL_SEND_MESSAGE_FAIL:
838 return "eSIR_SME_HAL_SEND_MESSAGE_FAIL\n";
839#endif // GEN4_SCAN
840
841 default:
842 return "INVALID resultCode\n";
843 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700844}
845
846void
847limPrintMsgName(tpAniSirGlobal pMac, tANI_U16 logLevel, tANI_U32 msgType)
848{
849 limLog(pMac, logLevel, limMsgStr(msgType));
850}
851
852
853#if defined(ANI_MIPS) || defined(ANI_ARM)
854#define LINK 0
855#else
856#define LINK 1
857#endif
858
859void
860limPrintMsgInfo(tpAniSirGlobal pMac, tANI_U16 logLevel, tSirMsgQ *msg)
861{
Jeff Johnson295189b2012-06-20 16:38:30 -0700862 if (logLevel <= pMac->utils.gLogDbgLevel[SIR_LIM_MODULE_ID - LOG_FIRST_MODULE_ID])
863 {
864 switch (msg->type)
865 {
866 case SIR_BB_XPORT_MGMT_MSG:
Jeff Johnson295189b2012-06-20 16:38:30 -0700867 limPrintMsgName(pMac, logLevel,msg->type);
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 break;
869 default:
870 limPrintMsgName(pMac, logLevel,msg->type);
871 break;
872 }
873 }
874}
875
876/**
877 * limInitMlm()
878 *
879 *FUNCTION:
880 * This function is called by limProcessSmeMessages() to
881 * initialize MLM state machine on STA
882 *
883 *PARAMS:
884 *
885 *LOGIC:
886 *
887 *ASSUMPTIONS:
888 * NA
889 *
890 *NOTE:
891 * NA
892 *
893 * @param pMac Pointer to Global MAC structure
894 * @return None
895 */
896void
897limInitMlm(tpAniSirGlobal pMac)
898{
Madan Mohan Koyyalamudi694f8d72012-10-11 16:32:55 -0700899 tANI_U32 retVal;
900
901 pMac->lim.gLimTimersCreated = 0;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -0700902
Jeff Johnsone7245742012-09-05 17:12:55 -0700903 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, NO_SESSION, pMac->lim.gLimMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700904
905 /// Initialize scan result hash table
906 limReInitScanResults(pMac); //sep26th review
907
908
909 /// Initialize number of pre-auth contexts
910 pMac->lim.gLimNumPreAuthContexts = 0;
911
912 /// Initialize MAC based Authentication STA list
913 limInitPreAuthList(pMac);
914
915 //pMac->lim.gpLimMlmJoinReq = NULL;
916
917 if (pMac->lim.gLimTimersCreated)
918 return;
919
920 // Create timers used by LIM
Madan Mohan Koyyalamudi694f8d72012-10-11 16:32:55 -0700921 retVal = limCreateTimers(pMac);
922 if(retVal == TX_SUCCESS)
923 {
924 pMac->lim.gLimTimersCreated = 1;
925 }
926 else
927 {
928 limLog(pMac, LOGP, FL(" limCreateTimers Failed to create lim timers \n"));
929 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700930} /*** end limInitMlm() ***/
931
932
933
934/**
935 * limCleanupMlm()
936 *
937 *FUNCTION:
938 * This function is called to cleanup any resources
939 * allocated by the MLM state machine.
940 *
941 *PARAMS:
942 *
943 *LOGIC:
944 *
945 *ASSUMPTIONS:
946 * NA
947 *
948 *NOTE:
949 * It is assumed that BSS is already informed that we're leaving it
950 * before this function is called.
951 *
952 * @param pMac Pointer to Global MAC structure
953 * @param None
954 * @return None
955 */
956void
957limCleanupMlm(tpAniSirGlobal pMac)
958{
959 tANI_U32 n;
960 tLimPreAuthNode *pAuthNode;
961
962 if (pMac->lim.gLimTimersCreated == 1)
963 {
964 // Deactivate and delete MIN/MAX channel timers.
965 tx_timer_deactivate(&pMac->lim.limTimers.gLimMinChannelTimer);
966 tx_timer_delete(&pMac->lim.limTimers.gLimMinChannelTimer);
967 tx_timer_deactivate(&pMac->lim.limTimers.gLimMaxChannelTimer);
968 tx_timer_delete(&pMac->lim.limTimers.gLimMaxChannelTimer);
969 tx_timer_deactivate(&pMac->lim.limTimers.gLimPeriodicProbeReqTimer);
970 tx_timer_delete(&pMac->lim.limTimers.gLimPeriodicProbeReqTimer);
971
972
973 // Deactivate and delete channel switch timer.
974 tx_timer_deactivate(&pMac->lim.limTimers.gLimChannelSwitchTimer);
975 tx_timer_delete(&pMac->lim.limTimers.gLimChannelSwitchTimer);
976
977
978 // Deactivate and delete addts response timer.
979 tx_timer_deactivate(&pMac->lim.limTimers.gLimAddtsRspTimer);
980 tx_timer_delete(&pMac->lim.limTimers.gLimAddtsRspTimer);
981
982 // Deactivate and delete Join failure timer.
983 tx_timer_deactivate(&pMac->lim.limTimers.gLimJoinFailureTimer);
984 tx_timer_delete(&pMac->lim.limTimers.gLimJoinFailureTimer);
985
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -0800986 // Deactivate and delete Periodic Join Probe Request timer.
987 tx_timer_deactivate(&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer);
988 tx_timer_delete(&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer);
989
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 // Deactivate and delete Association failure timer.
991 tx_timer_deactivate(&pMac->lim.limTimers.gLimAssocFailureTimer);
992 tx_timer_delete(&pMac->lim.limTimers.gLimAssocFailureTimer);
993
994 // Deactivate and delete Reassociation failure timer.
995 tx_timer_deactivate(&pMac->lim.limTimers.gLimReassocFailureTimer);
996 tx_timer_delete(&pMac->lim.limTimers.gLimReassocFailureTimer);
997
998 // Deactivate and delete Authentication failure timer.
999 tx_timer_deactivate(&pMac->lim.limTimers.gLimAuthFailureTimer);
1000 tx_timer_delete(&pMac->lim.limTimers.gLimAuthFailureTimer);
1001
1002 // Deactivate and delete Heartbeat timer.
1003 tx_timer_deactivate(&pMac->lim.limTimers.gLimHeartBeatTimer);
1004 tx_timer_delete(&pMac->lim.limTimers.gLimHeartBeatTimer);
1005
1006 // Deactivate and delete wait-for-probe-after-Heartbeat timer.
1007 tx_timer_deactivate(&pMac->lim.limTimers.gLimProbeAfterHBTimer);
1008 tx_timer_delete(&pMac->lim.limTimers.gLimProbeAfterHBTimer);
1009
1010 // Deactivate and delete Quiet timer.
1011 tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietTimer);
1012 tx_timer_delete(&pMac->lim.limTimers.gLimQuietTimer);
1013
1014 // Deactivate and delete Quiet BSS timer.
1015 tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietBssTimer);
1016 tx_timer_delete(&pMac->lim.limTimers.gLimQuietBssTimer);
1017
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 // Deactivate and delete LIM background scan timer.
1019 tx_timer_deactivate(&pMac->lim.limTimers.gLimBackgroundScanTimer);
1020 tx_timer_delete(&pMac->lim.limTimers.gLimBackgroundScanTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07001021
1022
1023 // Deactivate and delete cnf wait timer
1024 for (n = 0; n < pMac->lim.maxStation; n++)
1025 {
1026 tx_timer_deactivate(&pMac->lim.limTimers.gpLimCnfWaitTimer[n]);
1027 tx_timer_delete(&pMac->lim.limTimers.gpLimCnfWaitTimer[n]);
1028 }
1029
1030 // Deactivate and delete keepalive timer
1031 tx_timer_deactivate(&pMac->lim.limTimers.gLimKeepaliveTimer);
1032 tx_timer_delete(&pMac->lim.limTimers.gLimKeepaliveTimer);
1033
1034 pAuthNode = pMac->lim.gLimPreAuthTimerTable.pTable;
1035
1036 //Deactivate any Authentication response timers
1037 limDeletePreAuthList(pMac);
1038
1039 for (n = 0; n < pMac->lim.gLimPreAuthTimerTable.numEntry; n++,pAuthNode++)
1040 {
1041 // Delete any Authentication response
1042 // timers, which might have been started.
1043 tx_timer_delete(&pAuthNode->timer);
1044 }
1045
Jeff Johnson295189b2012-06-20 16:38:30 -07001046
1047
1048 // Deactivate and delete Hash Miss throttle timer
1049 tx_timer_deactivate(&pMac->lim.limTimers.gLimSendDisassocFrameThresholdTimer);
1050 tx_timer_delete(&pMac->lim.limTimers.gLimSendDisassocFrameThresholdTimer);
1051
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 tx_timer_deactivate(&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer);
1053 tx_timer_delete(&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer);
1054 tx_timer_deactivate(&pMac->lim.limTimers.gLimPreAuthClnupTimer);
1055 tx_timer_delete(&pMac->lim.limTimers.gLimPreAuthClnupTimer);
1056
1057#if 0 // The WPS PBC clean up timer is disabled
1058 if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE)
1059 {
1060 if(pMac->lim.limTimers.gLimWPSOverlapTimerObj.isTimerCreated == eANI_BOOLEAN_TRUE)
1061 {
1062 tx_timer_deactivate(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer);
1063 tx_timer_delete(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer);
1064 pMac->lim.limTimers.gLimWPSOverlapTimerObj.isTimerCreated = eANI_BOOLEAN_FALSE;
1065 }
1066 }
1067#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001068#ifdef WLAN_FEATURE_VOWIFI_11R
1069 // Deactivate and delete FT Preauth response timer
1070 tx_timer_deactivate(&pMac->lim.limTimers.gLimFTPreAuthRspTimer);
1071 tx_timer_delete(&pMac->lim.limTimers.gLimFTPreAuthRspTimer);
1072#endif
1073
Jeff Johnson295189b2012-06-20 16:38:30 -07001074 // Deactivate and delete remain on channel timer
1075 tx_timer_deactivate(&pMac->lim.limTimers.gLimRemainOnChannelTimer);
1076 tx_timer_delete(&pMac->lim.limTimers.gLimRemainOnChannelTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -07001077
1078#ifdef FEATURE_WLAN_CCX
1079 // Deactivate and delete TSM
1080 tx_timer_deactivate(&pMac->lim.limTimers.gLimCcxTsmTimer);
1081 tx_timer_delete(&pMac->lim.limTimers.gLimCcxTsmTimer);
1082#endif
1083
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08001084 tx_timer_deactivate(&pMac->lim.limTimers.gLimDisassocAckTimer);
1085 tx_timer_delete(&pMac->lim.limTimers.gLimDisassocAckTimer);
1086
1087 tx_timer_deactivate(&pMac->lim.limTimers.gLimDeauthAckTimer);
1088 tx_timer_delete(&pMac->lim.limTimers.gLimDeauthAckTimer);
1089
Hoonki Leef63df0d2013-01-16 19:29:14 -08001090 tx_timer_deactivate(&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer);
1091 tx_timer_delete(&pMac->lim.limTimers.gLimP2pSingleShotNoaInsertTimer);
Hoonki Leef63df0d2013-01-16 19:29:14 -08001092
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 pMac->lim.gLimTimersCreated = 0;
1094 }
1095
1096 /// Cleanup cached scan list
1097 limReInitScanResults(pMac);
1098
1099} /*** end limCleanupMlm() ***/
1100
1101
1102
1103/**
1104 * limCleanupLmm()
1105 *
1106 *FUNCTION:
1107 * This function is called to cleanup any resources
1108 * allocated by LMM sub-module.
1109 *
1110 *PARAMS:
1111 *
1112 *LOGIC:
1113 *
1114 *ASSUMPTIONS:
1115 * NA
1116 *
1117 *NOTE:
1118 * NA
1119 *
1120 * @param pMac Pointer to Global MAC structure
1121 * @return None
1122 */
1123
1124void
1125limCleanupLmm(tpAniSirGlobal pMac)
1126{
Jeff Johnson295189b2012-06-20 16:38:30 -07001127} /*** end limCleanupLmm() ***/
1128
1129
1130
1131/**
1132 * limIsAddrBC()
1133 *
1134 *FUNCTION:
1135 * This function is called in various places within LIM code
1136 * to determine whether passed MAC address is a broadcast or not
1137 *
1138 *LOGIC:
1139 *
1140 *ASSUMPTIONS:
1141 * NA
1142 *
1143 *NOTE:
1144 * NA
1145 *
1146 * @param macAddr Indicates MAC address that need to be determined
1147 * whether it is Broadcast address or not
1148 *
1149 * @return true if passed address is Broadcast address else false
1150 */
1151
1152tANI_U8
1153limIsAddrBC(tSirMacAddr macAddr)
1154{
1155 int i;
1156 for (i = 0; i < 6; i++)
1157 {
1158 if ((macAddr[i] & 0xFF) != 0xFF)
1159 return false;
1160 }
1161
1162 return true;
1163} /****** end limIsAddrBC() ******/
1164
1165
1166
1167/**
1168 * limIsGroupAddr()
1169 *
1170 *FUNCTION:
1171 * This function is called in various places within LIM code
1172 * to determine whether passed MAC address is a group address or not
1173 *
1174 *LOGIC:
1175 * If least significant bit of first octet of the MAC address is
1176 * set to 1, it is a Group address.
1177 *
1178 *ASSUMPTIONS:
1179 * NA
1180 *
1181 *NOTE:
1182 * NA
1183 *
1184 * @param macAddr Indicates MAC address that need to be determined
1185 * whether it is Group address or not
1186 *
1187 * @return true if passed address is Group address else false
1188 */
1189
1190tANI_U8
1191limIsGroupAddr(tSirMacAddr macAddr)
1192{
1193 if ((macAddr[0] & 0x01) == 0x01)
1194 return true;
1195 else
1196 return false;
1197} /****** end limIsGroupAddr() ******/
1198
1199/**
1200 * limPostMsgApiNoWait()
1201 *
1202 *FUNCTION:
1203 * This function is called from other thread while posting a
1204 * message to LIM message Queue gSirLimMsgQ with NO_WAIT option
1205 *
1206 *LOGIC:
1207 * NA
1208 *
1209 *ASSUMPTIONS:
1210 * NA
1211 *
1212 *NOTE:
1213 * NA
1214 *
1215 * @param pMsg - Pointer to the Global MAC structure
1216 * @param pMsg - Pointer to the message structure
1217 * @return None
1218 */
1219
1220tANI_U32
1221limPostMsgApiNoWait(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1222{
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 limProcessMessages(pMac, pMsg);
1224 return TX_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001225} /*** end limPostMsgApiNoWait() ***/
1226
1227
1228
1229/**
1230 * limPrintMacAddr()
1231 *
1232 *FUNCTION:
1233 * This function is called to print passed MAC address
1234 * in : format.
1235 *
1236 *LOGIC:
1237 *
1238 *ASSUMPTIONS:
1239 * NA
1240 *
1241 *NOTE:
1242 * @param macAddr - MacAddr to be printed
1243 * @param logLevel - Loglevel to be used
1244 *
1245 * @return None.
1246 */
1247
1248void
1249limPrintMacAddr(tpAniSirGlobal pMac, tSirMacAddr macAddr, tANI_U8 logLevel)
1250{
1251 limLog(pMac, logLevel,
1252 FL("%X:%X:%X:%X:%X:%X\n"),
1253 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
1254 macAddr[5]);
1255} /****** end limPrintMacAddr() ******/
1256
1257
1258
1259
1260
1261
1262/*
1263 * limResetDeferredMsgQ()
1264 *
1265 *FUNCTION:
1266 * This function resets the deferred message queue parameters.
1267 *
1268 *PARAMS:
1269 * @param pMac - Pointer to Global MAC structure
1270 *
1271 *LOGIC:
1272 *
1273 *ASSUMPTIONS:
1274 * NA
1275 *
1276 *NOTE:
1277 * NA
1278 *
1279 *RETURNS:
1280 * None
1281 */
1282
1283void limResetDeferredMsgQ(tpAniSirGlobal pMac)
1284{
1285 pMac->lim.gLimDeferredMsgQ.size =
1286 pMac->lim.gLimDeferredMsgQ.write =
1287 pMac->lim.gLimDeferredMsgQ.read = 0;
1288
1289}
1290
1291
1292#define LIM_DEFERRED_Q_CHECK_THRESHOLD (MAX_DEFERRED_QUEUE_LEN/2)
1293#define LIM_MAX_NUM_MGMT_FRAME_DEFERRED (MAX_DEFERRED_QUEUE_LEN/2)
1294
1295/*
1296 * limWriteDeferredMsgQ()
1297 *
1298 *FUNCTION:
1299 * This function queues up a deferred message for later processing on the
1300 * STA side.
1301 *
1302 *PARAMS:
1303 * @param pMac - Pointer to Global MAC structure
1304 * @param limMsg - a LIM message
1305 *
1306 *LOGIC:
1307 *
1308 *ASSUMPTIONS:
1309 * NA
1310 *
1311 *NOTE:
1312 * NA
1313 *
1314 *RETURNS:
1315 * None
1316 */
1317
1318tANI_U8 limWriteDeferredMsgQ(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
1319{
1320 PELOG1(limLog(pMac, LOG1,
1321 FL("** Queue a deferred message (size %d, write %d) - type 0x%x **\n"),
1322 pMac->lim.gLimDeferredMsgQ.size, pMac->lim.gLimDeferredMsgQ.write,
1323 limMsg->type);)
1324
1325 /*
1326 ** check if the deferred message queue is full
1327 **/
1328 if (pMac->lim.gLimDeferredMsgQ.size >= MAX_DEFERRED_QUEUE_LEN)
1329 {
Leela Venkata Kiran Kumar Reddy Chirala2247e962013-03-22 19:21:10 -07001330 if(!(pMac->lim.deferredMsgCnt & 0xF))
1331 {
1332 PELOGE(limLog(pMac, LOGE, FL("Deferred Message Queue is full. Msg:%d Messages Failed:%d\n"), limMsg->type, ++pMac->lim.deferredMsgCnt);)
1333 }
1334 else
1335 {
1336 pMac->lim.deferredMsgCnt++;
1337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 return TX_QUEUE_FULL;
1339 }
1340
1341 /*
1342 ** In the application, there should not be more than 1 message get
1343 ** queued up. If happens, flags a warning. In the future, this can
1344 ** happen.
1345 **/
1346 if (pMac->lim.gLimDeferredMsgQ.size > 0)
1347 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001348 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 -07001349 pMac->lim.gLimDeferredMsgQ.size, limMsg->type,
1350 limIsSystemInScanState(pMac),
1351 pMac->lim.gLimSmeState, pMac->lim.gLimMlmState,
1352 pMac->lim.gLimAddtsSent);)
1353 }
1354
1355 /*
1356 ** To prevent the deferred Q is full of management frames, only give them certain space
1357 **/
1358 if( SIR_BB_XPORT_MGMT_MSG == limMsg->type )
1359 {
1360 if( LIM_DEFERRED_Q_CHECK_THRESHOLD < pMac->lim.gLimDeferredMsgQ.size )
1361 {
1362 tANI_U16 idx, count = 0;
1363 for(idx = 0; idx < pMac->lim.gLimDeferredMsgQ.size; idx++)
1364 {
1365 if( SIR_BB_XPORT_MGMT_MSG == pMac->lim.gLimDeferredMsgQ.deferredQueue[idx].type )
1366 {
1367 count++;
1368 }
1369 }
1370 if( LIM_MAX_NUM_MGMT_FRAME_DEFERRED < count )
1371 {
1372 //We reach the quota for management frames, drop this one
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07001373 PELOGW(limLog(pMac, LOGW, FL("Cannot deferred. Msg: %d Too many (count=%d) already"), limMsg->type, count);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001374 //Return error, caller knows what to do
1375 return TX_QUEUE_FULL;
1376 }
1377 }
1378 }
1379
1380 ++pMac->lim.gLimDeferredMsgQ.size;
1381
Leela Venkata Kiran Kumar Reddy Chirala2247e962013-03-22 19:21:10 -07001382 /* reset the count here since we are able to defer the message */
1383 if(pMac->lim.deferredMsgCnt != 0)
1384 {
1385 pMac->lim.deferredMsgCnt = 0;
1386 }
1387
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 /*
1389 ** if the write pointer hits the end of the queue, rewind it
1390 **/
1391 if (pMac->lim.gLimDeferredMsgQ.write >= MAX_DEFERRED_QUEUE_LEN)
1392 pMac->lim.gLimDeferredMsgQ.write = 0;
1393
1394 /*
1395 ** save the message to the queue and advanced the write pointer
1396 **/
1397 palCopyMemory(pMac->hHdd,
1398 (tANI_U8 *)&pMac->lim.gLimDeferredMsgQ.deferredQueue[pMac->lim.gLimDeferredMsgQ.write++],
1399 (tANI_U8 *)limMsg,
1400 sizeof(tSirMsgQ));
1401 return TX_SUCCESS;
1402
1403}
1404
1405/*
1406 * limReadDeferredMsgQ()
1407 *
1408 *FUNCTION:
1409 * This function dequeues a deferred message for processing on the
1410 * STA side.
1411 *
1412 *PARAMS:
1413 * @param pMac - Pointer to Global MAC structure
1414 *
1415 *LOGIC:
1416 *
1417 *ASSUMPTIONS:
1418 * NA
1419 *
1420 *NOTE:
1421 *
1422 *
1423 *RETURNS:
1424 * Returns the message at the head of the deferred message queue
1425 */
1426
1427tSirMsgQ* limReadDeferredMsgQ(tpAniSirGlobal pMac)
1428{
1429 tSirMsgQ *msg;
1430
1431 /*
1432 ** check any messages left. If no, return
1433 **/
1434 if (pMac->lim.gLimDeferredMsgQ.size <= 0)
1435 return NULL;
1436
1437 /*
1438 ** decrement the queue size
1439 **/
1440 pMac->lim.gLimDeferredMsgQ.size--;
1441
1442 /*
1443 ** retrieve the message from the head of the queue
1444 **/
1445 msg = &pMac->lim.gLimDeferredMsgQ.deferredQueue[pMac->lim.gLimDeferredMsgQ.read];
1446
1447 /*
1448 ** advance the read pointer
1449 **/
1450 pMac->lim.gLimDeferredMsgQ.read++;
1451
1452 /*
1453 ** if the read pointer hits the end of the queue, rewind it
1454 **/
1455 if (pMac->lim.gLimDeferredMsgQ.read >= MAX_DEFERRED_QUEUE_LEN)
1456 pMac->lim.gLimDeferredMsgQ.read = 0;
1457
1458 PELOG1(limLog(pMac, LOG1,
1459 FL("** DeQueue a deferred message (size %d read %d) - type 0x%x **\n"),
1460 pMac->lim.gLimDeferredMsgQ.size, pMac->lim.gLimDeferredMsgQ.read,
1461 msg->type);)
1462
Jeff Johnsone7245742012-09-05 17:12:55 -07001463 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 -07001464 limIsSystemInScanState(pMac),
1465 pMac->lim.gLimSmeState, pMac->lim.gLimMlmState,
1466 pMac->lim.gLimAddtsSent);)
1467
1468 return(msg);
1469}
1470
1471tSirRetStatus
1472limSysProcessMmhMsgApi(tpAniSirGlobal pMac,
1473 tSirMsgQ *pMsg,
1474 tANI_U8 qType)
1475{
1476// FIXME
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 SysProcessMmhMsg(pMac, pMsg);
1478 return eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001479}
1480
1481char *limFrameStr(tANI_U32 type, tANI_U32 subType)
1482{
1483#ifdef FIXME_GEN6
1484
1485 if (type == SIR_MAC_MGMT_FRAME)
1486 {
1487 switch (subType)
1488 {
1489 case SIR_MAC_MGMT_ASSOC_REQ:
1490 return "MAC_MGMT_ASSOC_REQ";
1491 case SIR_MAC_MGMT_ASSOC_RSP:
1492 return "MAC_MGMT_ASSOC_RSP";
1493 case SIR_MAC_MGMT_REASSOC_REQ:
1494 return "MAC_MGMT_REASSOC_REQ";
1495 case SIR_MAC_MGMT_REASSOC_RSP:
1496 return "MAC_MGMT_REASSOC_RSP";
1497 case SIR_MAC_MGMT_PROBE_REQ:
1498 return "MAC_MGMT_PROBE_REQ";
1499 case SIR_MAC_MGMT_PROBE_RSP:
1500 return "MAC_MGMT_PROBE_RSP";
1501 case SIR_MAC_MGMT_BEACON:
1502 return "MAC_MGMT_BEACON";
1503 case SIR_MAC_MGMT_ATIM:
1504 return "MAC_MGMT_ATIM";
1505 case SIR_MAC_MGMT_DISASSOC:
1506 return "MAC_MGMT_DISASSOC";
1507 case SIR_MAC_MGMT_AUTH:
1508 return "MAC_MGMT_AUTH";
1509 case SIR_MAC_MGMT_DEAUTH:
1510 return "MAC_MGMT_DEAUTH";
1511 case SIR_MAC_MGMT_ACTION:
1512 return "MAC_MGMT_ACTION";
1513 case SIR_MAC_MGMT_RESERVED15:
1514 return "MAC_MGMT_RESERVED15";
1515 default:
1516 return "Unknown MGMT Frame";
1517 }
1518 }
1519
1520 else if (type == SIR_MAC_CTRL_FRAME)
1521 {
1522 switch (subType)
1523 {
1524 case SIR_MAC_CTRL_RR:
1525 return "MAC_CTRL_RR";
1526 case SIR_MAC_CTRL_BAR:
1527 return "MAC_CTRL_BAR";
1528 case SIR_MAC_CTRL_BA:
1529 return "MAC_CTRL_BA";
1530 case SIR_MAC_CTRL_PS_POLL:
1531 return "MAC_CTRL_PS_POLL";
1532 case SIR_MAC_CTRL_RTS:
1533 return "MAC_CTRL_RTS";
1534 case SIR_MAC_CTRL_CTS:
1535 return "MAC_CTRL_CTS";
1536 case SIR_MAC_CTRL_ACK:
1537 return "MAC_CTRL_ACK";
1538 case SIR_MAC_CTRL_CF_END:
1539 return "MAC_CTRL_CF_END";
1540 case SIR_MAC_CTRL_CF_END_ACK:
1541 return "MAC_CTRL_CF_END_ACK";
1542 default:
1543 return "Unknown CTRL Frame";
1544 }
1545 }
1546
1547 else if (type == SIR_MAC_DATA_FRAME)
1548 {
1549 switch (subType)
1550 {
1551 case SIR_MAC_DATA_DATA:
1552 return "MAC_DATA_DATA";
1553 case SIR_MAC_DATA_DATA_ACK:
1554 return "MAC_DATA_DATA_ACK";
1555 case SIR_MAC_DATA_DATA_POLL:
1556 return "MAC_DATA_DATA_POLL";
1557 case SIR_MAC_DATA_DATA_ACK_POLL:
1558 return "MAC_DATA_DATA_ACK_POLL";
1559 case SIR_MAC_DATA_NULL:
1560 return "MAC_DATA_NULL";
1561 case SIR_MAC_DATA_NULL_ACK:
1562 return "MAC_DATA_NULL_ACK";
1563 case SIR_MAC_DATA_NULL_POLL:
1564 return "MAC_DATA_NULL_POLL";
1565 case SIR_MAC_DATA_NULL_ACK_POLL:
1566 return "MAC_DATA_NULL_ACK_POLL";
1567 case SIR_MAC_DATA_QOS_DATA:
1568 return "MAC_DATA_QOS_DATA";
1569 case SIR_MAC_DATA_QOS_DATA_ACK:
1570 return "MAC_DATA_QOS_DATA_ACK";
1571 case SIR_MAC_DATA_QOS_DATA_POLL:
1572 return "MAC_DATA_QOS_DATA_POLL";
1573 case SIR_MAC_DATA_QOS_DATA_ACK_POLL:
1574 return "MAC_DATA_QOS_DATA_ACK_POLL";
1575 case SIR_MAC_DATA_QOS_NULL:
1576 return "MAC_DATA_QOS_NULL";
1577 case SIR_MAC_DATA_QOS_NULL_ACK:
1578 return "MAC_DATA_QOS_NULL_ACK";
1579 case SIR_MAC_DATA_QOS_NULL_POLL:
1580 return "MAC_DATA_QOS_NULL_POLL";
1581 case SIR_MAC_DATA_QOS_NULL_ACK_POLL:
1582 return "MAC_DATA_QOS_NULL_ACK_POLL";
1583 default:
1584 return "Unknown Data Frame";
1585 }
1586 }
1587 else
1588 return "Unknown";
1589#endif
1590return "";
1591}
1592
Jeff Johnson295189b2012-06-20 16:38:30 -07001593void limHandleUpdateOlbcCache(tpAniSirGlobal pMac)
1594{
1595 int i;
1596 static int enable;
1597 tUpdateBeaconParams beaconParams;
1598
1599 tpPESession psessionEntry = limIsApSessionActive(pMac);
1600
1601 if (psessionEntry == NULL)
Madan Mohan Koyyalamudi788b4ee2012-09-25 10:42:09 -07001602 {
1603 PELOGE(limLog(pMac, LOGE, FL(" Session not found\n"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 return;
Madan Mohan Koyyalamudi788b4ee2012-09-25 10:42:09 -07001605 }
Pratik Bhalgatb44ea3f2012-11-22 16:41:39 +05301606
Madan Mohan Koyyalamudib2733142012-10-31 13:59:17 -07001607 palZeroMemory( pMac->hHdd, ( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams) );
1608 beaconParams.bssIdx = psessionEntry->bssIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001609
1610 beaconParams.paramChangeBitmap = 0;
1611 /*
1612 ** This is doing a 2 pass check. The first pass is to invalidate
1613 ** all the cache entries. The second pass is to decide whether to
1614 ** disable protection.
1615 **/
1616 if (!enable)
1617 {
1618
1619 PELOG2(limLog(pMac, LOG2, FL("Resetting OLBC cache\n"));)
1620 psessionEntry->gLimOlbcParams.numSta = 0;
1621 psessionEntry->gLimOverlap11gParams.numSta = 0;
1622 psessionEntry->gLimOverlapHt20Params.numSta = 0;
1623 psessionEntry->gLimNonGfParams.numSta = 0;
1624 psessionEntry->gLimLsigTxopParams.numSta = 0;
1625
1626 for (i=0; i < LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
1627 pMac->lim.protStaOverlapCache[i].active = false;
1628
1629 enable = 1;
1630 }
1631 else
1632 {
1633
Madan Mohan Koyyalamudi788b4ee2012-09-25 10:42:09 -07001634 if (!psessionEntry->gLimOlbcParams.numSta)
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 {
1636 if (psessionEntry->gLimOlbcParams.protectionEnabled)
1637 {
1638 if (!psessionEntry->gLim11bParams.protectionEnabled)
1639 {
1640 PELOG1(limLog(pMac, LOG1, FL("Overlap cache all clear and no 11B STA detected\n"));)
1641 limEnable11gProtection(pMac, false, true, &beaconParams, psessionEntry);
1642 }
1643 }
1644 }
1645
1646 if (!psessionEntry->gLimOverlap11gParams.numSta)
1647 {
1648 if (psessionEntry->gLimOverlap11gParams.protectionEnabled)
1649 {
1650 if (!psessionEntry->gLim11gParams.protectionEnabled)
1651 {
1652 PELOG1(limLog(pMac, LOG1, FL("Overlap cache all clear and no 11G STA detected\n"));)
1653 limEnableHtProtectionFrom11g(pMac, false, true, &beaconParams,psessionEntry);
1654 }
1655 }
1656 }
1657
1658 if (!psessionEntry->gLimOverlapHt20Params.numSta)
1659 {
1660 if (psessionEntry->gLimOverlapHt20Params.protectionEnabled)
1661 {
1662 if (!psessionEntry->gLimHt20Params.protectionEnabled)
1663 {
1664 PELOG1(limLog(pMac, LOG1, FL("Overlap cache all clear and no HT20 STA detected\n"));)
1665 limEnable11gProtection(pMac, false, true, &beaconParams,psessionEntry);
1666 }
1667 }
1668 }
1669
1670 enable = 0;
1671 }
1672
1673 if(beaconParams.paramChangeBitmap)
1674 {
1675 schSetFixedBeaconFields(pMac,psessionEntry);
1676 limSendBeaconParams(pMac, &beaconParams, psessionEntry);
1677 }
1678
1679 // Start OLBC timer
1680 if (tx_timer_activate(&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer) != TX_SUCCESS)
1681 {
1682 limLog(pMac, LOGE, FL("tx_timer_activate failed\n"));
1683 }
1684}
Jeff Johnson295189b2012-06-20 16:38:30 -07001685
1686/**
1687 * limIsNullSsid()
1688 *
1689 *FUNCTION:
1690 * This function checks if Ssid supplied is Null SSID
1691 *
1692 *
1693 *LOGIC:
1694 *
1695 *ASSUMPTIONS:
1696 * NA
1697 *
1698 *NOTE:
1699 * NA
1700 *
1701 * @param tSirMacSSid *
1702 *
1703 *
1704 * @return true if SSID is Null SSID else false
1705 */
1706
1707tANI_U8
1708limIsNullSsid( tSirMacSSid *pSsid )
1709{
1710 tANI_U8 fNullSsid = false;
1711 tANI_U32 SsidLength;
1712 tANI_U8 *pSsidStr;
1713
1714 do
1715 {
1716 if ( 0 == pSsid->length )
1717 {
1718 fNullSsid = true;
1719 break;
1720 }
1721
1722#define ASCII_SPACE_CHARACTER 0x20
1723 /* If the first charactes is space, then check if all characters in
1724 * SSID are spaces to consider it as NULL SSID*/
1725 if( ASCII_SPACE_CHARACTER == pSsid->ssId[0])
1726 {
1727 SsidLength = pSsid->length;
1728 pSsidStr = pSsid->ssId;
1729 /* check if all the charactes in SSID are spaces*/
1730 while ( SsidLength )
1731 {
1732 if( ASCII_SPACE_CHARACTER != *pSsidStr )
1733 break;
1734
1735 pSsidStr++;
1736 SsidLength--;
1737 }
1738
1739 if( 0 == SsidLength )
1740 {
1741 fNullSsid = true;
1742 break;
1743 }
1744 }
1745 else
1746 {
1747 /* check if all the charactes in SSID are NULL*/
1748 SsidLength = pSsid->length;
1749 pSsidStr = pSsid->ssId;
1750
1751 while ( SsidLength )
1752 {
1753 if( *pSsidStr )
1754 break;
1755
1756 pSsidStr++;
1757 SsidLength--;
1758 }
1759
1760 if( 0 == SsidLength )
1761 {
1762 fNullSsid = true;
1763 break;
1764 }
1765 }
1766 }
1767 while( 0 );
1768
1769 return fNullSsid;
1770} /****** end limIsNullSsid() ******/
1771
1772
1773
Jeff Johnson295189b2012-06-20 16:38:30 -07001774
1775/** -------------------------------------------------------------
1776\fn limUpdateProtStaParams
1777\brief updates protection related counters.
1778\param tpAniSirGlobal pMac
1779\param tSirMacAddr peerMacAddr
1780\param tLimProtStaCacheType protStaCacheType
1781\param tHalBitVal gfSupported
1782\param tHalBitVal lsigTxopSupported
1783\return None
1784 -------------------------------------------------------------*/
1785void
1786limUpdateProtStaParams(tpAniSirGlobal pMac,
1787tSirMacAddr peerMacAddr, tLimProtStaCacheType protStaCacheType,
1788tHalBitVal gfSupported, tHalBitVal lsigTxopSupported,
1789tpPESession psessionEntry)
1790{
1791 tANI_U32 i;
1792
1793 PELOG1(limLog(pMac,LOG1, FL("A STA is associated:"));
1794 limLog(pMac,LOG1, FL("Addr : "));
1795 limPrintMacAddr(pMac, peerMacAddr, LOG1);)
1796
1797 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1798 {
1799 if (psessionEntry->protStaCache[i].active)
1800 {
1801 PELOG1(limLog(pMac, LOG1, FL("Addr: "));)
1802 PELOG1(limPrintMacAddr(pMac, psessionEntry->protStaCache[i].addr, LOG1);)
1803
1804 if (palEqualMemory( pMac->hHdd,
1805 psessionEntry->protStaCache[i].addr,
1806 peerMacAddr, sizeof(tSirMacAddr)))
1807 {
1808 PELOG1(limLog(pMac, LOG1, FL("matching cache entry at %d already active.\n"), i);)
1809 return;
1810 }
1811 }
1812 }
1813
1814 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1815 {
1816 if (!psessionEntry->protStaCache[i].active)
1817 break;
1818 }
1819
1820 if (i >= LIM_PROT_STA_CACHE_SIZE)
1821 {
1822 PELOGE(limLog(pMac, LOGE, FL("No space in ProtStaCache\n"));)
1823 return;
1824 }
1825
1826 palCopyMemory( pMac->hHdd, psessionEntry->protStaCache[i].addr,
1827 peerMacAddr,
1828 sizeof(tSirMacAddr));
1829
1830 psessionEntry->protStaCache[i].protStaCacheType = protStaCacheType;
1831 psessionEntry->protStaCache[i].active = true;
1832 if(eLIM_PROT_STA_CACHE_TYPE_llB == protStaCacheType)
1833 {
1834 psessionEntry->gLim11bParams.numSta++;
1835 limLog(pMac,LOG1, FL("11B, "));
1836 }
1837 else if(eLIM_PROT_STA_CACHE_TYPE_llG == protStaCacheType)
1838 {
1839 psessionEntry->gLim11gParams.numSta++;
1840 limLog(pMac,LOG1, FL("11G, "));
1841 }
1842 else if(eLIM_PROT_STA_CACHE_TYPE_HT20 == protStaCacheType)
1843 {
1844 psessionEntry->gLimHt20Params.numSta++;
1845 limLog(pMac,LOG1, FL("HT20, "));
1846 }
1847
1848 if(!gfSupported)
1849 {
1850 psessionEntry->gLimNonGfParams.numSta++;
1851 limLog(pMac,LOG1, FL("NonGf, "));
1852 }
1853 if(!lsigTxopSupported)
1854 {
1855 psessionEntry->gLimLsigTxopParams.numSta++;
1856 limLog(pMac,LOG1, FL("!lsigTxopSupported\n"));
1857 }
1858}// ---------------------------------------------------------------------
1859
1860/** -------------------------------------------------------------
1861\fn limDecideApProtection
1862\brief Decides all the protection related staiton coexistence and also sets
1863\ short preamble and short slot appropriately. This function will be called
1864\ when AP is ready to send assocRsp tp the station joining right now.
1865\param tpAniSirGlobal pMac
1866\param tSirMacAddr peerMacAddr
1867\return None
1868 -------------------------------------------------------------*/
1869void
1870limDecideApProtection(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1871{
1872 tANI_U16 tmpAid;
1873 tpDphHashNode pStaDs;
1874 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1875 tANI_U32 phyMode;
1876 tLimProtStaCacheType protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_INVALID;
1877 tHalBitVal gfSupported = eHAL_SET, lsigTxopSupported = eHAL_SET;
1878
1879 pBeaconParams->paramChangeBitmap = 0;
1880 // check whether to enable protection or not
1881 pStaDs = dphLookupHashEntry(pMac, peerMacAddr, &tmpAid, &psessionEntry->dph.dphHashTable);
1882 if(NULL == pStaDs)
1883 {
1884 PELOG1(limLog(pMac, LOG1, FL("pStaDs is NULL\n"));)
1885 return;
1886 }
1887 limGetRfBand(pMac, &rfBand, psessionEntry);
1888 //if we are in 5 GHZ band
1889 if(SIR_BAND_5_GHZ == rfBand)
1890 {
1891 //We are 11N. we need to protect from 11A and Ht20. we don't need any other protection in 5 GHZ.
1892 //HT20 case is common between both the bands and handled down as common code.
Jeff Johnsone7245742012-09-05 17:12:55 -07001893 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 {
1895 //we are 11N and 11A station is joining.
1896 //protection from 11A required.
1897 if(false == pStaDs->mlmStaContext.htCapability)
1898 {
1899 limEnable11aProtection(pMac, true, false, pBeaconParams,psessionEntry);
1900 return;
1901 }
1902 }
1903 }
1904 else if(SIR_BAND_2_4_GHZ== rfBand)
1905 {
1906 limGetPhyMode(pMac, &phyMode, psessionEntry);
1907
1908 //We are 11G. Check if we need protection from 11b Stations.
1909 if ((phyMode == WNI_CFG_PHY_MODE_11G) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001910 (false == psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07001911 {
1912
1913 if (pStaDs->erpEnabled== eHAL_CLEAR)
1914 {
1915 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llB;
1916 // enable protection
1917 PELOG3(limLog(pMac, LOG3, FL("Enabling protection from 11B\n"));)
1918 limEnable11gProtection(pMac, true, false, pBeaconParams,psessionEntry);
1919 }
1920 }
1921
1922 //HT station.
Jeff Johnsone7245742012-09-05 17:12:55 -07001923 if (true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 {
1925 //check if we need protection from 11b station
1926 if ((pStaDs->erpEnabled == eHAL_CLEAR) &&
1927 (!pStaDs->mlmStaContext.htCapability))
1928 {
1929 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llB;
1930 // enable protection
1931 PELOG3(limLog(pMac, LOG3, FL("Enabling protection from 11B\n"));)
1932 limEnable11gProtection(pMac, true, false, pBeaconParams, psessionEntry);
1933 }
1934 //station being joined is non-11b and non-ht ==> 11g device
1935 else if(!pStaDs->mlmStaContext.htCapability)
1936 {
1937 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llG;
1938 //enable protection
1939 limEnableHtProtectionFrom11g(pMac, true, false, pBeaconParams, psessionEntry);
1940 }
1941 //ERP mode is enabled for the latest station joined
1942 //latest station joined is HT capable
1943 //This case is being handled in common code (commn between both the bands) below.
1944 }
1945 }
1946
1947 //we are HT and HT station is joining. This code is common for both the bands.
Jeff Johnsone7245742012-09-05 17:12:55 -07001948 if((true == psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 (true == pStaDs->mlmStaContext.htCapability))
1950 {
1951 if(!pStaDs->htGreenfield)
1952 {
1953 limEnableHTNonGfProtection(pMac, true, false, pBeaconParams, psessionEntry);
1954 gfSupported = eHAL_CLEAR;
1955 }
1956 //Station joining is HT 20Mhz
1957 if(eHT_CHANNEL_WIDTH_20MHZ == pStaDs->htSupportedChannelWidthSet)
1958 {
1959 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_HT20;
1960 limEnableHT20Protection(pMac, true, false, pBeaconParams, psessionEntry);
1961 }
1962 //Station joining does not support LSIG TXOP Protection
1963 if(!pStaDs->htLsigTXOPProtection)
1964 {
1965 limEnableHTLsigTxopProtection(pMac, false, false, pBeaconParams,psessionEntry);
1966 lsigTxopSupported = eHAL_CLEAR;
1967 }
1968 }
1969
1970 limUpdateProtStaParams(pMac, peerMacAddr, protStaCacheType,
1971 gfSupported, lsigTxopSupported, psessionEntry);
1972
1973 return;
1974}
Jeff Johnson295189b2012-06-20 16:38:30 -07001975
1976
1977/** -------------------------------------------------------------
1978\fn limEnableOverlap11gProtection
1979\brief wrapper function for setting overlap 11g protection.
1980\param tpAniSirGlobal pMac
1981\param tpUpdateBeaconParams pBeaconParams
1982\param tpSirMacMgmtHdr pMh
1983\return None
1984 -------------------------------------------------------------*/
1985void
1986limEnableOverlap11gProtection(tpAniSirGlobal pMac,
1987tpUpdateBeaconParams pBeaconParams, tpSirMacMgmtHdr pMh,tpPESession psessionEntry)
1988{
1989 limUpdateOverlapStaParam(pMac, pMh->bssId, &(psessionEntry->gLimOlbcParams));
1990
1991 if (psessionEntry->gLimOlbcParams.numSta &&
1992 !psessionEntry->gLimOlbcParams.protectionEnabled)
1993 {
1994 // enable protection
1995 PELOG1(limLog(pMac, LOG1, FL("OLBC happens!!!\n"));)
1996 limEnable11gProtection(pMac, true, true, pBeaconParams,psessionEntry);
1997 }
1998}
1999
2000
2001/** -------------------------------------------------------------
2002\fn limUpdateShortPreamble
2003\brief Updates short preamble if needed when a new station joins.
2004\param tpAniSirGlobal pMac
2005\param tSirMacAddr peerMacAddr
2006\param tpUpdateBeaconParams pBeaconParams
2007\return None
2008 -------------------------------------------------------------*/
2009void
2010limUpdateShortPreamble(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2011 tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
2012{
2013 tANI_U16 tmpAid;
2014 tpDphHashNode pStaDs;
2015 tANI_U32 phyMode;
2016 tANI_U16 i;
2017
2018 // check whether to enable protection or not
2019 pStaDs = dphLookupHashEntry(pMac, peerMacAddr, &tmpAid, &psessionEntry->dph.dphHashTable);
2020
2021 limGetPhyMode(pMac, &phyMode, psessionEntry);
2022
2023 if (pStaDs != NULL && phyMode == WNI_CFG_PHY_MODE_11G)
2024
2025 {
2026 if (pStaDs->shortPreambleEnabled == eHAL_CLEAR)
2027 {
2028 PELOG1(limLog(pMac,LOG1,FL("Short Preamble is not enabled in Assoc Req from "));
2029 limPrintMacAddr(pMac, peerMacAddr, LOG1);)
2030
2031 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
2032 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002033 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
2034 psessionEntry->gLimNoShortParams.staNoShortCache[i].active)
2035 {
2036 if (palEqualMemory( pMac->hHdd,
2037 psessionEntry->gLimNoShortParams.staNoShortCache[i].addr,
2038 peerMacAddr, sizeof(tSirMacAddr)))
2039 return;
2040 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 {
2042 if (pMac->lim.gLimNoShortParams.staNoShortCache[i].active)
2043 {
2044 if (palEqualMemory( pMac->hHdd,
2045 pMac->lim.gLimNoShortParams.staNoShortCache[i].addr,
2046 peerMacAddr, sizeof(tSirMacAddr)))
2047 return;
2048 }
2049 }
2050 }
2051
2052
2053 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
2054 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
2056 !psessionEntry->gLimNoShortParams.staNoShortCache[i].active)
2057 break;
2058 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 {
2060 if (!pMac->lim.gLimNoShortParams.staNoShortCache[i].active)
2061 break;
2062 }
2063 }
2064
2065 if (i >= LIM_PROT_STA_CACHE_SIZE)
2066 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002067 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
2068 limLog(pMac, LOGE, FL("No space in Short cache (#active %d, #sta %d) for sta "),
2069 i, psessionEntry->gLimNoShortParams.numNonShortPreambleSta);
2070 limPrintMacAddr(pMac, peerMacAddr, LOGE);
2071 return;
2072 }
2073 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 {
2075 limLog(pMac, LOGE, FL("No space in Short cache (#active %d, #sta %d) for sta "),
2076 i, pMac->lim.gLimNoShortParams.numNonShortPreambleSta);
2077 limPrintMacAddr(pMac, peerMacAddr, LOGE);
2078 return;
2079 }
2080
2081 }
2082
2083
Jeff Johnson295189b2012-06-20 16:38:30 -07002084 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
2085 palCopyMemory( pMac->hHdd, psessionEntry->gLimNoShortParams.staNoShortCache[i].addr,
2086 peerMacAddr, sizeof(tSirMacAddr));
2087 psessionEntry->gLimNoShortParams.staNoShortCache[i].active = true;
2088 psessionEntry->gLimNoShortParams.numNonShortPreambleSta++;
2089 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 {
2091 palCopyMemory( pMac->hHdd, pMac->lim.gLimNoShortParams.staNoShortCache[i].addr,
2092 peerMacAddr, sizeof(tSirMacAddr));
2093 pMac->lim.gLimNoShortParams.staNoShortCache[i].active = true;
2094 pMac->lim.gLimNoShortParams.numNonShortPreambleSta++;
2095 }
2096
2097
2098 // enable long preamble
2099 PELOG1(limLog(pMac, LOG1, FL("Disabling short preamble\n"));)
2100
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 if (limEnableShortPreamble(pMac, false, pBeaconParams, psessionEntry) != eSIR_SUCCESS)
2102 PELOGE(limLog(pMac, LOGE, FL("Cannot enable long preamble\n"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002103 }
2104 }
2105}
2106
2107/** -------------------------------------------------------------
2108\fn limUpdateShortSlotTime
2109\brief Updates short slot time if needed when a new station joins.
2110\param tpAniSirGlobal pMac
2111\param tSirMacAddr peerMacAddr
2112\param tpUpdateBeaconParams pBeaconParams
2113\return None
2114 -------------------------------------------------------------*/
2115
2116void
2117limUpdateShortSlotTime(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2118 tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
2119{
2120 tANI_U16 tmpAid;
2121 tpDphHashNode pStaDs;
2122 tANI_U32 phyMode;
2123 tANI_U32 val;
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 tANI_U16 i;
2125
2126 // check whether to enable protection or not
2127 pStaDs = dphLookupHashEntry(pMac, peerMacAddr, &tmpAid, &psessionEntry->dph.dphHashTable);
2128 limGetPhyMode(pMac, &phyMode, psessionEntry);
2129
Jeff Johnsone7245742012-09-05 17:12:55 -07002130 /* Only in case of softap in 11g mode, slot time might change depending on the STA being added. In 11a case, it should
2131 * be always 1 and in 11b case, it should be always 0
2132 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 if (pStaDs != NULL && phyMode == WNI_CFG_PHY_MODE_11G)
2134 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002135 /* Only when the new STA has short slot time disabled, we need to change softap's overall slot time settings
2136 * else the default for softap is always short slot enabled. When the last long slot STA leaves softAP, we take care of
2137 * it in limDecideShortSlot
2138 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 if (pStaDs->shortSlotTimeEnabled == eHAL_CLEAR)
2140 {
2141 PELOG1(limLog(pMac, LOG1, FL("Short Slot Time is not enabled in Assoc Req from "));
2142 limPrintMacAddr(pMac, peerMacAddr, LOG1);)
2143 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
2144 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002145 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
2146 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active)
2147 {
2148 if (palEqualMemory( pMac->hHdd,
2149 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
2150 peerMacAddr, sizeof(tSirMacAddr)))
2151 return;
2152 }
2153 else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07002154 {
2155 if (pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active)
2156 {
2157 if (palEqualMemory( pMac->hHdd,
2158 pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
2159 peerMacAddr, sizeof(tSirMacAddr)))
2160 return;
2161 }
2162 }
2163 }
2164
2165 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
2166 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
2168 !psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active)
2169 break;
2170 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 {
2172 if (!pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active)
2173 break;
2174 }
2175 }
2176
2177 if (i >= LIM_PROT_STA_CACHE_SIZE)
2178 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
2180 limLog(pMac, LOGE, FL("No space in ShortSlot cache (#active %d, #sta %d) for sta "),
2181 i, psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta);
2182 limPrintMacAddr(pMac, peerMacAddr, LOGE);
2183 return;
2184 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 {
2186 limLog(pMac, LOGE, FL("No space in ShortSlot cache (#active %d, #sta %d) for sta "),
2187 i, pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta);
2188 limPrintMacAddr(pMac, peerMacAddr, LOGE);
2189 return;
2190 }
2191 }
2192
2193
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
2195 palCopyMemory( pMac->hHdd, psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
2196 peerMacAddr, sizeof(tSirMacAddr));
2197 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active = true;
2198 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta++;
2199 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 {
2201 palCopyMemory( pMac->hHdd, pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
2202 peerMacAddr, sizeof(tSirMacAddr));
2203 pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active = true;
2204 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta++;
2205 }
2206 wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val);
2207
Jeff Johnsone7245742012-09-05 17:12:55 -07002208 /* 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
2209 * only long slot enabled, we need to change our beacon/pb rsp to broadcast short slot disabled
2210 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002211 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07002212 (val && psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta && psessionEntry->shortSlotTimeSupported))
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 {
2214 // enable long slot time
2215 pBeaconParams->fShortSlotTime = false;
2216 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
2217 PELOG1(limLog(pMac, LOG1, FL("Disable short slot time. Enable long slot time.\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002218 psessionEntry->shortSlotTimeSupported = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 }
2220 else if ( psessionEntry->limSystemRole != eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002221 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002222 if (val && pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta && psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 {
2224 // enable long slot time
2225 pBeaconParams->fShortSlotTime = false;
2226 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
2227 PELOG1(limLog(pMac, LOG1, FL("Disable short slot time. Enable long slot time.\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002228 psessionEntry->shortSlotTimeSupported = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07002229 }
2230 }
2231 }
2232 }
2233}
2234
Jeff Johnson295189b2012-06-20 16:38:30 -07002235
2236/** -------------------------------------------------------------
2237\fn limDecideStaProtectionOnAssoc
2238\brief Decide protection related settings on Sta while association.
2239\param tpAniSirGlobal pMac
2240\param tpSchBeaconStruct pBeaconStruct
2241\return None
2242 -------------------------------------------------------------*/
2243void
2244limDecideStaProtectionOnAssoc(tpAniSirGlobal pMac,
2245 tpSchBeaconStruct pBeaconStruct, tpPESession psessionEntry)
2246{
2247 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
2248 tANI_U32 phyMode = WNI_CFG_PHY_MODE_NONE;
2249
2250 limGetRfBand(pMac, &rfBand, psessionEntry);
2251 limGetPhyMode(pMac, &phyMode, psessionEntry);
2252
2253 if(SIR_BAND_5_GHZ == rfBand)
2254 {
2255 if((eSIR_HT_OP_MODE_MIXED == pBeaconStruct->HTInfo.opMode) ||
2256 (eSIR_HT_OP_MODE_OVERLAP_LEGACY == pBeaconStruct->HTInfo.opMode))
2257 {
2258 if(pMac->lim.cfgProtection.fromlla)
2259 psessionEntry->beaconParams.llaCoexist = true;
2260 }
2261 else if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == pBeaconStruct->HTInfo.opMode)
2262 {
2263 if(pMac->lim.cfgProtection.ht20)
2264 psessionEntry->beaconParams.ht20Coexist = true;
2265 }
2266
2267 }
2268 else if(SIR_BAND_2_4_GHZ == rfBand)
2269 {
2270 //spec 7.3.2.13
2271 //UseProtection will be set when nonERP STA is associated.
2272 //NonERPPresent bit will be set when:
2273 //--nonERP Sta is associated OR
2274 //--nonERP Sta exists in overlapping BSS
2275 //when useProtection is not set then protection from nonERP stations is optional.
2276
2277 //CFG protection from 11b is enabled and
2278 //11B device in the BSS
2279 /* TODO, This is not sessionized */
2280 if (phyMode != WNI_CFG_PHY_MODE_11B)
2281 {
2282 if (pMac->lim.cfgProtection.fromllb &&
2283 pBeaconStruct->erpPresent &&
2284 (pBeaconStruct->erpIEInfo.useProtection ||
2285 pBeaconStruct->erpIEInfo.nonErpPresent))
2286 {
2287 psessionEntry->beaconParams.llbCoexist = true;
2288 }
2289 //AP has no 11b station associated.
2290 else
2291 {
2292 psessionEntry->beaconParams.llbCoexist = false;
2293 }
2294 }
2295 //following code block is only for HT station.
Jeff Johnsone7245742012-09-05 17:12:55 -07002296 if((psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 (pBeaconStruct->HTInfo.present))
2298 {
2299 tDot11fIEHTInfo htInfo = pBeaconStruct->HTInfo;
2300
2301 //Obss Non HT STA present mode
2302 psessionEntry->beaconParams.gHTObssMode = (tANI_U8)htInfo.obssNonHTStaPresent;
2303
2304
2305 //CFG protection from 11G is enabled and
2306 //our AP has at least one 11G station associated.
2307 if(pMac->lim.cfgProtection.fromllg &&
2308 ((eSIR_HT_OP_MODE_MIXED == htInfo.opMode) ||
2309 (eSIR_HT_OP_MODE_OVERLAP_LEGACY == htInfo.opMode))&&
2310 (!psessionEntry->beaconParams.llbCoexist))
2311 {
2312 if(pMac->lim.cfgProtection.fromllg)
2313 psessionEntry->beaconParams.llgCoexist = true;
2314 }
2315
2316 //AP has only HT stations associated and at least one station is HT 20
2317 //disable protection from any non-HT devices.
2318 //decision for disabling protection from 11b has already been taken above.
2319 if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == htInfo.opMode)
2320 {
2321 //Disable protection from 11G station.
2322 psessionEntry->beaconParams.llgCoexist = false;
2323 //CFG protection from HT 20 is enabled.
2324 if(pMac->lim.cfgProtection.ht20)
2325 psessionEntry->beaconParams.ht20Coexist = true;
2326 }
2327 //Disable protection from non-HT and HT20 devices.
2328 //decision for disabling protection from 11b has already been taken above.
2329 if(eSIR_HT_OP_MODE_PURE == htInfo.opMode)
2330 {
2331 psessionEntry->beaconParams.llgCoexist = false;
2332 psessionEntry->beaconParams.ht20Coexist = false;
2333 }
2334
2335 }
2336 }
2337
2338 //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 -07002339 if((psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002340 (pBeaconStruct->HTInfo.present))
2341 {
2342 tDot11fIEHTInfo htInfo = pBeaconStruct->HTInfo;
2343 psessionEntry->beaconParams.fRIFSMode =
2344 ( tANI_U8 ) htInfo.rifsMode;
2345 psessionEntry->beaconParams.llnNonGFCoexist =
2346 ( tANI_U8 )htInfo.nonGFDevicesPresent;
2347 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport =
2348 ( tANI_U8 )htInfo.lsigTXOPProtectionFullSupport;
2349 }
2350}
2351
2352
2353/** -------------------------------------------------------------
2354\fn limDecideStaProtection
2355\brief Decides protection related settings on Sta while processing beacon.
2356\param tpAniSirGlobal pMac
2357\param tpUpdateBeaconParams pBeaconParams
2358\return None
2359 -------------------------------------------------------------*/
2360void
2361limDecideStaProtection(tpAniSirGlobal pMac,
2362 tpSchBeaconStruct pBeaconStruct, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
2363{
2364
2365 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
2366 tANI_U32 phyMode = WNI_CFG_PHY_MODE_NONE;
2367
2368 limGetRfBand(pMac, &rfBand, psessionEntry);
2369 limGetPhyMode(pMac, &phyMode, psessionEntry);
2370
2371 if(SIR_BAND_5_GHZ == rfBand)
2372 {
2373 //we are HT capable.
Jeff Johnsone7245742012-09-05 17:12:55 -07002374 if((true == psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 (pBeaconStruct->HTInfo.present))
2376 {
2377 //we are HT capable, AP's HT OPMode is mixed / overlap legacy ==> need protection from 11A.
2378 if((eSIR_HT_OP_MODE_MIXED == pBeaconStruct->HTInfo.opMode) ||
2379 (eSIR_HT_OP_MODE_OVERLAP_LEGACY == pBeaconStruct->HTInfo.opMode))
2380 {
2381 limEnable11aProtection(pMac, true, false, pBeaconParams,psessionEntry);
2382 }
2383 //we are HT capable, AP's HT OPMode is HT20 ==> disable protection from 11A if enabled. enabled
2384 //protection from HT20 if needed.
2385 else if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT== pBeaconStruct->HTInfo.opMode)
2386 {
2387 limEnable11aProtection(pMac, false, false, pBeaconParams,psessionEntry);
2388 limEnableHT20Protection(pMac, true, false, pBeaconParams,psessionEntry);
2389 }
2390 else if(eSIR_HT_OP_MODE_PURE == pBeaconStruct->HTInfo.opMode)
2391 {
2392 limEnable11aProtection(pMac, false, false, pBeaconParams,psessionEntry);
2393 limEnableHT20Protection(pMac, false, false, pBeaconParams,psessionEntry);
2394 }
2395 }
2396 }
2397 else if(SIR_BAND_2_4_GHZ == rfBand)
2398 {
2399 /* spec 7.3.2.13
2400 * UseProtection will be set when nonERP STA is associated.
2401 * NonERPPresent bit will be set when:
2402 * --nonERP Sta is associated OR
2403 * --nonERP Sta exists in overlapping BSS
2404 * when useProtection is not set then protection from nonERP stations is optional.
2405 */
2406
2407 if (phyMode != WNI_CFG_PHY_MODE_11B)
2408 {
2409 if (pBeaconStruct->erpPresent &&
2410 (pBeaconStruct->erpIEInfo.useProtection ||
2411 pBeaconStruct->erpIEInfo.nonErpPresent))
2412 {
2413 limEnable11gProtection(pMac, true, false, pBeaconParams, psessionEntry);
2414 }
2415 //AP has no 11b station associated.
2416 else
2417 {
2418 //disable protection from 11b station
2419 limEnable11gProtection(pMac, false, false, pBeaconParams, psessionEntry);
2420 }
2421 }
2422
2423 //following code block is only for HT station.
Jeff Johnsone7245742012-09-05 17:12:55 -07002424 if((psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002425 (pBeaconStruct->HTInfo.present))
2426 {
2427
2428 tDot11fIEHTInfo htInfo = pBeaconStruct->HTInfo;
2429 //AP has at least one 11G station associated.
2430 if(((eSIR_HT_OP_MODE_MIXED == htInfo.opMode) ||
2431 (eSIR_HT_OP_MODE_OVERLAP_LEGACY == htInfo.opMode))&&
2432 (!psessionEntry->beaconParams.llbCoexist))
2433 {
2434 limEnableHtProtectionFrom11g(pMac, true, false, pBeaconParams,psessionEntry);
2435
2436 }
2437
2438 //no HT operating mode change ==> no change in protection settings except for MIXED_MODE/Legacy Mode.
2439 //in Mixed mode/legacy Mode even if there is no change in HT operating mode, there might be change in 11bCoexist
2440 //or 11gCoexist. that is why this check is being done after mixed/legacy mode check.
2441 if ( pMac->lim.gHTOperMode != ( tSirMacHTOperatingMode )htInfo.opMode )
2442 {
2443 pMac->lim.gHTOperMode = ( tSirMacHTOperatingMode )htInfo.opMode;
2444
2445 //AP has only HT stations associated and at least one station is HT 20
2446 //disable protection from any non-HT devices.
2447 //decision for disabling protection from 11b has already been taken above.
2448 if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == htInfo.opMode)
2449 {
2450 //Disable protection from 11G station.
2451 limEnableHtProtectionFrom11g(pMac, false, false, pBeaconParams,psessionEntry);
2452
2453 limEnableHT20Protection(pMac, true, false, pBeaconParams,psessionEntry);
2454 }
2455 //Disable protection from non-HT and HT20 devices.
2456 //decision for disabling protection from 11b has already been taken above.
2457 else if(eSIR_HT_OP_MODE_PURE == htInfo.opMode)
2458 {
2459 limEnableHtProtectionFrom11g(pMac, false, false, pBeaconParams,psessionEntry);
2460 limEnableHT20Protection(pMac, false, false, pBeaconParams,psessionEntry);
2461
2462 }
2463 }
2464 }
2465 }
2466
2467 //following code block is only for HT station. ( 2.4 GHZ as well as 5 GHZ)
Jeff Johnsone7245742012-09-05 17:12:55 -07002468 if((psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002469 (pBeaconStruct->HTInfo.present))
2470 {
2471 tDot11fIEHTInfo htInfo = pBeaconStruct->HTInfo;
2472 //Check for changes in protection related factors other than HT operating mode.
2473 //Check for changes in RIFS mode, nonGFDevicesPresent, lsigTXOPProtectionFullSupport.
2474 if ( psessionEntry->beaconParams.fRIFSMode !=
2475 ( tANI_U8 ) htInfo.rifsMode )
2476 {
2477 pBeaconParams->fRIFSMode =
2478 psessionEntry->beaconParams.fRIFSMode =
2479 ( tANI_U8 ) htInfo.rifsMode;
2480 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
2481 }
2482
2483 if ( psessionEntry->beaconParams.llnNonGFCoexist !=
2484 htInfo.nonGFDevicesPresent )
2485 {
2486 pBeaconParams->llnNonGFCoexist =
2487 psessionEntry->beaconParams.llnNonGFCoexist =
2488 ( tANI_U8 )htInfo.nonGFDevicesPresent;
2489 pBeaconParams->paramChangeBitmap |=
2490 PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
2491 }
2492
2493 if ( psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport !=
2494 ( tANI_U8 )htInfo.lsigTXOPProtectionFullSupport )
2495 {
2496 pBeaconParams->fLsigTXOPProtectionFullSupport =
2497 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport =
2498 ( tANI_U8 )htInfo.lsigTXOPProtectionFullSupport;
2499 pBeaconParams->paramChangeBitmap |=
2500 PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
2501 }
2502
2503 // For Station just update the global lim variable, no need to send message to HAL
2504 // Station already taking care of HT OPR Mode=01, meaning AP is seeing legacy
2505 //stations in overlapping BSS.
2506 if ( psessionEntry->beaconParams.gHTObssMode != ( tANI_U8 )htInfo.obssNonHTStaPresent )
2507 psessionEntry->beaconParams.gHTObssMode = ( tANI_U8 )htInfo.obssNonHTStaPresent ;
2508
2509 }
2510}
2511
2512
2513/**
2514 * limProcessChannelSwitchTimeout()
2515 *
2516 *FUNCTION:
2517 * This function is invoked when Channel Switch Timer expires at
2518 * the STA. Now, STA must stop traffic, and then change/disable
2519 * primary or secondary channel.
2520 *
2521 *
2522 *NOTE:
2523 * @param pMac - Pointer to Global MAC structure
2524 * @return None
2525 */
2526void limProcessChannelSwitchTimeout(tpAniSirGlobal pMac)
2527{
2528 tpPESession psessionEntry = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07002529 tANI_U8 channel; // This is received and stored from channelSwitch Action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07002530
2531 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimChannelSwitchTimer.sessionId))== NULL)
2532 {
2533 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
2534 return;
2535 }
2536
2537 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
2538 {
2539 PELOGW(limLog(pMac, LOGW, "Channel switch can be done only in STA role, Current Role = %d\n", psessionEntry->limSystemRole);)
2540 return;
2541 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002542 channel = psessionEntry->gLimChannelSwitch.primaryChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07002543 /*
2544 * This potentially can create issues if the function tries to set
2545 * channel while device is in power-save, hence putting an extra check
2546 * to verify if the device is in power-save or not
2547 */
2548 if(!limIsSystemInActiveState(pMac))
2549 {
2550 PELOGW(limLog(pMac, LOGW, FL("Device is not in active state, cannot switch channel\n"));)
2551 return;
2552 }
2553
2554 // Restore Channel Switch parameters to default
Jeff Johnsone7245742012-09-05 17:12:55 -07002555 psessionEntry->gLimChannelSwitch.switchTimeoutValue = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002556
2557 /* Channel-switch timeout has occurred. reset the state */
Jeff Johnsone7245742012-09-05 17:12:55 -07002558 psessionEntry->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_END;
Jeff Johnson295189b2012-06-20 16:38:30 -07002559
2560 /* Check if the AP is switching to a channel that we support.
2561 * Else, just don't bother to switch. Indicate HDD to look for a
2562 * better AP to associate
2563 */
2564 if(!limIsChannelValidForChannelSwitch(pMac, channel))
2565 {
2566 /* We need to restore pre-channelSwitch state on the STA */
2567 if(limRestorePreChannelSwitchState(pMac, psessionEntry) != eSIR_SUCCESS)
2568 {
2569 limLog(pMac, LOGP, FL("Could not restore pre-channelSwitch (11h) state, resetting the system\n"));
2570 return;
2571 }
2572
2573 /* If the channel-list that AP is asking us to switch is invalid,
2574 * then we cannot switch the channel. Just disassociate from AP.
2575 * We will find a better AP !!!
2576 */
2577 limTearDownLinkWithAp(pMac,
2578 pMac->lim.limTimers.gLimChannelSwitchTimer.sessionId,
2579 eSIR_MAC_UNSPEC_FAILURE_REASON);
2580 return;
2581 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002582 switch(psessionEntry->gLimChannelSwitch.state)
Jeff Johnson295189b2012-06-20 16:38:30 -07002583 {
2584 case eLIM_CHANNEL_SWITCH_PRIMARY_ONLY:
2585 PELOGW(limLog(pMac, LOGW, FL("CHANNEL_SWITCH_PRIMARY_ONLY \n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002586 limSwitchPrimaryChannel(pMac, psessionEntry->gLimChannelSwitch.primaryChannel,psessionEntry);
2587 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002588 break;
2589
2590 case eLIM_CHANNEL_SWITCH_SECONDARY_ONLY:
2591 PELOGW(limLog(pMac, LOGW, FL("CHANNEL_SWITCH_SECONDARY_ONLY \n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002592 limSwitchPrimarySecondaryChannel(pMac, psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 psessionEntry->currentOperChannel,
Jeff Johnsone7245742012-09-05 17:12:55 -07002594 psessionEntry->gLimChannelSwitch.secondarySubBand);
2595 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002596 break;
2597
2598 case eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY:
2599 PELOGW(limLog(pMac, LOGW, FL("CHANNEL_SWITCH_PRIMARY_AND_SECONDARY\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002600 limSwitchPrimarySecondaryChannel(pMac, psessionEntry,
2601 psessionEntry->gLimChannelSwitch.primaryChannel,
2602 psessionEntry->gLimChannelSwitch.secondarySubBand);
2603 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002604 break;
2605
2606 case eLIM_CHANNEL_SWITCH_IDLE:
2607 default:
2608 PELOGE(limLog(pMac, LOGE, FL("incorrect state \n"));)
2609 if(limRestorePreChannelSwitchState(pMac, psessionEntry) != eSIR_SUCCESS)
2610 {
2611 limLog(pMac, LOGP, FL("Could not restore pre-channelSwitch (11h) state, resetting the system\n"));
2612 }
2613 return; /* Please note, this is 'return' and not 'break' */
2614 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002615}
Jeff Johnson295189b2012-06-20 16:38:30 -07002616
2617/**
2618 * limUpdateChannelSwitch()
2619 *
2620 *FUNCTION:
2621 * This function is invoked whenever Station receives
2622 * either 802.11h channel switch IE or airgo proprietary
2623 * channel switch IE.
2624 *
2625 *NOTE:
2626 * @param pMac - Pointer to Global MAC structure
2627 * @return tpSirProbeRespBeacon - Pointer to Beacon/Probe Rsp
2628 * @param psessionentry
2629 */
2630void
2631limUpdateChannelSwitch(struct sAniSirGlobal *pMac, tpSirProbeRespBeacon pBeacon, tpPESession psessionEntry)
2632{
2633
2634 tANI_U16 beaconPeriod;
Jeff Johnson295189b2012-06-20 16:38:30 -07002635 tChannelSwitchPropIEStruct *pPropChnlSwitch;
2636 tDot11fIEChanSwitchAnn *pChnlSwitch;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002637#ifdef WLAN_FEATURE_11AC
2638 tDot11fIEWiderBWChanSwitchAnn *pWiderChnlSwitch;
2639#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002640
Jeff Johnsone7245742012-09-05 17:12:55 -07002641 beaconPeriod = psessionEntry->beaconParams.beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002642
2643 /* STA either received proprietary channel switch IE or 802.11h
2644 * standard channel switch IE.
2645 */
2646 if (pBeacon->propIEinfo.propChannelSwitchPresent)
2647 {
2648 pPropChnlSwitch = &(pBeacon->propIEinfo.channelSwitch);
2649
2650 /* Add logic to determine which change this is: */
2651 /* primary, secondary, both. For now assume both. */
Jeff Johnsone7245742012-09-05 17:12:55 -07002652 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2653 psessionEntry->gLimChannelSwitch.primaryChannel = pPropChnlSwitch->primaryChannel;
2654 psessionEntry->gLimChannelSwitch.secondarySubBand = (ePhyChanBondState)pPropChnlSwitch->subBand;
2655 psessionEntry->gLimChannelSwitch.switchCount = pPropChnlSwitch->channelSwitchCount;
2656 psessionEntry->gLimChannelSwitch.switchTimeoutValue =
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 SYS_MS_TO_TICKS(beaconPeriod)* (pPropChnlSwitch->channelSwitchCount);
Jeff Johnsone7245742012-09-05 17:12:55 -07002658 psessionEntry->gLimChannelSwitch.switchMode = pPropChnlSwitch->mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 }
2660 else
2661 {
2662 pChnlSwitch = &(pBeacon->channelSwitchIE);
Jeff Johnsone7245742012-09-05 17:12:55 -07002663 psessionEntry->gLimChannelSwitch.primaryChannel = pChnlSwitch->newChannel;
2664 psessionEntry->gLimChannelSwitch.switchCount = pChnlSwitch->switchCount;
2665 psessionEntry->gLimChannelSwitch.switchTimeoutValue =
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 SYS_MS_TO_TICKS(beaconPeriod)* (pChnlSwitch->switchCount);
Jeff Johnsone7245742012-09-05 17:12:55 -07002667 psessionEntry->gLimChannelSwitch.switchMode = pChnlSwitch->switchMode;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002668#ifdef WLAN_FEATURE_11AC
2669 pWiderChnlSwitch = &(pBeacon->WiderBWChanSwitchAnn);
2670 if(pBeacon->WiderBWChanSwitchAnnPresent)
2671 {
2672 psessionEntry->gLimWiderBWChannelSwitch.newChanWidth = pWiderChnlSwitch->newChanWidth;
2673 psessionEntry->gLimWiderBWChannelSwitch.newCenterChanFreq0 = pWiderChnlSwitch->newCenterChanFreq0;
2674 psessionEntry->gLimWiderBWChannelSwitch.newCenterChanFreq1 = pWiderChnlSwitch->newCenterChanFreq1;
2675 }
2676#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002677
2678 /* Only primary channel switch element is present */
Jeff Johnsone7245742012-09-05 17:12:55 -07002679 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2680 psessionEntry->gLimChannelSwitch.secondarySubBand = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07002681
2682 /* Do not bother to look and operate on extended channel switch element
2683 * if our own channel-bonding state is not enabled
2684 */
Jeff Johnsone7245742012-09-05 17:12:55 -07002685 if (psessionEntry->htSupportedChannelWidthSet)
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 {
2687 if (pBeacon->extChannelSwitchPresent)
2688 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002689 if ((pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_LOW_PRIMARY) ||
2690 (pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY))
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002692 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2693 psessionEntry->gLimChannelSwitch.secondarySubBand = pBeacon->extChannelSwitchIE.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002694 }
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002695#ifdef WLAN_FEATURE_11AC
2696 if(psessionEntry->vhtCapability && pBeacon->WiderBWChanSwitchAnnPresent)
2697 {
2698 if (pWiderChnlSwitch->newChanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
2699 {
2700 if(pBeacon->extChannelSwitchPresent)
2701 {
2702 if ((pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_LOW_PRIMARY) ||
2703 (pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY))
2704 {
2705 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2706 psessionEntry->gLimChannelSwitch.secondarySubBand = limGet11ACPhyCBState(pMac,
2707 psessionEntry->gLimChannelSwitch.primaryChannel,
2708 pBeacon->extChannelSwitchIE.secondaryChannelOffset,
2709 pWiderChnlSwitch->newCenterChanFreq0,
2710 psessionEntry);
2711 }
2712 }
2713 }
2714 }
2715#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002716 }
2717 }
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002718 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 if (eSIR_SUCCESS != limStartChannelSwitch(pMac, psessionEntry))
2720 {
2721 PELOGW(limLog(pMac, LOGW, FL("Could not start Channel Switch\n"));)
2722 }
2723
2724 limLog(pMac, LOGW,
Jeff Johnsone7245742012-09-05 17:12:55 -07002725 FL("session %d primary chl %d, subband %d, count %d (%d ticks) \n"),
2726 psessionEntry->peSessionId,
2727 psessionEntry->gLimChannelSwitch.primaryChannel,
2728 psessionEntry->gLimChannelSwitch.secondarySubBand,
2729 psessionEntry->gLimChannelSwitch.switchCount,
2730 psessionEntry->gLimChannelSwitch.switchTimeoutValue);
Jeff Johnson295189b2012-06-20 16:38:30 -07002731 return;
2732}
2733
2734/**
2735 * limCancelDot11hChannelSwitch
2736 *
2737 *FUNCTION:
2738 * This function is called when STA does not send updated channel-swith IE
2739 * after indicating channel-switch start. This will cancel the channel-swith
2740 * timer which is already running.
2741 *
2742 *LOGIC:
2743 *
2744 *ASSUMPTIONS:
2745 *
2746 *NOTE:
2747 *
2748 * @param pMac - Pointer to Global MAC structure
2749 *
2750 * @return None
2751 */
2752void limCancelDot11hChannelSwitch(tpAniSirGlobal pMac, tpPESession psessionEntry)
2753{
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
2755 return;
2756
2757 PELOGW(limLog(pMac, LOGW, FL("Received a beacon without channel switch IE\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002758 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_CHANNEL_SWITCH_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002759
2760 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimChannelSwitchTimer) != eSIR_SUCCESS)
2761 {
2762 PELOGE(limLog(pMac, LOGE, FL("tx_timer_deactivate failed!\n"));)
2763 }
2764
2765 /* We need to restore pre-channelSwitch state on the STA */
2766 if (limRestorePreChannelSwitchState(pMac, psessionEntry) != eSIR_SUCCESS)
2767 {
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08002768 PELOGE(limLog(pMac, LOGE, FL("LIM: Could not restore pre-channelSwitch (11h) state, resetting the system\n"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002769
2770 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002771}
2772
2773/**----------------------------------------------
2774\fn limCancelDot11hQuiet
2775\brief Cancel the quieting on Station if latest
2776 beacon doesn't contain quiet IE in it.
2777
2778\param pMac
2779\return NONE
2780-----------------------------------------------*/
2781void limCancelDot11hQuiet(tpAniSirGlobal pMac, tpPESession psessionEntry)
2782{
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
2784 return;
2785
Jeff Johnsone7245742012-09-05 17:12:55 -07002786 if (psessionEntry->gLimSpecMgmt.quietState == eLIM_QUIET_BEGIN)
Jeff Johnson295189b2012-06-20 16:38:30 -07002787 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002788 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_QUIET_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietTimer) != TX_SUCCESS)
2790 {
2791 PELOGE(limLog(pMac, LOGE, FL("tx_timer_deactivate failed\n"));)
2792 }
2793 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002794 else if (psessionEntry->gLimSpecMgmt.quietState == eLIM_QUIET_RUNNING)
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002796 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_QUIET_BSS_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietBssTimer) != TX_SUCCESS)
2798 {
2799 PELOGE(limLog(pMac, LOGE, FL("tx_timer_deactivate failed\n"));)
2800 }
2801 /**
2802 * If the channel switch is already running in silent mode, dont resume the
2803 * transmission. Channel switch timer when timeout, transmission will be resumed.
2804 */
Jeff Johnsone7245742012-09-05 17:12:55 -07002805 if(!((psessionEntry->gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING) &&
2806 (psessionEntry->gLimChannelSwitch.switchMode == eSIR_CHANSW_MODE_SILENT)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002807 {
2808 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
Jeff Johnsone7245742012-09-05 17:12:55 -07002809 limRestorePreQuietState(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 }
2811 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002812 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002813}
2814
2815/**
2816 * limProcessQuietTimeout
2817 *
2818 * FUNCTION:
2819 * This function is active only on the STA.
2820 * Handles SIR_LIM_QUIET_TIMEOUT
2821 *
2822 * LOGIC:
2823 * This timeout can occur under only one circumstance:
2824 *
2825 * 1) When gLimQuietState = eLIM_QUIET_BEGIN
2826 * This indicates that the timeout "interval" has
2827 * expired. This is a trigger for the STA to now
2828 * shut-off Tx/Rx for the specified gLimQuietDuration
2829 * -> The TIMER object gLimQuietBssTimer is
2830 * activated
2831 * -> With timeout = gLimQuietDuration
2832 * -> gLimQuietState is set to eLIM_QUIET_RUNNING
2833 *
2834 * ASSUMPTIONS:
2835 * Using two TIMER objects -
2836 * gLimQuietTimer & gLimQuietBssTimer
2837 *
2838 * NOTE:
2839 *
2840 * @param pMac - Pointer to Global MAC structure
2841 *
2842 * @return None
2843 */
2844void limProcessQuietTimeout(tpAniSirGlobal pMac)
2845{
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 //fetch the sessionEntry based on the sessionId
2847 //priority - MEDIUM
Jeff Johnsone7245742012-09-05 17:12:55 -07002848 tpPESession psessionEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07002849
Jeff Johnsone7245742012-09-05 17:12:55 -07002850 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimQuietTimer.sessionId))== NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002852 limLog(pMac, LOGE,FL("Session Does not exist for given sessionID\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 return;
2854 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002855
Jeff Johnsone7245742012-09-05 17:12:55 -07002856 PELOG1(limLog(pMac, LOG1, FL("quietState = %d\n"), psessionEntry->gLimSpecMgmt.quietState);)
2857 switch( psessionEntry->gLimSpecMgmt.quietState )
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 {
2859 case eLIM_QUIET_BEGIN:
2860 // Time to Stop data traffic for quietDuration
Jeff Johnsone7245742012-09-05 17:12:55 -07002861 //limDeactivateAndChangeTimer(pMac, eLIM_QUIET_BSS_TIMER);
2862 if (TX_SUCCESS !=
2863 tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietBssTimer))
2864 {
2865 limLog( pMac, LOGE,
2866 FL("Unable to de-activate gLimQuietBssTimer! Will attempt to activate anyway...\n"));
2867 }
2868
2869 // gLimQuietDuration appears to be in units of ticks
2870 // Use it as is
2871 if (TX_SUCCESS !=
2872 tx_timer_change( &pMac->lim.limTimers.gLimQuietBssTimer,
2873 psessionEntry->gLimSpecMgmt.quietDuration,
2874 0))
2875 {
2876 limLog( pMac, LOGE,
2877 FL("Unable to change gLimQuietBssTimer! Will still attempt to activate anyway...\n"));
2878 }
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08002879 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, pMac->lim.limTimers.gLimQuietTimer.sessionId, eLIM_QUIET_BSS_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002880#ifdef GEN6_TODO
2881 /* revisit this piece of code to assign the appropriate sessionId below
2882 * priority - HIGH
2883 */
2884 pMac->lim.limTimers.gLimQuietBssTimer.sessionId = sessionId;
2885#endif
2886 if( TX_SUCCESS !=
2887 tx_timer_activate( &pMac->lim.limTimers.gLimQuietBssTimer ))
2888 {
2889 limLog( pMac, LOGW,
2890 FL("Unable to activate gLimQuietBssTimer! The STA will be unable to honor Quiet BSS...\n"));
2891 }
2892 else
2893 {
2894 // Transition to eLIM_QUIET_RUNNING
Jeff Johnsone7245742012-09-05 17:12:55 -07002895 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_RUNNING;
Jeff Johnson295189b2012-06-20 16:38:30 -07002896
2897 /* If we have sta bk scan triggered and trigger bk scan actually started successfully, */
2898 /* print message, otherwise, stop data traffic and stay quiet */
2899 if( pMac->lim.gLimTriggerBackgroundScanDuringQuietBss &&
2900 (eSIR_TRUE == (glimTriggerBackgroundScanDuringQuietBss_Status = limTriggerBackgroundScanDuringQuietBss( pMac ))) )
2901 {
2902 limLog( pMac, LOG2,
2903 FL("Attempting to trigger a background scan...\n"));
2904 }
2905 else
2906 {
2907 // Shut-off Tx/Rx for gLimSpecMgmt.quietDuration
2908 /* freeze the transmission */
2909 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_STOP_TX);
2910
2911 limLog( pMac, LOG2,
2912 FL("Quiet BSS: STA shutting down for %d ticks\n"),
Jeff Johnsone7245742012-09-05 17:12:55 -07002913 psessionEntry->gLimSpecMgmt.quietDuration );
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 }
2915 }
2916 break;
2917
2918 case eLIM_QUIET_RUNNING:
2919 case eLIM_QUIET_INIT:
2920 case eLIM_QUIET_END:
2921 default:
2922 //
2923 // As of now, nothing to be done
2924 //
2925 break;
2926 }
2927}
2928
2929/**
2930 * limProcessQuietBssTimeout
2931 *
2932 * FUNCTION:
2933 * This function is active on the AP and STA.
2934 * Handles SIR_LIM_QUIET_BSS_TIMEOUT
2935 *
2936 * LOGIC:
2937 * On the AP -
2938 * When the SIR_LIM_QUIET_BSS_TIMEOUT is triggered, it is
2939 * an indication for the AP to START sending out the
2940 * Quiet BSS IE.
2941 * If 802.11H is enabled, the Quiet BSS IE is sent as per
2942 * the 11H spec
2943 * If 802.11H is not enabled, the Quiet BSS IE is sent as
2944 * a Proprietary IE. This will be understood by all the
2945 * TITAN STA's
2946 * Transitioning gLimQuietState to eLIM_QUIET_BEGIN will
2947 * initiate the SCH to include the Quiet BSS IE in all
2948 * its subsequent Beacons/PR's.
2949 * The Quiet BSS IE will be included in all the Beacons
2950 * & PR's until the next DTIM period
2951 *
2952 * On the STA -
2953 * When gLimQuietState = eLIM_QUIET_RUNNING
2954 * This indicates that the STA was successfully shut-off
2955 * for the specified gLimQuietDuration. This is a trigger
2956 * for the STA to now resume data traffic.
2957 * -> gLimQuietState is set to eLIM_QUIET_INIT
2958 *
2959 * ASSUMPTIONS:
2960 *
2961 * NOTE:
2962 *
2963 * @param pMac - Pointer to Global MAC structure
2964 *
2965 * @return None
2966 */
2967void limProcessQuietBssTimeout( tpAniSirGlobal pMac )
2968{
Jeff Johnsone7245742012-09-05 17:12:55 -07002969 tpPESession psessionEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07002970
Jeff Johnsone7245742012-09-05 17:12:55 -07002971 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimQuietBssTimer.sessionId))== NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 {
2973 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
2974 return;
2975 }
2976
Jeff Johnsone7245742012-09-05 17:12:55 -07002977 PELOG1(limLog(pMac, LOG1, FL("quietState = %d\n"), psessionEntry->gLimSpecMgmt.quietState);)
2978 if (eLIM_AP_ROLE == psessionEntry->limSystemRole)
Jeff Johnson295189b2012-06-20 16:38:30 -07002979 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 }
2981 else
2982 {
2983 // eLIM_STA_ROLE
Jeff Johnsone7245742012-09-05 17:12:55 -07002984 switch( psessionEntry->gLimSpecMgmt.quietState )
Jeff Johnson295189b2012-06-20 16:38:30 -07002985 {
2986 case eLIM_QUIET_RUNNING:
2987 // Transition to eLIM_QUIET_INIT
Jeff Johnsone7245742012-09-05 17:12:55 -07002988 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002989
2990 if( !pMac->lim.gLimTriggerBackgroundScanDuringQuietBss || (glimTriggerBackgroundScanDuringQuietBss_Status == eSIR_FALSE) )
2991 {
2992 // Resume data traffic only if channel switch is not running in silent mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07002993 if (!((psessionEntry->gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING) &&
2994 (psessionEntry->gLimChannelSwitch.switchMode == eSIR_CHANSW_MODE_SILENT)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 {
2996 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
Jeff Johnsone7245742012-09-05 17:12:55 -07002997 limRestorePreQuietState(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 }
2999
3000 /* Reset status flag */
3001 if(glimTriggerBackgroundScanDuringQuietBss_Status == eSIR_FALSE)
3002 glimTriggerBackgroundScanDuringQuietBss_Status = eSIR_TRUE;
3003
3004 limLog( pMac, LOG2,
3005 FL("Quiet BSS: Resuming traffic...\n"));
3006 }
3007 else
3008 {
3009 //
3010 // Nothing specific to be done in this case
3011 // A background scan that was triggered during
3012 // SIR_LIM_QUIET_TIMEOUT will complete on its own
3013 //
3014 limLog( pMac, LOG2,
3015 FL("Background scan should be complete now...\n"));
3016 }
3017 break;
3018
3019 case eLIM_QUIET_INIT:
3020 case eLIM_QUIET_BEGIN:
3021 case eLIM_QUIET_END:
3022 PELOG2(limLog(pMac, LOG2, FL("Quiet state not in RUNNING\n"));)
3023 /* If the quiet period has ended, then resume the frame transmission */
3024 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
Jeff Johnsone7245742012-09-05 17:12:55 -07003025 limRestorePreQuietState(pMac, psessionEntry);
3026 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003027 break;
3028
3029 default:
3030 //
3031 // As of now, nothing to be done
3032 //
3033 break;
3034 }
3035 }
3036}
Jeff Johnson295189b2012-06-20 16:38:30 -07003037/**
3038 * limProcessWPSOverlapTimeout
3039 *
3040 * FUNCTION: This function call limWPSPBCTimeout() to clean WPS PBC probe request entries
3041 *
3042 * LOGIC:
3043 *
3044 * ASSUMPTIONS:
3045 *
3046 * NOTE:
3047 *
3048 * @param pMac - Pointer to Global MAC structure
3049 *
3050 * @return None
3051 */
3052#if 0
3053void limProcessWPSOverlapTimeout(tpAniSirGlobal pMac)
3054{
3055
3056 tpPESession psessionEntry;
3057 tANI_U32 sessionId;
3058
3059 if (tx_timer_activate(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer) != TX_SUCCESS)
3060 {
3061 limLog(pMac, LOGP, FL("tx_timer_activate failed\n"));
3062 }
3063
3064 sessionId = pMac->lim.limTimers.gLimWPSOverlapTimerObj.sessionId;
3065
3066 PELOGE(limLog(pMac, LOGE, FL("WPS overlap timeout, sessionId=%d\n"), sessionId);)
3067
3068 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId)) == NULL)
3069 {
3070 PELOGE(limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));)
3071 return;
3072 }
3073
3074 limWPSPBCTimeout(pMac, psessionEntry);
3075}
3076#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003077
Jeff Johnson295189b2012-06-20 16:38:30 -07003078/**----------------------------------------------
3079\fn limStartQuietTimer
3080\brief Starts the quiet timer.
3081
3082\param pMac
3083\return NONE
3084-----------------------------------------------*/
3085void limStartQuietTimer(tpAniSirGlobal pMac, tANI_U8 sessionId)
3086{
3087 tpPESession psessionEntry;
3088 psessionEntry = peFindSessionBySessionId(pMac , sessionId);
3089
3090 if(psessionEntry == NULL) {
3091 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
3092 return;
3093 }
3094
Jeff Johnson295189b2012-06-20 16:38:30 -07003095
3096 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3097 return;
3098 // First, de-activate Timer, if its already active
3099 limCancelDot11hQuiet(pMac, psessionEntry);
3100
Jeff Johnsone7245742012-09-05 17:12:55 -07003101 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, sessionId, eLIM_QUIET_TIMER));
3102 if( TX_SUCCESS != tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietTimer))
3103 {
3104 limLog( pMac, LOGE,
3105 FL( "Unable to deactivate gLimQuietTimer! Will still attempt to re-activate anyway...\n" ));
3106 }
3107
3108 // Set the NEW timeout value, in ticks
3109 if( TX_SUCCESS != tx_timer_change( &pMac->lim.limTimers.gLimQuietTimer,
3110 SYS_MS_TO_TICKS(psessionEntry->gLimSpecMgmt.quietTimeoutValue), 0))
3111 {
3112 limLog( pMac, LOGE,
3113 FL( "Unable to change gLimQuietTimer! Will still attempt to re-activate anyway...\n" ));
3114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003115
3116 pMac->lim.limTimers.gLimQuietTimer.sessionId = sessionId;
3117 if( TX_SUCCESS != tx_timer_activate(&pMac->lim.limTimers.gLimQuietTimer))
3118 {
3119 limLog( pMac, LOGE,
3120 FL("Unable to activate gLimQuietTimer! STA cannot honor Quiet BSS!\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003121 limRestorePreQuietState(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003122
Jeff Johnsone7245742012-09-05 17:12:55 -07003123 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 return;
3125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003126}
3127
Jeff Johnson295189b2012-06-20 16:38:30 -07003128
3129/** ------------------------------------------------------------------------ **/
3130/**
3131 * keep track of the number of ANI peers associated in the BSS
3132 * For the first and last ANI peer, we have to update EDCA params as needed
3133 *
3134 * When the first ANI peer joins the BSS, we notify SCH
3135 * When the last ANI peer leaves the BSS, we notfiy SCH
3136 */
3137void
3138limUtilCountStaAdd(
3139 tpAniSirGlobal pMac,
3140 tpDphHashNode pSta,
3141 tpPESession psessionEntry)
3142{
3143
3144 if ((! pSta) || (! pSta->valid) || (! pSta->aniPeer) || (pSta->fAniCount))
3145 return;
3146
3147 pSta->fAniCount = 1;
3148
3149 if (pMac->lim.gLimNumOfAniSTAs++ != 0)
3150 return;
3151
3152 // get here only if this is the first ANI peer in the BSS
3153 schEdcaProfileUpdate(pMac, psessionEntry);
3154}
3155
3156void
3157limUtilCountStaDel(
3158 tpAniSirGlobal pMac,
3159 tpDphHashNode pSta,
3160 tpPESession psessionEntry)
3161{
3162
3163 if ((pSta == NULL) || (pSta->aniPeer == eHAL_CLEAR) || (! pSta->fAniCount))
3164 return;
3165
3166 /* Only if sta is invalid and the validInDummyState bit is set to 1,
3167 * then go ahead and update the count and profiles. This ensures
3168 * that the "number of ani station" count is properly incremented/decremented.
3169 */
3170 if (pSta->valid == 1)
3171 return;
3172
3173 pSta->fAniCount = 0;
3174
3175 if (pMac->lim.gLimNumOfAniSTAs <= 0)
3176 {
3177 limLog(pMac, LOGE, FL("CountStaDel: ignoring Delete Req when AniPeer count is %d\n"),
3178 pMac->lim.gLimNumOfAniSTAs);
3179 return;
3180 }
3181
3182 pMac->lim.gLimNumOfAniSTAs--;
3183
3184 if (pMac->lim.gLimNumOfAniSTAs != 0)
3185 return;
3186
3187 // get here only if this is the last ANI peer in the BSS
3188 schEdcaProfileUpdate(pMac, psessionEntry);
3189}
3190
Jeff Johnson295189b2012-06-20 16:38:30 -07003191/**
3192 * limSwitchChannelCback()
3193 *
3194 *FUNCTION:
3195 * This is the callback function registered while requesting to switch channel
3196 * after AP indicates a channel switch for spectrum management (11h).
3197 *
3198 *NOTE:
3199 * @param pMac Pointer to Global MAC structure
3200 * @param status Status of channel switch request
3201 * @param data User data
3202 * @param psessionEntry Session information
3203 * @return NONE
3204 */
3205void limSwitchChannelCback(tpAniSirGlobal pMac, eHalStatus status,
3206 tANI_U32 *data, tpPESession psessionEntry)
3207{
3208 tSirMsgQ mmhMsg = {0};
3209 tSirSmeSwitchChannelInd *pSirSmeSwitchChInd;
3210
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 psessionEntry->currentOperChannel = psessionEntry->currentReqChannel;
3212
3213 /* We need to restore pre-channelSwitch state on the STA */
3214 if (limRestorePreChannelSwitchState(pMac, psessionEntry) != eSIR_SUCCESS)
3215 {
3216 limLog(pMac, LOGP, FL("Could not restore pre-channelSwitch (11h) state, resetting the system\n"));
3217 return;
3218 }
3219
3220 mmhMsg.type = eWNI_SME_SWITCH_CHL_REQ;
3221 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pSirSmeSwitchChInd, sizeof(tSirSmeSwitchChannelInd)))
3222 {
3223 limLog(pMac, LOGP, FL("Failed to allocate buffer for buffer descriptor\n"));
3224 return;
3225 }
3226
3227 pSirSmeSwitchChInd->messageType = eWNI_SME_SWITCH_CHL_REQ;
3228 pSirSmeSwitchChInd->length = sizeof(tSirSmeSwitchChannelInd);
Jeff Johnsone7245742012-09-05 17:12:55 -07003229 pSirSmeSwitchChInd->newChannelId = psessionEntry->gLimChannelSwitch.primaryChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 pSirSmeSwitchChInd->sessionId = psessionEntry->smeSessionId;
3231 //BSS ID
3232 palCopyMemory( pMac->hHdd, pSirSmeSwitchChInd->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
3233 mmhMsg.bodyptr = pSirSmeSwitchChInd;
3234 mmhMsg.bodyval = 0;
3235
Jeff Johnsone7245742012-09-05 17:12:55 -07003236 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003237
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 SysProcessMmhMsg(pMac, &mmhMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -07003239}
3240
3241/**
3242 * limSwitchPrimaryChannel()
3243 *
3244 *FUNCTION:
3245 * This function changes the current operating channel
3246 * and sets the new new channel ID in WNI_CFG_CURRENT_CHANNEL.
3247 *
3248 *NOTE:
3249 * @param pMac Pointer to Global MAC structure
3250 * @param newChannel new chnannel ID
3251 * @return NONE
3252 */
3253void limSwitchPrimaryChannel(tpAniSirGlobal pMac, tANI_U8 newChannel,tpPESession psessionEntry)
3254{
3255#if !defined WLAN_FEATURE_VOWIFI
3256 tANI_U32 localPwrConstraint;
3257#endif
3258
3259 PELOG3(limLog(pMac, LOG3, FL("limSwitchPrimaryChannel: old chnl %d --> new chnl %d \n"),
3260 psessionEntry->currentOperChannel, newChannel);)
3261 psessionEntry->currentReqChannel = newChannel;
3262 psessionEntry->limRFBand = limGetRFBand(newChannel);
3263
3264 psessionEntry->channelChangeReasonCode=LIM_SWITCH_CHANNEL_OPERATION;
3265
3266 pMac->lim.gpchangeChannelCallback = limSwitchChannelCback;
3267 pMac->lim.gpchangeChannelData = NULL;
3268
3269#if defined WLAN_FEATURE_VOWIFI
Jeff Johnsone7245742012-09-05 17:12:55 -07003270 limSendSwitchChnlParams(pMac, newChannel, PHY_SINGLE_CHANNEL_CENTERED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003271 psessionEntry->maxTxPower, psessionEntry->peSessionId);
3272#else
3273 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS)
3274 {
3275 limLog( pMac, LOGP, FL( "Unable to read Local Power Constraint from cfg\n" ));
3276 return;
3277 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003278 limSendSwitchChnlParams(pMac, newChannel, PHY_SINGLE_CHANNEL_CENTERED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 (tPowerdBm)localPwrConstraint, psessionEntry->peSessionId);
3280#endif
3281 return;
3282}
3283
3284/**
3285 * limSwitchPrimarySecondaryChannel()
3286 *
3287 *FUNCTION:
3288 * This function changes the primary and secondary channel.
3289 * If 11h is enabled and user provides a "new channel ID"
3290 * that is different from the current operating channel,
3291 * then we must set this new channel in WNI_CFG_CURRENT_CHANNEL,
3292 * assign notify LIM of such change.
3293 *
3294 *NOTE:
3295 * @param pMac Pointer to Global MAC structure
3296 * @param newChannel New chnannel ID (or current channel ID)
3297 * @param subband CB secondary info:
3298 * - eANI_CB_SECONDARY_NONE
3299 * - eANI_CB_SECONDARY_UP
3300 * - eANI_CB_SECONDARY_DOWN
3301 * @return NONE
3302 */
Jeff Johnsone7245742012-09-05 17:12:55 -07003303void limSwitchPrimarySecondaryChannel(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 newChannel, ePhyChanBondState subband)
Jeff Johnson295189b2012-06-20 16:38:30 -07003304{
3305#if !defined WLAN_FEATURE_VOWIFI
3306 tANI_U32 localPwrConstraint;
3307#endif
3308
Jeff Johnson295189b2012-06-20 16:38:30 -07003309#if !defined WLAN_FEATURE_VOWIFI
3310 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
3311 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg\n" ));
3312 return;
3313 }
3314#endif
3315
Jeff Johnson295189b2012-06-20 16:38:30 -07003316#if defined WLAN_FEATURE_VOWIFI
Jeff Johnsone7245742012-09-05 17:12:55 -07003317 limSendSwitchChnlParams(pMac, newChannel, subband, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003318#else
Jeff Johnsone7245742012-09-05 17:12:55 -07003319 limSendSwitchChnlParams(pMac, newChannel, subband, (tPowerdBm)localPwrConstraint, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003320#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003321
Jeff Johnsone7245742012-09-05 17:12:55 -07003322 // Store the new primary and secondary channel in session entries if different
3323 if (psessionEntry->currentOperChannel != newChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 {
3325 limLog(pMac, LOGW,
3326 FL("switch old chnl %d --> new chnl %d \n"),
3327 psessionEntry->currentOperChannel, newChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 psessionEntry->currentOperChannel = newChannel;
3329 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003330 if (psessionEntry->htSecondaryChannelOffset != subband)
3331 {
3332 limLog(pMac, LOGW,
3333 FL("switch old sec chnl %d --> new sec chnl %d \n"),
3334 psessionEntry->htSecondaryChannelOffset, subband);
3335 psessionEntry->htSecondaryChannelOffset = subband;
3336 if (psessionEntry->htSecondaryChannelOffset == PHY_SINGLE_CHANNEL_CENTERED)
3337 {
3338 psessionEntry->htSupportedChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3339 }
3340 else
3341 {
3342 psessionEntry->htSupportedChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
3343 }
3344 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
3345 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003346
3347 return;
3348}
3349
3350
3351/**
3352 * limActiveScanAllowed()
3353 *
3354 *FUNCTION:
3355 * Checks if active scans are permitted on the given channel
3356 *
3357 *LOGIC:
3358 * The config variable SCAN_CONTROL_LIST contains pairs of (channelNum, activeScanAllowed)
3359 * Need to check if the channelNum matches, then depending on the corresponding
3360 * scan flag, return true (for activeScanAllowed==1) or false (otherwise).
3361 *
3362 *ASSUMPTIONS:
3363 *
3364 *NOTE:
3365 *
3366 * @param pMac Pointer to Global MAC structure
3367 * @param channelNum channel number
3368 * @return None
3369 */
3370
3371tANI_U8 limActiveScanAllowed(
3372 tpAniSirGlobal pMac,
3373 tANI_U8 channelNum)
3374{
3375 tANI_U32 i;
3376 tANI_U8 channelPair[WNI_CFG_SCAN_CONTROL_LIST_LEN];
3377 tANI_U32 len = WNI_CFG_SCAN_CONTROL_LIST_LEN;
3378 if (wlan_cfgGetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, channelPair, &len)
3379 != eSIR_SUCCESS)
3380 {
3381 PELOGE(limLog(pMac, LOGE, FL("Unable to get scan control list\n"));)
3382 return false;
3383 }
3384
3385 if (len > WNI_CFG_SCAN_CONTROL_LIST_LEN)
3386 {
3387 limLog(pMac, LOGE, FL("Invalid scan control list length:%d\n"),
3388 len);
3389 return false;
3390 }
3391
3392 for (i=0; (i+1) < len; i+=2)
3393 {
3394 if (channelPair[i] == channelNum)
3395 return ((channelPair[i+1] == eSIR_ACTIVE_SCAN) ? true : false);
3396 }
3397 return false;
3398}
3399
3400/**
3401 * limTriggerBackgroundScanDuringQuietBss()
3402 *
3403 *FUNCTION:
3404 * This function is applicable to the STA only.
3405 * This function is called by limProcessQuietTimeout(),
3406 * when it is time to honor the Quiet BSS IE from the AP.
3407 *
3408 *LOGIC:
3409 * If 11H is enabled:
3410 * We cannot trigger a background scan. The STA needs to
3411 * shut-off Tx/Rx.
3412 * If 11 is not enabled:
3413 * Determine if the next channel that we are going to
3414 * scan is NOT the same channel (or not) on which the
3415 * Quiet BSS was requested.
3416 * If yes, then we cannot trigger a background scan on
3417 * this channel. Return with a false.
3418 * If no, then trigger a background scan. Return with
3419 * a true.
3420 *
3421 *ASSUMPTIONS:
3422 *
3423 *NOTE:
3424 * This API is redundant if the existing API,
3425 * limTriggerBackgroundScan(), were to return a valid
3426 * response instead of returning void.
3427 * If possible, try to revisit this API
3428 *
3429 * @param pMac Pointer to Global MAC structure
3430 * @return eSIR_TRUE, if a background scan was attempted
3431 * eSIR_FALSE, if not
3432 */
3433tAniBool limTriggerBackgroundScanDuringQuietBss( tpAniSirGlobal pMac )
3434{
3435 tAniBool bScanTriggered = eSIR_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003436
3437
3438
3439 //TBD-RAJESH HOW TO GET sessionEntry?????
3440 tpPESession psessionEntry = &pMac->lim.gpSession[0];
3441
3442 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3443 return bScanTriggered;
3444
Jeff Johnsone7245742012-09-05 17:12:55 -07003445 if( !psessionEntry->lim11hEnable )
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 {
3447 tSirMacChanNum bgScanChannelList[WNI_CFG_BG_SCAN_CHANNEL_LIST_LEN];
3448 tANI_U32 len = WNI_CFG_BG_SCAN_CHANNEL_LIST_LEN;
3449
3450 // Determine the next scan channel
3451
3452 // Get background scan channel list from CFG
3453 if( eSIR_SUCCESS == wlan_cfgGetStr( pMac,
3454 WNI_CFG_BG_SCAN_CHANNEL_LIST,
3455 (tANI_U8 *) bgScanChannelList,
3456 (tANI_U32 *) &len ))
3457 {
3458 // Ensure that we do not go off scanning on the same
3459 // channel on which the Quiet BSS was requested
3460 if( psessionEntry->currentOperChannel!=
3461 bgScanChannelList[pMac->lim.gLimBackgroundScanChannelId] )
3462 {
3463 // For now, try and attempt a background scan. It will
3464 // be ideal if this API actually returns a success or
3465 // failure instead of having a void return type
3466 limTriggerBackgroundScan( pMac );
3467
3468 bScanTriggered = eSIR_TRUE;
3469 }
3470 else
3471 {
3472 limLog( pMac, LOGW,
3473 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"));
3474 }
3475 }
3476 else
3477 {
3478 limLog( pMac, LOGW,
3479 FL("Unable to retrieve WNI_CFG_VALID_CHANNEL_LIST from CFG! A background scan will not be triggered during this Quiet BSS period...\n"));
3480 }
3481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003482 return bScanTriggered;
3483}
3484
3485
3486/**
3487 * limGetHTCapability()
3488 *
3489 *FUNCTION:
3490 * A utility function that returns the "current HT capability state" for the HT
3491 * capability of interest (as requested in the API)
3492 *
3493 *LOGIC:
3494 * This routine will return with the "current" setting of a requested HT
3495 * capability. This state info could be retrieved from -
3496 * a) CFG (for static entries)
3497 * b) Run time info
3498 * - Dynamic state maintained by LIM
3499 * - Configured at radio init time by SME
3500 *
3501 *
3502 *ASSUMPTIONS:
3503 * NA
3504 *
3505 *NOTE:
3506 *
3507 * @param pMac Pointer to Global MAC structure
3508 * @param htCap The HT capability being queried
3509 * @return tANI_U8 The current state of the requested HT capability is returned in a
3510 * tANI_U8 variable
3511 */
3512
Jeff Johnson295189b2012-06-20 16:38:30 -07003513tANI_U8 limGetHTCapability( tpAniSirGlobal pMac,
3514 tANI_U32 htCap, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003515{
3516tANI_U8 retVal = 0;
3517tANI_U8 *ptr;
3518tANI_U32 cfgValue;
3519tSirMacHTCapabilityInfo macHTCapabilityInfo = {0};
3520tSirMacExtendedHTCapabilityInfo macExtHTCapabilityInfo = {0};
3521tSirMacTxBFCapabilityInfo macTxBFCapabilityInfo = {0};
3522tSirMacASCapabilityInfo macASCapabilityInfo = {0};
3523
3524 //
3525 // Determine which CFG to read from. Not ALL of the HT
3526 // related CFG's need to be read each time this API is
3527 // accessed
3528 //
3529 if( htCap >= eHT_ANTENNA_SELECTION &&
3530 htCap < eHT_SI_GRANULARITY )
3531 {
3532 // Get Antenna Seletion HT Capabilities
3533 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_AS_CAP, &cfgValue ))
3534 cfgValue = 0;
3535 ptr = (tANI_U8 *) &macASCapabilityInfo;
3536 *((tANI_U8 *)ptr) = (tANI_U8) (cfgValue & 0xff);
3537 }
3538 else
3539 {
3540 if( htCap >= eHT_TX_BEAMFORMING &&
3541 htCap < eHT_ANTENNA_SELECTION )
3542 {
3543 // Get Transmit Beam Forming HT Capabilities
3544 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_TX_BF_CAP, &cfgValue ))
3545 cfgValue = 0;
3546 ptr = (tANI_U8 *) &macTxBFCapabilityInfo;
3547 *((tANI_U32 *)ptr) = (tANI_U32) (cfgValue);
3548 }
3549 else
3550 {
3551 if( htCap >= eHT_PCO &&
3552 htCap < eHT_TX_BEAMFORMING )
3553 {
3554 // Get Extended HT Capabilities
3555 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_EXT_HT_CAP_INFO, &cfgValue ))
3556 cfgValue = 0;
3557 ptr = (tANI_U8 *) &macExtHTCapabilityInfo;
3558 *((tANI_U16 *)ptr) = (tANI_U16) (cfgValue & 0xffff);
3559 }
3560 else
3561 {
3562 if( htCap < eHT_MAX_RX_AMPDU_FACTOR )
3563 {
3564 // Get HT Capabilities
3565 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_HT_CAP_INFO, &cfgValue ))
3566 cfgValue = 0;
3567 ptr = (tANI_U8 *) &macHTCapabilityInfo;
3568 // 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
3569 *ptr++ = cfgValue & 0xff;
3570 *ptr = (cfgValue >> 8) & 0xff;
3571 }
3572 }
3573 }
3574 }
3575
3576 switch( htCap )
3577 {
3578 case eHT_LSIG_TXOP_PROTECTION:
3579 retVal = pMac->lim.gHTLsigTXOPProtection;
3580 break;
3581
3582 case eHT_STBC_CONTROL_FRAME:
3583 retVal = (tANI_U8) macHTCapabilityInfo.stbcControlFrame;
3584 break;
3585
3586 case eHT_PSMP:
3587 retVal = pMac->lim.gHTPSMPSupport;
3588 break;
3589
3590 case eHT_DSSS_CCK_MODE_40MHZ:
3591 retVal = pMac->lim.gHTDsssCckRate40MHzSupport;
3592 break;
3593
3594 case eHT_MAX_AMSDU_LENGTH:
3595 retVal = (tANI_U8) macHTCapabilityInfo.maximalAMSDUsize;
3596 break;
3597
3598 case eHT_DELAYED_BA:
3599 retVal = (tANI_U8) macHTCapabilityInfo.delayedBA;
3600 break;
3601
3602 case eHT_RX_STBC:
3603 retVal = (tANI_U8) macHTCapabilityInfo.rxSTBC;
3604 break;
3605
3606 case eHT_TX_STBC:
3607 retVal = (tANI_U8) macHTCapabilityInfo.txSTBC;
3608 break;
3609
3610 case eHT_SHORT_GI_40MHZ:
3611 retVal = (tANI_U8) macHTCapabilityInfo.shortGI40MHz;
3612 break;
3613
3614 case eHT_SHORT_GI_20MHZ:
3615 retVal = (tANI_U8) macHTCapabilityInfo.shortGI20MHz;
3616 break;
3617
3618 case eHT_GREENFIELD:
3619 retVal = (tANI_U8) macHTCapabilityInfo.greenField;
3620 break;
3621
3622 case eHT_MIMO_POWER_SAVE:
3623 retVal = (tANI_U8) pMac->lim.gHTMIMOPSState;
3624 break;
3625
3626 case eHT_SUPPORTED_CHANNEL_WIDTH_SET:
Jeff Johnsone7245742012-09-05 17:12:55 -07003627 retVal = (tANI_U8) psessionEntry->htSupportedChannelWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 break;
3629
3630 case eHT_ADVANCED_CODING:
3631 retVal = (tANI_U8) macHTCapabilityInfo.advCodingCap;
3632 break;
3633
3634 case eHT_MAX_RX_AMPDU_FACTOR:
3635 retVal = pMac->lim.gHTMaxRxAMpduFactor;
3636 break;
3637
3638 case eHT_MPDU_DENSITY:
3639 retVal = pMac->lim.gHTAMpduDensity;
3640 break;
3641
3642 case eHT_PCO:
3643 retVal = (tANI_U8) macExtHTCapabilityInfo.pco;
3644 break;
3645
3646 case eHT_TRANSITION_TIME:
3647 retVal = (tANI_U8) macExtHTCapabilityInfo.transitionTime;
3648 break;
3649
3650 case eHT_MCS_FEEDBACK:
3651 retVal = (tANI_U8) macExtHTCapabilityInfo.mcsFeedback;
3652 break;
3653
3654 case eHT_TX_BEAMFORMING:
3655 retVal = (tANI_U8) macTxBFCapabilityInfo.txBF;
3656 break;
3657
3658 case eHT_ANTENNA_SELECTION:
3659 retVal = (tANI_U8) macASCapabilityInfo.antennaSelection;
3660 break;
3661
3662 case eHT_SI_GRANULARITY:
3663 retVal = pMac->lim.gHTServiceIntervalGranularity;
3664 break;
3665
3666 case eHT_CONTROLLED_ACCESS:
3667 retVal = pMac->lim.gHTControlledAccessOnly;
3668 break;
3669
3670 case eHT_RIFS_MODE:
3671 retVal = psessionEntry->beaconParams.fRIFSMode;
3672 break;
3673
3674 case eHT_RECOMMENDED_TX_WIDTH_SET:
Jeff Johnsone7245742012-09-05 17:12:55 -07003675 retVal = psessionEntry->htRecommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 break;
3677
3678 case eHT_EXTENSION_CHANNEL_OFFSET:
Jeff Johnsone7245742012-09-05 17:12:55 -07003679 retVal = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07003680 break;
3681
3682 case eHT_OP_MODE:
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 if(psessionEntry->limSystemRole == eLIM_AP_ROLE )
3684 retVal = psessionEntry->htOperMode;
3685 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 retVal = pMac->lim.gHTOperMode;
3687 break;
3688
3689 case eHT_BASIC_STBC_MCS:
3690 retVal = pMac->lim.gHTSTBCBasicMCS;
3691 break;
3692
3693 case eHT_DUAL_CTS_PROTECTION:
3694 retVal = pMac->lim.gHTDualCTSProtection;
3695 break;
3696
3697 case eHT_LSIG_TXOP_PROTECTION_FULL_SUPPORT:
3698 retVal = psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport;
3699 break;
3700
3701 case eHT_PCO_ACTIVE:
3702 retVal = pMac->lim.gHTPCOActive;
3703 break;
3704
3705 case eHT_PCO_PHASE:
3706 retVal = pMac->lim.gHTPCOPhase;
3707 break;
3708
3709 default:
3710 break;
3711 }
3712
3713 return retVal;
3714}
3715
Jeff Johnson295189b2012-06-20 16:38:30 -07003716void limGetMyMacAddr(tpAniSirGlobal pMac, tANI_U8 *mac)
3717{
3718 palCopyMemory( pMac->hHdd, mac, pMac->lim.gLimMyMacAddr, sizeof(tSirMacAddr));
3719 return;
3720}
3721
3722
3723
3724
3725/** -------------------------------------------------------------
3726\fn limEnable11aProtection
3727\brief based on config setting enables\disables 11a protection.
3728\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
3729\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
3730\param tpUpdateBeaconParams pBeaconParams
3731\return None
3732 -------------------------------------------------------------*/
3733tSirRetStatus
3734limEnable11aProtection(tpAniSirGlobal pMac, tANI_U8 enable,
3735 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
3736{
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07003737 if(NULL == psessionEntry)
3738 {
3739 PELOG3(limLog(pMac, LOG3, FL("psessionEntry is NULL\n"));)
3740 return eSIR_FAILURE;
3741 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 //overlapping protection configuration check.
3743 if(overlap)
3744 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 }
3746 else
3747 {
3748 //normal protection config check
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07003749 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07003750 (!psessionEntry->cfgProtection.fromlla))
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 {
3752 // protection disabled.
3753 PELOG3(limLog(pMac, LOG3, FL("protection from 11a is disabled\n"));)
3754 return eSIR_SUCCESS;
3755 }
3756 }
3757
3758 if (enable)
3759 {
3760 //If we are AP and HT capable, we need to set the HT OP mode
3761 //appropriately.
3762 if(((eLIM_AP_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole))&&
Jeff Johnsone7245742012-09-05 17:12:55 -07003763 (true == psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 {
3765 if(overlap)
3766 {
3767 pMac->lim.gLimOverlap11aParams.protectionEnabled = true;
3768 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
3769 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
3770 {
3771 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
3772 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
3773 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3774 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3775 }
3776 }
3777 else
3778 {
3779 psessionEntry->gLim11aParams.protectionEnabled = true;
3780 if(eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode)
3781 {
3782 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_MIXED;
Jeff Johnsone7245742012-09-05 17:12:55 -07003783 psessionEntry->htOperMode = eSIR_HT_OP_MODE_MIXED;
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3785 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3786
3787 }
3788 }
3789 }
3790
3791 //This part is common for staiton as well.
3792 if(false == psessionEntry->beaconParams.llaCoexist)
3793 {
3794 PELOG1(limLog(pMac, LOG1, FL(" => protection from 11A Enabled\n"));)
3795 pBeaconParams->llaCoexist = psessionEntry->beaconParams.llaCoexist = true;
3796 pBeaconParams->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
3797 }
3798 }
3799 else if (true == psessionEntry->beaconParams.llaCoexist)
3800 {
3801 //for AP role.
3802 //we need to take care of HT OP mode change if needed.
3803 //We need to take care of Overlap cases.
3804 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
3805 {
3806 if(overlap)
3807 {
3808 //Overlap Legacy protection disabled.
3809 pMac->lim.gLimOverlap11aParams.protectionEnabled = false;
3810
3811 //We need to take care of HT OP mode iff we are HT AP.
Jeff Johnsone7245742012-09-05 17:12:55 -07003812 if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 {
3814 // no HT op mode change if any of the overlap protection enabled.
3815 if(!(pMac->lim.gLimOverlap11aParams.protectionEnabled ||
3816 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
3817 pMac->lim.gLimOverlapNonGfParams.protectionEnabled))
3818
3819 {
3820 //Check if there is a need to change HT OP mode.
3821 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
3822 {
3823 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
3824 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
3825
3826 if(psessionEntry->gLimHt20Params.protectionEnabled)
3827 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
3828 else
3829 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
3830 }
3831 }
3832 }
3833 }
3834 else
3835 {
3836 //Disable protection from 11A stations.
3837 psessionEntry->gLim11aParams.protectionEnabled = false;
3838 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
3839
3840 //Check if any other non-HT protection enabled.
3841 //Right now we are in HT OP Mixed mode.
3842 //Change HT op mode appropriately.
3843
3844 //Change HT OP mode to 01 if any overlap protection enabled
3845 if(pMac->lim.gLimOverlap11aParams.protectionEnabled ||
3846 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
3847 pMac->lim.gLimOverlapNonGfParams.protectionEnabled)
3848
3849 {
3850 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
Jeff Johnsone7245742012-09-05 17:12:55 -07003851 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3853 }
3854 else if(psessionEntry->gLimHt20Params.protectionEnabled)
3855 {
3856 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003857 psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
3859 }
3860 else
3861 {
3862 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003863 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
3865 }
3866 }
3867 if(!pMac->lim.gLimOverlap11aParams.protectionEnabled &&
3868 !psessionEntry->gLim11aParams.protectionEnabled)
3869 {
3870 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11A Disabled\n"));)
3871 pBeaconParams->llaCoexist = psessionEntry->beaconParams.llaCoexist = false;
3872 pBeaconParams->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
3873 }
3874 }
3875 //for station role
3876 else
3877 {
3878 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11A Disabled\n"));)
3879 pBeaconParams->llaCoexist = psessionEntry->beaconParams.llaCoexist = false;
3880 pBeaconParams->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
3881 }
3882 }
3883
3884 return eSIR_SUCCESS;
3885}
3886
3887/** -------------------------------------------------------------
3888\fn limEnable11gProtection
3889\brief based on config setting enables\disables 11g protection.
3890\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
3891\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
3892\param tpUpdateBeaconParams pBeaconParams
3893\return None
3894 -------------------------------------------------------------*/
3895
3896tSirRetStatus
3897limEnable11gProtection(tpAniSirGlobal pMac, tANI_U8 enable,
3898 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
3899{
3900
3901 //overlapping protection configuration check.
3902 if(overlap)
3903 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 }
3905 else
3906 {
3907 //normal protection config check
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
3909 !psessionEntry->cfgProtection.fromllb)
3910 {
3911 // protection disabled.
3912 PELOG1(limLog(pMac, LOG1, FL("protection from 11b is disabled\n"));)
3913 return eSIR_SUCCESS;
3914 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 {
3916 if(!pMac->lim.cfgProtection.fromllb)
3917 {
3918 // protection disabled.
3919 PELOG1(limLog(pMac, LOG1, FL("protection from 11b is disabled\n"));)
3920 return eSIR_SUCCESS;
3921 }
3922 }
3923 }
3924
3925 if (enable)
3926 {
3927 //If we are AP and HT capable, we need to set the HT OP mode
3928 //appropriately.
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
3930 {
3931 if(overlap)
3932 {
3933 psessionEntry->gLimOlbcParams.protectionEnabled = true;
3934 PELOGE(limLog(pMac, LOGE, FL("protection from olbc is enabled\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07003935 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 {
3937 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != psessionEntry->htOperMode) &&
3938 (eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode))
3939 {
3940 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
3941 }
3942 //CR-263021: OBSS bit is not switching back to 0 after disabling the overlapping legacy BSS
3943 // This fixes issue of OBSS bit not set after 11b, 11g station leaves
3944 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3945 //Not processing OBSS bit from other APs, as we are already taking care
3946 //of Protection from overlapping BSS based on erp IE or useProtection bit
3947 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams, psessionEntry);
3948 }
3949 }
3950 else
3951 {
3952 psessionEntry->gLim11bParams.protectionEnabled = true;
3953 PELOGE(limLog(pMac, LOGE, FL("protection from 11b is enabled\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07003954 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07003955 {
3956 if(eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode)
3957 {
3958 psessionEntry->htOperMode = eSIR_HT_OP_MODE_MIXED;
3959 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3960 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3961 }
3962 }
3963 }
3964 }else if ((eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07003965 (true == psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 {
3967 if(overlap)
3968 {
3969 psessionEntry->gLimOlbcParams.protectionEnabled = true;
3970 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
3971 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
3972 {
3973 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
3974 }
3975 //CR-263021: OBSS bit is not switching back to 0 after disabling the overlapping legacy BSS
3976 // This fixes issue of OBSS bit not set after 11b, 11g station leaves
3977 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3978 //Not processing OBSS bit from other APs, as we are already taking care
3979 //of Protection from overlapping BSS based on erp IE or useProtection bit
3980 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams, psessionEntry);
3981 }
3982 else
3983 {
3984 psessionEntry->gLim11bParams.protectionEnabled = true;
3985 if(eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode)
3986 {
3987 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_MIXED;
3988 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3989 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
3990 }
3991 }
3992 }
3993
3994 //This part is common for staiton as well.
3995 if(false == psessionEntry->beaconParams.llbCoexist)
3996 {
3997 PELOG1(limLog(pMac, LOG1, FL("=> 11G Protection Enabled\n"));)
3998 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = true;
3999 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4000 }
4001 }
4002 else if (true == psessionEntry->beaconParams.llbCoexist)
4003 {
4004 //for AP role.
4005 //we need to take care of HT OP mode change if needed.
4006 //We need to take care of Overlap cases.
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4008 {
4009 if(overlap)
4010 {
4011 //Overlap Legacy protection disabled.
4012 psessionEntry->gLimOlbcParams.protectionEnabled = false;
4013
4014 //We need to take care of HT OP mode if we are HT AP.
Jeff Johnsone7245742012-09-05 17:12:55 -07004015 if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004016 {
4017 // no HT op mode change if any of the overlap protection enabled.
4018 if(!(psessionEntry->gLimOverlap11gParams.protectionEnabled ||
4019 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4020 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
4021 {
4022 //Check if there is a need to change HT OP mode.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004023 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == psessionEntry->htOperMode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 {
4025 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4026 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4027 if(psessionEntry->gLimHt20Params.protectionEnabled){
4028 //Commenting out beacuse of CR 258588 WFA cert
4029 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4030 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4031 }
4032 else
4033 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4034 }
4035 }
4036 }
4037 }
4038 else
4039 {
4040 //Disable protection from 11B stations.
4041 psessionEntry->gLim11bParams.protectionEnabled = false;
4042 PELOGE(limLog(pMac, LOGE, FL("===> 11B Protection Disabled\n"));)
4043 //Check if any other non-HT protection enabled.
4044 if(!psessionEntry->gLim11gParams.protectionEnabled)
4045 {
4046 //Right now we are in HT OP Mixed mode.
4047 //Change HT op mode appropriately.
4048 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4049
4050 //Change HT OP mode to 01 if any overlap protection enabled
4051 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4052 psessionEntry->gLimOverlap11gParams.protectionEnabled ||
4053 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4054 psessionEntry->gLimOverlapNonGfParams.protectionEnabled)
4055 {
4056 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4057 PELOGE(limLog(pMac, LOGE, FL("===> 11G Protection Disabled\n"));)
4058 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4059 }
4060 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4061 {
4062 //Commenting because of CR 258588 WFA cert
4063 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4064 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4065 PELOGE(limLog(pMac, LOGE, FL("===> 11G Protection Disabled\n"));)
4066 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4067 }
4068 else
4069 {
4070 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4071 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4072 }
4073 }
4074 }
4075 if(!psessionEntry->gLimOlbcParams.protectionEnabled &&
4076 !psessionEntry->gLim11bParams.protectionEnabled)
4077 {
4078 PELOGE(limLog(pMac, LOGE, FL("===> 11G Protection Disabled\n"));)
4079 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
4080 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4081 }
4082 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 {
4084 if(overlap)
4085 {
4086 //Overlap Legacy protection disabled.
4087 psessionEntry->gLimOlbcParams.protectionEnabled = false;
4088
4089 //We need to take care of HT OP mode iff we are HT AP.
Jeff Johnsone7245742012-09-05 17:12:55 -07004090 if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 {
4092 // no HT op mode change if any of the overlap protection enabled.
4093 if(!(pMac->lim.gLimOverlap11gParams.protectionEnabled ||
4094 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4095 pMac->lim.gLimOverlapNonGfParams.protectionEnabled))
4096
4097 {
4098 //Check if there is a need to change HT OP mode.
4099 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
4100 {
4101 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4102 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4103 if(psessionEntry->gLimHt20Params.protectionEnabled)
4104 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4105 else
4106 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4107 }
4108 }
4109 }
4110 }
4111 else
4112 {
4113 //Disable protection from 11B stations.
4114 psessionEntry->gLim11bParams.protectionEnabled = false;
4115 //Check if any other non-HT protection enabled.
4116 if(!psessionEntry->gLim11gParams.protectionEnabled)
4117 {
4118 //Right now we are in HT OP Mixed mode.
4119 //Change HT op mode appropriately.
4120 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4121
4122 //Change HT OP mode to 01 if any overlap protection enabled
4123 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4124 pMac->lim.gLimOverlap11gParams.protectionEnabled ||
4125 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4126 pMac->lim.gLimOverlapNonGfParams.protectionEnabled)
4127
4128 {
4129 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4130 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4131 }
4132 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4133 {
4134 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4135 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4136 }
4137 else
4138 {
4139 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4140 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4141 }
4142 }
4143 }
4144 if(!psessionEntry->gLimOlbcParams.protectionEnabled &&
4145 !psessionEntry->gLim11bParams.protectionEnabled)
4146 {
4147 PELOG1(limLog(pMac, LOG1, FL("===> 11G Protection Disabled\n"));)
4148 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
4149 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4150 }
4151 }
4152 //for station role
4153 else
4154 {
4155 PELOG1(limLog(pMac, LOG1, FL("===> 11G Protection Disabled\n"));)
4156 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
4157 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4158 }
4159 }
4160 return eSIR_SUCCESS;
4161}
4162
4163/** -------------------------------------------------------------
4164\fn limEnableHtProtectionFrom11g
4165\brief based on cofig enables\disables protection from 11g.
4166\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4167\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4168\param tpUpdateBeaconParams pBeaconParams
4169\return None
4170 -------------------------------------------------------------*/
4171tSirRetStatus
4172limEnableHtProtectionFrom11g(tpAniSirGlobal pMac, tANI_U8 enable,
4173 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4174{
Jeff Johnsone7245742012-09-05 17:12:55 -07004175 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 return eSIR_SUCCESS; // protection from 11g is only for HT stations.
4177
4178 //overlapping protection configuration check.
4179 if(overlap)
4180 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004181 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) && (!psessionEntry->cfgProtection.overlapFromllg))
4182 {
4183 // protection disabled.
4184 PELOG3(limLog(pMac, LOG3, FL("overlap protection from 11g is disabled\n")););
4185 return eSIR_SUCCESS;
4186 }else if ((psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) && (!pMac->lim.cfgProtection.overlapFromllg))
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 {
4188 // protection disabled.
4189 PELOG3(limLog(pMac, LOG3, FL("overlap protection from 11g is disabled\n")););
4190 return eSIR_SUCCESS;
4191 }
4192 }
4193 else
4194 {
4195 //normal protection config check
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
4197 !psessionEntry->cfgProtection.fromllg){
4198 // protection disabled.
4199 PELOG3(limLog(pMac, LOG3, FL("protection from 11g is disabled\n"));)
4200 return eSIR_SUCCESS;
4201 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 {
4203 if(!pMac->lim.cfgProtection.fromllg)
4204 {
4205 // protection disabled.
4206 PELOG3(limLog(pMac, LOG3, FL("protection from 11g is disabled\n"));)
4207 return eSIR_SUCCESS;
4208 }
4209 }
4210 }
4211 if (enable)
4212 {
4213 //If we are AP and HT capable, we need to set the HT OP mode
4214 //appropriately.
4215
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4217 {
4218 if(overlap)
4219 {
4220 psessionEntry->gLimOverlap11gParams.protectionEnabled = true;
4221 //11g exists in overlap BSS.
4222 //need not to change the operating mode to overlap_legacy
4223 //if higher or same protection operating mode is enabled right now.
4224 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != psessionEntry->htOperMode) &&
4225 (eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode))
4226 {
4227 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4228 }
4229 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4230 limEnableHtOBSSProtection(pMac, true , overlap, pBeaconParams, psessionEntry);
4231 }
4232 else
4233 {
4234 //11g is associated to an AP operating in 11n mode.
4235 //Change the HT operating mode to 'mixed mode'.
4236 psessionEntry->gLim11gParams.protectionEnabled = true;
4237 if(eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode)
4238 {
4239 psessionEntry->htOperMode = eSIR_HT_OP_MODE_MIXED;
4240 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4241 limEnableHtOBSSProtection(pMac, true , overlap, pBeaconParams,psessionEntry);
4242 }
4243 }
4244 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
Jeff Johnson295189b2012-06-20 16:38:30 -07004245 {
4246 if(overlap)
4247 {
4248 pMac->lim.gLimOverlap11gParams.protectionEnabled = true;
4249 //11g exists in overlap BSS.
4250 //need not to change the operating mode to overlap_legacy
4251 //if higher or same protection operating mode is enabled right now.
4252 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
4253 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
4254 {
4255 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4256 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4257 }
4258 }
4259 else
4260 {
4261 //11g is associated to an AP operating in 11n mode.
4262 //Change the HT operating mode to 'mixed mode'.
4263 psessionEntry->gLim11gParams.protectionEnabled = true;
4264 if(eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode)
4265 {
4266 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_MIXED;
4267 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4268 limEnableHtOBSSProtection(pMac, true , overlap, pBeaconParams,psessionEntry);
4269 }
4270 }
4271 }
4272
4273 //This part is common for staiton as well.
4274 if(false == psessionEntry->beaconParams.llgCoexist)
4275 {
4276 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = true;
4277 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004279 else if (true == psessionEntry->gLimOverlap11gParams.protectionEnabled)
4280 {
4281 // As operating mode changed after G station assoc some way to update beacon
4282 // This addresses the issue of mode not changing to - 11 in beacon when OBSS overlap is enabled
4283 //pMac->sch.schObject.fBeaconChanged = 1;
4284 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4285 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 }
4287 else if (true == psessionEntry->beaconParams.llgCoexist)
4288 {
4289 //for AP role.
4290 //we need to take care of HT OP mode change if needed.
4291 //We need to take care of Overlap cases.
4292
Jeff Johnson295189b2012-06-20 16:38:30 -07004293 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4294 {
4295 if(overlap)
4296 {
4297 //Overlap Legacy protection disabled.
4298 if (psessionEntry->gLim11gParams.numSta == 0)
4299 psessionEntry->gLimOverlap11gParams.protectionEnabled = false;
4300
4301 // no HT op mode change if any of the overlap protection enabled.
4302 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
4303 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4304 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
4305 {
4306 //Check if there is a need to change HT OP mode.
4307 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == psessionEntry->htOperMode)
4308 {
4309 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4310 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4311
4312 if(psessionEntry->gLimHt20Params.protectionEnabled){
4313 //Commenting because of CR 258588 WFA cert
4314 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4315 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4316 }
4317 else
4318 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4319 }
4320 }
4321 }
4322 else
4323 {
4324 //Disable protection from 11G stations.
4325 psessionEntry->gLim11gParams.protectionEnabled = false;
4326 //Check if any other non-HT protection enabled.
4327 if(!psessionEntry->gLim11bParams.protectionEnabled)
4328 {
4329
4330 //Right now we are in HT OP Mixed mode.
4331 //Change HT op mode appropriately.
4332 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4333
4334 //Change HT OP mode to 01 if any overlap protection enabled
4335 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4336 psessionEntry->gLimOverlap11gParams.protectionEnabled ||
4337 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4338 psessionEntry->gLimOverlapNonGfParams.protectionEnabled)
4339
4340 {
4341 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4342 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4343 }
4344 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4345 {
4346 //Commenting because of CR 258588 WFA cert
4347 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4348 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4349 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4350 }
4351 else
4352 {
4353 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4354 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4355 }
4356 }
4357 }
4358 if(!psessionEntry->gLimOverlap11gParams.protectionEnabled &&
4359 !psessionEntry->gLim11gParams.protectionEnabled)
4360 {
4361 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11G Disabled\n"));)
4362 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = false;
4363 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4364 }
4365 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 {
4367 if(overlap)
4368 {
4369 //Overlap Legacy protection disabled.
4370 pMac->lim.gLimOverlap11gParams.protectionEnabled = false;
4371
4372 // no HT op mode change if any of the overlap protection enabled.
4373 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
4374 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4375 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
4376 {
4377 //Check if there is a need to change HT OP mode.
4378 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
4379 {
4380 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4381 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4382
4383 if(psessionEntry->gLimHt20Params.protectionEnabled)
4384 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4385 else
4386 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4387 }
4388 }
4389 }
4390 else
4391 {
4392 //Disable protection from 11G stations.
4393 psessionEntry->gLim11gParams.protectionEnabled = false;
4394 //Check if any other non-HT protection enabled.
4395 if(!psessionEntry->gLim11bParams.protectionEnabled)
4396 {
4397
4398 //Right now we are in HT OP Mixed mode.
4399 //Change HT op mode appropriately.
4400 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4401
4402 //Change HT OP mode to 01 if any overlap protection enabled
4403 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4404 pMac->lim.gLimOverlap11gParams.protectionEnabled ||
4405 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4406 pMac->lim.gLimOverlapNonGfParams.protectionEnabled)
4407
4408 {
4409 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4410 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4411 }
4412 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4413 {
4414 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4415 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4416 }
4417 else
4418 {
4419 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4420 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4421 }
4422 }
4423 }
4424 if(!pMac->lim.gLimOverlap11gParams.protectionEnabled &&
4425 !psessionEntry->gLim11gParams.protectionEnabled)
4426 {
4427 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11G Disabled\n"));)
4428 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = false;
4429 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4430 }
4431 }
4432 //for station role
4433 else
4434 {
4435 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11G Disabled\n"));)
4436 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = false;
4437 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4438 }
4439 }
4440 return eSIR_SUCCESS;
4441}
4442//FIXME_PROTECTION : need to check for no APSD whenever we want to enable this protection.
4443//This check will be done at the caller.
4444
4445/** -------------------------------------------------------------
4446\fn limEnableHtObssProtection
4447\brief based on cofig enables\disables obss protection.
4448\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4449\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4450\param tpUpdateBeaconParams pBeaconParams
4451\return None
4452 -------------------------------------------------------------*/
4453tSirRetStatus
4454limEnableHtOBSSProtection(tpAniSirGlobal pMac, tANI_U8 enable,
4455 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4456{
4457
4458
Jeff Johnsone7245742012-09-05 17:12:55 -07004459 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 return eSIR_SUCCESS; // this protection is only for HT stations.
4461
4462 //overlapping protection configuration check.
4463 if(overlap)
4464 {
4465 //overlapping protection configuration check.
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 }
4467 else
4468 {
4469 //normal protection config check
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 if((psessionEntry->limSystemRole == eLIM_AP_ROLE) && !psessionEntry->cfgProtection.obss)
4471 { //ToDo Update this field
4472 // protection disabled.
4473 PELOG1(limLog(pMac, LOG1, FL("protection from Obss is disabled\n"));)
4474 return eSIR_SUCCESS;
4475 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 {
4477 if(!pMac->lim.cfgProtection.obss)
4478 { //ToDo Update this field
4479 // protection disabled.
4480 PELOG1(limLog(pMac, LOG1, FL("protection from Obss is disabled\n"));)
4481 return eSIR_SUCCESS;
4482 }
4483 }
4484 }
4485
4486
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 if (eLIM_AP_ROLE == psessionEntry->limSystemRole){
4488 if ((enable) && (false == psessionEntry->beaconParams.gHTObssMode) )
4489 {
4490 PELOG1(limLog(pMac, LOG1, FL("=>obss protection enabled\n"));)
4491 psessionEntry->beaconParams.gHTObssMode = true;
4492 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED; // UPDATE AN ENUM FOR OBSS MODE <todo>
4493
4494 }
4495 else if (!enable && (true == psessionEntry->beaconParams.gHTObssMode))
4496 {
4497 PELOG1(limLog(pMac, LOG1, FL("===> obss Protection disabled\n"));)
4498 psessionEntry->beaconParams.gHTObssMode = false;
4499 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED;
4500
4501 }
4502//CR-263021: OBSS bit is not switching back to 0 after disabling the overlapping legacy BSS
4503 if (!enable && !overlap)
4504 {
4505 psessionEntry->gLimOverlap11gParams.protectionEnabled = false;
4506 }
4507 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 {
4509 if ((enable) && (false == psessionEntry->beaconParams.gHTObssMode) )
4510 {
4511 PELOG1(limLog(pMac, LOG1, FL("=>obss protection enabled\n"));)
4512 psessionEntry->beaconParams.gHTObssMode = true;
4513 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED; // UPDATE AN ENUM FOR OBSS MODE <todo>
4514
4515 }
4516 else if (!enable && (true == psessionEntry->beaconParams.gHTObssMode))
4517 {
4518
4519 PELOG1(limLog(pMac, LOG1, FL("===> obss Protection disabled\n"));)
4520 psessionEntry->beaconParams.gHTObssMode = false;
4521 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED;
4522
4523 }
4524 }
4525 return eSIR_SUCCESS;
4526}
4527/** -------------------------------------------------------------
4528\fn limEnableHT20Protection
4529\brief based on cofig enables\disables protection from Ht20.
4530\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4531\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4532\param tpUpdateBeaconParams pBeaconParams
4533\return None
4534 -------------------------------------------------------------*/
4535tSirRetStatus
4536limEnableHT20Protection(tpAniSirGlobal pMac, tANI_U8 enable,
4537 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4538{
Jeff Johnsone7245742012-09-05 17:12:55 -07004539 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 return eSIR_SUCCESS; // this protection is only for HT stations.
4541
4542 //overlapping protection configuration check.
4543 if(overlap)
4544 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 }
4546 else
4547 {
4548 //normal protection config check
Jeff Johnson295189b2012-06-20 16:38:30 -07004549 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
4550 !psessionEntry->cfgProtection.ht20)
4551 {
4552 // protection disabled.
4553 PELOG3(limLog(pMac, LOG3, FL("protection from HT20 is disabled\n"));)
4554 return eSIR_SUCCESS;
4555 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 {
4557 if(!pMac->lim.cfgProtection.ht20)
4558 {
4559 // protection disabled.
4560 PELOG3(limLog(pMac, LOG3, FL("protection from HT20 is disabled\n"));)
4561 return eSIR_SUCCESS;
4562 }
4563 }
4564 }
4565
4566 if (enable)
4567 {
4568 //If we are AP and HT capable, we need to set the HT OP mode
4569 //appropriately.
4570
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 if(eLIM_AP_ROLE == psessionEntry->limSystemRole){
4572 if(overlap)
4573 {
4574 psessionEntry->gLimOverlapHt20Params.protectionEnabled = true;
4575 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != psessionEntry->htOperMode) &&
4576 (eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode))
4577 {
4578 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4579 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4580 }
4581 }
4582 else
4583 {
4584 psessionEntry->gLimHt20Params.protectionEnabled = true;
4585 if(eSIR_HT_OP_MODE_PURE == psessionEntry->htOperMode)
4586 {
4587 //Commenting because of CR 258588 WFA cert
4588 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4589 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4590 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4591 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4592 }
4593 }
4594 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 {
4596 if(overlap)
4597 {
4598 pMac->lim.gLimOverlapHt20Params.protectionEnabled = true;
4599 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
4600 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
4601 {
4602 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4603 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4604 }
4605 }
4606 else
4607 {
4608 psessionEntry->gLimHt20Params.protectionEnabled = true;
4609 if(eSIR_HT_OP_MODE_PURE == pMac->lim.gHTOperMode)
4610 {
4611 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4612 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4613 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4614 }
4615 }
4616 }
4617
4618 //This part is common for staiton as well.
4619 if(false == psessionEntry->beaconParams.ht20Coexist)
4620 {
4621 PELOG1(limLog(pMac, LOG1, FL("=> Prtection from HT20 Enabled\n"));)
4622 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = true;
4623 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
4624 }
4625 }
4626 else if (true == psessionEntry->beaconParams.ht20Coexist)
4627 {
4628 //for AP role.
4629 //we need to take care of HT OP mode change if needed.
4630 //We need to take care of Overlap cases.
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 if(eLIM_AP_ROLE == psessionEntry->limSystemRole){
4632 if(overlap)
4633 {
4634 //Overlap Legacy protection disabled.
4635 psessionEntry->gLimOverlapHt20Params.protectionEnabled = false;
4636
4637 // no HT op mode change if any of the overlap protection enabled.
4638 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
4639 psessionEntry->gLimOverlap11gParams.protectionEnabled ||
4640 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4641 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
4642 {
4643
4644 //Check if there is a need to change HT OP mode.
4645 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == psessionEntry->htOperMode)
4646 {
4647 if(psessionEntry->gLimHt20Params.protectionEnabled)
4648 {
4649 //Commented beacuse of CR 258588 for WFA Cert
4650 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4651 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4652 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4653 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4654 }
4655 else
4656 {
4657 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4658 }
4659 }
4660 }
4661 }
4662 else
4663 {
4664 //Disable protection from 11G stations.
4665 psessionEntry->gLimHt20Params.protectionEnabled = false;
4666
4667 //Change HT op mode appropriately.
4668 if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == psessionEntry->htOperMode)
4669 {
4670 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4671 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4672 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4673 }
4674 }
4675 PELOG1(limLog(pMac, LOG1, FL("===> Protection from HT 20 Disabled\n"));)
4676 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = false;
4677 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
4678 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 {
4680 if(overlap)
4681 {
4682 //Overlap Legacy protection disabled.
4683 pMac->lim.gLimOverlapHt20Params.protectionEnabled = false;
4684
4685 // no HT op mode change if any of the overlap protection enabled.
4686 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
4687 pMac->lim.gLimOverlap11gParams.protectionEnabled ||
4688 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4689 pMac->lim.gLimOverlapNonGfParams.protectionEnabled))
4690 {
4691
4692 //Check if there is a need to change HT OP mode.
4693 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
4694 {
4695 if(psessionEntry->gLimHt20Params.protectionEnabled)
4696 {
4697 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4698 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4699 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4700 }
4701 else
4702 {
4703 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4704 }
4705 }
4706 }
4707 }
4708 else
4709 {
4710 //Disable protection from 11G stations.
4711 psessionEntry->gLimHt20Params.protectionEnabled = false;
4712
4713 //Change HT op mode appropriately.
4714 if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == pMac->lim.gHTOperMode)
4715 {
4716 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4717 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4718 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4719 }
4720 }
4721 PELOG1(limLog(pMac, LOG1, FL("===> Protection from HT 20 Disabled\n"));)
4722 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = false;
4723 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
4724 }
4725 //for station role
4726 else
4727 {
4728 PELOG1(limLog(pMac, LOG1, FL("===> Protection from HT20 Disabled\n"));)
4729 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = false;
4730 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
4731 }
4732 }
4733
4734 return eSIR_SUCCESS;
4735}
4736
4737/** -------------------------------------------------------------
4738\fn limEnableHTNonGfProtection
4739\brief based on cofig enables\disables protection from NonGf.
4740\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4741\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4742\param tpUpdateBeaconParams pBeaconParams
4743\return None
4744 -------------------------------------------------------------*/
4745tSirRetStatus
4746limEnableHTNonGfProtection(tpAniSirGlobal pMac, tANI_U8 enable,
4747 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4748{
Jeff Johnsone7245742012-09-05 17:12:55 -07004749 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004750 return eSIR_SUCCESS; // this protection is only for HT stations.
4751
4752 //overlapping protection configuration check.
4753 if(overlap)
4754 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004755 }
4756 else
4757 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 //normal protection config check
4759 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
4760 !psessionEntry->cfgProtection.nonGf)
4761 {
4762 // protection disabled.
4763 PELOG3(limLog(pMac, LOG3, FL("protection from NonGf is disabled\n"));)
4764 return eSIR_SUCCESS;
4765 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 {
4767 //normal protection config check
4768 if(!pMac->lim.cfgProtection.nonGf)
4769 {
4770 // protection disabled.
4771 PELOG3(limLog(pMac, LOG3, FL("protection from NonGf is disabled\n"));)
4772 return eSIR_SUCCESS;
4773 }
4774 }
4775 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004776 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
4777 if ((enable) && (false == psessionEntry->beaconParams.llnNonGFCoexist))
4778 {
4779 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from non GF Enabled\n"));)
4780 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = true;
4781 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
4782 }
4783 else if (!enable && (true == psessionEntry->beaconParams.llnNonGFCoexist))
4784 {
4785 PELOG1(limLog(pMac, LOG1, FL("===> Protection from Non GF Disabled\n"));)
4786 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = false;
4787 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
4788 }
4789 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 {
4791 if ((enable) && (false == psessionEntry->beaconParams.llnNonGFCoexist))
4792 {
4793 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from non GF Enabled\n"));)
4794 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = true;
4795 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
4796 }
4797 else if (!enable && (true == psessionEntry->beaconParams.llnNonGFCoexist))
4798 {
4799 PELOG1(limLog(pMac, LOG1, FL("===> Protection from Non GF Disabled\n"));)
4800 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = false;
4801 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
4802 }
4803 }
4804
4805 return eSIR_SUCCESS;
4806}
4807
4808/** -------------------------------------------------------------
4809\fn limEnableHTLsigTxopProtection
4810\brief based on cofig enables\disables LsigTxop protection.
4811\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4812\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4813\param tpUpdateBeaconParams pBeaconParams
4814\return None
4815 -------------------------------------------------------------*/
4816tSirRetStatus
4817limEnableHTLsigTxopProtection(tpAniSirGlobal pMac, tANI_U8 enable,
4818 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4819{
Jeff Johnsone7245742012-09-05 17:12:55 -07004820 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 return eSIR_SUCCESS; // this protection is only for HT stations.
4822
4823 //overlapping protection configuration check.
4824 if(overlap)
4825 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 }
4827 else
4828 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 //normal protection config check
4830 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
4831 !psessionEntry->cfgProtection.lsigTxop)
4832 {
4833 // protection disabled.
4834 PELOG3(limLog(pMac, LOG3, FL(" protection from LsigTxop not supported is disabled\n"));)
4835 return eSIR_SUCCESS;
4836 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004837 {
4838 //normal protection config check
4839 if(!pMac->lim.cfgProtection.lsigTxop)
4840 {
4841 // protection disabled.
4842 PELOG3(limLog(pMac, LOG3, FL(" protection from LsigTxop not supported is disabled\n"));)
4843 return eSIR_SUCCESS;
4844 }
4845 }
4846 }
4847
4848
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
4850 if ((enable) && (false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
4851 {
4852 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from LsigTxop Enabled\n"));)
4853 pBeaconParams->fLsigTXOPProtectionFullSupport = psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = true;
4854 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
4855 }
4856 else if (!enable && (true == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
4857 {
4858 PELOG1(limLog(pMac, LOG1, FL("===> Protection from LsigTxop Disabled\n"));)
4859 pBeaconParams->fLsigTXOPProtectionFullSupport= psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = false;
4860 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
4861 }
4862 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07004863 {
4864 if ((enable) && (false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
4865 {
4866 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from LsigTxop Enabled\n"));)
4867 pBeaconParams->fLsigTXOPProtectionFullSupport = psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = true;
4868 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
4869 }
4870 else if (!enable && (true == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
4871 {
4872 PELOG1(limLog(pMac, LOG1, FL("===> Protection from LsigTxop Disabled\n"));)
4873 pBeaconParams->fLsigTXOPProtectionFullSupport= psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = false;
4874 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
4875 }
4876 }
4877 return eSIR_SUCCESS;
4878}
4879//FIXME_PROTECTION : need to check for no APSD whenever we want to enable this protection.
4880//This check will be done at the caller.
4881/** -------------------------------------------------------------
4882\fn limEnableHtRifsProtection
4883\brief based on cofig enables\disables Rifs protection.
4884\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4885\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4886\param tpUpdateBeaconParams pBeaconParams
4887\return None
4888 -------------------------------------------------------------*/
4889tSirRetStatus
4890limEnableHtRifsProtection(tpAniSirGlobal pMac, tANI_U8 enable,
4891 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4892{
Jeff Johnsone7245742012-09-05 17:12:55 -07004893 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004894 return eSIR_SUCCESS; // this protection is only for HT stations.
4895
4896
4897 //overlapping protection configuration check.
4898 if(overlap)
4899 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 }
4901 else
4902 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 //normal protection config check
4904 if((psessionEntry->limSystemRole == eLIM_AP_ROLE) &&
4905 !psessionEntry->cfgProtection.rifs)
4906 {
4907 // protection disabled.
4908 PELOG3(limLog(pMac, LOG3, FL(" protection from Rifs is disabled\n"));)
4909 return eSIR_SUCCESS;
4910 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 {
4912 //normal protection config check
4913 if(!pMac->lim.cfgProtection.rifs)
4914 {
4915 // protection disabled.
4916 PELOG3(limLog(pMac, LOG3, FL(" protection from Rifs is disabled\n"));)
4917 return eSIR_SUCCESS;
4918 }
4919 }
4920 }
4921
Jeff Johnson295189b2012-06-20 16:38:30 -07004922 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
4923 // Disabling the RIFS Protection means Enable the RIFS mode of operation in the BSS
4924 if ((!enable) && (false == psessionEntry->beaconParams.fRIFSMode))
4925 {
4926 PELOG1(limLog(pMac, LOG1, FL(" => Rifs protection Disabled\n"));)
4927 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = true;
4928 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
4929 }
4930 // Enabling the RIFS Protection means Disable the RIFS mode of operation in the BSS
4931 else if (enable && (true == psessionEntry->beaconParams.fRIFSMode))
4932 {
4933 PELOG1(limLog(pMac, LOG1, FL("===> Rifs Protection Enabled\n"));)
4934 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = false;
4935 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
4936 }
4937 }else
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 {
4939 // Disabling the RIFS Protection means Enable the RIFS mode of operation in the BSS
4940 if ((!enable) && (false == psessionEntry->beaconParams.fRIFSMode))
4941 {
4942 PELOG1(limLog(pMac, LOG1, FL(" => Rifs protection Disabled\n"));)
4943 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = true;
4944 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
4945 }
4946 // Enabling the RIFS Protection means Disable the RIFS mode of operation in the BSS
4947 else if (enable && (true == psessionEntry->beaconParams.fRIFSMode))
4948 {
4949 PELOG1(limLog(pMac, LOG1, FL("===> Rifs Protection Enabled\n"));)
4950 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = false;
4951 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
4952 }
4953 }
4954 return eSIR_SUCCESS;
4955}
4956
4957// ---------------------------------------------------------------------
4958/**
4959 * limEnableShortPreamble
4960 *
4961 * FUNCTION:
4962 * Enable/Disable short preamble
4963 *
4964 * LOGIC:
4965 *
4966 * ASSUMPTIONS:
4967 *
4968 * NOTE:
4969 *
4970 * @param enable Flag to enable/disable short preamble
4971 * @return None
4972 */
4973
4974tSirRetStatus
4975limEnableShortPreamble(tpAniSirGlobal pMac, tANI_U8 enable, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
4976{
4977 tANI_U32 val;
4978
4979 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val) != eSIR_SUCCESS)
4980 {
4981 /* Could not get short preamble enabled flag from CFG. Log error. */
4982 limLog(pMac, LOGP, FL("could not retrieve short preamble flag\n"));
4983 return eSIR_FAILURE;
4984 }
4985
4986 if (!val)
4987 return eSIR_SUCCESS;
4988
4989 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_PREAMBLE_ENABLED, &val) != eSIR_SUCCESS)
4990 {
4991 limLog(pMac, LOGP, FL("could not retrieve 11G short preamble switching enabled flag\n"));
4992 return eSIR_FAILURE;
4993 }
4994
4995 if (!val) // 11G short preamble switching is disabled.
4996 return eSIR_SUCCESS;
4997
4998 if ( psessionEntry->limSystemRole == eLIM_AP_ROLE )
4999 {
5000 if (enable && (psessionEntry->beaconParams.fShortPreamble == 0))
5001 {
5002 PELOG1(limLog(pMac, LOG1, FL("===> Short Preamble Enabled\n"));)
5003 psessionEntry->beaconParams.fShortPreamble = true;
5004 pBeaconParams->fShortPreamble = (tANI_U8) psessionEntry->beaconParams.fShortPreamble;
5005 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_PREAMBLE_CHANGED;
5006 }
5007 else if (!enable && (psessionEntry->beaconParams.fShortPreamble == 1))
5008 {
5009 PELOG1(limLog(pMac, LOG1, FL("===> Short Preamble Disabled\n"));)
5010 psessionEntry->beaconParams.fShortPreamble = false;
5011 pBeaconParams->fShortPreamble = (tANI_U8) psessionEntry->beaconParams.fShortPreamble;
5012 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_PREAMBLE_CHANGED;
5013 }
5014 }
5015
5016 return eSIR_SUCCESS;
5017 }
5018
5019/**
5020 * limTxComplete
5021 *
5022 * Function:
5023 * This is LIM's very own "TX MGMT frame complete" completion routine.
5024 *
5025 * Logic:
5026 * LIM wants to send a MGMT frame (broadcast or unicast)
5027 * LIM allocates memory using palPktAlloc( ..., **pData, **pPacket )
5028 * LIM transmits the MGMT frame using the API:
5029 * halTxFrame( ... pPacket, ..., (void *) limTxComplete, pData )
5030 * HDD, via halTxFrame/DXE, "transfers" the packet over to BMU
5031 * HDD, if it determines that a TX completion routine (in this case
5032 * limTxComplete) has been provided, will invoke this callback
5033 * LIM will try to free the TX MGMT packet that was earlier allocated, in order
5034 * to send this MGMT frame, using the PAL API palPktFree( ... pData, pPacket )
5035 *
5036 * Assumptions:
5037 * Presently, this is ONLY being used for MGMT frames/packets
5038 * TODO:
5039 * Would it do good for LIM to have some sort of "signature" validation to
5040 * ensure that the pData argument passed in was a buffer that was actually
5041 * allocated by LIM and/or is not corrupted?
5042 *
5043 * Note: FIXME and TODO
5044 * Looks like palPktFree() is interested in pPacket. But, when this completion
5045 * routine is called, only pData is made available to LIM!!
5046 *
5047 * @param void A pointer to pData. Shouldn't it be pPacket?!
5048 *
5049 * @return none
5050 */
5051void limTxComplete( tHalHandle hHal, void *pData )
5052{
5053 tpAniSirGlobal pMac;
5054 pMac = (tpAniSirGlobal)hHal;
5055
5056#ifdef FIXME_PRIMA
5057 /* the trace logic needs to be fixed for Prima. Refer to CR 306075 */
5058#ifdef TRACE_RECORD
5059 {
5060 tpSirMacMgmtHdr mHdr;
5061 v_U8_t *pRxBd;
5062 vos_pkt_t *pVosPkt;
5063 VOS_STATUS vosStatus;
5064
5065
5066
5067 pVosPkt = (vos_pkt_t *)pData;
5068 vosStatus = vos_pkt_peek_data( pVosPkt, 0, (v_PVOID_t *)&pRxBd, WLANHAL_RX_BD_HEADER_SIZE);
5069
5070 if(VOS_IS_STATUS_SUCCESS(vosStatus))
5071 {
5072 mHdr = WDA_GET_RX_MAC_HEADER(pRxBd);
Jeff Johnsone7245742012-09-05 17:12:55 -07005073 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE, NO_SESSION, mHdr->fc.subType);)
Jeff Johnson295189b2012-06-20 16:38:30 -07005074
5075 }
5076 }
5077#endif
5078#endif
5079
5080 palPktFree( pMac->hHdd,
5081 HAL_TXRX_FRM_802_11_MGMT,
5082 (void *) NULL, // this is ignored and will likely be removed from this API
5083 (void *) pData ); // lim passed in pPacket in the pData pointer that is given in this completion routine
5084}
5085
5086/**
5087 * \brief This function updates lim global structure, if CB parameters in the BSS
5088 * have changed, and sends an indication to HAL also with the
5089 * updated HT Parameters.
5090 * This function does not detect the change in the primary channel, that is done as part
5091 * of channel Swtich IE processing.
5092 * If STA is configured with '20Mhz only' mode, then this function does not do anything
5093 * This function changes the CB mode, only if the self capability is set to '20 as well as 40Mhz'
5094 *
5095 *
5096 * \param pMac Pointer to global MAC structure
5097 *
5098 * \param pRcvdHTInfo Pointer to HT Info IE obtained from a Beacon or
5099 * Probe Response
5100 *
5101 * \param bssIdx BSS Index of the Bss to which Station is associated.
5102 *
5103 *
5104 */
5105
5106void limUpdateStaRunTimeHTSwitchChnlParams( tpAniSirGlobal pMac,
5107 tDot11fIEHTInfo *pHTInfo,
5108 tANI_U8 bssIdx,
5109 tpPESession psessionEntry)
5110{
Jeff Johnsone7245742012-09-05 17:12:55 -07005111 ePhyChanBondState secondaryChnlOffset = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07005112#if !defined WLAN_FEATURE_VOWIFI
5113 tANI_U32 localPwrConstraint;
5114#endif
5115
5116 //If self capability is set to '20Mhz only', then do not change the CB mode.
Jeff Johnson295189b2012-06-20 16:38:30 -07005117 if( !limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry ))
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 return;
5119
5120#if !defined WLAN_FEATURE_VOWIFI
5121 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
5122 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg\n" ));
5123 return;
5124 }
5125#endif
5126
Jeff Johnsone7245742012-09-05 17:12:55 -07005127 if ( psessionEntry->htSecondaryChannelOffset != ( tANI_U8 ) pHTInfo->secondaryChannelOffset ||
5128 psessionEntry->htRecommendedTxWidthSet != ( tANI_U8 ) pHTInfo->recommendedTxWidthSet )
Jeff Johnson295189b2012-06-20 16:38:30 -07005129 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005130 psessionEntry->htSecondaryChannelOffset = ( ePhyChanBondState ) pHTInfo->secondaryChannelOffset;
5131 psessionEntry->htRecommendedTxWidthSet = ( tANI_U8 ) pHTInfo->recommendedTxWidthSet;
5132 if ( eHT_CHANNEL_WIDTH_40MHZ == psessionEntry->htRecommendedTxWidthSet )
5133 secondaryChnlOffset = (ePhyChanBondState)pHTInfo->secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07005134
5135 // Notify HAL
5136 limLog( pMac, LOGW, FL( "Channel Information in HT IE change"
5137 "d; sending notification to HAL.\n" ) );
5138 limLog( pMac, LOGW, FL( "Primary Channel: %d, Secondary Chan"
5139 "nel Offset: %d, Channel Width: %d\n" ),
5140 pHTInfo->primaryChannel, secondaryChnlOffset,
Jeff Johnsone7245742012-09-05 17:12:55 -07005141 psessionEntry->htRecommendedTxWidthSet );
Madan Mohan Koyyalamudifd322a02012-10-05 12:01:26 -07005142 psessionEntry->channelChangeReasonCode=LIM_SWITCH_CHANNEL_OPERATION;
5143 pMac->lim.gpchangeChannelCallback = NULL;
5144 pMac->lim.gpchangeChannelData = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005145
5146#if defined WLAN_FEATURE_VOWIFI
5147 limSendSwitchChnlParams( pMac, ( tANI_U8 ) pHTInfo->primaryChannel,
5148 secondaryChnlOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
5149#else
5150 limSendSwitchChnlParams( pMac, ( tANI_U8 ) pHTInfo->primaryChannel,
5151 secondaryChnlOffset, (tPowerdBm)localPwrConstraint, psessionEntry->peSessionId);
5152#endif
5153
5154 //In case of IBSS, if STA should update HT Info IE in its beacons.
5155 if (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole)
5156 {
5157 schSetFixedBeaconFields(pMac,psessionEntry);
5158 }
5159
5160 }
5161} // End limUpdateStaRunTimeHTParams.
5162
5163/**
5164 * \brief This function updates the lim global structure, if any of the
5165 * HT Capabilities have changed.
5166 *
5167 *
5168 * \param pMac Pointer to Global MAC structure
5169 *
5170 * \param pHTCapability Pointer to HT Capability Information Element
5171 * obtained from a Beacon or Probe Response
5172 *
5173 *
5174 *
5175 */
5176
5177void limUpdateStaRunTimeHTCapability( tpAniSirGlobal pMac,
5178 tDot11fIEHTCaps *pHTCaps )
5179{
5180
5181 if ( pMac->lim.gHTLsigTXOPProtection != ( tANI_U8 ) pHTCaps->lsigTXOPProtection )
5182 {
5183 pMac->lim.gHTLsigTXOPProtection = ( tANI_U8 ) pHTCaps->lsigTXOPProtection;
5184 // Send change notification to HAL
5185 }
5186
5187 if ( pMac->lim.gHTAMpduDensity != ( tANI_U8 ) pHTCaps->mpduDensity )
5188 {
5189 pMac->lim.gHTAMpduDensity = ( tANI_U8 ) pHTCaps->mpduDensity;
5190 // Send change notification to HAL
5191 }
5192
5193 if ( pMac->lim.gHTMaxRxAMpduFactor != ( tANI_U8 ) pHTCaps->maxRxAMPDUFactor )
5194 {
5195 pMac->lim.gHTMaxRxAMpduFactor = ( tANI_U8 ) pHTCaps->maxRxAMPDUFactor;
5196 // Send change notification to HAL
5197 }
5198
5199
5200} // End limUpdateStaRunTimeHTCapability.
5201
5202/**
5203 * \brief This function updates lim global structure, if any of the HT
5204 * Info Parameters have changed.
5205 *
5206 *
5207 * \param pMac Pointer to the global MAC structure
5208 *
5209 * \param pHTInfo Pointer to the HT Info IE obtained from a Beacon or
5210 * Probe Response
5211 *
5212 *
5213 */
5214
5215void limUpdateStaRunTimeHTInfo( tpAniSirGlobal pMac,
5216 tDot11fIEHTInfo *pHTInfo , tpPESession psessionEntry)
5217{
Jeff Johnsone7245742012-09-05 17:12:55 -07005218 if ( psessionEntry->htRecommendedTxWidthSet != ( tANI_U8 )pHTInfo->recommendedTxWidthSet )
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005220 psessionEntry->htRecommendedTxWidthSet = ( tANI_U8 )pHTInfo->recommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -07005221 // Send change notification to HAL
5222 }
5223
5224 if ( psessionEntry->beaconParams.fRIFSMode != ( tANI_U8 )pHTInfo->rifsMode )
5225 {
5226 psessionEntry->beaconParams.fRIFSMode = ( tANI_U8 )pHTInfo->rifsMode;
5227 // Send change notification to HAL
5228 }
5229
5230 if ( pMac->lim.gHTServiceIntervalGranularity != ( tANI_U8 )pHTInfo->serviceIntervalGranularity )
5231 {
5232 pMac->lim.gHTServiceIntervalGranularity = ( tANI_U8 )pHTInfo->serviceIntervalGranularity;
5233 // Send change notification to HAL
5234 }
5235
5236 if ( pMac->lim.gHTOperMode != ( tSirMacHTOperatingMode )pHTInfo->opMode )
5237 {
5238 pMac->lim.gHTOperMode = ( tSirMacHTOperatingMode )pHTInfo->opMode;
5239 // Send change notification to HAL
5240 }
5241
5242 if ( psessionEntry->beaconParams.llnNonGFCoexist != pHTInfo->nonGFDevicesPresent )
5243 {
5244 psessionEntry->beaconParams.llnNonGFCoexist = ( tANI_U8 )pHTInfo->nonGFDevicesPresent;
5245 }
5246
5247 if ( pMac->lim.gHTSTBCBasicMCS != ( tANI_U8 )pHTInfo->basicSTBCMCS )
5248 {
5249 pMac->lim.gHTSTBCBasicMCS = ( tANI_U8 )pHTInfo->basicSTBCMCS;
5250 // Send change notification to HAL
5251 }
5252
5253 if ( pMac->lim.gHTDualCTSProtection != ( tANI_U8 )pHTInfo->dualCTSProtection )
5254 {
5255 pMac->lim.gHTDualCTSProtection = ( tANI_U8 )pHTInfo->dualCTSProtection;
5256 // Send change notification to HAL
5257 }
5258
5259 if ( pMac->lim.gHTSecondaryBeacon != ( tANI_U8 )pHTInfo->secondaryBeacon )
5260 {
5261 pMac->lim.gHTSecondaryBeacon = ( tANI_U8 )pHTInfo->secondaryBeacon;
5262 // Send change notification to HAL
5263 }
5264
5265 if ( psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport != ( tANI_U8 )pHTInfo->lsigTXOPProtectionFullSupport )
5266 {
5267 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = ( tANI_U8 )pHTInfo->lsigTXOPProtectionFullSupport;
5268 // Send change notification to HAL
5269 }
5270
5271 if ( pMac->lim.gHTPCOActive != ( tANI_U8 )pHTInfo->pcoActive )
5272 {
5273 pMac->lim.gHTPCOActive = ( tANI_U8 )pHTInfo->pcoActive;
5274 // Send change notification to HAL
5275 }
5276
5277 if ( pMac->lim.gHTPCOPhase != ( tANI_U8 )pHTInfo->pcoPhase )
5278 {
5279 pMac->lim.gHTPCOPhase = ( tANI_U8 )pHTInfo->pcoPhase;
5280 // Send change notification to HAL
5281 }
5282
5283} // End limUpdateStaRunTimeHTInfo.
5284
5285
5286/** -------------------------------------------------------------
5287\fn limProcessHalIndMessages
5288\brief callback function for HAL indication
5289\param tpAniSirGlobal pMac
5290\param tANI_U32 mesgId
5291\param void *mesgParam
5292\return tSirRetStatu - status
5293 -------------------------------------------------------------*/
5294
5295tSirRetStatus limProcessHalIndMessages(tpAniSirGlobal pMac, tANI_U32 msgId, void *msgParam )
5296{
5297 //its PE's responsibility to free msgparam when its done extracting the message parameters.
5298 tSirMsgQ msg;
5299
5300 switch(msgId)
5301 {
5302 case SIR_LIM_DEL_TS_IND:
5303 case SIR_LIM_ADD_BA_IND:
5304 case SIR_LIM_DEL_BA_ALL_IND:
5305 case SIR_LIM_DELETE_STA_CONTEXT_IND:
5306 case SIR_LIM_BEACON_GEN_IND:
5307 msg.type = (tANI_U16) msgId;
5308 msg.bodyptr = msgParam;
5309 msg.bodyval = 0;
5310 break;
5311
5312 default:
5313 palFreeMemory(pMac->hHdd, msgParam);
5314 limLog(pMac, LOGP, FL("invalid message id = %d received\n"), msgId);
5315 return eSIR_FAILURE;
5316 }
5317
5318 if (limPostMsgApi(pMac, &msg) != eSIR_SUCCESS)
5319 {
5320 palFreeMemory(pMac->hHdd, msgParam);
5321 limLog(pMac, LOGP, FL("limPostMsgApi failed for msgid = %d"), msg.type);
5322 return eSIR_FAILURE;
5323 }
5324 return eSIR_SUCCESS;
5325}
5326
5327/** -------------------------------------------------------------
5328\fn limValidateDeltsReq
5329\brief Validates DelTs req originated by SME or by HAL and also sends halMsg_DelTs to HAL
5330\param tpAniSirGlobal pMac
5331\param tpSirDeltsReq pDeltsReq
5332\param tSirMacAddr peerMacAddr
5333\return eSirRetStatus - status
5334 -------------------------------------------------------------*/
5335
5336tSirRetStatus
5337limValidateDeltsReq(tpAniSirGlobal pMac, tpSirDeltsReq pDeltsReq, tSirMacAddr peerMacAddr,tpPESession psessionEntry)
5338{
5339 tpDphHashNode pSta;
5340 tANI_U8 tsStatus;
5341 tSirMacTSInfo *tsinfo;
5342 tANI_U32 i;
5343 tANI_U8 tspecIdx;
5344 /* if sta
5345 * - verify assoc state
5346 * - del tspec locally
5347 * if ap,
5348 * - verify sta is in assoc state
5349 * - del sta tspec locally
5350 */
5351 if(pDeltsReq == NULL)
5352 {
5353 PELOGE(limLog(pMac, LOGE, FL("Delete TS request pointer is NULL\n"));)
5354 return eSIR_FAILURE;
5355 }
5356
5357 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
5358 {
5359 tANI_U32 val;
5360
5361 // station always talks to the AP
5362 pSta = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
5363
5364 val = sizeof(tSirMacAddr);
5365 #if 0
5366 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMacAddr, &val) != eSIR_SUCCESS)
5367 {
5368 /// Could not get BSSID from CFG. Log error.
5369 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
5370 return eSIR_FAILURE;
5371 }
5372 #endif// TO SUPPORT BT-AMP
5373 sirCopyMacAddr(peerMacAddr,psessionEntry->bssId);
5374
5375 }
5376 else
5377 {
5378 tANI_U16 assocId;
5379 tANI_U8 *macaddr = (tANI_U8 *) peerMacAddr;
5380
5381 assocId = pDeltsReq->aid;
5382 if (assocId != 0)
5383 pSta = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
5384 else
5385 pSta = dphLookupHashEntry(pMac, pDeltsReq->macAddr, &assocId, &psessionEntry->dph.dphHashTable);
5386
5387 if (pSta != NULL)
5388 // TBD: check sta assoc state as well
5389 for (i =0; i < sizeof(tSirMacAddr); i++)
5390 macaddr[i] = pSta->staAddr[i];
5391 }
5392
5393 if (pSta == NULL)
5394 {
5395 PELOGE(limLog(pMac, LOGE, "Cannot find station context for delts req\n");)
5396 return eSIR_FAILURE;
5397 }
5398
5399 if ((! pSta->valid) ||
5400 (pSta->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE))
5401 {
5402 PELOGE(limLog(pMac, LOGE, "Invalid Sta (or state) for DelTsReq\n");)
5403 return eSIR_FAILURE;
5404 }
5405
5406 pDeltsReq->req.wsmTspecPresent = 0;
5407 pDeltsReq->req.wmeTspecPresent = 0;
5408 pDeltsReq->req.lleTspecPresent = 0;
5409
5410 if ((pSta->wsmEnabled) &&
5411 (pDeltsReq->req.tspec.tsinfo.traffic.accessPolicy != SIR_MAC_ACCESSPOLICY_EDCA))
5412 pDeltsReq->req.wsmTspecPresent = 1;
5413 else if (pSta->wmeEnabled)
5414 pDeltsReq->req.wmeTspecPresent = 1;
5415 else if (pSta->lleEnabled)
5416 pDeltsReq->req.lleTspecPresent = 1;
5417 else
5418 {
5419 PELOGW(limLog(pMac, LOGW, FL("DELTS_REQ ignore - qos is disabled\n"));)
5420 return eSIR_FAILURE;
5421 }
5422
5423 tsinfo = pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.tsinfo
5424 : &pDeltsReq->req.tsinfo;
5425 PELOG1(limLog(pMac, LOG1,
5426 FL("received DELTS_REQ message (wmeTspecPresent = %d, lleTspecPresent = %d, wsmTspecPresent = %d, tsid %d, up %d, direction = %d)\n"),
5427 pDeltsReq->req.wmeTspecPresent, pDeltsReq->req.lleTspecPresent, pDeltsReq->req.wsmTspecPresent,
5428 tsinfo->traffic.tsid, tsinfo->traffic.userPrio, tsinfo->traffic.direction);)
5429
5430 // if no Access Control, ignore the request
Jeff Johnson295189b2012-06-20 16:38:30 -07005431
5432 if (limAdmitControlDeleteTS(pMac, pSta->assocId, tsinfo, &tsStatus, &tspecIdx)
5433 != eSIR_SUCCESS)
5434 {
5435 PELOGE(limLog(pMac, LOGE, "ERROR DELTS request for sta assocId %d (tsid %d, up %d)\n",
5436 pSta->assocId, tsinfo->traffic.tsid, tsinfo->traffic.userPrio);)
5437 return eSIR_FAILURE;
5438 }
5439 else if ((tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
5440 (tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH))
5441 {
5442 //edca only now.
5443 }
5444 else
5445 {
5446 if((tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_EDCA) &&
5447 psessionEntry->gLimEdcaParams[upToAc(tsinfo->traffic.userPrio)].aci.acm)
5448 {
5449 //send message to HAL to delete TS
Jeff Johnsone7245742012-09-05 17:12:55 -07005450 if(eSIR_SUCCESS != limSendHalMsgDelTs(pMac, pSta->staIndex, tspecIdx, pDeltsReq->req, psessionEntry->peSessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 {
5452 limLog(pMac, LOGW, FL("DelTs with UP %d failed in limSendHalMsgDelTs - ignoring request\n"),
5453 tsinfo->traffic.userPrio);
5454 return eSIR_FAILURE;
5455 }
5456 }
5457 }
5458 return eSIR_SUCCESS;
5459}
5460
5461/** -------------------------------------------------------------
5462\fn limRegisterHalIndCallBack
5463\brief registers callback function to HAL for any indication.
5464\param tpAniSirGlobal pMac
5465\return none.
5466 -------------------------------------------------------------*/
5467void
5468limRegisterHalIndCallBack(tpAniSirGlobal pMac)
5469{
5470 tSirMsgQ msg;
5471 tpHalIndCB pHalCB;
5472
5473 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pHalCB, sizeof(tHalIndCB)))
5474 {
5475 limLog(pMac, LOGP, FL("palAllocateMemory() failed\n"));
5476 return;
5477 }
5478
5479 pHalCB->pHalIndCB = limProcessHalIndMessages;
5480
5481 msg.type = WDA_REGISTER_PE_CALLBACK;
5482 msg.bodyptr = pHalCB;
5483 msg.bodyval = 0;
5484
Jeff Johnsone7245742012-09-05 17:12:55 -07005485 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07005486 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5487 {
5488 palFreeMemory(pMac->hHdd, pHalCB);
5489 limLog(pMac, LOGP, FL("wdaPostCtrlMsg() failed\n"));
5490 }
5491
5492 return;
5493}
5494
5495
5496/** -------------------------------------------------------------
5497\fn limProcessAddBaInd
5498
5499\brief handles the BA activity check timeout indication coming from HAL.
5500 Validates the request, posts request for sending addBaReq message for every candidate in the list.
5501\param tpAniSirGlobal pMac
5502\param tSirMsgQ limMsg
5503\return None
5504-------------------------------------------------------------*/
5505void
5506limProcessAddBaInd(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
5507{
5508 tANI_U8 i;
5509 tANI_U8 tid;
5510 tANI_U16 assocId;
5511 tpDphHashNode pSta;
5512 tpAddBaCandidate pBaCandidate;
5513 tANI_U32 baCandidateCnt;
5514 tpBaActivityInd pBaActivityInd;
5515 tpPESession psessionEntry;
5516 tANI_U8 sessionId;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005517#ifdef FEATURE_WLAN_TDLS
5518 boolean htCapable = FALSE;
5519#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005520
5521
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005522 if (limMsg->bodyptr == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 return;
5524
5525 pBaActivityInd = (tpBaActivityInd)limMsg->bodyptr;
5526 baCandidateCnt = pBaActivityInd->baCandidateCnt;
5527
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005528 if ((psessionEntry = peFindSessionByBssid(pMac,pBaActivityInd->bssId,&sessionId))== NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07005529 {
5530 limLog(pMac, LOGE,FL("session does not exist for given BSSId\n"));
5531 palFreeMemory(pMac->hHdd, limMsg->bodyptr);
5532 return;
5533 }
5534
5535 //if we are not HT capable we don't need to handle BA timeout indication from HAL.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005536#ifdef FEATURE_WLAN_TDLS
5537 if ((baCandidateCnt > pMac->lim.maxStation))
5538#else
5539 if ((baCandidateCnt > pMac->lim.maxStation) || !psessionEntry->htCapability )
5540#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005541 {
5542 palFreeMemory(pMac->hHdd, limMsg->bodyptr);
5543 return;
5544 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005545
5546#ifdef FEATURE_WLAN_TDLS
5547 //if we have TDLS peers, we should look at peers HT capability, which can be different than
5548 //AP capability
5549 pBaCandidate = (tpAddBaCandidate) (((tANI_U8*)pBaActivityInd) + sizeof(tBaActivityInd));
5550
5551 for (i=0; i<baCandidateCnt; i++, pBaCandidate++)
5552 {
5553 pSta = dphLookupHashEntry(pMac, pBaCandidate->staAddr, &assocId, &psessionEntry->dph.dphHashTable);
5554 if ((NULL == pSta) || (!pSta->valid))
5555 continue;
5556
5557 if (STA_ENTRY_TDLS_PEER == pSta->staType)
5558 htCapable = pSta->mlmStaContext.htCapability;
5559 else
5560 htCapable = psessionEntry->htCapability;
5561
5562 if (htCapable)
5563 break;
5564 }
5565 if (!htCapable)
5566 {
5567 palFreeMemory(pMac->hHdd, limMsg->bodyptr);
5568 return;
5569 }
5570#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005571
5572 //delete the complete dialoguetoken linked list
5573 limDeleteDialogueTokenList(pMac);
5574 pBaCandidate = (tpAddBaCandidate) (((tANI_U8*)pBaActivityInd) + sizeof(tBaActivityInd));
5575
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005576 for (i=0; i<baCandidateCnt; i++, pBaCandidate++)
Jeff Johnson295189b2012-06-20 16:38:30 -07005577 {
5578 pSta = dphLookupHashEntry(pMac, pBaCandidate->staAddr, &assocId, &psessionEntry->dph.dphHashTable);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005579 if ((NULL == pSta) || (!pSta->valid))
5580 continue;
Jeff Johnson295189b2012-06-20 16:38:30 -07005581
5582 for (tid=0; tid<STACFG_MAX_TC; tid++)
5583 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005584 if((eBA_DISABLE == pSta->tcCfg[tid].fUseBATx) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07005585 (pBaCandidate->baInfo[tid].fBaEnable))
5586 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08005587 PELOG2(limLog(pMac, LOG2, FL("BA setup for staId = %d, TID: %d, SSN: %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 pSta->staIndex, tid, pBaCandidate->baInfo[tid].startingSeqNum);)
5589 limPostMlmAddBAReq(pMac, pSta, tid, pBaCandidate->baInfo[tid].startingSeqNum,psessionEntry);
5590 }
5591 }
5592 }
5593 palFreeMemory(pMac->hHdd, limMsg->bodyptr);
5594 return;
5595}
5596
5597
5598/** -------------------------------------------------------------
5599\fn limDelAllBASessions
5600\brief Deletes all the exisitng BA sessions.
5601\ Note : This API is provided for Mac OSx only. The reason for this is that Mac OSx may not
5602\ restart after CFG update.
5603\param tpAniSirGlobal pMac
5604\return None
5605-------------------------------------------------------------*/
5606
5607void
5608limDelAllBASessions(tpAniSirGlobal pMac)
5609{
5610 tANI_U32 i;
5611 tANI_U8 tid;
5612 tpDphHashNode pSta;
5613
5614 tpPESession psessionEntry = &pMac->lim.gpSession[0]; //TBD-RAJESH HOW TO GET sessionEntry?????
5615 for(tid = 0; tid < STACFG_MAX_TC; tid++)
5616 {
5617 if((eLIM_AP_ROLE == psessionEntry->limSystemRole) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)||
5618 (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole))
5619 {
5620 for(i = 0; i < pMac->lim.maxStation; i++)
5621 {
5622 pSta = psessionEntry->dph.dphHashTable.pDphNodeArray + i;
5623 if (pSta && pSta->added)
5624 {
5625 if(eBA_ENABLE == pSta->tcCfg[tid].fUseBATx)
5626 {
5627 limPostMlmDelBAReq(pMac, pSta, eBA_INITIATOR, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
5628 }
5629 else if(eBA_ENABLE == pSta->tcCfg[tid].fUseBARx)
5630 {
5631 limPostMlmDelBAReq(pMac, pSta, eBA_RECIPIENT, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
5632 }
5633 }
5634 }
5635 }
5636 else if((eLIM_STA_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_STA_ROLE == psessionEntry->limSystemRole))
5637 {
5638 pSta = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
5639 if (pSta && pSta->added)
5640 {
5641 if(eBA_ENABLE == pSta->tcCfg[tid].fUseBATx)
5642 {
5643 limPostMlmDelBAReq(pMac, pSta, eBA_INITIATOR, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
5644 }
5645 if(eBA_ENABLE == pSta->tcCfg[tid].fUseBARx)
5646 {
5647 limPostMlmDelBAReq(pMac, pSta, eBA_RECIPIENT, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
5648 }
5649 }
5650 }
5651 }
5652}
5653/** -------------------------------------------------------------
5654\fn limProcessDelTsInd
5655\brief handles the DeleteTS indication coming from HAL or generated by PE itself in some error cases.
5656 Validates the request, sends the DelTs action frame to the Peer and sends DelTs indicatoin to HDD.
5657\param tpAniSirGlobal pMac
5658\param tSirMsgQ limMsg
5659\return None
5660-------------------------------------------------------------*/
5661void
5662limProcessDelTsInd(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
5663{
5664 tpDphHashNode pSta;
5665 tpDelTsParams pDelTsParam = (tpDelTsParams) (limMsg->bodyptr);
5666 tpSirDeltsReq pDelTsReq = NULL;
5667 tSirMacAddr peerMacAddr;
5668 tpSirDeltsReqInfo pDelTsReqInfo;
5669 tpLimTspecInfo pTspecInfo;
5670 tpPESession psessionEntry;
5671 tANI_U8 sessionId;
5672
5673if((psessionEntry = peFindSessionByBssid(pMac,pDelTsParam->bssId,&sessionId))== NULL)
5674 {
5675 limLog(pMac, LOGE,FL("session does not exist for given BssId\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07005676 palFreeMemory(pMac->hHdd, (void *)(limMsg->bodyptr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 return;
5678 }
5679
5680 pTspecInfo = &(pMac->lim.tspecInfo[pDelTsParam->tspecIdx]);
5681 if(pTspecInfo->inuse == false)
5682 {
5683 PELOGE(limLog(pMac, LOGE, FL("tspec entry with index %d is not in use\n"), pDelTsParam->tspecIdx);)
5684 goto error1;
5685 }
5686
5687 pSta = dphGetHashEntry(pMac, pTspecInfo->assocId, &psessionEntry->dph.dphHashTable);
5688 if(pSta == NULL)
5689 {
5690 limLog(pMac, LOGE, FL("Could not find entry in DPH table for assocId = %d\n"),
5691 pTspecInfo->assocId);
5692 goto error1;
5693 }
5694
5695 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pDelTsReq, sizeof(tSirDeltsReq)))
5696 {
5697 PELOGE(limLog(pMac, LOGE, FL("palAllocateMemory() failed\n"));)
5698 goto error1;
5699 }
5700
5701 palZeroMemory( pMac->hHdd, (tANI_U8 *)pDelTsReq, sizeof(tSirDeltsReq));
5702
5703 if(pSta->wmeEnabled)
5704 palCopyMemory(pMac->hHdd, &(pDelTsReq->req.tspec), &(pTspecInfo->tspec), sizeof(tSirMacTspecIE));
5705 else
5706 palCopyMemory(pMac->hHdd, &(pDelTsReq->req.tsinfo), &(pTspecInfo->tspec.tsinfo), sizeof(tSirMacTSInfo));
5707
5708
5709 //validate the req
5710 if (eSIR_SUCCESS != limValidateDeltsReq(pMac, pDelTsReq, peerMacAddr,psessionEntry))
5711 {
5712 PELOGE(limLog(pMac, LOGE, FL("limValidateDeltsReq failed\n"));)
5713 goto error2;
5714 }
5715 PELOG1(limLog(pMac, LOG1, "Sent DELTS request to station with assocId = %d MacAddr = %x:%x:%x:%x:%x:%x\n",
5716 pDelTsReq->aid, peerMacAddr[0], peerMacAddr[1], peerMacAddr[2],
5717 peerMacAddr[3], peerMacAddr[4], peerMacAddr[5]);)
5718
5719 limSendDeltsReqActionFrame(pMac, peerMacAddr, pDelTsReq->req.wmeTspecPresent, &pDelTsReq->req.tsinfo, &pDelTsReq->req.tspec,
5720 psessionEntry);
5721
5722 // prepare and send an sme indication to HDD
5723 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pDelTsReqInfo, sizeof(tSirDeltsReqInfo)))
5724 {
5725 PELOGE(limLog(pMac, LOGE, FL("palAllocateMemory() failed\n"));)
5726 goto error3;
5727 }
5728 palZeroMemory( pMac->hHdd, (tANI_U8 *)pDelTsReqInfo, sizeof(tSirDeltsReqInfo));
5729
5730 if(pSta->wmeEnabled)
5731 palCopyMemory(pMac->hHdd, &(pDelTsReqInfo->tspec), &(pTspecInfo->tspec), sizeof(tSirMacTspecIE));
5732 else
5733 palCopyMemory(pMac->hHdd, &(pDelTsReqInfo->tsinfo), &(pTspecInfo->tspec.tsinfo), sizeof(tSirMacTSInfo));
5734
5735 limSendSmeDeltsInd(pMac, pDelTsReqInfo, pDelTsReq->aid,psessionEntry);
5736
5737error3:
5738 palFreeMemory(pMac->hHdd, (void *) pDelTsReqInfo);
5739error2:
5740 palFreeMemory(pMac->hHdd, (void *) pDelTsReq);
5741error1:
5742 palFreeMemory(pMac->hHdd, (void *)(limMsg->bodyptr));
5743 return;
5744}
5745
5746/**
5747 * \brief Setup an A-MPDU/BA session
5748 *
5749 * \sa limPostMlmAddBAReq
5750 *
5751 * \param pMac The global tpAniSirGlobal object
5752 *
5753 * \param pStaDs DPH Hash Node object of peer STA
5754 *
5755 * \param tid TID for which a BA is being setup.
5756 * If this is set to 0xFFFF, then we retrieve
5757 * the default TID from the CFG
5758 *
5759 * \return eSIR_SUCCESS if setup completes successfully
5760 * eSIR_FAILURE is some problem is encountered
5761 */
5762tSirRetStatus limPostMlmAddBAReq( tpAniSirGlobal pMac,
5763 tpDphHashNode pStaDs,
5764 tANI_U8 tid, tANI_U16 startingSeqNum,tpPESession psessionEntry)
5765{
5766 tSirRetStatus status = eSIR_SUCCESS;
Jeff Johnson09fb4cd2013-04-03 15:27:59 -07005767 tpLimMlmAddBAReq pMlmAddBAReq = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005768 tpDialogueToken dialogueTokenNode;
5769 tANI_U32 val = 0;
Jeff Johnson09fb4cd2013-04-03 15:27:59 -07005770
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 // Check if the peer is a 11n capable STA
5772 // FIXME - Need a 11n peer indication in DPH.
5773 // For now, using the taurusPeer attribute
5774 //if( 0 == pStaDs->taurusPeer == )
5775 //return eSIR_SUCCESS;
5776
5777 // Allocate for LIM_MLM_ADDBA_REQ
5778 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
5779 (void **) &pMlmAddBAReq,
5780 sizeof( tLimMlmAddBAReq )))
5781 {
5782 limLog( pMac, LOGP, FL("palAllocateMemory failed\n"));
5783 status = eSIR_MEM_ALLOC_FAILED;
5784 goto returnFailure;
5785 }
5786
5787 palZeroMemory( pMac->hHdd, (void *) pMlmAddBAReq, sizeof( tLimMlmAddBAReq ));
5788
5789 // Copy the peer MAC
5790 palCopyMemory( pMac->hHdd,
5791 pMlmAddBAReq->peerMacAddr,
5792 pStaDs->staAddr,
5793 sizeof( tSirMacAddr ));
5794
5795 // Update the TID
5796 pMlmAddBAReq->baTID = tid;
5797
5798 // Determine the supported BA policy of local STA
5799 // for the TID of interest
5800 pMlmAddBAReq->baPolicy = (pStaDs->baPolicyFlag >> tid) & 0x1;
5801
5802 // BA Buffer Size
5803 // Requesting the ADDBA recipient to populate the size.
5804 // If ADDBA is accepted, a non-zero buffer size should
5805 // be returned in the ADDBA Rsp
5806 pMlmAddBAReq->baBufferSize = 0;
5807
5808 limLog( pMac, LOGW,
5809 FL( "Requesting an ADDBA to setup a %s BA session with STA %d for TID %d\n" ),
5810 (pMlmAddBAReq->baPolicy ? "Immediate": "Delayed"),
5811 pStaDs->staIndex,
5812 tid );
5813
5814 // BA Timeout
Jeff Johnson09fb4cd2013-04-03 15:27:59 -07005815 if (wlan_cfgGetInt(pMac, WNI_CFG_BA_TIMEOUT, &val) != eSIR_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 {
5817 limLog(pMac, LOGE, FL("could not retrieve BA TIME OUT Param CFG\n"));
5818 status = eSIR_FAILURE;
5819 goto returnFailure;
5820 }
5821 pMlmAddBAReq->baTimeout = val; // In TU's
5822
5823 // ADDBA Failure Timeout
Jeff Johnson09fb4cd2013-04-03 15:27:59 -07005824 // FIXME_AMPDU - Need to retrieve this from CFG.
Jeff Johnson295189b2012-06-20 16:38:30 -07005825 //right now we are not checking for response timeout. so this field is dummy just to be compliant with the spec.
5826 pMlmAddBAReq->addBAFailureTimeout = 2000; // In TU's
5827
5828 // BA Starting Sequence Number
5829 pMlmAddBAReq->baSSN = startingSeqNum;
5830
5831 /* Update PE session Id*/
5832 pMlmAddBAReq->sessionId = psessionEntry->peSessionId;
5833
5834 LIM_SET_STA_BA_STATE(pStaDs, tid, eLIM_BA_STATE_WT_ADD_RSP);
5835
Jeff Johnson09fb4cd2013-04-03 15:27:59 -07005836 dialogueTokenNode = limAssignDialogueToken(pMac);
5837 if (NULL == dialogueTokenNode)
5838 {
5839 limLog(pMac, LOGE, FL("could not assign dialogue token"));
5840 status = eSIR_FAILURE;
5841 goto returnFailure;
5842 }
5843
Jeff Johnson295189b2012-06-20 16:38:30 -07005844 pMlmAddBAReq->baDialogToken = dialogueTokenNode->token;
Jeff Johnson09fb4cd2013-04-03 15:27:59 -07005845 //set assocId and tid information in the lim linked list
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 dialogueTokenNode->assocId = pStaDs->assocId;
5847 dialogueTokenNode->tid = tid;
5848 // Send ADDBA Req to MLME
5849 limPostMlmMessage( pMac,
5850 LIM_MLM_ADDBA_REQ,
5851 (tANI_U32 *) pMlmAddBAReq );
Jeff Johnson09fb4cd2013-04-03 15:27:59 -07005852 return eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005853
5854returnFailure:
Jeff Johnson09fb4cd2013-04-03 15:27:59 -07005855 palFreeMemory(pMac->hHdd, pMlmAddBAReq);
Jeff Johnson295189b2012-06-20 16:38:30 -07005856 return status;
5857}
5858
5859/**
5860 * \brief Post LIM_MLM_ADDBA_RSP to MLME. MLME
5861 * will then send an ADDBA Rsp to peer MAC entity
5862 * with the appropriate ADDBA status code
5863 *
5864 * \sa limPostMlmAddBARsp
5865 *
5866 * \param pMac The global tpAniSirGlobal object
5867 *
5868 * \param peerMacAddr MAC address of peer entity that will
5869 * be the recipient of this ADDBA Rsp
5870 *
5871 * \param baStatusCode ADDBA Rsp status code
5872 *
5873 * \param baDialogToken ADDBA Rsp dialog token
5874 *
5875 * \param baTID TID of interest
5876 *
5877 * \param baPolicy The BA policy
5878 *
5879 * \param baBufferSize The BA buffer size
5880 *
5881 * \param baTimeout BA timeout in TU's
5882 *
5883 * \return eSIR_SUCCESS if setup completes successfully
5884 * eSIR_FAILURE is some problem is encountered
5885 */
5886tSirRetStatus limPostMlmAddBARsp( tpAniSirGlobal pMac,
5887 tSirMacAddr peerMacAddr,
5888 tSirMacStatusCodes baStatusCode,
5889 tANI_U8 baDialogToken,
5890 tANI_U8 baTID,
5891 tANI_U8 baPolicy,
5892 tANI_U16 baBufferSize,
5893 tANI_U16 baTimeout,
5894 tpPESession psessionEntry)
5895{
5896tSirRetStatus status = eSIR_SUCCESS;
5897tpLimMlmAddBARsp pMlmAddBARsp;
5898
5899 // Allocate for LIM_MLM_ADDBA_RSP
5900 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
5901 (void **) &pMlmAddBARsp,
5902 sizeof( tLimMlmAddBARsp )))
5903 {
5904 limLog( pMac, LOGE,
5905 FL("palAllocateMemory failed with error code %d\n"),
5906 status );
5907
5908 status = eSIR_MEM_ALLOC_FAILED;
5909 goto returnFailure;
5910 }
5911
5912 palZeroMemory( pMac->hHdd, (void *) pMlmAddBARsp, sizeof( tLimMlmAddBARsp ));
5913
5914 // Copy the peer MAC
5915 palCopyMemory( pMac->hHdd,
5916 pMlmAddBARsp->peerMacAddr,
5917 peerMacAddr,
5918 sizeof( tSirMacAddr ));
5919
5920 pMlmAddBARsp->baDialogToken = baDialogToken;
5921 pMlmAddBARsp->addBAResultCode = baStatusCode;
5922 pMlmAddBARsp->baTID = baTID;
5923 pMlmAddBARsp->baPolicy = baPolicy;
5924 pMlmAddBARsp->baBufferSize = baBufferSize;
5925 pMlmAddBARsp->baTimeout = baTimeout;
5926
5927 /* UPdate PE session ID*/
5928 pMlmAddBARsp->sessionId = psessionEntry->peSessionId;
5929
5930 // Send ADDBA Rsp to MLME
5931 limPostMlmMessage( pMac,
5932 LIM_MLM_ADDBA_RSP,
5933 (tANI_U32 *) pMlmAddBARsp );
5934
5935returnFailure:
5936
5937 return status;
5938}
5939
5940/**
5941 * \brief Post LIM_MLM_DELBA_REQ to MLME. MLME
5942 * will then send an DELBA Ind to peer MAC entity
5943 * with the appropriate DELBA status code
5944 *
5945 * \sa limPostMlmDelBAReq
5946 *
5947 * \param pMac The global tpAniSirGlobal object
5948 *
5949 * \param pSta DPH Hash Node object of peer MAC entity
5950 * for which the BA session is being deleted
5951 *
5952 * \param baDirection DELBA direction
5953 *
5954 * \param baTID TID for which the BA session is being deleted
5955 *
5956 * \param baReasonCode DELBA Req reason code
5957 *
5958 * \return eSIR_SUCCESS if setup completes successfully
5959 * eSIR_FAILURE is some problem is encountered
5960 */
5961tSirRetStatus limPostMlmDelBAReq( tpAniSirGlobal pMac,
5962 tpDphHashNode pSta,
5963 tANI_U8 baDirection,
5964 tANI_U8 baTID,
5965 tSirMacReasonCodes baReasonCode,
5966 tpPESession psessionEntry)
5967{
5968tSirRetStatus status = eSIR_SUCCESS;
5969tpLimMlmDelBAReq pMlmDelBAReq;
5970tLimBAState curBaState;
5971
5972if(NULL == pSta)
5973 return eSIR_FAILURE;
5974
5975LIM_GET_STA_BA_STATE(pSta, baTID, &curBaState);
5976
5977 // Need to validate the current BA State.
5978 if( eLIM_BA_STATE_IDLE != curBaState)
5979 {
5980 limLog( pMac, LOGE,
5981 FL( "Received unexpected DELBA REQ when STA BA state for tid = %d is %d\n" ),
5982 baTID,
5983 curBaState);
5984
5985 status = eSIR_FAILURE;
5986 goto returnFailure;
5987 }
5988
5989 // Allocate for LIM_MLM_DELBA_REQ
5990 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
5991 (void **) &pMlmDelBAReq,
5992 sizeof( tLimMlmDelBAReq )))
5993 {
5994 limLog( pMac, LOGE,
5995 FL("palAllocateMemory failed with error code %d\n"),
5996 status );
5997
5998 status = eSIR_MEM_ALLOC_FAILED;
5999 goto returnFailure;
6000 }
6001
6002 palZeroMemory( pMac->hHdd, (void *) pMlmDelBAReq, sizeof( tLimMlmDelBAReq ));
6003
6004 // Copy the peer MAC
6005 palCopyMemory( pMac->hHdd,
6006 pMlmDelBAReq->peerMacAddr,
6007 pSta->staAddr,
6008 sizeof( tSirMacAddr ));
6009
6010 pMlmDelBAReq->baDirection = baDirection;
6011 pMlmDelBAReq->baTID = baTID;
6012 pMlmDelBAReq->delBAReasonCode = baReasonCode;
6013
6014 /* Update PE session ID*/
6015 pMlmDelBAReq->sessionId = psessionEntry->peSessionId;
6016
6017 //we don't have valid BA session for the given direction.
6018 // HDD wants to get the BA session deleted on PEER in this case.
6019 // in this case we just need to send DelBA to the peer.
6020 if(((eBA_RECIPIENT == baDirection) && (eBA_DISABLE == pSta->tcCfg[baTID].fUseBARx)) ||
6021 ((eBA_INITIATOR == baDirection) && (eBA_DISABLE == pSta->tcCfg[baTID].fUseBATx)))
6022 {
6023 // Send DELBA Ind over the air
6024 if( eSIR_SUCCESS !=
6025 (status = limSendDelBAInd( pMac, pMlmDelBAReq,psessionEntry)))
6026 status = eSIR_FAILURE;
6027
6028 palFreeMemory(pMac->hHdd, (void*) pMlmDelBAReq);
6029 return status;
6030 }
6031
6032
6033 // Update the BA state in STA
6034 LIM_SET_STA_BA_STATE(pSta, pMlmDelBAReq->baTID, eLIM_BA_STATE_WT_DEL_RSP);
6035
6036 // Send DELBA Req to MLME
6037 limPostMlmMessage( pMac,
6038 LIM_MLM_DELBA_REQ,
6039 (tANI_U32 *) pMlmDelBAReq );
6040
6041returnFailure:
6042
6043 return status;
6044}
6045
6046/**
6047 * \brief Send WDA_ADDBA_REQ to HAL, in order
6048 * to setup a new BA session with a peer
6049 *
6050 * \sa limPostMsgAddBAReq
6051 *
6052 * \param pMac The global tpAniSirGlobal object
6053 *
6054 * \param pSta Runtime, STA-related configuration cached
6055 * in the HashNode object
6056 *
6057 * \param baDialogToken The Action Frame dialog token
6058 *
6059 * \param baTID TID for which the BA session is being setup
6060 *
6061 * \param baPolicy BA Policy
6062 *
6063 * \param baBufferSize The requested BA buffer size
6064 *
6065 * \param baTimeout BA Timeout. 0 indicates no BA timeout enforced
6066 *
6067 * \param baSSN Starting Sequence Number for this BA session
6068 *
6069 * \param baDirection BA Direction: 1 - Initiator, 0 - Recipient
6070 *
6071 * \return none
6072 *
6073 */
6074tSirRetStatus limPostMsgAddBAReq( tpAniSirGlobal pMac,
6075 tpDphHashNode pSta,
6076 tANI_U8 baDialogToken,
6077 tANI_U8 baTID,
6078 tANI_U8 baPolicy,
6079 tANI_U16 baBufferSize,
6080 tANI_U16 baTimeout,
6081 tANI_U16 baSSN,
6082 tANI_U8 baDirection,
6083 tpPESession psessionEntry)
6084{
6085tpAddBAParams pAddBAParams = NULL;
6086tSirRetStatus retCode = eSIR_SUCCESS;
6087eHalStatus status;
6088tSirMsgQ msgQ;
6089
6090#ifdef WLAN_SOFTAP_VSTA_FEATURE
6091 // we can only do BA on "hard" STAs
6092 if (!(IS_HWSTA_IDX(pSta->staIndex)))
6093 {
6094 retCode = eHAL_STATUS_FAILURE;
6095 goto returnFailure;
6096 }
6097#endif //WLAN_SOFTAP_VSTA_FEATURE
6098
6099 // Allocate for WDA_ADDBA_REQ
6100 if( eHAL_STATUS_SUCCESS !=
6101 (status = palAllocateMemory( pMac->hHdd,
6102 (void **) &pAddBAParams,
6103 sizeof( tAddBAParams ))))
6104 {
6105 limLog( pMac, LOGE,
6106 FL("palAllocateMemory failed with error code %d\n"),
6107 status );
6108
6109 retCode = eSIR_MEM_ALLOC_FAILED;
6110 goto returnFailure;
6111 }
6112
6113 palZeroMemory( pMac->hHdd, (void *) pAddBAParams, sizeof( tAddBAParams ));
6114
6115 // Copy the peer MAC address
6116 palCopyMemory( pMac->hHdd,
6117 (void *) pAddBAParams->peerMacAddr,
6118 (void *) pSta->staAddr,
6119 sizeof( tSirMacAddr ));
6120
6121 // Populate the REQ parameters
6122 pAddBAParams->staIdx = pSta->staIndex;
6123 pAddBAParams->baDialogToken = baDialogToken;
6124 pAddBAParams->baTID = baTID;
6125 pAddBAParams->baPolicy = baPolicy;
6126 pAddBAParams->baBufferSize = baBufferSize;
6127 pAddBAParams->baTimeout = baTimeout;
6128 pAddBAParams->baSSN = baSSN;
6129 pAddBAParams->baDirection = baDirection;
6130 pAddBAParams->respReqd = 1;
6131
6132 /* UPdate PE session ID */
6133 pAddBAParams->sessionId = psessionEntry->peSessionId;
6134
6135 // Post WDA_ADDBA_REQ to HAL.
6136 msgQ.type = WDA_ADDBA_REQ;
6137 //
6138 // FIXME_AMPDU
6139 // A global counter (dialog token) is required to keep track of
6140 // all PE <-> HAL communication(s)
6141 //
6142 msgQ.reserved = 0;
6143 msgQ.bodyptr = pAddBAParams;
6144 msgQ.bodyval = 0;
6145
6146 limLog( pMac, LOGW,
6147 FL( "Sending WDA_ADDBA_REQ..." ));
6148
6149 //defer any other message until we get response back.
6150 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
6151
Jeff Johnsone7245742012-09-05 17:12:55 -07006152 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006153#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
6154 limDiagEventReport(pMac, WLAN_PE_DIAG_HAL_ADDBA_REQ_EVENT, psessionEntry, 0, 0);
6155#endif //FEATURE_WLAN_DIAG_SUPPORT
6156
6157 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
6158 limLog( pMac, LOGE,
6159 FL("Posting WDA_ADDBA_REQ to HAL failed! Reason = %d\n"),
6160 retCode );
6161 else
6162 return retCode;
6163
6164returnFailure:
6165
6166 // Clean-up...
6167 if( NULL != pAddBAParams )
6168 palFreeMemory( pMac->hHdd, (void *) pAddBAParams );
6169
6170 return retCode;
6171
6172}
6173
6174/**
6175 * \brief Send WDA_DELBA_IND to HAL, in order
6176 * to delete an existing BA session with peer
6177 *
6178 * \sa limPostMsgDelBAInd
6179 *
6180 * \param pMac The global tpAniSirGlobal object
6181 *
6182 * \param pSta Runtime, STA-related configuration cached
6183 * in the HashNode object
6184 *
6185 * \param baTID TID for which the BA session is being setup
6186 *
6187 * \param baDirection Identifies whether the DELBA Ind was
6188 * sent by the BA initiator or recipient
6189 *
6190 * \return none
6191 *
6192 */
6193tSirRetStatus limPostMsgDelBAInd( tpAniSirGlobal pMac,
6194 tpDphHashNode pSta,
6195 tANI_U8 baTID,
6196 tANI_U8 baDirection,
6197 tpPESession psessionEntry)
6198{
6199tpDelBAParams pDelBAParams = NULL;
6200tSirRetStatus retCode = eSIR_SUCCESS;
6201eHalStatus status;
6202tSirMsgQ msgQ;
6203
6204 // Allocate for SIR_HAL_DELBA_IND
6205 if( eHAL_STATUS_SUCCESS !=
6206 (status = palAllocateMemory( pMac->hHdd,
6207 (void **) &pDelBAParams,
6208 sizeof( tDelBAParams ))))
6209 {
6210 limLog( pMac, LOGE,
6211 FL("palAllocateMemory failed with error code %d\n"),
6212 status );
6213
6214 retCode = eSIR_MEM_ALLOC_FAILED;
6215 goto returnFailure;
6216 }
6217
6218 palZeroMemory( pMac->hHdd, (void *) pDelBAParams, sizeof( tDelBAParams ));
6219
6220 // Populate the REQ parameters
6221 pDelBAParams->staIdx = pSta->staIndex;
6222 pDelBAParams->baTID = baTID;
6223 pDelBAParams->baDirection = baDirection;
6224
6225 /* Update PE session ID */
6226
6227
6228 //TBD-RAJESH Updating of the session ID is requird for SIR_HAL_DELBA_IND?????
6229 //pDelBAParams->sessionId = psessionEntry->peSessionId;
6230
6231 // Post WDA_DELBA_IND to HAL.
6232 msgQ.type = WDA_DELBA_IND;
6233 //
6234 // FIXME:
6235 // A global counter (dialog token) is required to keep track of
6236 // all PE <-> HAL communication(s)
6237 //
6238 msgQ.reserved = 0;
6239 msgQ.bodyptr = pDelBAParams;
6240 msgQ.bodyval = 0;
6241
6242 limLog( pMac, LOGW,
6243 FL( "Sending SIR_HAL_DELBA_IND..." ));
6244
Jeff Johnsone7245742012-09-05 17:12:55 -07006245 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006246#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
6247 limDiagEventReport(pMac, WLAN_PE_DIAG_HAL_DELBA_IND_EVENT, psessionEntry, 0, 0);
6248#endif //FEATURE_WLAN_DIAG_SUPPORT
6249
6250 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
6251 limLog( pMac, LOGE,
6252 FL("Posting WDA_DELBA_IND to HAL failed! Reason = %d\n"),
6253 retCode );
6254 else
6255 {
6256 // Update LIM's internal cache...
6257 if( eBA_INITIATOR == baDirection)
6258 {
6259 pSta->tcCfg[baTID].fUseBATx = 0;
6260 pSta->tcCfg[baTID].txBufSize = 0;
6261 }
6262 else
6263 {
6264 pSta->tcCfg[baTID].fUseBARx = 0;
6265 pSta->tcCfg[baTID].rxBufSize = 0;
6266 }
6267
6268 return retCode;
6269 }
6270
6271returnFailure:
6272
6273 // Clean-up...
6274 if( NULL != pDelBAParams )
6275 palFreeMemory( pMac->hHdd, (void *) pDelBAParams );
6276
6277 return retCode;
6278
6279}
6280
6281/**
6282 * @function : limPostSMStateUpdate()
6283 *
6284 * @brief : This function Updates the HAL and Softmac about the change in the STA's SMPS state.
6285 *
6286 * LOGIC:
6287 *
6288 * ASSUMPTIONS:
6289 * NA
6290 *
6291 * NOTE:
6292 * NA
6293 *
6294 * @param pMac - Pointer to Global MAC structure
6295 * @param limMsg - Lim Message structure object with the MimoPSparam in body
6296 * @return None
6297 */
6298tSirRetStatus
6299limPostSMStateUpdate(tpAniSirGlobal pMac,
6300 tANI_U16 staIdx, tSirMacHTMIMOPowerSaveState state)
6301{
6302 tSirRetStatus retCode = eSIR_SUCCESS;
6303 tSirMsgQ msgQ;
6304 eHalStatus status;
6305 tpSetMIMOPS pMIMO_PSParams;
6306
6307 msgQ.reserved = 0;
6308 msgQ.type = WDA_SET_MIMOPS_REQ;
6309
6310 // Allocate for WDA_SET_MIMOPS_REQ
6311 status = palAllocateMemory( pMac->hHdd, (void **) &pMIMO_PSParams, sizeof( tSetMIMOPS));
6312 if( eHAL_STATUS_SUCCESS != status) {
6313 limLog( pMac, LOGP,FL(" palAllocateMemory failed with error code %d\n"), status );
6314 return eSIR_MEM_ALLOC_FAILED;
6315 }
6316
6317 pMIMO_PSParams->htMIMOPSState = state;
6318 pMIMO_PSParams->staIdx = staIdx;
6319 pMIMO_PSParams->fsendRsp = true;
6320 msgQ.bodyptr = pMIMO_PSParams;
6321 msgQ.bodyval = 0;
6322
6323 limLog( pMac, LOG2, FL( "Sending WDA_SET_MIMOPS_REQ..." ));
6324
Jeff Johnsone7245742012-09-05 17:12:55 -07006325 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 retCode = wdaPostCtrlMsg( pMac, &msgQ );
6327 if (eSIR_SUCCESS != retCode)
6328 {
6329 limLog( pMac, LOGP, FL("Posting WDA_SET_MIMOPS_REQ to HAL failed! Reason = %d\n"), retCode );
6330 palFreeMemory(pMac->hHdd, (void *) pMIMO_PSParams);
6331 return retCode;
6332 }
6333
6334 return retCode;
6335}
6336
6337void limPktFree (
6338 tpAniSirGlobal pMac,
6339 eFrameType frmType,
6340 tANI_U8 *pRxPacketInfo,
6341 void *pBody)
6342{
6343 (void) pMac; (void) frmType; (void) pRxPacketInfo; (void) pBody;
Jeff Johnson295189b2012-06-20 16:38:30 -07006344}
6345
6346/**
6347 * limGetBDfromRxPacket()
6348 *
6349 *FUNCTION:
6350 * This function is called to get pointer to Polaris
6351 * Buffer Descriptor containing MAC header & other control
6352 * info from the body of the message posted to LIM.
6353 *
6354 *LOGIC:
6355 * NA
6356 *
6357 *ASSUMPTIONS:
6358 * NA
6359 *
6360 *NOTE:
6361 * NA
6362 *
6363 * @param body - Received message body
6364 * @param pRxPacketInfo - Pointer to received BD
6365 * @return None
6366 */
6367
6368void
6369limGetBDfromRxPacket(tpAniSirGlobal pMac, void *body, tANI_U32 **pRxPacketInfo)
6370{
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 *pRxPacketInfo = (tANI_U32 *) body;
Jeff Johnson295189b2012-06-20 16:38:30 -07006372} /*** end limGetBDfromRxPacket() ***/
6373
6374
6375
6376
6377
6378void limRessetScanChannelInfo(tpAniSirGlobal pMac)
6379{
6380 palZeroMemory(pMac->hHdd, &pMac->lim.scanChnInfo, sizeof(tLimScanChnInfo));
6381}
6382
6383
6384void limAddScanChannelInfo(tpAniSirGlobal pMac, tANI_U8 channelId)
6385{
6386 tANI_U8 i;
6387 tANI_BOOLEAN fFound = eANI_BOOLEAN_FALSE;
6388
6389 for(i = 0; i < pMac->lim.scanChnInfo.numChnInfo; i++)
6390 {
6391 if(pMac->lim.scanChnInfo.scanChn[i].channelId == channelId)
6392 {
6393 pMac->lim.scanChnInfo.scanChn[i].numTimeScan++;
6394 fFound = eANI_BOOLEAN_TRUE;
6395 break;
6396 }
6397 }
6398 if(eANI_BOOLEAN_FALSE == fFound)
6399 {
6400 if(pMac->lim.scanChnInfo.numChnInfo < SIR_MAX_SUPPORTED_CHANNEL_LIST)
6401 {
6402 pMac->lim.scanChnInfo.scanChn[pMac->lim.scanChnInfo.numChnInfo].channelId = channelId;
6403 pMac->lim.scanChnInfo.scanChn[pMac->lim.scanChnInfo.numChnInfo++].numTimeScan = 1;
6404 }
6405 else
6406 {
6407 PELOGW(limLog(pMac, LOGW, FL(" -- number of channels exceed mac\n"));)
6408 }
6409 }
6410}
6411
6412
6413/**
6414 * @function : limIsChannelValidForChannelSwitch()
6415 *
6416 * @brief : This function checks if the channel to which AP
6417 * is expecting us to switch, is a valid channel for us.
6418 * LOGIC:
6419 *
6420 * ASSUMPTIONS:
6421 * NA
6422 *
6423 * NOTE:
6424 * NA
6425 *
6426 * @param pMac - Pointer to Global MAC structure
6427 * @param channel - New channel to which we are expected to move
6428 * @return None
6429 */
6430tAniBool
6431limIsChannelValidForChannelSwitch(tpAniSirGlobal pMac, tANI_U8 channel)
6432{
6433 tANI_U8 index;
6434 tANI_U32 validChannelListLen = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6435 tSirMacChanNum validChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6436
6437 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
6438 (tANI_U8 *)validChannelList,
6439 (tANI_U32 *)&validChannelListLen) != eSIR_SUCCESS)
6440 {
6441 PELOGE(limLog(pMac, LOGE, FL("could not retrieve valid channel list\n"));)
6442 return (eSIR_FALSE);
6443 }
6444
6445 for(index = 0; index < validChannelListLen; index++)
6446 {
6447 if(validChannelList[index] == channel)
6448 return (eSIR_TRUE);
6449 }
6450
6451 /* channel does not belong to list of valid channels */
6452 return (eSIR_FALSE);
6453}
6454
6455/**------------------------------------------------------
6456\fn __limFillTxControlParams
6457\brief Fill the message for stopping/resuming tx.
6458
6459\param pMac
6460\param pTxCtrlMsg - Pointer to tx control message.
6461\param type - Which way we want to stop/ resume tx.
6462\param mode - To stop/resume.
6463 -------------------------------------------------------*/
6464static eHalStatus
6465__limFillTxControlParams(tpAniSirGlobal pMac, tpTxControlParams pTxCtrlMsg,
6466 tLimQuietTxMode type, tLimControlTx mode)
6467{
6468
6469 //TBD-RAJESH HOW TO GET sessionEntry?????
6470 tpPESession psessionEntry = &pMac->lim.gpSession[0];
6471
6472 if (mode == eLIM_STOP_TX)
6473 pTxCtrlMsg->stopTx = eANI_BOOLEAN_TRUE;
6474 else
6475 pTxCtrlMsg->stopTx = eANI_BOOLEAN_FALSE;
6476
6477 switch (type)
6478 {
6479 case eLIM_TX_ALL:
6480 /** Stops/resumes transmission completely */
6481 pTxCtrlMsg->fCtrlGlobal = 1;
6482 break;
6483
6484 case eLIM_TX_BSS_BUT_BEACON:
6485 /** Stops/resumes transmission on a particular BSS. Stopping BSS, doesnt
6486 * stop beacon transmission.
6487 */
6488 pTxCtrlMsg->ctrlBss = 1;
6489 pTxCtrlMsg->bssBitmap |= (1 << psessionEntry->bssIdx);
6490 break;
6491
6492 case eLIM_TX_STA:
6493 /** Memory for station bitmap is allocated dynamically in caller of this
6494 * so decode properly here and fill the bitmap. Now not implemented,
6495 * fall through.
6496 */
6497 case eLIM_TX_BSS:
6498 //Fall thru...
6499 default:
6500 PELOGW(limLog(pMac, LOGW, FL("Invalid case: Not Handled\n"));)
6501 return eHAL_STATUS_FAILURE;
6502 }
6503
6504 return eHAL_STATUS_SUCCESS;
6505}
6506
6507/**
6508 * @function : limFrameTransmissionControl()
6509 *
6510 * @brief : This API is called by the user to halt/resume any frame
6511 * transmission from the device. If stopped, all frames will be
6512 * queued starting from hardware. Then back-pressure
6513 * is built till the driver.
6514 * LOGIC:
6515 *
6516 * ASSUMPTIONS:
6517 * NA
6518 *
6519 * NOTE:
6520 * NA
6521 *
6522 * @param pMac - Pointer to Global MAC structure
6523 * @return None
6524 */
6525void limFrameTransmissionControl(tpAniSirGlobal pMac, tLimQuietTxMode type, tLimControlTx mode)
6526{
6527
6528 eHalStatus status = eHAL_STATUS_FAILURE;
6529 tpTxControlParams pTxCtrlMsg;
6530 tSirMsgQ msgQ;
6531 tANI_U8 nBytes = 0; // No of bytes required for station bitmap.
6532
6533 /** Allocate only required number of bytes for station bitmap
6534 * Make it to align to 4 byte boundary */
6535 nBytes = (tANI_U8)HALMSG_NUMBYTES_STATION_BITMAP(pMac->lim.maxStation);
6536
6537 status = palAllocateMemory(pMac->hHdd, (void **) &pTxCtrlMsg,
6538 (sizeof(*pTxCtrlMsg) + nBytes));
6539 if (status != eHAL_STATUS_SUCCESS)
6540 {
6541 limLog(pMac, LOGP, FL("palAllocateMemory() failed\n"));
6542 return;
6543 }
6544
6545 status = palZeroMemory(pMac->hHdd, (void *) pTxCtrlMsg,
6546 (sizeof(*pTxCtrlMsg) + nBytes));
6547 if (status != eHAL_STATUS_SUCCESS)
6548 {
6549 palFreeMemory(pMac->hHdd, (void *) pTxCtrlMsg);
6550 limLog(pMac, LOGP, FL("palZeroMemory() failed, status = %d\n"), status);
6551 return;
6552 }
6553
6554 status = __limFillTxControlParams(pMac, pTxCtrlMsg, type, mode);
6555 if (status != eHAL_STATUS_SUCCESS)
6556 {
6557 palFreeMemory(pMac->hHdd, (void *) pTxCtrlMsg);
6558 limLog(pMac, LOGP, FL("__limFillTxControlParams failed, status = %d\n"), status);
6559 return;
6560 }
6561
6562 msgQ.bodyptr = (void *) pTxCtrlMsg;
6563 msgQ.bodyval = 0;
6564 msgQ.reserved = 0;
6565 msgQ.type = WDA_TRANSMISSION_CONTROL_IND;
6566
Jeff Johnsone7245742012-09-05 17:12:55 -07006567 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006568 if(wdaPostCtrlMsg( pMac, &msgQ) != eSIR_SUCCESS)
6569 {
6570 palFreeMemory(pMac->hHdd, (void *) pTxCtrlMsg);
6571 limLog( pMac, LOGP, FL("Posting Message to HAL failed\n"));
6572 return;
6573 }
6574
6575 if (mode == eLIM_STOP_TX)
6576 {
6577 PELOG1(limLog(pMac, LOG1, FL("Stopping the transmission of all packets, indicated softmac\n"));)
6578 }
6579 else
6580 {
6581 PELOG1(limLog(pMac, LOG1, FL("Resuming the transmission of all packets, indicated softmac\n"));)
6582 }
6583 return;
6584}
6585
6586
6587/**
6588 * @function : limRestorePreChannelSwitchState()
6589 *
6590 * @brief : This API is called by the user to undo any
6591 * specific changes done on the device during
6592 * channel switch.
6593 * LOGIC:
6594 *
6595 * ASSUMPTIONS:
6596 * NA
6597 *
6598 * NOTE:
6599 * NA
6600 *
6601 * @param pMac - Pointer to Global MAC structure
6602 * @return None
6603 */
6604
6605tSirRetStatus
6606limRestorePreChannelSwitchState(tpAniSirGlobal pMac, tpPESession psessionEntry)
6607{
6608
6609 tSirRetStatus retCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006610 tANI_U32 val = 0;
6611
6612 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
6613 return retCode;
6614
6615 /* Channel switch should be ready for the next time */
Jeff Johnsone7245742012-09-05 17:12:55 -07006616 psessionEntry->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07006617
6618 /* Restore the frame transmission, all the time. */
6619 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
6620
6621 /* Free to enter BMPS */
6622 limSendSmePostChannelSwitchInd(pMac);
6623
6624 //Background scan is now enabled by SME
6625 if(pMac->lim.gLimBackgroundScanTerminate == FALSE)
6626 {
6627 /* Enable background scan if already enabled, else don't bother */
6628 if ((retCode = wlan_cfgGetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD,
6629 &val)) != eSIR_SUCCESS)
6630
6631 {
6632 limLog(pMac, LOGP, FL("could not retrieve Background scan period value\n"));
6633 return (retCode);
6634 }
6635
6636 if (val > 0 && TX_TIMER_VALID(pMac->lim.limTimers.gLimBackgroundScanTimer))
6637 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006638 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_BACKGROUND_SCAN_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 if(tx_timer_activate(&pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
6640 {
6641 limLog(pMac, LOGP, FL("Could not restart background scan timer, doing LOGP"));
6642 return (eSIR_FAILURE);
6643 }
6644
6645 }
6646 }
6647
6648 /* Enable heartbeat timer */
6649 if (TX_TIMER_VALID(pMac->lim.limTimers.gLimHeartBeatTimer))
6650 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006651 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_HEART_BEAT_TIMER));
Yathish9f22e662012-12-10 14:21:35 -08006652 if((limActivateHearBeatTimer(pMac) != TX_SUCCESS) && (!IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 {
6654 limLog(pMac, LOGP, FL("Could not restart heartbeat timer, doing LOGP"));
6655 return (eSIR_FAILURE);
6656 }
6657 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006658 return (retCode);
6659}
6660
6661
6662/**--------------------------------------------
6663\fn limRestorePreQuietState
6664\brief Restore the pre quiet state
6665
6666\param pMac
6667\return NONE
6668---------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07006669tSirRetStatus limRestorePreQuietState(tpAniSirGlobal pMac, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07006670{
6671
6672 tSirRetStatus retCode = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006673 tANI_U32 val = 0;
6674
6675 if (pMac->lim.gLimSystemRole != eLIM_STA_ROLE)
6676 return retCode;
6677
6678 /* Quiet should be ready for the next time */
Jeff Johnsone7245742012-09-05 17:12:55 -07006679 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07006680
6681 /* Restore the frame transmission, all the time. */
Jeff Johnsone7245742012-09-05 17:12:55 -07006682 if (psessionEntry->gLimSpecMgmt.quietState == eLIM_QUIET_RUNNING)
Jeff Johnson295189b2012-06-20 16:38:30 -07006683 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
6684
6685
6686 //Background scan is now enabled by SME
6687 if(pMac->lim.gLimBackgroundScanTerminate == FALSE)
6688 {
6689 /* Enable background scan if already enabled, else don't bother */
6690 if ((retCode = wlan_cfgGetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD,
6691 &val)) != eSIR_SUCCESS)
6692
6693 {
6694 limLog(pMac, LOGP, FL("could not retrieve Background scan period value\n"));
6695 return (retCode);
6696 }
6697
6698 if (val > 0 && TX_TIMER_VALID(pMac->lim.limTimers.gLimBackgroundScanTimer))
6699 {
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08006700 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_BACKGROUND_SCAN_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07006701 if(tx_timer_activate(&pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
6702 {
6703 limLog(pMac, LOGP, FL("Could not restart background scan timer, doing LOGP"));
6704 return (eSIR_FAILURE);
6705 }
6706
6707 }
6708 }
6709
6710 /* Enable heartbeat timer */
6711 if (TX_TIMER_VALID(pMac->lim.limTimers.gLimHeartBeatTimer))
6712 {
Leela V Kiran Kumar Reddy Chiralac3b9d382013-01-31 20:49:53 -08006713 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_HEART_BEAT_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07006714 if(limActivateHearBeatTimer(pMac) != TX_SUCCESS)
6715 {
6716 limLog(pMac, LOGP, FL("Could not restart heartbeat timer, doing LOGP"));
6717 return (eSIR_FAILURE);
6718 }
6719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 return (retCode);
6721}
6722
6723
6724/**
6725 * @function: limPrepareFor11hChannelSwitch()
6726 *
6727 * @brief : This API is called by the user to prepare for
6728 * 11h channel switch. As of now, the API does
6729 * very minimal work. User can add more into the
6730 * same API if needed.
6731 * LOGIC:
6732 *
6733 * ASSUMPTIONS:
6734 * NA
6735 *
6736 * NOTE:
6737 * NA
6738 *
6739 * @param pMac - Pointer to Global MAC structure
6740 * @param psessionEntry
6741 * @return None
6742 */
6743void
6744limPrepareFor11hChannelSwitch(tpAniSirGlobal pMac, tpPESession psessionEntry)
6745{
Jeff Johnson295189b2012-06-20 16:38:30 -07006746 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
6747 return;
6748
6749 /* Flag to indicate 11h channel switch in progress */
Jeff Johnsone7245742012-09-05 17:12:55 -07006750 psessionEntry->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_RUNNING;
Jeff Johnson295189b2012-06-20 16:38:30 -07006751
6752 /* Disable, Stop background scan if enabled and running */
6753 limDeactivateAndChangeTimer(pMac, eLIM_BACKGROUND_SCAN_TIMER);
6754
6755 /* Stop heart-beat timer to stop heartbeat disassociation */
6756 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
6757
6758 if(pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE ||
6759 pMac->lim.gLimSmeState == eLIM_SME_CHANNEL_SCAN_STATE)
6760 {
6761 PELOGE(limLog(pMac, LOGE, FL("Posting finish scan as we are in scan state\n"));)
6762 /* Stop ongoing scanning if any */
6763 if (GET_LIM_PROCESS_DEFD_MESGS(pMac))
6764 {
6765 //Set the resume channel to Any valid channel (invalid).
6766 //This will instruct HAL to set it to any previous valid channel.
6767 peSetResumeChannel(pMac, 0, 0);
6768 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
6769 }
6770 else
6771 {
6772 limRestorePreChannelSwitchState(pMac, psessionEntry);
6773 }
6774 return;
6775 }
6776 else
6777 {
6778 PELOGE(limLog(pMac, LOGE, FL("Not in scan state, start channel switch timer\n"));)
6779 /** We are safe to switch channel at this point */
6780 limStopTxAndSwitchChannel(pMac, psessionEntry->peSessionId);
6781 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006782}
6783
6784
6785
6786/**----------------------------------------------------
6787\fn limGetNwType
6788
6789\brief Get type of the network from data packet or beacon
6790\param pMac
6791\param channelNum - Channel number
6792\param type - Type of packet.
6793\param pBeacon - Pointer to beacon or probe response
6794
6795\return Network type a/b/g.
6796-----------------------------------------------------*/
6797tSirNwType limGetNwType(tpAniSirGlobal pMac, tANI_U8 channelNum, tANI_U32 type, tpSchBeaconStruct pBeacon)
6798{
6799 tSirNwType nwType = eSIR_11B_NW_TYPE;
6800
6801 if (type == SIR_MAC_DATA_FRAME)
6802 {
6803 if ((channelNum > 0) && (channelNum < 15))
6804 {
6805 nwType = eSIR_11G_NW_TYPE;
6806 }
6807 else
6808 {
6809 nwType = eSIR_11A_NW_TYPE;
6810 }
6811 }
6812 else
6813 {
6814 if ((channelNum > 0) && (channelNum < 15))
6815 {
6816 int i;
6817 // 11b or 11g packet
6818 // 11g iff extended Rate IE is present or
6819 // if there is an A rate in suppRate IE
6820 for (i = 0; i < pBeacon->supportedRates.numRates; i++)
6821 {
6822 if (sirIsArate(pBeacon->supportedRates.rate[i] & 0x7f))
6823 {
6824 nwType = eSIR_11G_NW_TYPE;
6825 break;
6826 }
6827 }
6828 if (pBeacon->extendedRatesPresent)
6829 {
6830 PELOG3(limLog(pMac, LOG3, FL("Beacon, nwtype=G\n"));)
6831 nwType = eSIR_11G_NW_TYPE;
6832 }
6833 }
6834 else
6835 {
6836 // 11a packet
6837 PELOG3(limLog(pMac, LOG3,FL("Beacon, nwtype=A\n"));)
6838 nwType = eSIR_11A_NW_TYPE;
6839 }
6840 }
6841 return nwType;
6842}
6843
6844
6845/**---------------------------------------------------------
6846\fn limGetChannelFromBeacon
6847\brief To extract channel number from beacon
6848
6849\param pMac
6850\param pBeacon - Pointer to beacon or probe rsp
6851\return channel number
6852-----------------------------------------------------------*/
6853tANI_U8 limGetChannelFromBeacon(tpAniSirGlobal pMac, tpSchBeaconStruct pBeacon)
6854{
6855 tANI_U8 channelNum = 0;
6856
6857 if (pBeacon->dsParamsPresent)
6858 channelNum = pBeacon->channelNumber;
6859 else if(pBeacon->HTInfo.present)
6860 channelNum = pBeacon->HTInfo.primaryChannel;
6861 else
6862 channelNum = pBeacon->channelNumber;
6863
6864 return channelNum;
6865}
6866
6867
6868/** ---------------------------------------------------------
6869\fn limSetTspecUapsdMask
6870\brief This function sets the PE global variable:
6871\ 1) gUapsdPerAcTriggerEnableMask and
6872\ 2) gUapsdPerAcDeliveryEnableMask
6873\ based on the user priority field and direction field
6874\ in the TS Info Fields.
6875\
6876\ An AC is a trigger-enabled AC if the PSB subfield
6877\ is set to 1 in the uplink direction.
6878\ An AC is a delivery-enabled AC if the PSB subfield
6879\ is set to 1 in the down-link direction.
6880\
6881\param tpAniSirGlobal pMac
6882\param tSirMacTSInfo pTsInfo
6883\param tANI_U32 action
6884\return None
6885 ------------------------------------------------------------*/
6886void limSetTspecUapsdMask(tpAniSirGlobal pMac, tSirMacTSInfo *pTsInfo, tANI_U32 action)
6887{
6888 tANI_U8 userPrio = (tANI_U8)pTsInfo->traffic.userPrio;
6889 tANI_U16 direction = pTsInfo->traffic.direction;
6890 tANI_U8 ac = upToAc(userPrio);
6891
6892 PELOG1(limLog(pMac, LOG1, FL(" Set UAPSD mask for AC %d, direction %d, action=%d (1=set,0=clear) \n"),ac, direction, action );)
6893
6894 /* Converting AC to appropriate Uapsd Bit Mask
6895 * AC_BE(0) --> UAPSD_BITOFFSET_ACVO(3)
6896 * AC_BK(1) --> UAPSD_BITOFFSET_ACVO(2)
6897 * AC_VI(2) --> UAPSD_BITOFFSET_ACVO(1)
6898 * AC_VO(3) --> UAPSD_BITOFFSET_ACVO(0)
6899 */
6900 ac = ((~ac) & 0x3);
6901
6902 if (action == CLEAR_UAPSD_MASK)
6903 {
6904 if (direction == SIR_MAC_DIRECTION_UPLINK)
6905 pMac->lim.gUapsdPerAcTriggerEnableMask &= ~(1 << ac);
6906 else if (direction == SIR_MAC_DIRECTION_DNLINK)
6907 pMac->lim.gUapsdPerAcDeliveryEnableMask &= ~(1 << ac);
6908 else if (direction == SIR_MAC_DIRECTION_BIDIR)
6909 {
6910 pMac->lim.gUapsdPerAcTriggerEnableMask &= ~(1 << ac);
6911 pMac->lim.gUapsdPerAcDeliveryEnableMask &= ~(1 << ac);
6912 }
6913 }
6914 else if (action == SET_UAPSD_MASK)
6915 {
6916 if (direction == SIR_MAC_DIRECTION_UPLINK)
6917 pMac->lim.gUapsdPerAcTriggerEnableMask |= (1 << ac);
6918 else if (direction == SIR_MAC_DIRECTION_DNLINK)
6919 pMac->lim.gUapsdPerAcDeliveryEnableMask |= (1 << ac);
6920 else if (direction == SIR_MAC_DIRECTION_BIDIR)
6921 {
6922 pMac->lim.gUapsdPerAcTriggerEnableMask |= (1 << ac);
6923 pMac->lim.gUapsdPerAcDeliveryEnableMask |= (1 << ac);
6924 }
6925 }
6926
6927 limLog(pMac, LOGE, FL("New pMac->lim.gUapsdPerAcTriggerEnableMask = 0x%x \n"), pMac->lim.gUapsdPerAcTriggerEnableMask );
6928 limLog(pMac, LOGE, FL("New pMac->lim.gUapsdPerAcDeliveryEnableMask = 0x%x \n"), pMac->lim.gUapsdPerAcDeliveryEnableMask );
6929
6930 return;
6931}
6932
6933
6934
6935void limHandleHeartBeatTimeout(tpAniSirGlobal pMac )
6936{
6937
6938 tANI_U8 i;
6939 for(i =0;i < pMac->lim.maxBssId;i++)
6940 {
6941 if(pMac->lim.gpSession[i].valid == TRUE )
6942 {
6943 if(pMac->lim.gpSession[i].bssType == eSIR_IBSS_MODE)
6944 {
6945 limIbssHeartBeatHandle(pMac,&pMac->lim.gpSession[i]);
6946 break;
6947 }
6948
6949 if((pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) &&
6950 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_ROLE))
6951 {
6952 limHandleHeartBeatFailure(pMac,&pMac->lim.gpSession[i]);
6953 }
6954 }
6955 }
6956 for(i=0; i< pMac->lim.maxBssId; i++)
6957 {
6958 if(pMac->lim.gpSession[i].valid == TRUE )
6959 {
6960 if((pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) &&
6961 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_ROLE))
6962 {
6963 if(pMac->lim.gpSession[i].LimHBFailureStatus == eANI_BOOLEAN_TRUE)
6964 {
6965 /* Activate Probe After HeartBeat Timer incase HB Failure detected */
6966 PELOGW(limLog(pMac, LOGW,FL("Sending Probe for Session: %d\n"),
6967 i);)
6968 limDeactivateAndChangeTimer(pMac, eLIM_PROBE_AFTER_HB_TIMER);
6969 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0, eLIM_PROBE_AFTER_HB_TIMER));
6970 if (tx_timer_activate(&pMac->lim.limTimers.gLimProbeAfterHBTimer) != TX_SUCCESS)
6971 {
6972 limLog(pMac, LOGP, FL("Fail to re-activate Probe-after-heartbeat timer\n"));
6973 limReactivateHeartBeatTimer(pMac, &pMac->lim.gpSession[i]);
6974 }
6975 break;
6976 }
6977 }
6978 }
6979 }
6980}
6981
Leela Venkata Kiran Kumar Reddy Chirala3ca17902013-02-27 19:50:05 -08006982void limHandleHeartBeatTimeoutForSession(tpAniSirGlobal pMac, tpPESession psessionEntry)
6983{
6984 if(psessionEntry->valid == TRUE )
6985 {
6986 if(psessionEntry->bssType == eSIR_IBSS_MODE)
6987 {
6988 limIbssHeartBeatHandle(pMac,psessionEntry);
6989 }
6990 if((psessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE) &&
6991 (psessionEntry->limSystemRole == eLIM_STA_ROLE))
6992 {
6993 limHandleHeartBeatFailure(pMac,psessionEntry);
6994 }
6995 }
6996 /* In the function limHandleHeartBeatFailure things can change so check for the session entry valid
6997 and the other things again */
6998 if(psessionEntry->valid == TRUE )
6999 {
7000 if((psessionEntry->bssType == eSIR_INFRASTRUCTURE_MODE) &&
7001 (psessionEntry->limSystemRole == eLIM_STA_ROLE))
7002 {
7003 if(psessionEntry->LimHBFailureStatus == eANI_BOOLEAN_TRUE)
7004 {
7005 /* Activate Probe After HeartBeat Timer incase HB Failure detected */
7006 PELOGW(limLog(pMac, LOGW,FL("Sending Probe for Session: %d"),
7007 psessionEntry->bssIdx);)
7008 limDeactivateAndChangeTimer(pMac, eLIM_PROBE_AFTER_HB_TIMER);
7009 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0, eLIM_PROBE_AFTER_HB_TIMER));
7010 if (tx_timer_activate(&pMac->lim.limTimers.gLimProbeAfterHBTimer) != TX_SUCCESS)
7011 {
7012 limLog(pMac, LOGP, FL("Fail to re-activate Probe-after-heartbeat timer"));
7013 limReactivateHeartBeatTimer(pMac, psessionEntry);
7014 }
7015 }
7016 }
7017 }
7018}
7019
7020
Jeff Johnson295189b2012-06-20 16:38:30 -07007021tANI_U8 limGetCurrentOperatingChannel(tpAniSirGlobal pMac)
7022{
7023 tANI_U8 i;
7024 for(i =0;i < pMac->lim.maxBssId;i++)
7025 {
7026 if(pMac->lim.gpSession[i].valid == TRUE )
7027 {
7028 if((pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) &&
7029 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_ROLE))
7030 {
7031 return pMac->lim.gpSession[i].currentOperChannel;
7032 }
7033 }
7034 }
7035 return 0;
7036}
7037
7038void limProcessAddStaRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ)
7039{
7040
7041 tpPESession psessionEntry;
7042// tANI_U8 sessionId;
7043 tpAddStaParams pAddStaParams;
7044
7045 pAddStaParams = (tpAddStaParams)limMsgQ->bodyptr;
7046
7047 if((psessionEntry = peFindSessionBySessionId(pMac,pAddStaParams->sessionId))==NULL)
7048 {
7049 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07007050 palFreeMemory(pMac, pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07007051 return;
7052 }
7053 if (psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
7054 (void) limIbssAddStaRsp(pMac, limMsgQ->bodyptr,psessionEntry);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007055#ifdef FEATURE_WLAN_TDLS
7056 else if(pMac->lim.gLimAddStaTdls)
7057 {
7058 limProcessTdlsAddStaRsp(pMac, limMsgQ->bodyptr, psessionEntry) ;
7059 pMac->lim.gLimAddStaTdls = FALSE ;
7060 }
7061#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007062 else
7063 limProcessMlmAddStaRsp(pMac, limMsgQ,psessionEntry);
7064
7065}
7066
7067
7068void limUpdateBeacon(tpAniSirGlobal pMac)
7069{
7070 tANI_U8 i;
7071
7072 for(i =0;i < pMac->lim.maxBssId;i++)
7073 {
7074 if(pMac->lim.gpSession[i].valid == TRUE )
7075 {
7076 if( ( (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) ||
7077 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_IN_IBSS_ROLE) )
7078 && (eLIM_SME_NORMAL_STATE == pMac->lim.gpSession[i].limSmeState)
7079 )
7080 {
7081 schSetFixedBeaconFields(pMac,&pMac->lim.gpSession[i]);
7082 limSendBeaconInd(pMac, &pMac->lim.gpSession[i]);
7083 }
7084 else
7085 {
7086 if( (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)||
7087 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE))
7088 {
7089
7090 if(pMac->lim.gpSession[i].statypeForBss == STA_ENTRY_SELF)
7091 {
7092 schSetFixedBeaconFields(pMac,&pMac->lim.gpSession[i]);
7093 }
7094 }
7095 }
7096 }
7097 }
7098}
7099
7100void limHandleHeartBeatFailureTimeout(tpAniSirGlobal pMac)
7101{
7102 tANI_U8 i;
7103 tpPESession psessionEntry;
7104 /* Probe response is not received after HB failure. This is handled by LMM sub module. */
7105 for(i =0; i < pMac->lim.maxBssId; i++)
7106 {
7107 if(pMac->lim.gpSession[i].valid == TRUE)
7108 {
7109 psessionEntry = &pMac->lim.gpSession[i];
7110 if(psessionEntry->LimHBFailureStatus == eANI_BOOLEAN_TRUE)
7111 {
7112 limLog(pMac, LOGE, FL("Probe_hb_failure: SME %d, MLME %d, HB-Count %d\n"),psessionEntry->limSmeState,
7113 psessionEntry->limMlmState, psessionEntry->LimRxedBeaconCntDuringHB);
7114 if (psessionEntry->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)
7115 {
7116 if (!LIM_IS_CONNECTION_ACTIVE(psessionEntry))
7117 {
7118 limLog(pMac, LOGE, FL("Probe_hb_failure: for session:%d \n" ),psessionEntry->peSessionId);
7119 /* AP did not respond to Probe Request. Tear down link with it.*/
7120 limTearDownLinkWithAp(pMac,
7121 psessionEntry->peSessionId,
7122 eSIR_BEACON_MISSED);
7123 pMac->lim.gLimProbeFailureAfterHBfailedCnt++ ;
7124 }
7125 else // restart heartbeat timer
7126 {
7127 limReactivateHeartBeatTimer(pMac, psessionEntry);
7128 }
7129 }
7130 else
7131 {
7132 limLog(pMac, LOGE, FL("Unexpected wt-probe-timeout in state \n"));
7133 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
7134 limReactivateHeartBeatTimer(pMac, psessionEntry);
7135 }
7136
7137 }
7138 }
7139 }
7140 /* Deactivate Timer ProbeAfterHB Timer -> As its a oneshot timer, need not deactivate the timer */
7141 // tx_timer_deactivate(&pMac->lim.limTimers.gLimProbeAfterHBTimer);
7142}
7143
7144
7145/*
7146* This function assumes there will not be more than one IBSS session active at any time.
7147*/
7148tpPESession limIsIBSSSessionActive(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_STA_IN_IBSS_ROLE))
7156 return (&pMac->lim.gpSession[i]);
7157 }
7158
7159 return NULL;
7160}
7161
7162tpPESession limIsApSessionActive(tpAniSirGlobal pMac)
7163{
7164 tANI_U8 i;
7165
7166 for(i =0;i < pMac->lim.maxBssId;i++)
7167 {
7168 if( (pMac->lim.gpSession[i].valid) &&
7169 ( (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) ||
7170 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)))
7171 return (&pMac->lim.gpSession[i]);
7172 }
7173
7174 return NULL;
7175}
7176
7177/**---------------------------------------------------------
7178\fn limHandleDeferMsgError
7179\brief handles error scenario, when the msg can not be deferred.
7180\param pMac
7181\param pLimMsg LIM msg, which could not be deferred.
7182\return void
7183-----------------------------------------------------------*/
7184
7185void limHandleDeferMsgError(tpAniSirGlobal pMac, tpSirMsgQ pLimMsg)
7186{
7187 if(SIR_BB_XPORT_MGMT_MSG == pLimMsg->type)
7188 {
7189 vos_pkt_return_packet((vos_pkt_t*)pLimMsg->bodyptr);
7190 }
7191 else if(pLimMsg->bodyptr != NULL)
7192 palFreeMemory( pMac->hHdd, (tANI_U8 *) pLimMsg->bodyptr);
7193
7194}
7195
7196
7197#ifdef FEATURE_WLAN_DIAG_SUPPORT
7198/**---------------------------------------------------------
7199\fn limDiagEventReport
7200\brief This function reports Diag event
7201\param pMac
7202\param eventType
7203\param bssid
7204\param status
7205\param reasonCode
7206\return void
7207-----------------------------------------------------------*/
7208void limDiagEventReport(tpAniSirGlobal pMac, tANI_U16 eventType, tpPESession pSessionEntry, tANI_U16 status, tANI_U16 reasonCode)
7209{
7210 tSirMacAddr nullBssid = { 0, 0, 0, 0, 0, 0 };
7211 WLAN_VOS_DIAG_EVENT_DEF(peEvent, vos_event_wlan_pe_payload_type);
7212
7213 palZeroMemory(pMac->hHdd, &peEvent, sizeof(vos_event_wlan_pe_payload_type));
7214
7215 if (NULL == pSessionEntry)
7216 {
7217 palCopyMemory(pMac->hHdd, peEvent.bssid, nullBssid, sizeof(tSirMacAddr));
7218 peEvent.sme_state = (tANI_U16)pMac->lim.gLimSmeState;
7219 peEvent.mlm_state = (tANI_U16)pMac->lim.gLimMlmState;
7220
7221 }
7222 else
7223 {
7224 palCopyMemory(pMac->hHdd, peEvent.bssid, pSessionEntry->bssId, sizeof(tSirMacAddr));
7225 peEvent.sme_state = (tANI_U16)pSessionEntry->limSmeState;
7226 peEvent.mlm_state = (tANI_U16)pSessionEntry->limMlmState;
7227 }
7228 peEvent.event_type = eventType;
7229 peEvent.status = status;
7230 peEvent.reason_code = reasonCode;
7231
7232 WLAN_VOS_DIAG_EVENT_REPORT(&peEvent, EVENT_WLAN_PE);
7233 return;
7234}
7235
7236#endif /* FEATURE_WLAN_DIAG_SUPPORT */
7237
7238void limProcessAddStaSelfRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ)
7239{
7240
7241 tpAddStaSelfParams pAddStaSelfParams;
7242 tSirMsgQ mmhMsg;
7243 tpSirSmeAddStaSelfRsp pRsp;
7244
7245
7246 pAddStaSelfParams = (tpAddStaSelfParams)limMsgQ->bodyptr;
7247
7248 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pRsp, sizeof(tSirSmeAddStaSelfRsp)))
7249 {
7250 /// Buffer not available. Log error
7251 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for Add Sta self RSP\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07007252 palFreeMemory( pMac->hHdd, (tANI_U8 *)pAddStaSelfParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07007253 return;
7254 }
7255
7256 palZeroMemory(pMac, (tANI_U8*)pRsp, sizeof(tSirSmeAddStaSelfRsp));
7257
7258 pRsp->mesgType = eWNI_SME_ADD_STA_SELF_RSP;
7259 pRsp->mesgLen = (tANI_U16) sizeof(tSirSmeAddStaSelfRsp);
7260 pRsp->status = pAddStaSelfParams->status;
7261
7262 palCopyMemory( pMac->hHdd, pRsp->selfMacAddr, pAddStaSelfParams->selfMacAddr, sizeof(tSirMacAddr) );
7263
7264 palFreeMemory( pMac->hHdd, (tANI_U8 *)pAddStaSelfParams);
7265
7266 mmhMsg.type = eWNI_SME_ADD_STA_SELF_RSP;
7267 mmhMsg.bodyptr = pRsp;
7268 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007269 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07007270 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
7271
7272}
7273
7274void limProcessDelStaSelfRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ)
7275{
7276
7277 tpDelStaSelfParams pDelStaSelfParams;
7278 tSirMsgQ mmhMsg;
7279 tpSirSmeDelStaSelfRsp pRsp;
7280
7281
7282 pDelStaSelfParams = (tpDelStaSelfParams)limMsgQ->bodyptr;
7283
7284 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pRsp, sizeof(tSirSmeDelStaSelfRsp)))
7285 {
7286 /// Buffer not available. Log error
7287 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for Add Sta self RSP\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07007288 palFreeMemory( pMac->hHdd, (tANI_U8 *)pDelStaSelfParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07007289 return;
7290 }
7291
7292 palZeroMemory(pMac, (tANI_U8*)pRsp, sizeof(tSirSmeDelStaSelfRsp));
7293
7294 pRsp->mesgType = eWNI_SME_DEL_STA_SELF_RSP;
7295 pRsp->mesgLen = (tANI_U16) sizeof(tSirSmeDelStaSelfRsp);
7296 pRsp->status = pDelStaSelfParams->status;
7297
7298 palCopyMemory( pMac->hHdd, pRsp->selfMacAddr, pDelStaSelfParams->selfMacAddr, sizeof(tSirMacAddr) );
7299
7300 palFreeMemory( pMac->hHdd, (tANI_U8 *)pDelStaSelfParams);
7301
7302 mmhMsg.type = eWNI_SME_DEL_STA_SELF_RSP;
7303 mmhMsg.bodyptr = pRsp;
7304 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007305 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07007306 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
7307
7308}
7309
7310/***************************************************************
7311* tANI_U8 limUnmapChannel(tANI_U8 mapChannel)
7312* To unmap the channel to reverse the effect of mapping
7313* a band channel in hal .Mapping was done hal to overcome the
7314* limitation of the rxbd which use only 4 bit for channel number.
7315*****************************************************************/
7316tANI_U8 limUnmapChannel(tANI_U8 mapChannel)
7317{
7318 if( mapChannel > 0 && mapChannel < 25 )
7319 return abChannel[mapChannel -1];
7320 else
7321 return 0;
7322}
7323
7324
7325v_U8_t* limGetIEPtr(tpAniSirGlobal pMac, v_U8_t *pIes, int length, v_U8_t eid,eSizeOfLenField size_of_len_field)
7326{
7327 int left = length;
7328 v_U8_t *ptr = pIes;
7329 v_U8_t elem_id;
7330 v_U16_t elem_len;
7331
7332 while(left >= (size_of_len_field+1))
7333 {
7334 elem_id = ptr[0];
7335 if (size_of_len_field == TWO_BYTE)
7336 {
7337 elem_len = ((v_U16_t) ptr[1]) | (ptr[2]<<8);
7338 }
7339 else
7340 {
7341 elem_len = ptr[1];
7342 }
7343
7344
7345 left -= (size_of_len_field+1);
7346 if(elem_len > left)
7347 {
7348 limLog(pMac, LOGE,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007349 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007350 eid,elem_len,left);
7351 return NULL;
7352 }
7353 if (elem_id == eid)
7354 {
7355 return ptr;
7356 }
7357
7358 left -= elem_len;
7359 ptr += (elem_len + (size_of_len_field+1));
7360 }
7361 return NULL;
7362}
7363
7364/* return NULL if oui is not found in ie
7365 return !NULL pointer to vendor IE (starting from 0xDD) if oui is found
7366 */
7367v_U8_t* limGetVendorIEOuiPtr(tpAniSirGlobal pMac, tANI_U8 *oui, tANI_U8 oui_size, tANI_U8 *ie, tANI_U16 ie_len)
7368{
7369 int left = ie_len;
7370 v_U8_t *ptr = ie;
7371 v_U8_t elem_id, elem_len;
7372
7373 while(left >= 2)
7374 {
7375 elem_id = ptr[0];
7376 elem_len = ptr[1];
7377 left -= 2;
7378 if(elem_len > left)
7379 {
7380 limLog( pMac, LOGE,
7381 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****\n"),
7382 elem_id,elem_len,left);
7383 return NULL;
7384 }
7385 if (SIR_MAC_EID_VENDOR == elem_id)
7386 {
7387 if(memcmp(&ptr[2], oui, oui_size)==0)
7388 return ptr;
7389 }
7390
7391 left -= elem_len;
7392 ptr += (elem_len + 2);
7393 }
7394 return NULL;
7395}
7396
Jeff Johnson295189b2012-06-20 16:38:30 -07007397//Returns length of P2P stream and Pointer ie passed to this function is filled with noa stream
7398
7399v_U8_t limBuildP2pIe(tpAniSirGlobal pMac, tANI_U8 *ie, tANI_U8 *data, tANI_U8 ie_len)
7400{
7401 int length = 0;
7402 tANI_U8 *ptr = ie;
7403
7404 ptr[length++] = SIR_MAC_EID_VENDOR;
7405 ptr[length++] = ie_len + SIR_MAC_P2P_OUI_SIZE;
7406 palCopyMemory( pMac->hHdd, &ptr[length], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
7407 palCopyMemory( pMac->hHdd, &ptr[length + SIR_MAC_P2P_OUI_SIZE], data, ie_len);
7408 return (ie_len + SIR_P2P_IE_HEADER_LEN);
7409}
7410
7411//Returns length of NoA stream and Pointer pNoaStream passed to this function is filled with noa stream
7412
7413v_U8_t limGetNoaAttrStreamInMultP2pIes(tpAniSirGlobal pMac,v_U8_t* noaStream,v_U8_t noaLen,v_U8_t overFlowLen)
7414{
7415 v_U8_t overFlowP2pStream[SIR_MAX_NOA_ATTR_LEN];
7416 palCopyMemory( pMac->hHdd, overFlowP2pStream, noaStream + noaLen - overFlowLen, overFlowLen);
7417 noaStream[noaLen - overFlowLen] = SIR_MAC_EID_VENDOR;
7418 noaStream[noaLen - overFlowLen+1] = overFlowLen + SIR_MAC_P2P_OUI_SIZE;
7419 palCopyMemory( pMac->hHdd, noaStream+ noaLen - overFlowLen+2,SIR_MAC_P2P_OUI,SIR_MAC_P2P_OUI_SIZE);
7420
7421 palCopyMemory( pMac->hHdd, noaStream+ noaLen - overFlowLen+2+SIR_MAC_P2P_OUI_SIZE,overFlowP2pStream,overFlowLen);
7422 return (noaLen + SIR_P2P_IE_HEADER_LEN);
7423
7424}
7425
7426//Returns length of NoA stream and Pointer pNoaStream passed to this function is filled with noa stream
7427v_U8_t limGetNoaAttrStream(tpAniSirGlobal pMac, v_U8_t*pNoaStream,tpPESession psessionEntry)
7428{
7429 v_U8_t len=0;
7430
7431 v_U8_t *pBody = pNoaStream;
7432
7433
7434 if ( (psessionEntry != NULL) && (psessionEntry->valid) &&
7435 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
7436 {
7437 if ((!(psessionEntry->p2pGoPsUpdate.uNoa1Duration)) && (!(psessionEntry->p2pGoPsUpdate.uNoa2Duration))
7438 && (!psessionEntry->p2pGoPsUpdate.oppPsFlag)
7439 )
7440 return 0; //No NoA Descriptor then return 0
7441
7442
7443 pBody[0] = SIR_P2P_NOA_ATTR;
7444
7445 pBody[3] = psessionEntry->p2pGoPsUpdate.index;
7446 pBody[4] = psessionEntry->p2pGoPsUpdate.ctWin | (psessionEntry->p2pGoPsUpdate.oppPsFlag<<7);
7447 len = 5;
7448 pBody += len;
7449
7450
7451 if (psessionEntry->p2pGoPsUpdate.uNoa1Duration)
7452 {
7453 *pBody = psessionEntry->p2pGoPsUpdate.uNoa1IntervalCnt;
7454 pBody += 1;
7455 len +=1;
7456
7457 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa1Duration);
7458 pBody += sizeof(tANI_U32);
7459 len +=4;
7460
7461 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa1Interval);
7462 pBody += sizeof(tANI_U32);
7463 len +=4;
7464
7465 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa1StartTime);
7466 pBody += sizeof(tANI_U32);
7467 len +=4;
7468
7469 }
7470
7471 if (psessionEntry->p2pGoPsUpdate.uNoa2Duration)
7472 {
7473 *pBody = psessionEntry->p2pGoPsUpdate.uNoa2IntervalCnt;
7474 pBody += 1;
7475 len +=1;
7476
7477 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa2Duration);
7478 pBody += sizeof(tANI_U32);
7479 len +=4;
7480
7481 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa2Interval);
7482 pBody += sizeof(tANI_U32);
7483 len +=4;
7484
7485 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa2StartTime);
7486 pBody += sizeof(tANI_U32);
7487 len +=4;
7488
7489 }
7490
7491
7492 pBody = pNoaStream + 1;
7493 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(len-3);/*one byte for Attr and 2 bytes for length*/
7494
7495 return (len);
7496
7497 }
7498 return 0;
7499
7500}
Jeff Johnsone7245742012-09-05 17:12:55 -07007501
7502void peSetResumeChannel(tpAniSirGlobal pMac, tANI_U16 channel, ePhyChanBondState phyCbState)
Jeff Johnson295189b2012-06-20 16:38:30 -07007503{
7504
7505 pMac->lim.gResumeChannel = channel;
Jeff Johnsone7245742012-09-05 17:12:55 -07007506 pMac->lim.gResumePhyCbState = phyCbState;
Jeff Johnson295189b2012-06-20 16:38:30 -07007507}
Jeff Johnsone7245742012-09-05 17:12:55 -07007508
Jeff Johnson295189b2012-06-20 16:38:30 -07007509/*--------------------------------------------------------------------------
7510
7511 \brief peGetResumeChannel() - Returns the channel number for scanning, from a valid session.
7512
Jeff Johnsone7245742012-09-05 17:12:55 -07007513 This function returns the channel to resume to during link resume. channel id of 0 means HAL will
7514 resume to previous channel before link suspend
Jeff Johnson295189b2012-06-20 16:38:30 -07007515
7516 \param pMac - pointer to global adapter context
7517 \return - channel to scan from valid session else zero.
7518
7519 \sa
7520
7521 --------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07007522void peGetResumeChannel(tpAniSirGlobal pMac, tANI_U8* resumeChannel, ePhyChanBondState* resumePhyCbState)
Jeff Johnson295189b2012-06-20 16:38:30 -07007523{
7524
7525 //Rationale - this could be the suspend/resume for assoc and it is essential that
7526 //the new BSS is active for some time. Other BSS was anyway suspended.
7527 //TODO: Comeup with a better alternative. Sending NULL with PM=0 on other BSS means
7528 //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 -07007529 //and hence should be ok. Need to discuss this further
7530 if( !limIsInMCC(pMac) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007531 {
7532 //Get current active session channel
Jeff Johnsone7245742012-09-05 17:12:55 -07007533 peGetActiveSessionChannel(pMac, resumeChannel, resumePhyCbState);
Jeff Johnson295189b2012-06-20 16:38:30 -07007534 }
7535 else
7536 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007537 *resumeChannel = pMac->lim.gResumeChannel;
7538 *resumePhyCbState = pMac->lim.gResumePhyCbState;
Jeff Johnson295189b2012-06-20 16:38:30 -07007539 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007540 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007541}
7542
Viral Modid86bde22012-12-10 13:09:21 -08007543tANI_BOOLEAN limIsNOAInsertReqd(tpAniSirGlobal pMac)
7544{
7545 tANI_U8 i;
7546 for(i =0; i < pMac->lim.maxBssId; i++)
7547 {
7548 if(pMac->lim.gpSession[i].valid == TRUE)
7549 {
7550 if( (eLIM_AP_ROLE == pMac->lim.gpSession[i].limSystemRole )
7551 && ( VOS_P2P_GO_MODE == pMac->lim.gpSession[i].pePersona )
7552 )
7553 {
7554 return TRUE;
7555 }
7556 }
7557 }
7558 return FALSE;
7559}
Jeff Johnsone7245742012-09-05 17:12:55 -07007560
Jeff Johnson295189b2012-06-20 16:38:30 -07007561
7562tANI_BOOLEAN limIsconnectedOnDFSChannel(tANI_U8 currentChannel)
7563{
7564 if(NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(currentChannel))
7565 {
7566 return eANI_BOOLEAN_TRUE;
7567 }
7568 else
7569 {
7570 return eANI_BOOLEAN_FALSE;
7571 }
7572}
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07007573
Mohit Khanna4a70d262012-09-11 16:30:12 -07007574#ifdef WLAN_FEATURE_11AC
7575tANI_BOOLEAN limCheckVHTOpModeChange( tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 chanWidth, tANI_U8 staId)
7576{
7577 tUpdateVHTOpMode tempParam;
7578
7579 tempParam.opMode = chanWidth;
7580 tempParam.staId = staId;
7581
7582 limSendModeUpdate( pMac, &tempParam, psessionEntry );
7583
7584 return eANI_BOOLEAN_TRUE;
7585}
Madan Mohan Koyyalamudi6db7ad12012-10-29 16:14:41 -07007586#endif
7587
7588tANI_U8 limGetShortSlotFromPhyMode(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U32 phyMode)
7589{
7590 tANI_U8 val=0;
7591
7592 if (phyMode == WNI_CFG_PHY_MODE_11A)
7593 {
7594 // 11a mode always uses short slot
7595 // Check this since some APs in 11a mode broadcast long slot in their beacons. As per standard, always use what PHY mandates.
7596 val = true;
7597 }
7598 else if (phyMode == WNI_CFG_PHY_MODE_11G)
7599 {
7600 if ((psessionEntry->pePersona == VOS_STA_SAP_MODE) ||
7601 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
7602 {
7603 val = true;
7604 }
7605
7606 // Program Polaris based on AP capability
7607
7608 if (psessionEntry->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE)
7609 // Joining BSS.
7610 val = SIR_MAC_GET_SHORT_SLOT_TIME( psessionEntry->limCurrentBssCaps);
7611 else if (psessionEntry->limMlmState == eLIM_MLM_WT_REASSOC_RSP_STATE)
7612 // Reassociating with AP.
7613 val = SIR_MAC_GET_SHORT_SLOT_TIME( psessionEntry->limReassocBssCaps);
7614 }
7615 else // if (phyMode == WNI_CFG_PHY_MODE_11B) - use this if another phymode is added later ON
7616 {
7617 // Will reach here in 11b case
7618 val = false;
7619 }
7620 limLog(pMac, LOG1, FL("phyMode = %u shortslotsupported = %u\n"), phyMode, val);
7621 return val;
7622}