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