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