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