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