blob: b48d55f22e013a43cc3991eb969b60a978ea7e65 [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
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -0800971 // Deactivate and delete Periodic Join Probe Request timer.
972 tx_timer_deactivate(&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer);
973 tx_timer_delete(&pMac->lim.limTimers.gLimPeriodicJoinProbeReqTimer);
974
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 // Deactivate and delete Association failure timer.
976 tx_timer_deactivate(&pMac->lim.limTimers.gLimAssocFailureTimer);
977 tx_timer_delete(&pMac->lim.limTimers.gLimAssocFailureTimer);
978
979 // Deactivate and delete Reassociation failure timer.
980 tx_timer_deactivate(&pMac->lim.limTimers.gLimReassocFailureTimer);
981 tx_timer_delete(&pMac->lim.limTimers.gLimReassocFailureTimer);
982
983 // Deactivate and delete Authentication failure timer.
984 tx_timer_deactivate(&pMac->lim.limTimers.gLimAuthFailureTimer);
985 tx_timer_delete(&pMac->lim.limTimers.gLimAuthFailureTimer);
986
987 // Deactivate and delete Heartbeat timer.
988 tx_timer_deactivate(&pMac->lim.limTimers.gLimHeartBeatTimer);
989 tx_timer_delete(&pMac->lim.limTimers.gLimHeartBeatTimer);
990
991 // Deactivate and delete wait-for-probe-after-Heartbeat timer.
992 tx_timer_deactivate(&pMac->lim.limTimers.gLimProbeAfterHBTimer);
993 tx_timer_delete(&pMac->lim.limTimers.gLimProbeAfterHBTimer);
994
995 // Deactivate and delete Quiet timer.
996 tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietTimer);
997 tx_timer_delete(&pMac->lim.limTimers.gLimQuietTimer);
998
999 // Deactivate and delete Quiet BSS timer.
1000 tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietBssTimer);
1001 tx_timer_delete(&pMac->lim.limTimers.gLimQuietBssTimer);
1002
1003#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
1004 // Deactivate and delete LIM background scan timer.
1005 tx_timer_deactivate(&pMac->lim.limTimers.gLimBackgroundScanTimer);
1006 tx_timer_delete(&pMac->lim.limTimers.gLimBackgroundScanTimer);
1007#endif
1008
1009
1010 // Deactivate and delete cnf wait timer
1011 for (n = 0; n < pMac->lim.maxStation; n++)
1012 {
1013 tx_timer_deactivate(&pMac->lim.limTimers.gpLimCnfWaitTimer[n]);
1014 tx_timer_delete(&pMac->lim.limTimers.gpLimCnfWaitTimer[n]);
1015 }
1016
1017 // Deactivate and delete keepalive timer
1018 tx_timer_deactivate(&pMac->lim.limTimers.gLimKeepaliveTimer);
1019 tx_timer_delete(&pMac->lim.limTimers.gLimKeepaliveTimer);
1020
1021 pAuthNode = pMac->lim.gLimPreAuthTimerTable.pTable;
1022
1023 //Deactivate any Authentication response timers
1024 limDeletePreAuthList(pMac);
1025
1026 for (n = 0; n < pMac->lim.gLimPreAuthTimerTable.numEntry; n++,pAuthNode++)
1027 {
1028 // Delete any Authentication response
1029 // timers, which might have been started.
1030 tx_timer_delete(&pAuthNode->timer);
1031 }
1032
1033#ifdef ANI_PRODUCT_TYPE_AP
1034
1035 if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE)
1036 {
1037 // Deactivate and cleanup the periodic pre-auth
1038 // cleanup timer
1039
1040 tx_timer_deactivate(&pMac->lim.limTimers.gLimPreAuthClnupTimer);
1041 tx_timer_delete(&pMac->lim.limTimers.gLimPreAuthClnupTimer);
1042
1043 /// Deactivate and delete OLBC cache update timeout
1044 tx_timer_deactivate(&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer);
1045 tx_timer_delete(&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer);
1046
1047 }
1048#endif
1049
1050
1051 // Deactivate and delete Hash Miss throttle timer
1052 tx_timer_deactivate(&pMac->lim.limTimers.gLimSendDisassocFrameThresholdTimer);
1053 tx_timer_delete(&pMac->lim.limTimers.gLimSendDisassocFrameThresholdTimer);
1054
1055#ifdef WLAN_SOFTAP_FEATURE
1056 tx_timer_deactivate(&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer);
1057 tx_timer_delete(&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer);
1058 tx_timer_deactivate(&pMac->lim.limTimers.gLimPreAuthClnupTimer);
1059 tx_timer_delete(&pMac->lim.limTimers.gLimPreAuthClnupTimer);
1060
1061#if 0 // The WPS PBC clean up timer is disabled
1062 if (pMac->lim.gLimSystemRole == eLIM_AP_ROLE)
1063 {
1064 if(pMac->lim.limTimers.gLimWPSOverlapTimerObj.isTimerCreated == eANI_BOOLEAN_TRUE)
1065 {
1066 tx_timer_deactivate(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer);
1067 tx_timer_delete(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer);
1068 pMac->lim.limTimers.gLimWPSOverlapTimerObj.isTimerCreated = eANI_BOOLEAN_FALSE;
1069 }
1070 }
1071#endif
1072#endif
1073#ifdef WLAN_FEATURE_VOWIFI_11R
1074 // Deactivate and delete FT Preauth response timer
1075 tx_timer_deactivate(&pMac->lim.limTimers.gLimFTPreAuthRspTimer);
1076 tx_timer_delete(&pMac->lim.limTimers.gLimFTPreAuthRspTimer);
1077#endif
1078
1079#ifdef WLAN_FEATURE_P2P
1080 // Deactivate and delete remain on channel timer
1081 tx_timer_deactivate(&pMac->lim.limTimers.gLimRemainOnChannelTimer);
1082 tx_timer_delete(&pMac->lim.limTimers.gLimRemainOnChannelTimer);
1083#endif
1084
1085#ifdef FEATURE_WLAN_CCX
1086 // Deactivate and delete TSM
1087 tx_timer_deactivate(&pMac->lim.limTimers.gLimCcxTsmTimer);
1088 tx_timer_delete(&pMac->lim.limTimers.gLimCcxTsmTimer);
1089#endif
1090
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08001091 tx_timer_deactivate(&pMac->lim.limTimers.gLimDisassocAckTimer);
1092 tx_timer_delete(&pMac->lim.limTimers.gLimDisassocAckTimer);
1093
1094 tx_timer_deactivate(&pMac->lim.limTimers.gLimDeauthAckTimer);
1095 tx_timer_delete(&pMac->lim.limTimers.gLimDeauthAckTimer);
1096
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 pMac->lim.gLimTimersCreated = 0;
1098 }
1099
1100 /// Cleanup cached scan list
1101 limReInitScanResults(pMac);
1102
1103} /*** end limCleanupMlm() ***/
1104
1105
1106
1107/**
1108 * limCleanupLmm()
1109 *
1110 *FUNCTION:
1111 * This function is called to cleanup any resources
1112 * allocated by LMM sub-module.
1113 *
1114 *PARAMS:
1115 *
1116 *LOGIC:
1117 *
1118 *ASSUMPTIONS:
1119 * NA
1120 *
1121 *NOTE:
1122 * NA
1123 *
1124 * @param pMac Pointer to Global MAC structure
1125 * @return None
1126 */
1127
1128void
1129limCleanupLmm(tpAniSirGlobal pMac)
1130{
1131#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined (ANI_PRODUCT_TYPE_AP)
1132 limCleanupMeasResources(pMac);
1133 pMac->sys.gSysEnableLearnMode = eANI_BOOLEAN_FALSE;
1134#endif
1135} /*** end limCleanupLmm() ***/
1136
1137
1138
1139/**
1140 * limIsAddrBC()
1141 *
1142 *FUNCTION:
1143 * This function is called in various places within LIM code
1144 * to determine whether passed MAC address is a broadcast or not
1145 *
1146 *LOGIC:
1147 *
1148 *ASSUMPTIONS:
1149 * NA
1150 *
1151 *NOTE:
1152 * NA
1153 *
1154 * @param macAddr Indicates MAC address that need to be determined
1155 * whether it is Broadcast address or not
1156 *
1157 * @return true if passed address is Broadcast address else false
1158 */
1159
1160tANI_U8
1161limIsAddrBC(tSirMacAddr macAddr)
1162{
1163 int i;
1164 for (i = 0; i < 6; i++)
1165 {
1166 if ((macAddr[i] & 0xFF) != 0xFF)
1167 return false;
1168 }
1169
1170 return true;
1171} /****** end limIsAddrBC() ******/
1172
1173
1174
1175/**
1176 * limIsGroupAddr()
1177 *
1178 *FUNCTION:
1179 * This function is called in various places within LIM code
1180 * to determine whether passed MAC address is a group address or not
1181 *
1182 *LOGIC:
1183 * If least significant bit of first octet of the MAC address is
1184 * set to 1, it is a Group address.
1185 *
1186 *ASSUMPTIONS:
1187 * NA
1188 *
1189 *NOTE:
1190 * NA
1191 *
1192 * @param macAddr Indicates MAC address that need to be determined
1193 * whether it is Group address or not
1194 *
1195 * @return true if passed address is Group address else false
1196 */
1197
1198tANI_U8
1199limIsGroupAddr(tSirMacAddr macAddr)
1200{
1201 if ((macAddr[0] & 0x01) == 0x01)
1202 return true;
1203 else
1204 return false;
1205} /****** end limIsGroupAddr() ******/
1206
1207/**
1208 * limPostMsgApiNoWait()
1209 *
1210 *FUNCTION:
1211 * This function is called from other thread while posting a
1212 * message to LIM message Queue gSirLimMsgQ with NO_WAIT option
1213 *
1214 *LOGIC:
1215 * NA
1216 *
1217 *ASSUMPTIONS:
1218 * NA
1219 *
1220 *NOTE:
1221 * NA
1222 *
1223 * @param pMsg - Pointer to the Global MAC structure
1224 * @param pMsg - Pointer to the message structure
1225 * @return None
1226 */
1227
1228tANI_U32
1229limPostMsgApiNoWait(tpAniSirGlobal pMac, tSirMsgQ *pMsg)
1230{
1231#ifdef ANI_OS_TYPE_WINDOWS
1232 tANI_U32 retCode;
1233
1234 if ((retCode = tx_queue_send(&pMac->sys.gSirLimMsgQ, pMsg, TX_NO_WAIT))
1235 != TX_SUCCESS)
1236 {
1237 // Failure in sending DFS duration timeout indication
1238 // to LIM thread
1239
1240 // Log error
1241 limLog(pMac, LOGP,
1242 FL("could not post a message %X to LIM msgq, status=%d\n"),
1243 pMsg->type, retCode);
1244 }
1245
1246 return retCode;
1247#else
1248 limProcessMessages(pMac, pMsg);
1249 return TX_SUCCESS;
1250#endif
1251} /*** end limPostMsgApiNoWait() ***/
1252
1253
1254
1255/**
1256 * limPrintMacAddr()
1257 *
1258 *FUNCTION:
1259 * This function is called to print passed MAC address
1260 * in : format.
1261 *
1262 *LOGIC:
1263 *
1264 *ASSUMPTIONS:
1265 * NA
1266 *
1267 *NOTE:
1268 * @param macAddr - MacAddr to be printed
1269 * @param logLevel - Loglevel to be used
1270 *
1271 * @return None.
1272 */
1273
1274void
1275limPrintMacAddr(tpAniSirGlobal pMac, tSirMacAddr macAddr, tANI_U8 logLevel)
1276{
1277 limLog(pMac, logLevel,
1278 FL("%X:%X:%X:%X:%X:%X\n"),
1279 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
1280 macAddr[5]);
1281} /****** end limPrintMacAddr() ******/
1282
1283
1284
1285
1286
1287
1288/*
1289 * limResetDeferredMsgQ()
1290 *
1291 *FUNCTION:
1292 * This function resets the deferred message queue parameters.
1293 *
1294 *PARAMS:
1295 * @param pMac - Pointer to Global MAC structure
1296 *
1297 *LOGIC:
1298 *
1299 *ASSUMPTIONS:
1300 * NA
1301 *
1302 *NOTE:
1303 * NA
1304 *
1305 *RETURNS:
1306 * None
1307 */
1308
1309void limResetDeferredMsgQ(tpAniSirGlobal pMac)
1310{
1311 pMac->lim.gLimDeferredMsgQ.size =
1312 pMac->lim.gLimDeferredMsgQ.write =
1313 pMac->lim.gLimDeferredMsgQ.read = 0;
1314
1315}
1316
1317
1318#define LIM_DEFERRED_Q_CHECK_THRESHOLD (MAX_DEFERRED_QUEUE_LEN/2)
1319#define LIM_MAX_NUM_MGMT_FRAME_DEFERRED (MAX_DEFERRED_QUEUE_LEN/2)
1320
1321/*
1322 * limWriteDeferredMsgQ()
1323 *
1324 *FUNCTION:
1325 * This function queues up a deferred message for later processing on the
1326 * STA side.
1327 *
1328 *PARAMS:
1329 * @param pMac - Pointer to Global MAC structure
1330 * @param limMsg - a LIM message
1331 *
1332 *LOGIC:
1333 *
1334 *ASSUMPTIONS:
1335 * NA
1336 *
1337 *NOTE:
1338 * NA
1339 *
1340 *RETURNS:
1341 * None
1342 */
1343
1344tANI_U8 limWriteDeferredMsgQ(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
1345{
1346 PELOG1(limLog(pMac, LOG1,
1347 FL("** Queue a deferred message (size %d, write %d) - type 0x%x **\n"),
1348 pMac->lim.gLimDeferredMsgQ.size, pMac->lim.gLimDeferredMsgQ.write,
1349 limMsg->type);)
1350
1351 /*
1352 ** check if the deferred message queue is full
1353 **/
1354 if (pMac->lim.gLimDeferredMsgQ.size >= MAX_DEFERRED_QUEUE_LEN)
1355 {
1356 PELOGE(limLog(pMac, LOGE, FL("Deferred Message Queue is full. Msg: %d\n"), limMsg->type);)
1357 return TX_QUEUE_FULL;
1358 }
1359
1360 /*
1361 ** In the application, there should not be more than 1 message get
1362 ** queued up. If happens, flags a warning. In the future, this can
1363 ** happen.
1364 **/
1365 if (pMac->lim.gLimDeferredMsgQ.size > 0)
1366 {
Jeff Johnsone7245742012-09-05 17:12:55 -07001367 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 -07001368 pMac->lim.gLimDeferredMsgQ.size, limMsg->type,
1369 limIsSystemInScanState(pMac),
1370 pMac->lim.gLimSmeState, pMac->lim.gLimMlmState,
1371 pMac->lim.gLimAddtsSent);)
1372 }
1373
1374 /*
1375 ** To prevent the deferred Q is full of management frames, only give them certain space
1376 **/
1377 if( SIR_BB_XPORT_MGMT_MSG == limMsg->type )
1378 {
1379 if( LIM_DEFERRED_Q_CHECK_THRESHOLD < pMac->lim.gLimDeferredMsgQ.size )
1380 {
1381 tANI_U16 idx, count = 0;
1382 for(idx = 0; idx < pMac->lim.gLimDeferredMsgQ.size; idx++)
1383 {
1384 if( SIR_BB_XPORT_MGMT_MSG == pMac->lim.gLimDeferredMsgQ.deferredQueue[idx].type )
1385 {
1386 count++;
1387 }
1388 }
1389 if( LIM_MAX_NUM_MGMT_FRAME_DEFERRED < count )
1390 {
1391 //We reach the quota for management frames, drop this one
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07001392 PELOGW(limLog(pMac, LOGW, FL("Cannot deferred. Msg: %d Too many (count=%d) already"), limMsg->type, count);)
Jeff Johnson295189b2012-06-20 16:38:30 -07001393 //Return error, caller knows what to do
1394 return TX_QUEUE_FULL;
1395 }
1396 }
1397 }
1398
1399 ++pMac->lim.gLimDeferredMsgQ.size;
1400
1401 /*
1402 ** if the write pointer hits the end of the queue, rewind it
1403 **/
1404 if (pMac->lim.gLimDeferredMsgQ.write >= MAX_DEFERRED_QUEUE_LEN)
1405 pMac->lim.gLimDeferredMsgQ.write = 0;
1406
1407 /*
1408 ** save the message to the queue and advanced the write pointer
1409 **/
1410 palCopyMemory(pMac->hHdd,
1411 (tANI_U8 *)&pMac->lim.gLimDeferredMsgQ.deferredQueue[pMac->lim.gLimDeferredMsgQ.write++],
1412 (tANI_U8 *)limMsg,
1413 sizeof(tSirMsgQ));
1414 return TX_SUCCESS;
1415
1416}
1417
1418/*
1419 * limReadDeferredMsgQ()
1420 *
1421 *FUNCTION:
1422 * This function dequeues a deferred message for processing on the
1423 * STA side.
1424 *
1425 *PARAMS:
1426 * @param pMac - Pointer to Global MAC structure
1427 *
1428 *LOGIC:
1429 *
1430 *ASSUMPTIONS:
1431 * NA
1432 *
1433 *NOTE:
1434 *
1435 *
1436 *RETURNS:
1437 * Returns the message at the head of the deferred message queue
1438 */
1439
1440tSirMsgQ* limReadDeferredMsgQ(tpAniSirGlobal pMac)
1441{
1442 tSirMsgQ *msg;
1443
1444 /*
1445 ** check any messages left. If no, return
1446 **/
1447 if (pMac->lim.gLimDeferredMsgQ.size <= 0)
1448 return NULL;
1449
1450 /*
1451 ** decrement the queue size
1452 **/
1453 pMac->lim.gLimDeferredMsgQ.size--;
1454
1455 /*
1456 ** retrieve the message from the head of the queue
1457 **/
1458 msg = &pMac->lim.gLimDeferredMsgQ.deferredQueue[pMac->lim.gLimDeferredMsgQ.read];
1459
1460 /*
1461 ** advance the read pointer
1462 **/
1463 pMac->lim.gLimDeferredMsgQ.read++;
1464
1465 /*
1466 ** if the read pointer hits the end of the queue, rewind it
1467 **/
1468 if (pMac->lim.gLimDeferredMsgQ.read >= MAX_DEFERRED_QUEUE_LEN)
1469 pMac->lim.gLimDeferredMsgQ.read = 0;
1470
1471 PELOG1(limLog(pMac, LOG1,
1472 FL("** DeQueue a deferred message (size %d read %d) - type 0x%x **\n"),
1473 pMac->lim.gLimDeferredMsgQ.size, pMac->lim.gLimDeferredMsgQ.read,
1474 msg->type);)
1475
Jeff Johnsone7245742012-09-05 17:12:55 -07001476 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 -07001477 limIsSystemInScanState(pMac),
1478 pMac->lim.gLimSmeState, pMac->lim.gLimMlmState,
1479 pMac->lim.gLimAddtsSent);)
1480
1481 return(msg);
1482}
1483
1484tSirRetStatus
1485limSysProcessMmhMsgApi(tpAniSirGlobal pMac,
1486 tSirMsgQ *pMsg,
1487 tANI_U8 qType)
1488{
1489// FIXME
1490#if defined( FEATURE_WLAN_INTEGRATED_SOC )
1491 SysProcessMmhMsg(pMac, pMsg);
1492 return eSIR_SUCCESS;
1493#else
1494 return(halMmhPostMsgApi(pMac, pMsg, qType));
1495#endif
1496}
1497
1498char *limFrameStr(tANI_U32 type, tANI_U32 subType)
1499{
1500#ifdef FIXME_GEN6
1501
1502 if (type == SIR_MAC_MGMT_FRAME)
1503 {
1504 switch (subType)
1505 {
1506 case SIR_MAC_MGMT_ASSOC_REQ:
1507 return "MAC_MGMT_ASSOC_REQ";
1508 case SIR_MAC_MGMT_ASSOC_RSP:
1509 return "MAC_MGMT_ASSOC_RSP";
1510 case SIR_MAC_MGMT_REASSOC_REQ:
1511 return "MAC_MGMT_REASSOC_REQ";
1512 case SIR_MAC_MGMT_REASSOC_RSP:
1513 return "MAC_MGMT_REASSOC_RSP";
1514 case SIR_MAC_MGMT_PROBE_REQ:
1515 return "MAC_MGMT_PROBE_REQ";
1516 case SIR_MAC_MGMT_PROBE_RSP:
1517 return "MAC_MGMT_PROBE_RSP";
1518 case SIR_MAC_MGMT_BEACON:
1519 return "MAC_MGMT_BEACON";
1520 case SIR_MAC_MGMT_ATIM:
1521 return "MAC_MGMT_ATIM";
1522 case SIR_MAC_MGMT_DISASSOC:
1523 return "MAC_MGMT_DISASSOC";
1524 case SIR_MAC_MGMT_AUTH:
1525 return "MAC_MGMT_AUTH";
1526 case SIR_MAC_MGMT_DEAUTH:
1527 return "MAC_MGMT_DEAUTH";
1528 case SIR_MAC_MGMT_ACTION:
1529 return "MAC_MGMT_ACTION";
1530 case SIR_MAC_MGMT_RESERVED15:
1531 return "MAC_MGMT_RESERVED15";
1532 default:
1533 return "Unknown MGMT Frame";
1534 }
1535 }
1536
1537 else if (type == SIR_MAC_CTRL_FRAME)
1538 {
1539 switch (subType)
1540 {
1541 case SIR_MAC_CTRL_RR:
1542 return "MAC_CTRL_RR";
1543 case SIR_MAC_CTRL_BAR:
1544 return "MAC_CTRL_BAR";
1545 case SIR_MAC_CTRL_BA:
1546 return "MAC_CTRL_BA";
1547 case SIR_MAC_CTRL_PS_POLL:
1548 return "MAC_CTRL_PS_POLL";
1549 case SIR_MAC_CTRL_RTS:
1550 return "MAC_CTRL_RTS";
1551 case SIR_MAC_CTRL_CTS:
1552 return "MAC_CTRL_CTS";
1553 case SIR_MAC_CTRL_ACK:
1554 return "MAC_CTRL_ACK";
1555 case SIR_MAC_CTRL_CF_END:
1556 return "MAC_CTRL_CF_END";
1557 case SIR_MAC_CTRL_CF_END_ACK:
1558 return "MAC_CTRL_CF_END_ACK";
1559 default:
1560 return "Unknown CTRL Frame";
1561 }
1562 }
1563
1564 else if (type == SIR_MAC_DATA_FRAME)
1565 {
1566 switch (subType)
1567 {
1568 case SIR_MAC_DATA_DATA:
1569 return "MAC_DATA_DATA";
1570 case SIR_MAC_DATA_DATA_ACK:
1571 return "MAC_DATA_DATA_ACK";
1572 case SIR_MAC_DATA_DATA_POLL:
1573 return "MAC_DATA_DATA_POLL";
1574 case SIR_MAC_DATA_DATA_ACK_POLL:
1575 return "MAC_DATA_DATA_ACK_POLL";
1576 case SIR_MAC_DATA_NULL:
1577 return "MAC_DATA_NULL";
1578 case SIR_MAC_DATA_NULL_ACK:
1579 return "MAC_DATA_NULL_ACK";
1580 case SIR_MAC_DATA_NULL_POLL:
1581 return "MAC_DATA_NULL_POLL";
1582 case SIR_MAC_DATA_NULL_ACK_POLL:
1583 return "MAC_DATA_NULL_ACK_POLL";
1584 case SIR_MAC_DATA_QOS_DATA:
1585 return "MAC_DATA_QOS_DATA";
1586 case SIR_MAC_DATA_QOS_DATA_ACK:
1587 return "MAC_DATA_QOS_DATA_ACK";
1588 case SIR_MAC_DATA_QOS_DATA_POLL:
1589 return "MAC_DATA_QOS_DATA_POLL";
1590 case SIR_MAC_DATA_QOS_DATA_ACK_POLL:
1591 return "MAC_DATA_QOS_DATA_ACK_POLL";
1592 case SIR_MAC_DATA_QOS_NULL:
1593 return "MAC_DATA_QOS_NULL";
1594 case SIR_MAC_DATA_QOS_NULL_ACK:
1595 return "MAC_DATA_QOS_NULL_ACK";
1596 case SIR_MAC_DATA_QOS_NULL_POLL:
1597 return "MAC_DATA_QOS_NULL_POLL";
1598 case SIR_MAC_DATA_QOS_NULL_ACK_POLL:
1599 return "MAC_DATA_QOS_NULL_ACK_POLL";
1600 default:
1601 return "Unknown Data Frame";
1602 }
1603 }
1604 else
1605 return "Unknown";
1606#endif
1607return "";
1608}
1609
1610#ifdef WLAN_SOFTAP_FEATURE
1611void limHandleUpdateOlbcCache(tpAniSirGlobal pMac)
1612{
1613 int i;
1614 static int enable;
1615 tUpdateBeaconParams beaconParams;
1616
1617 tpPESession psessionEntry = limIsApSessionActive(pMac);
1618
1619 if (psessionEntry == NULL)
Madan Mohan Koyyalamudi788b4ee2012-09-25 10:42:09 -07001620 {
1621 PELOGE(limLog(pMac, LOGE, FL(" Session not found\n"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001622 return;
Madan Mohan Koyyalamudi788b4ee2012-09-25 10:42:09 -07001623 }
Pratik Bhalgatb44ea3f2012-11-22 16:41:39 +05301624
Madan Mohan Koyyalamudib2733142012-10-31 13:59:17 -07001625 palZeroMemory( pMac->hHdd, ( tANI_U8* )&beaconParams, sizeof( tUpdateBeaconParams) );
1626 beaconParams.bssIdx = psessionEntry->bssIdx;
Jeff Johnson295189b2012-06-20 16:38:30 -07001627
1628 beaconParams.paramChangeBitmap = 0;
1629 /*
1630 ** This is doing a 2 pass check. The first pass is to invalidate
1631 ** all the cache entries. The second pass is to decide whether to
1632 ** disable protection.
1633 **/
1634 if (!enable)
1635 {
1636
1637 PELOG2(limLog(pMac, LOG2, FL("Resetting OLBC cache\n"));)
1638 psessionEntry->gLimOlbcParams.numSta = 0;
1639 psessionEntry->gLimOverlap11gParams.numSta = 0;
1640 psessionEntry->gLimOverlapHt20Params.numSta = 0;
1641 psessionEntry->gLimNonGfParams.numSta = 0;
1642 psessionEntry->gLimLsigTxopParams.numSta = 0;
1643
1644 for (i=0; i < LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
1645 pMac->lim.protStaOverlapCache[i].active = false;
1646
1647 enable = 1;
1648 }
1649 else
1650 {
1651
Madan Mohan Koyyalamudi788b4ee2012-09-25 10:42:09 -07001652 if (!psessionEntry->gLimOlbcParams.numSta)
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 {
1654 if (psessionEntry->gLimOlbcParams.protectionEnabled)
1655 {
1656 if (!psessionEntry->gLim11bParams.protectionEnabled)
1657 {
1658 PELOG1(limLog(pMac, LOG1, FL("Overlap cache all clear and no 11B STA detected\n"));)
1659 limEnable11gProtection(pMac, false, true, &beaconParams, psessionEntry);
1660 }
1661 }
1662 }
1663
1664 if (!psessionEntry->gLimOverlap11gParams.numSta)
1665 {
1666 if (psessionEntry->gLimOverlap11gParams.protectionEnabled)
1667 {
1668 if (!psessionEntry->gLim11gParams.protectionEnabled)
1669 {
1670 PELOG1(limLog(pMac, LOG1, FL("Overlap cache all clear and no 11G STA detected\n"));)
1671 limEnableHtProtectionFrom11g(pMac, false, true, &beaconParams,psessionEntry);
1672 }
1673 }
1674 }
1675
1676 if (!psessionEntry->gLimOverlapHt20Params.numSta)
1677 {
1678 if (psessionEntry->gLimOverlapHt20Params.protectionEnabled)
1679 {
1680 if (!psessionEntry->gLimHt20Params.protectionEnabled)
1681 {
1682 PELOG1(limLog(pMac, LOG1, FL("Overlap cache all clear and no HT20 STA detected\n"));)
1683 limEnable11gProtection(pMac, false, true, &beaconParams,psessionEntry);
1684 }
1685 }
1686 }
1687
1688 enable = 0;
1689 }
1690
1691 if(beaconParams.paramChangeBitmap)
1692 {
1693 schSetFixedBeaconFields(pMac,psessionEntry);
1694 limSendBeaconParams(pMac, &beaconParams, psessionEntry);
1695 }
1696
1697 // Start OLBC timer
1698 if (tx_timer_activate(&pMac->lim.limTimers.gLimUpdateOlbcCacheTimer) != TX_SUCCESS)
1699 {
1700 limLog(pMac, LOGE, FL("tx_timer_activate failed\n"));
1701 }
1702}
1703#endif
1704
1705/**
1706 * limIsNullSsid()
1707 *
1708 *FUNCTION:
1709 * This function checks if Ssid supplied is Null SSID
1710 *
1711 *
1712 *LOGIC:
1713 *
1714 *ASSUMPTIONS:
1715 * NA
1716 *
1717 *NOTE:
1718 * NA
1719 *
1720 * @param tSirMacSSid *
1721 *
1722 *
1723 * @return true if SSID is Null SSID else false
1724 */
1725
1726tANI_U8
1727limIsNullSsid( tSirMacSSid *pSsid )
1728{
1729 tANI_U8 fNullSsid = false;
1730 tANI_U32 SsidLength;
1731 tANI_U8 *pSsidStr;
1732
1733 do
1734 {
1735 if ( 0 == pSsid->length )
1736 {
1737 fNullSsid = true;
1738 break;
1739 }
1740
1741#define ASCII_SPACE_CHARACTER 0x20
1742 /* If the first charactes is space, then check if all characters in
1743 * SSID are spaces to consider it as NULL SSID*/
1744 if( ASCII_SPACE_CHARACTER == pSsid->ssId[0])
1745 {
1746 SsidLength = pSsid->length;
1747 pSsidStr = pSsid->ssId;
1748 /* check if all the charactes in SSID are spaces*/
1749 while ( SsidLength )
1750 {
1751 if( ASCII_SPACE_CHARACTER != *pSsidStr )
1752 break;
1753
1754 pSsidStr++;
1755 SsidLength--;
1756 }
1757
1758 if( 0 == SsidLength )
1759 {
1760 fNullSsid = true;
1761 break;
1762 }
1763 }
1764 else
1765 {
1766 /* check if all the charactes in SSID are NULL*/
1767 SsidLength = pSsid->length;
1768 pSsidStr = pSsid->ssId;
1769
1770 while ( SsidLength )
1771 {
1772 if( *pSsidStr )
1773 break;
1774
1775 pSsidStr++;
1776 SsidLength--;
1777 }
1778
1779 if( 0 == SsidLength )
1780 {
1781 fNullSsid = true;
1782 break;
1783 }
1784 }
1785 }
1786 while( 0 );
1787
1788 return fNullSsid;
1789} /****** end limIsNullSsid() ******/
1790
1791
1792
1793#ifdef WLAN_SOFTAP_FEATURE
1794
1795/** -------------------------------------------------------------
1796\fn limUpdateProtStaParams
1797\brief updates protection related counters.
1798\param tpAniSirGlobal pMac
1799\param tSirMacAddr peerMacAddr
1800\param tLimProtStaCacheType protStaCacheType
1801\param tHalBitVal gfSupported
1802\param tHalBitVal lsigTxopSupported
1803\return None
1804 -------------------------------------------------------------*/
1805void
1806limUpdateProtStaParams(tpAniSirGlobal pMac,
1807tSirMacAddr peerMacAddr, tLimProtStaCacheType protStaCacheType,
1808tHalBitVal gfSupported, tHalBitVal lsigTxopSupported,
1809tpPESession psessionEntry)
1810{
1811 tANI_U32 i;
1812
1813 PELOG1(limLog(pMac,LOG1, FL("A STA is associated:"));
1814 limLog(pMac,LOG1, FL("Addr : "));
1815 limPrintMacAddr(pMac, peerMacAddr, LOG1);)
1816
1817 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1818 {
1819 if (psessionEntry->protStaCache[i].active)
1820 {
1821 PELOG1(limLog(pMac, LOG1, FL("Addr: "));)
1822 PELOG1(limPrintMacAddr(pMac, psessionEntry->protStaCache[i].addr, LOG1);)
1823
1824 if (palEqualMemory( pMac->hHdd,
1825 psessionEntry->protStaCache[i].addr,
1826 peerMacAddr, sizeof(tSirMacAddr)))
1827 {
1828 PELOG1(limLog(pMac, LOG1, FL("matching cache entry at %d already active.\n"), i);)
1829 return;
1830 }
1831 }
1832 }
1833
1834 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1835 {
1836 if (!psessionEntry->protStaCache[i].active)
1837 break;
1838 }
1839
1840 if (i >= LIM_PROT_STA_CACHE_SIZE)
1841 {
1842 PELOGE(limLog(pMac, LOGE, FL("No space in ProtStaCache\n"));)
1843 return;
1844 }
1845
1846 palCopyMemory( pMac->hHdd, psessionEntry->protStaCache[i].addr,
1847 peerMacAddr,
1848 sizeof(tSirMacAddr));
1849
1850 psessionEntry->protStaCache[i].protStaCacheType = protStaCacheType;
1851 psessionEntry->protStaCache[i].active = true;
1852 if(eLIM_PROT_STA_CACHE_TYPE_llB == protStaCacheType)
1853 {
1854 psessionEntry->gLim11bParams.numSta++;
1855 limLog(pMac,LOG1, FL("11B, "));
1856 }
1857 else if(eLIM_PROT_STA_CACHE_TYPE_llG == protStaCacheType)
1858 {
1859 psessionEntry->gLim11gParams.numSta++;
1860 limLog(pMac,LOG1, FL("11G, "));
1861 }
1862 else if(eLIM_PROT_STA_CACHE_TYPE_HT20 == protStaCacheType)
1863 {
1864 psessionEntry->gLimHt20Params.numSta++;
1865 limLog(pMac,LOG1, FL("HT20, "));
1866 }
1867
1868 if(!gfSupported)
1869 {
1870 psessionEntry->gLimNonGfParams.numSta++;
1871 limLog(pMac,LOG1, FL("NonGf, "));
1872 }
1873 if(!lsigTxopSupported)
1874 {
1875 psessionEntry->gLimLsigTxopParams.numSta++;
1876 limLog(pMac,LOG1, FL("!lsigTxopSupported\n"));
1877 }
1878}// ---------------------------------------------------------------------
1879
1880/** -------------------------------------------------------------
1881\fn limDecideApProtection
1882\brief Decides all the protection related staiton coexistence and also sets
1883\ short preamble and short slot appropriately. This function will be called
1884\ when AP is ready to send assocRsp tp the station joining right now.
1885\param tpAniSirGlobal pMac
1886\param tSirMacAddr peerMacAddr
1887\return None
1888 -------------------------------------------------------------*/
1889void
1890limDecideApProtection(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1891{
1892 tANI_U16 tmpAid;
1893 tpDphHashNode pStaDs;
1894 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1895 tANI_U32 phyMode;
1896 tLimProtStaCacheType protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_INVALID;
1897 tHalBitVal gfSupported = eHAL_SET, lsigTxopSupported = eHAL_SET;
1898
1899 pBeaconParams->paramChangeBitmap = 0;
1900 // check whether to enable protection or not
1901 pStaDs = dphLookupHashEntry(pMac, peerMacAddr, &tmpAid, &psessionEntry->dph.dphHashTable);
1902 if(NULL == pStaDs)
1903 {
1904 PELOG1(limLog(pMac, LOG1, FL("pStaDs is NULL\n"));)
1905 return;
1906 }
1907 limGetRfBand(pMac, &rfBand, psessionEntry);
1908 //if we are in 5 GHZ band
1909 if(SIR_BAND_5_GHZ == rfBand)
1910 {
1911 //We are 11N. we need to protect from 11A and Ht20. we don't need any other protection in 5 GHZ.
1912 //HT20 case is common between both the bands and handled down as common code.
Jeff Johnsone7245742012-09-05 17:12:55 -07001913 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 {
1915 //we are 11N and 11A station is joining.
1916 //protection from 11A required.
1917 if(false == pStaDs->mlmStaContext.htCapability)
1918 {
1919 limEnable11aProtection(pMac, true, false, pBeaconParams,psessionEntry);
1920 return;
1921 }
1922 }
1923 }
1924 else if(SIR_BAND_2_4_GHZ== rfBand)
1925 {
1926 limGetPhyMode(pMac, &phyMode, psessionEntry);
1927
1928 //We are 11G. Check if we need protection from 11b Stations.
1929 if ((phyMode == WNI_CFG_PHY_MODE_11G) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07001930 (false == psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 {
1932
1933 if (pStaDs->erpEnabled== eHAL_CLEAR)
1934 {
1935 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llB;
1936 // enable protection
1937 PELOG3(limLog(pMac, LOG3, FL("Enabling protection from 11B\n"));)
1938 limEnable11gProtection(pMac, true, false, pBeaconParams,psessionEntry);
1939 }
1940 }
1941
1942 //HT station.
Jeff Johnsone7245742012-09-05 17:12:55 -07001943 if (true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001944 {
1945 //check if we need protection from 11b station
1946 if ((pStaDs->erpEnabled == eHAL_CLEAR) &&
1947 (!pStaDs->mlmStaContext.htCapability))
1948 {
1949 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llB;
1950 // enable protection
1951 PELOG3(limLog(pMac, LOG3, FL("Enabling protection from 11B\n"));)
1952 limEnable11gProtection(pMac, true, false, pBeaconParams, psessionEntry);
1953 }
1954 //station being joined is non-11b and non-ht ==> 11g device
1955 else if(!pStaDs->mlmStaContext.htCapability)
1956 {
1957 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llG;
1958 //enable protection
1959 limEnableHtProtectionFrom11g(pMac, true, false, pBeaconParams, psessionEntry);
1960 }
1961 //ERP mode is enabled for the latest station joined
1962 //latest station joined is HT capable
1963 //This case is being handled in common code (commn between both the bands) below.
1964 }
1965 }
1966
1967 //we are HT and HT station is joining. This code is common for both the bands.
Jeff Johnsone7245742012-09-05 17:12:55 -07001968 if((true == psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 (true == pStaDs->mlmStaContext.htCapability))
1970 {
1971 if(!pStaDs->htGreenfield)
1972 {
1973 limEnableHTNonGfProtection(pMac, true, false, pBeaconParams, psessionEntry);
1974 gfSupported = eHAL_CLEAR;
1975 }
1976 //Station joining is HT 20Mhz
1977 if(eHT_CHANNEL_WIDTH_20MHZ == pStaDs->htSupportedChannelWidthSet)
1978 {
1979 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_HT20;
1980 limEnableHT20Protection(pMac, true, false, pBeaconParams, psessionEntry);
1981 }
1982 //Station joining does not support LSIG TXOP Protection
1983 if(!pStaDs->htLsigTXOPProtection)
1984 {
1985 limEnableHTLsigTxopProtection(pMac, false, false, pBeaconParams,psessionEntry);
1986 lsigTxopSupported = eHAL_CLEAR;
1987 }
1988 }
1989
1990 limUpdateProtStaParams(pMac, peerMacAddr, protStaCacheType,
1991 gfSupported, lsigTxopSupported, psessionEntry);
1992
1993 return;
1994}
1995#endif
1996
1997
1998/** -------------------------------------------------------------
1999\fn limEnableOverlap11gProtection
2000\brief wrapper function for setting overlap 11g protection.
2001\param tpAniSirGlobal pMac
2002\param tpUpdateBeaconParams pBeaconParams
2003\param tpSirMacMgmtHdr pMh
2004\return None
2005 -------------------------------------------------------------*/
2006void
2007limEnableOverlap11gProtection(tpAniSirGlobal pMac,
2008tpUpdateBeaconParams pBeaconParams, tpSirMacMgmtHdr pMh,tpPESession psessionEntry)
2009{
2010 limUpdateOverlapStaParam(pMac, pMh->bssId, &(psessionEntry->gLimOlbcParams));
2011
2012 if (psessionEntry->gLimOlbcParams.numSta &&
2013 !psessionEntry->gLimOlbcParams.protectionEnabled)
2014 {
2015 // enable protection
2016 PELOG1(limLog(pMac, LOG1, FL("OLBC happens!!!\n"));)
2017 limEnable11gProtection(pMac, true, true, pBeaconParams,psessionEntry);
2018 }
2019}
2020
2021
2022/** -------------------------------------------------------------
2023\fn limUpdateShortPreamble
2024\brief Updates short preamble if needed when a new station joins.
2025\param tpAniSirGlobal pMac
2026\param tSirMacAddr peerMacAddr
2027\param tpUpdateBeaconParams pBeaconParams
2028\return None
2029 -------------------------------------------------------------*/
2030void
2031limUpdateShortPreamble(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2032 tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
2033{
2034 tANI_U16 tmpAid;
2035 tpDphHashNode pStaDs;
2036 tANI_U32 phyMode;
2037 tANI_U16 i;
2038
2039 // check whether to enable protection or not
2040 pStaDs = dphLookupHashEntry(pMac, peerMacAddr, &tmpAid, &psessionEntry->dph.dphHashTable);
2041
2042 limGetPhyMode(pMac, &phyMode, psessionEntry);
2043
2044 if (pStaDs != NULL && phyMode == WNI_CFG_PHY_MODE_11G)
2045
2046 {
2047 if (pStaDs->shortPreambleEnabled == eHAL_CLEAR)
2048 {
2049 PELOG1(limLog(pMac,LOG1,FL("Short Preamble is not enabled in Assoc Req from "));
2050 limPrintMacAddr(pMac, peerMacAddr, LOG1);)
2051
2052 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
2053 {
2054#ifdef WLAN_SOFTAP_FEATURE
2055 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
2056 psessionEntry->gLimNoShortParams.staNoShortCache[i].active)
2057 {
2058 if (palEqualMemory( pMac->hHdd,
2059 psessionEntry->gLimNoShortParams.staNoShortCache[i].addr,
2060 peerMacAddr, sizeof(tSirMacAddr)))
2061 return;
2062 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
2063#endif
2064 {
2065 if (pMac->lim.gLimNoShortParams.staNoShortCache[i].active)
2066 {
2067 if (palEqualMemory( pMac->hHdd,
2068 pMac->lim.gLimNoShortParams.staNoShortCache[i].addr,
2069 peerMacAddr, sizeof(tSirMacAddr)))
2070 return;
2071 }
2072 }
2073 }
2074
2075
2076 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
2077 {
2078#ifdef WLAN_SOFTAP_FEATURE
2079 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
2080 !psessionEntry->gLimNoShortParams.staNoShortCache[i].active)
2081 break;
2082 else
2083#endif
2084 {
2085 if (!pMac->lim.gLimNoShortParams.staNoShortCache[i].active)
2086 break;
2087 }
2088 }
2089
2090 if (i >= LIM_PROT_STA_CACHE_SIZE)
2091 {
2092#ifdef WLAN_SOFTAP_FEATURE
2093 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
2094 limLog(pMac, LOGE, FL("No space in Short cache (#active %d, #sta %d) for sta "),
2095 i, psessionEntry->gLimNoShortParams.numNonShortPreambleSta);
2096 limPrintMacAddr(pMac, peerMacAddr, LOGE);
2097 return;
2098 }
2099 else
2100#endif
2101 {
2102 limLog(pMac, LOGE, FL("No space in Short cache (#active %d, #sta %d) for sta "),
2103 i, pMac->lim.gLimNoShortParams.numNonShortPreambleSta);
2104 limPrintMacAddr(pMac, peerMacAddr, LOGE);
2105 return;
2106 }
2107
2108 }
2109
2110
2111#ifdef WLAN_SOFTAP_FEATURE
2112 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
2113 palCopyMemory( pMac->hHdd, psessionEntry->gLimNoShortParams.staNoShortCache[i].addr,
2114 peerMacAddr, sizeof(tSirMacAddr));
2115 psessionEntry->gLimNoShortParams.staNoShortCache[i].active = true;
2116 psessionEntry->gLimNoShortParams.numNonShortPreambleSta++;
2117 }else
2118#endif
2119 {
2120 palCopyMemory( pMac->hHdd, pMac->lim.gLimNoShortParams.staNoShortCache[i].addr,
2121 peerMacAddr, sizeof(tSirMacAddr));
2122 pMac->lim.gLimNoShortParams.staNoShortCache[i].active = true;
2123 pMac->lim.gLimNoShortParams.numNonShortPreambleSta++;
2124 }
2125
2126
2127 // enable long preamble
2128 PELOG1(limLog(pMac, LOG1, FL("Disabling short preamble\n"));)
2129
2130#ifdef WLAN_SOFTAP_FEATURE
2131 if (limEnableShortPreamble(pMac, false, pBeaconParams, psessionEntry) != eSIR_SUCCESS)
2132 PELOGE(limLog(pMac, LOGE, FL("Cannot enable long preamble\n"));)
2133#else
2134 if (limEnableShortPreamble(pMac, false, pBeaconParams) != eSIR_SUCCESS)
2135 PELOGE(limLog(pMac, LOGE, FL("Cannot enable long preamble\n"));)
2136
2137#endif
2138 }
2139 }
2140}
2141
2142/** -------------------------------------------------------------
2143\fn limUpdateShortSlotTime
2144\brief Updates short slot time if needed when a new station joins.
2145\param tpAniSirGlobal pMac
2146\param tSirMacAddr peerMacAddr
2147\param tpUpdateBeaconParams pBeaconParams
2148\return None
2149 -------------------------------------------------------------*/
2150
2151void
2152limUpdateShortSlotTime(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2153 tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
2154{
2155 tANI_U16 tmpAid;
2156 tpDphHashNode pStaDs;
2157 tANI_U32 phyMode;
2158 tANI_U32 val;
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 tANI_U16 i;
2160
2161 // check whether to enable protection or not
2162 pStaDs = dphLookupHashEntry(pMac, peerMacAddr, &tmpAid, &psessionEntry->dph.dphHashTable);
2163 limGetPhyMode(pMac, &phyMode, psessionEntry);
2164
Jeff Johnsone7245742012-09-05 17:12:55 -07002165 /* Only in case of softap in 11g mode, slot time might change depending on the STA being added. In 11a case, it should
2166 * be always 1 and in 11b case, it should be always 0
2167 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 if (pStaDs != NULL && phyMode == WNI_CFG_PHY_MODE_11G)
2169 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002170 /* Only when the new STA has short slot time disabled, we need to change softap's overall slot time settings
2171 * else the default for softap is always short slot enabled. When the last long slot STA leaves softAP, we take care of
2172 * it in limDecideShortSlot
2173 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 if (pStaDs->shortSlotTimeEnabled == eHAL_CLEAR)
2175 {
2176 PELOG1(limLog(pMac, LOG1, FL("Short Slot Time is not enabled in Assoc Req from "));
2177 limPrintMacAddr(pMac, peerMacAddr, LOG1);)
2178 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
2179 {
2180#ifdef WLAN_SOFTAP_FEATURE
2181 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
2182 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active)
2183 {
2184 if (palEqualMemory( pMac->hHdd,
2185 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
2186 peerMacAddr, sizeof(tSirMacAddr)))
2187 return;
2188 }
2189 else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
2190#endif
2191 {
2192 if (pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active)
2193 {
2194 if (palEqualMemory( pMac->hHdd,
2195 pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
2196 peerMacAddr, sizeof(tSirMacAddr)))
2197 return;
2198 }
2199 }
2200 }
2201
2202 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
2203 {
2204#ifdef WLAN_SOFTAP_FEATURE
2205 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
2206 !psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active)
2207 break;
2208 else
2209#endif
2210 {
2211 if (!pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active)
2212 break;
2213 }
2214 }
2215
2216 if (i >= LIM_PROT_STA_CACHE_SIZE)
2217 {
2218#ifdef WLAN_SOFTAP_FEATURE
2219 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
2220 limLog(pMac, LOGE, FL("No space in ShortSlot cache (#active %d, #sta %d) for sta "),
2221 i, psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta);
2222 limPrintMacAddr(pMac, peerMacAddr, LOGE);
2223 return;
2224 }else
2225#endif
2226 {
2227 limLog(pMac, LOGE, FL("No space in ShortSlot cache (#active %d, #sta %d) for sta "),
2228 i, pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta);
2229 limPrintMacAddr(pMac, peerMacAddr, LOGE);
2230 return;
2231 }
2232 }
2233
2234
2235#ifdef WLAN_SOFTAP_FEATURE
2236 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
2237 palCopyMemory( pMac->hHdd, psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
2238 peerMacAddr, sizeof(tSirMacAddr));
2239 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active = true;
2240 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta++;
2241 }else
2242#endif
2243 {
2244 palCopyMemory( pMac->hHdd, pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
2245 peerMacAddr, sizeof(tSirMacAddr));
2246 pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active = true;
2247 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta++;
2248 }
2249 wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val);
2250
2251#ifdef WLAN_SOFTAP_FEATURE
Jeff Johnsone7245742012-09-05 17:12:55 -07002252 /* 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
2253 * only long slot enabled, we need to change our beacon/pb rsp to broadcast short slot disabled
2254 */
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07002256 (val && psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta && psessionEntry->shortSlotTimeSupported))
Jeff Johnson295189b2012-06-20 16:38:30 -07002257 {
2258 // enable long slot time
2259 pBeaconParams->fShortSlotTime = false;
2260 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
2261 PELOG1(limLog(pMac, LOG1, FL("Disable short slot time. Enable long slot time.\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002262 psessionEntry->shortSlotTimeSupported = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 }
2264 else if ( psessionEntry->limSystemRole != eLIM_AP_ROLE)
2265#endif
2266 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002267 if (val && pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta && psessionEntry->shortSlotTimeSupported)
Jeff Johnson295189b2012-06-20 16:38:30 -07002268 {
2269 // enable long slot time
2270 pBeaconParams->fShortSlotTime = false;
2271 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
2272 PELOG1(limLog(pMac, LOG1, FL("Disable short slot time. Enable long slot time.\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002273 psessionEntry->shortSlotTimeSupported = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07002274 }
2275 }
2276 }
2277 }
2278}
2279
2280#if (WNI_POLARIS_FW_PACKAGE == ADVANCED) && defined (ANI_PRODUCT_TYPE_AP)
2281/**
2282 * limDetectRadar()
2283 *
2284 *FUNCTION:
2285 * This function is invoked when LIM receives
2286 * SIR_LIM_RADAR_DETECT_IND in lim mesage queue.
2287 * LIM will notify WSM of this event by sending
2288 * WSM the wireless medium status change
2289 * notification message.
2290 *
2291 *
2292 *LOGIC:
2293 *
2294 *ASSUMPTIONS:
2295 * NA
2296 *
2297 *NOTE:
2298 * NA
2299 *
2300 * @param pMac - Pointer to Global MAC structure
2301 * @param message - a tSirRadarInfo struct type message send by HAL.
2302 * This message is not serialized.
2303 *
2304 * @return None
2305 */
2306
2307void
2308limDetectRadar(tpAniSirGlobal pMac, tANI_U32 *pMsg)
2309{
2310 tpSirRadarInfo pRadarInfo;
2311
2312 if (!pMsg)
2313 {
2314 limLog(pMac, LOGP, FL("Message is NULL\n"));
2315 return;
2316 }
2317
2318 pRadarInfo = (tpSirRadarInfo)pMsg;
2319
2320 if ((pMac->lim.gLimCurrentChannelId == pRadarInfo->channelNumber) &&
2321 (pMac->lim.gLimSystemRole != eLIM_UNKNOWN_ROLE))
2322 {
2323 LIM_SET_RADAR_DETECTED(pMac, eANI_BOOLEAN_TRUE);
2324 limStopMeasTimers(pMac);
2325 /* Stop the transmission of all packets except beacons.
2326 * This is done here, assuming that we will definitely get a channel switch
2327 * request from WSM.
2328 */
2329 PELOG1(limLog(pMac, LOG1, "Stopping the transmission on AP\n");)
2330 limFrameTransmissionControl(pMac, eLIM_TX_BSS_BUT_BEACON, eLIM_STOP_TX);
2331 }
2332
2333 PELOG1(limLog(pMac, LOG1,
2334 FL("limDetectRadar():: pulsewidth = %d, numPulse=%d, channelId=%d\n"),
2335 pRadarInfo->radarPulseWidth, pRadarInfo->numRadarPulse,
2336 pRadarInfo->channelNumber);)
2337
2338 limSendSmeWmStatusChangeNtf(pMac,
2339 eSIR_SME_RADAR_DETECTED,
2340 pMsg,
2341 (tANI_U16)sizeof(*pRadarInfo),0);
2342
2343}
2344#endif
2345
2346# if 0
2347//TBD_RAJESH :: TO SOLVE LINKING ISSUE
2348void
2349limUpdateShortSlotTime(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr, //dummy to avoid linking problem
2350 tpUpdateBeaconParams pBeaconParams)
2351{
2352
2353}
2354
2355//TBD_RAJESH :: TO SOLVE LINKING ISSUE
2356void
2357limUpdateShortPreamble(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr, //dummy to avoid linking problem
2358 tpUpdateBeaconParams pBeaconParams)
2359
2360{
2361}
2362
2363//TBD_RAJESH :: TO SOLVE LINKING ISSUE
2364
2365void //dummy to avoid linking problem
2366limDecideApProtection(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
2367{
2368}
2369
2370#endif
2371
2372
2373/** -------------------------------------------------------------
2374\fn limDecideStaProtectionOnAssoc
2375\brief Decide protection related settings on Sta while association.
2376\param tpAniSirGlobal pMac
2377\param tpSchBeaconStruct pBeaconStruct
2378\return None
2379 -------------------------------------------------------------*/
2380void
2381limDecideStaProtectionOnAssoc(tpAniSirGlobal pMac,
2382 tpSchBeaconStruct pBeaconStruct, tpPESession psessionEntry)
2383{
2384 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
2385 tANI_U32 phyMode = WNI_CFG_PHY_MODE_NONE;
2386
2387 limGetRfBand(pMac, &rfBand, psessionEntry);
2388 limGetPhyMode(pMac, &phyMode, psessionEntry);
2389
2390 if(SIR_BAND_5_GHZ == rfBand)
2391 {
2392 if((eSIR_HT_OP_MODE_MIXED == pBeaconStruct->HTInfo.opMode) ||
2393 (eSIR_HT_OP_MODE_OVERLAP_LEGACY == pBeaconStruct->HTInfo.opMode))
2394 {
2395 if(pMac->lim.cfgProtection.fromlla)
2396 psessionEntry->beaconParams.llaCoexist = true;
2397 }
2398 else if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == pBeaconStruct->HTInfo.opMode)
2399 {
2400 if(pMac->lim.cfgProtection.ht20)
2401 psessionEntry->beaconParams.ht20Coexist = true;
2402 }
2403
2404 }
2405 else if(SIR_BAND_2_4_GHZ == rfBand)
2406 {
2407 //spec 7.3.2.13
2408 //UseProtection will be set when nonERP STA is associated.
2409 //NonERPPresent bit will be set when:
2410 //--nonERP Sta is associated OR
2411 //--nonERP Sta exists in overlapping BSS
2412 //when useProtection is not set then protection from nonERP stations is optional.
2413
2414 //CFG protection from 11b is enabled and
2415 //11B device in the BSS
2416 /* TODO, This is not sessionized */
2417 if (phyMode != WNI_CFG_PHY_MODE_11B)
2418 {
2419 if (pMac->lim.cfgProtection.fromllb &&
2420 pBeaconStruct->erpPresent &&
2421 (pBeaconStruct->erpIEInfo.useProtection ||
2422 pBeaconStruct->erpIEInfo.nonErpPresent))
2423 {
2424 psessionEntry->beaconParams.llbCoexist = true;
2425 }
2426 //AP has no 11b station associated.
2427 else
2428 {
2429 psessionEntry->beaconParams.llbCoexist = false;
2430 }
2431 }
2432 //following code block is only for HT station.
Jeff Johnsone7245742012-09-05 17:12:55 -07002433 if((psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 (pBeaconStruct->HTInfo.present))
2435 {
2436 tDot11fIEHTInfo htInfo = pBeaconStruct->HTInfo;
2437
2438 //Obss Non HT STA present mode
2439 psessionEntry->beaconParams.gHTObssMode = (tANI_U8)htInfo.obssNonHTStaPresent;
2440
2441
2442 //CFG protection from 11G is enabled and
2443 //our AP has at least one 11G station associated.
2444 if(pMac->lim.cfgProtection.fromllg &&
2445 ((eSIR_HT_OP_MODE_MIXED == htInfo.opMode) ||
2446 (eSIR_HT_OP_MODE_OVERLAP_LEGACY == htInfo.opMode))&&
2447 (!psessionEntry->beaconParams.llbCoexist))
2448 {
2449 if(pMac->lim.cfgProtection.fromllg)
2450 psessionEntry->beaconParams.llgCoexist = true;
2451 }
2452
2453 //AP has only HT stations associated and at least one station is HT 20
2454 //disable protection from any non-HT devices.
2455 //decision for disabling protection from 11b has already been taken above.
2456 if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == htInfo.opMode)
2457 {
2458 //Disable protection from 11G station.
2459 psessionEntry->beaconParams.llgCoexist = false;
2460 //CFG protection from HT 20 is enabled.
2461 if(pMac->lim.cfgProtection.ht20)
2462 psessionEntry->beaconParams.ht20Coexist = true;
2463 }
2464 //Disable protection from non-HT and HT20 devices.
2465 //decision for disabling protection from 11b has already been taken above.
2466 if(eSIR_HT_OP_MODE_PURE == htInfo.opMode)
2467 {
2468 psessionEntry->beaconParams.llgCoexist = false;
2469 psessionEntry->beaconParams.ht20Coexist = false;
2470 }
2471
2472 }
2473 }
2474
2475 //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 -07002476 if((psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 (pBeaconStruct->HTInfo.present))
2478 {
2479 tDot11fIEHTInfo htInfo = pBeaconStruct->HTInfo;
2480 psessionEntry->beaconParams.fRIFSMode =
2481 ( tANI_U8 ) htInfo.rifsMode;
2482 psessionEntry->beaconParams.llnNonGFCoexist =
2483 ( tANI_U8 )htInfo.nonGFDevicesPresent;
2484 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport =
2485 ( tANI_U8 )htInfo.lsigTXOPProtectionFullSupport;
2486 }
2487}
2488
2489
2490/** -------------------------------------------------------------
2491\fn limDecideStaProtection
2492\brief Decides protection related settings on Sta while processing beacon.
2493\param tpAniSirGlobal pMac
2494\param tpUpdateBeaconParams pBeaconParams
2495\return None
2496 -------------------------------------------------------------*/
2497void
2498limDecideStaProtection(tpAniSirGlobal pMac,
2499 tpSchBeaconStruct pBeaconStruct, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
2500{
2501
2502 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
2503 tANI_U32 phyMode = WNI_CFG_PHY_MODE_NONE;
2504
2505 limGetRfBand(pMac, &rfBand, psessionEntry);
2506 limGetPhyMode(pMac, &phyMode, psessionEntry);
2507
2508 if(SIR_BAND_5_GHZ == rfBand)
2509 {
2510 //we are HT capable.
Jeff Johnsone7245742012-09-05 17:12:55 -07002511 if((true == psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 (pBeaconStruct->HTInfo.present))
2513 {
2514 //we are HT capable, AP's HT OPMode is mixed / overlap legacy ==> need protection from 11A.
2515 if((eSIR_HT_OP_MODE_MIXED == pBeaconStruct->HTInfo.opMode) ||
2516 (eSIR_HT_OP_MODE_OVERLAP_LEGACY == pBeaconStruct->HTInfo.opMode))
2517 {
2518 limEnable11aProtection(pMac, true, false, pBeaconParams,psessionEntry);
2519 }
2520 //we are HT capable, AP's HT OPMode is HT20 ==> disable protection from 11A if enabled. enabled
2521 //protection from HT20 if needed.
2522 else if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT== pBeaconStruct->HTInfo.opMode)
2523 {
2524 limEnable11aProtection(pMac, false, false, pBeaconParams,psessionEntry);
2525 limEnableHT20Protection(pMac, true, false, pBeaconParams,psessionEntry);
2526 }
2527 else if(eSIR_HT_OP_MODE_PURE == pBeaconStruct->HTInfo.opMode)
2528 {
2529 limEnable11aProtection(pMac, false, false, pBeaconParams,psessionEntry);
2530 limEnableHT20Protection(pMac, false, false, pBeaconParams,psessionEntry);
2531 }
2532 }
2533 }
2534 else if(SIR_BAND_2_4_GHZ == rfBand)
2535 {
2536 /* spec 7.3.2.13
2537 * UseProtection will be set when nonERP STA is associated.
2538 * NonERPPresent bit will be set when:
2539 * --nonERP Sta is associated OR
2540 * --nonERP Sta exists in overlapping BSS
2541 * when useProtection is not set then protection from nonERP stations is optional.
2542 */
2543
2544 if (phyMode != WNI_CFG_PHY_MODE_11B)
2545 {
2546 if (pBeaconStruct->erpPresent &&
2547 (pBeaconStruct->erpIEInfo.useProtection ||
2548 pBeaconStruct->erpIEInfo.nonErpPresent))
2549 {
2550 limEnable11gProtection(pMac, true, false, pBeaconParams, psessionEntry);
2551 }
2552 //AP has no 11b station associated.
2553 else
2554 {
2555 //disable protection from 11b station
2556 limEnable11gProtection(pMac, false, false, pBeaconParams, psessionEntry);
2557 }
2558 }
2559
2560 //following code block is only for HT station.
Jeff Johnsone7245742012-09-05 17:12:55 -07002561 if((psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 (pBeaconStruct->HTInfo.present))
2563 {
2564
2565 tDot11fIEHTInfo htInfo = pBeaconStruct->HTInfo;
2566 //AP has at least one 11G station associated.
2567 if(((eSIR_HT_OP_MODE_MIXED == htInfo.opMode) ||
2568 (eSIR_HT_OP_MODE_OVERLAP_LEGACY == htInfo.opMode))&&
2569 (!psessionEntry->beaconParams.llbCoexist))
2570 {
2571 limEnableHtProtectionFrom11g(pMac, true, false, pBeaconParams,psessionEntry);
2572
2573 }
2574
2575 //no HT operating mode change ==> no change in protection settings except for MIXED_MODE/Legacy Mode.
2576 //in Mixed mode/legacy Mode even if there is no change in HT operating mode, there might be change in 11bCoexist
2577 //or 11gCoexist. that is why this check is being done after mixed/legacy mode check.
2578 if ( pMac->lim.gHTOperMode != ( tSirMacHTOperatingMode )htInfo.opMode )
2579 {
2580 pMac->lim.gHTOperMode = ( tSirMacHTOperatingMode )htInfo.opMode;
2581
2582 //AP has only HT stations associated and at least one station is HT 20
2583 //disable protection from any non-HT devices.
2584 //decision for disabling protection from 11b has already been taken above.
2585 if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == htInfo.opMode)
2586 {
2587 //Disable protection from 11G station.
2588 limEnableHtProtectionFrom11g(pMac, false, false, pBeaconParams,psessionEntry);
2589
2590 limEnableHT20Protection(pMac, true, false, pBeaconParams,psessionEntry);
2591 }
2592 //Disable protection from non-HT and HT20 devices.
2593 //decision for disabling protection from 11b has already been taken above.
2594 else if(eSIR_HT_OP_MODE_PURE == htInfo.opMode)
2595 {
2596 limEnableHtProtectionFrom11g(pMac, false, false, pBeaconParams,psessionEntry);
2597 limEnableHT20Protection(pMac, false, false, pBeaconParams,psessionEntry);
2598
2599 }
2600 }
2601 }
2602 }
2603
2604 //following code block is only for HT station. ( 2.4 GHZ as well as 5 GHZ)
Jeff Johnsone7245742012-09-05 17:12:55 -07002605 if((psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 (pBeaconStruct->HTInfo.present))
2607 {
2608 tDot11fIEHTInfo htInfo = pBeaconStruct->HTInfo;
2609 //Check for changes in protection related factors other than HT operating mode.
2610 //Check for changes in RIFS mode, nonGFDevicesPresent, lsigTXOPProtectionFullSupport.
2611 if ( psessionEntry->beaconParams.fRIFSMode !=
2612 ( tANI_U8 ) htInfo.rifsMode )
2613 {
2614 pBeaconParams->fRIFSMode =
2615 psessionEntry->beaconParams.fRIFSMode =
2616 ( tANI_U8 ) htInfo.rifsMode;
2617 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
2618 }
2619
2620 if ( psessionEntry->beaconParams.llnNonGFCoexist !=
2621 htInfo.nonGFDevicesPresent )
2622 {
2623 pBeaconParams->llnNonGFCoexist =
2624 psessionEntry->beaconParams.llnNonGFCoexist =
2625 ( tANI_U8 )htInfo.nonGFDevicesPresent;
2626 pBeaconParams->paramChangeBitmap |=
2627 PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
2628 }
2629
2630 if ( psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport !=
2631 ( tANI_U8 )htInfo.lsigTXOPProtectionFullSupport )
2632 {
2633 pBeaconParams->fLsigTXOPProtectionFullSupport =
2634 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport =
2635 ( tANI_U8 )htInfo.lsigTXOPProtectionFullSupport;
2636 pBeaconParams->paramChangeBitmap |=
2637 PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
2638 }
2639
2640 // For Station just update the global lim variable, no need to send message to HAL
2641 // Station already taking care of HT OPR Mode=01, meaning AP is seeing legacy
2642 //stations in overlapping BSS.
2643 if ( psessionEntry->beaconParams.gHTObssMode != ( tANI_U8 )htInfo.obssNonHTStaPresent )
2644 psessionEntry->beaconParams.gHTObssMode = ( tANI_U8 )htInfo.obssNonHTStaPresent ;
2645
2646 }
2647}
2648
2649
2650/**
2651 * limProcessChannelSwitchTimeout()
2652 *
2653 *FUNCTION:
2654 * This function is invoked when Channel Switch Timer expires at
2655 * the STA. Now, STA must stop traffic, and then change/disable
2656 * primary or secondary channel.
2657 *
2658 *
2659 *NOTE:
2660 * @param pMac - Pointer to Global MAC structure
2661 * @return None
2662 */
2663void limProcessChannelSwitchTimeout(tpAniSirGlobal pMac)
2664{
2665 tpPESession psessionEntry = NULL;
2666#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
Jeff Johnsone7245742012-09-05 17:12:55 -07002667 tANI_U8 channel; // This is received and stored from channelSwitch Action frame
Jeff Johnson295189b2012-06-20 16:38:30 -07002668
2669 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimChannelSwitchTimer.sessionId))== NULL)
2670 {
2671 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
2672 return;
2673 }
2674
2675 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
2676 {
2677 PELOGW(limLog(pMac, LOGW, "Channel switch can be done only in STA role, Current Role = %d\n", psessionEntry->limSystemRole);)
2678 return;
2679 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002680 channel = psessionEntry->gLimChannelSwitch.primaryChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 /*
2682 * This potentially can create issues if the function tries to set
2683 * channel while device is in power-save, hence putting an extra check
2684 * to verify if the device is in power-save or not
2685 */
2686 if(!limIsSystemInActiveState(pMac))
2687 {
2688 PELOGW(limLog(pMac, LOGW, FL("Device is not in active state, cannot switch channel\n"));)
2689 return;
2690 }
2691
2692 // Restore Channel Switch parameters to default
Jeff Johnsone7245742012-09-05 17:12:55 -07002693 psessionEntry->gLimChannelSwitch.switchTimeoutValue = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07002694
2695 /* Channel-switch timeout has occurred. reset the state */
Jeff Johnsone7245742012-09-05 17:12:55 -07002696 psessionEntry->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_END;
Jeff Johnson295189b2012-06-20 16:38:30 -07002697
2698 /* Check if the AP is switching to a channel that we support.
2699 * Else, just don't bother to switch. Indicate HDD to look for a
2700 * better AP to associate
2701 */
2702 if(!limIsChannelValidForChannelSwitch(pMac, channel))
2703 {
2704 /* We need to restore pre-channelSwitch state on the STA */
2705 if(limRestorePreChannelSwitchState(pMac, psessionEntry) != eSIR_SUCCESS)
2706 {
2707 limLog(pMac, LOGP, FL("Could not restore pre-channelSwitch (11h) state, resetting the system\n"));
2708 return;
2709 }
2710
2711 /* If the channel-list that AP is asking us to switch is invalid,
2712 * then we cannot switch the channel. Just disassociate from AP.
2713 * We will find a better AP !!!
2714 */
2715 limTearDownLinkWithAp(pMac,
2716 pMac->lim.limTimers.gLimChannelSwitchTimer.sessionId,
2717 eSIR_MAC_UNSPEC_FAILURE_REASON);
2718 return;
2719 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002720 switch(psessionEntry->gLimChannelSwitch.state)
Jeff Johnson295189b2012-06-20 16:38:30 -07002721 {
2722 case eLIM_CHANNEL_SWITCH_PRIMARY_ONLY:
2723 PELOGW(limLog(pMac, LOGW, FL("CHANNEL_SWITCH_PRIMARY_ONLY \n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002724 limSwitchPrimaryChannel(pMac, psessionEntry->gLimChannelSwitch.primaryChannel,psessionEntry);
2725 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 break;
2727
2728 case eLIM_CHANNEL_SWITCH_SECONDARY_ONLY:
2729 PELOGW(limLog(pMac, LOGW, FL("CHANNEL_SWITCH_SECONDARY_ONLY \n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002730 limSwitchPrimarySecondaryChannel(pMac, psessionEntry,
Jeff Johnson295189b2012-06-20 16:38:30 -07002731 psessionEntry->currentOperChannel,
Jeff Johnsone7245742012-09-05 17:12:55 -07002732 psessionEntry->gLimChannelSwitch.secondarySubBand);
2733 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002734 break;
2735
2736 case eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY:
2737 PELOGW(limLog(pMac, LOGW, FL("CHANNEL_SWITCH_PRIMARY_AND_SECONDARY\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002738 limSwitchPrimarySecondaryChannel(pMac, psessionEntry,
2739 psessionEntry->gLimChannelSwitch.primaryChannel,
2740 psessionEntry->gLimChannelSwitch.secondarySubBand);
2741 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_IDLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 break;
2743
2744 case eLIM_CHANNEL_SWITCH_IDLE:
2745 default:
2746 PELOGE(limLog(pMac, LOGE, FL("incorrect state \n"));)
2747 if(limRestorePreChannelSwitchState(pMac, psessionEntry) != eSIR_SUCCESS)
2748 {
2749 limLog(pMac, LOGP, FL("Could not restore pre-channelSwitch (11h) state, resetting the system\n"));
2750 }
2751 return; /* Please note, this is 'return' and not 'break' */
2752 }
2753#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002754}
Jeff Johnson295189b2012-06-20 16:38:30 -07002755
2756/**
2757 * limUpdateChannelSwitch()
2758 *
2759 *FUNCTION:
2760 * This function is invoked whenever Station receives
2761 * either 802.11h channel switch IE or airgo proprietary
2762 * channel switch IE.
2763 *
2764 *NOTE:
2765 * @param pMac - Pointer to Global MAC structure
2766 * @return tpSirProbeRespBeacon - Pointer to Beacon/Probe Rsp
2767 * @param psessionentry
2768 */
2769void
2770limUpdateChannelSwitch(struct sAniSirGlobal *pMac, tpSirProbeRespBeacon pBeacon, tpPESession psessionEntry)
2771{
2772
2773 tANI_U16 beaconPeriod;
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 tChannelSwitchPropIEStruct *pPropChnlSwitch;
2775 tDot11fIEChanSwitchAnn *pChnlSwitch;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002776#ifdef WLAN_FEATURE_11AC
2777 tDot11fIEWiderBWChanSwitchAnn *pWiderChnlSwitch;
2778#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002779
Jeff Johnsone7245742012-09-05 17:12:55 -07002780 beaconPeriod = psessionEntry->beaconParams.beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002781
2782 /* STA either received proprietary channel switch IE or 802.11h
2783 * standard channel switch IE.
2784 */
2785 if (pBeacon->propIEinfo.propChannelSwitchPresent)
2786 {
2787 pPropChnlSwitch = &(pBeacon->propIEinfo.channelSwitch);
2788
2789 /* Add logic to determine which change this is: */
2790 /* primary, secondary, both. For now assume both. */
Jeff Johnsone7245742012-09-05 17:12:55 -07002791 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2792 psessionEntry->gLimChannelSwitch.primaryChannel = pPropChnlSwitch->primaryChannel;
2793 psessionEntry->gLimChannelSwitch.secondarySubBand = (ePhyChanBondState)pPropChnlSwitch->subBand;
2794 psessionEntry->gLimChannelSwitch.switchCount = pPropChnlSwitch->channelSwitchCount;
2795 psessionEntry->gLimChannelSwitch.switchTimeoutValue =
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 SYS_MS_TO_TICKS(beaconPeriod)* (pPropChnlSwitch->channelSwitchCount);
Jeff Johnsone7245742012-09-05 17:12:55 -07002797 psessionEntry->gLimChannelSwitch.switchMode = pPropChnlSwitch->mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 }
2799 else
2800 {
2801 pChnlSwitch = &(pBeacon->channelSwitchIE);
Jeff Johnsone7245742012-09-05 17:12:55 -07002802 psessionEntry->gLimChannelSwitch.primaryChannel = pChnlSwitch->newChannel;
2803 psessionEntry->gLimChannelSwitch.switchCount = pChnlSwitch->switchCount;
2804 psessionEntry->gLimChannelSwitch.switchTimeoutValue =
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 SYS_MS_TO_TICKS(beaconPeriod)* (pChnlSwitch->switchCount);
Jeff Johnsone7245742012-09-05 17:12:55 -07002806 psessionEntry->gLimChannelSwitch.switchMode = pChnlSwitch->switchMode;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002807#ifdef WLAN_FEATURE_11AC
2808 pWiderChnlSwitch = &(pBeacon->WiderBWChanSwitchAnn);
2809 if(pBeacon->WiderBWChanSwitchAnnPresent)
2810 {
2811 psessionEntry->gLimWiderBWChannelSwitch.newChanWidth = pWiderChnlSwitch->newChanWidth;
2812 psessionEntry->gLimWiderBWChannelSwitch.newCenterChanFreq0 = pWiderChnlSwitch->newCenterChanFreq0;
2813 psessionEntry->gLimWiderBWChannelSwitch.newCenterChanFreq1 = pWiderChnlSwitch->newCenterChanFreq1;
2814 }
2815#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002816
2817 /* Only primary channel switch element is present */
Jeff Johnsone7245742012-09-05 17:12:55 -07002818 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2819 psessionEntry->gLimChannelSwitch.secondarySubBand = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07002820
2821 /* Do not bother to look and operate on extended channel switch element
2822 * if our own channel-bonding state is not enabled
2823 */
Jeff Johnsone7245742012-09-05 17:12:55 -07002824 if (psessionEntry->htSupportedChannelWidthSet)
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 {
2826 if (pBeacon->extChannelSwitchPresent)
2827 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002828 if ((pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_LOW_PRIMARY) ||
2829 (pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY))
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002831 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2832 psessionEntry->gLimChannelSwitch.secondarySubBand = pBeacon->extChannelSwitchIE.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002833 }
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002834#ifdef WLAN_FEATURE_11AC
2835 if(psessionEntry->vhtCapability && pBeacon->WiderBWChanSwitchAnnPresent)
2836 {
2837 if (pWiderChnlSwitch->newChanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
2838 {
2839 if(pBeacon->extChannelSwitchPresent)
2840 {
2841 if ((pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_LOW_PRIMARY) ||
2842 (pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY))
2843 {
2844 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2845 psessionEntry->gLimChannelSwitch.secondarySubBand = limGet11ACPhyCBState(pMac,
2846 psessionEntry->gLimChannelSwitch.primaryChannel,
2847 pBeacon->extChannelSwitchIE.secondaryChannelOffset,
2848 pWiderChnlSwitch->newCenterChanFreq0,
2849 psessionEntry);
2850 }
2851 }
2852 }
2853 }
2854#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002855 }
2856 }
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 if (eSIR_SUCCESS != limStartChannelSwitch(pMac, psessionEntry))
2859 {
2860 PELOGW(limLog(pMac, LOGW, FL("Could not start Channel Switch\n"));)
2861 }
2862
2863 limLog(pMac, LOGW,
Jeff Johnsone7245742012-09-05 17:12:55 -07002864 FL("session %d primary chl %d, subband %d, count %d (%d ticks) \n"),
2865 psessionEntry->peSessionId,
2866 psessionEntry->gLimChannelSwitch.primaryChannel,
2867 psessionEntry->gLimChannelSwitch.secondarySubBand,
2868 psessionEntry->gLimChannelSwitch.switchCount,
2869 psessionEntry->gLimChannelSwitch.switchTimeoutValue);
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 return;
2871}
2872
2873/**
2874 * limCancelDot11hChannelSwitch
2875 *
2876 *FUNCTION:
2877 * This function is called when STA does not send updated channel-swith IE
2878 * after indicating channel-switch start. This will cancel the channel-swith
2879 * timer which is already running.
2880 *
2881 *LOGIC:
2882 *
2883 *ASSUMPTIONS:
2884 *
2885 *NOTE:
2886 *
2887 * @param pMac - Pointer to Global MAC structure
2888 *
2889 * @return None
2890 */
2891void limCancelDot11hChannelSwitch(tpAniSirGlobal pMac, tpPESession psessionEntry)
2892{
2893#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
2894 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
2895 return;
2896
2897 PELOGW(limLog(pMac, LOGW, FL("Received a beacon without channel switch IE\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002898 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_CHANNEL_SWITCH_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002899
2900 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimChannelSwitchTimer) != eSIR_SUCCESS)
2901 {
2902 PELOGE(limLog(pMac, LOGE, FL("tx_timer_deactivate failed!\n"));)
2903 }
2904
2905 /* We need to restore pre-channelSwitch state on the STA */
2906 if (limRestorePreChannelSwitchState(pMac, psessionEntry) != eSIR_SUCCESS)
2907 {
2908 PELOGE(limLog(pMac, LOGE, FL("LIM: Could not restore pre-channelSwitch (11h) state, reseting the system\n"));)
2909
2910 }
2911#endif
2912}
2913
2914/**----------------------------------------------
2915\fn limCancelDot11hQuiet
2916\brief Cancel the quieting on Station if latest
2917 beacon doesn't contain quiet IE in it.
2918
2919\param pMac
2920\return NONE
2921-----------------------------------------------*/
2922void limCancelDot11hQuiet(tpAniSirGlobal pMac, tpPESession psessionEntry)
2923{
2924#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
2925 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
2926 return;
2927
Jeff Johnsone7245742012-09-05 17:12:55 -07002928 if (psessionEntry->gLimSpecMgmt.quietState == eLIM_QUIET_BEGIN)
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002930 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_QUIET_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietTimer) != TX_SUCCESS)
2932 {
2933 PELOGE(limLog(pMac, LOGE, FL("tx_timer_deactivate failed\n"));)
2934 }
2935 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002936 else if (psessionEntry->gLimSpecMgmt.quietState == eLIM_QUIET_RUNNING)
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002938 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_QUIET_BSS_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietBssTimer) != TX_SUCCESS)
2940 {
2941 PELOGE(limLog(pMac, LOGE, FL("tx_timer_deactivate failed\n"));)
2942 }
2943 /**
2944 * If the channel switch is already running in silent mode, dont resume the
2945 * transmission. Channel switch timer when timeout, transmission will be resumed.
2946 */
Jeff Johnsone7245742012-09-05 17:12:55 -07002947 if(!((psessionEntry->gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING) &&
2948 (psessionEntry->gLimChannelSwitch.switchMode == eSIR_CHANSW_MODE_SILENT)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 {
2950 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
Jeff Johnsone7245742012-09-05 17:12:55 -07002951 limRestorePreQuietState(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 }
2953 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002954 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002955#endif
2956}
2957
2958/**
2959 * limProcessQuietTimeout
2960 *
2961 * FUNCTION:
2962 * This function is active only on the STA.
2963 * Handles SIR_LIM_QUIET_TIMEOUT
2964 *
2965 * LOGIC:
2966 * This timeout can occur under only one circumstance:
2967 *
2968 * 1) When gLimQuietState = eLIM_QUIET_BEGIN
2969 * This indicates that the timeout "interval" has
2970 * expired. This is a trigger for the STA to now
2971 * shut-off Tx/Rx for the specified gLimQuietDuration
2972 * -> The TIMER object gLimQuietBssTimer is
2973 * activated
2974 * -> With timeout = gLimQuietDuration
2975 * -> gLimQuietState is set to eLIM_QUIET_RUNNING
2976 *
2977 * ASSUMPTIONS:
2978 * Using two TIMER objects -
2979 * gLimQuietTimer & gLimQuietBssTimer
2980 *
2981 * NOTE:
2982 *
2983 * @param pMac - Pointer to Global MAC structure
2984 *
2985 * @return None
2986 */
2987void limProcessQuietTimeout(tpAniSirGlobal pMac)
2988{
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 //fetch the sessionEntry based on the sessionId
2990 //priority - MEDIUM
Jeff Johnsone7245742012-09-05 17:12:55 -07002991 tpPESession psessionEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07002992
Jeff Johnsone7245742012-09-05 17:12:55 -07002993 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimQuietTimer.sessionId))== NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002994 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002995 limLog(pMac, LOGE,FL("Session Does not exist for given sessionID\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 return;
2997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002998
Jeff Johnsone7245742012-09-05 17:12:55 -07002999 PELOG1(limLog(pMac, LOG1, FL("quietState = %d\n"), psessionEntry->gLimSpecMgmt.quietState);)
3000 switch( psessionEntry->gLimSpecMgmt.quietState )
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 {
3002 case eLIM_QUIET_BEGIN:
3003 // Time to Stop data traffic for quietDuration
Jeff Johnsone7245742012-09-05 17:12:55 -07003004 //limDeactivateAndChangeTimer(pMac, eLIM_QUIET_BSS_TIMER);
3005 if (TX_SUCCESS !=
3006 tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietBssTimer))
3007 {
3008 limLog( pMac, LOGE,
3009 FL("Unable to de-activate gLimQuietBssTimer! Will attempt to activate anyway...\n"));
3010 }
3011
3012 // gLimQuietDuration appears to be in units of ticks
3013 // Use it as is
3014 if (TX_SUCCESS !=
3015 tx_timer_change( &pMac->lim.limTimers.gLimQuietBssTimer,
3016 psessionEntry->gLimSpecMgmt.quietDuration,
3017 0))
3018 {
3019 limLog( pMac, LOGE,
3020 FL("Unable to change gLimQuietBssTimer! Will still attempt to activate anyway...\n"));
3021 }
3022 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_QUIET_BSS_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003023#ifdef GEN6_TODO
3024 /* revisit this piece of code to assign the appropriate sessionId below
3025 * priority - HIGH
3026 */
3027 pMac->lim.limTimers.gLimQuietBssTimer.sessionId = sessionId;
3028#endif
3029 if( TX_SUCCESS !=
3030 tx_timer_activate( &pMac->lim.limTimers.gLimQuietBssTimer ))
3031 {
3032 limLog( pMac, LOGW,
3033 FL("Unable to activate gLimQuietBssTimer! The STA will be unable to honor Quiet BSS...\n"));
3034 }
3035 else
3036 {
3037 // Transition to eLIM_QUIET_RUNNING
Jeff Johnsone7245742012-09-05 17:12:55 -07003038 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_RUNNING;
Jeff Johnson295189b2012-06-20 16:38:30 -07003039
3040 /* If we have sta bk scan triggered and trigger bk scan actually started successfully, */
3041 /* print message, otherwise, stop data traffic and stay quiet */
3042 if( pMac->lim.gLimTriggerBackgroundScanDuringQuietBss &&
3043 (eSIR_TRUE == (glimTriggerBackgroundScanDuringQuietBss_Status = limTriggerBackgroundScanDuringQuietBss( pMac ))) )
3044 {
3045 limLog( pMac, LOG2,
3046 FL("Attempting to trigger a background scan...\n"));
3047 }
3048 else
3049 {
3050 // Shut-off Tx/Rx for gLimSpecMgmt.quietDuration
3051 /* freeze the transmission */
3052 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_STOP_TX);
3053
3054 limLog( pMac, LOG2,
3055 FL("Quiet BSS: STA shutting down for %d ticks\n"),
Jeff Johnsone7245742012-09-05 17:12:55 -07003056 psessionEntry->gLimSpecMgmt.quietDuration );
Jeff Johnson295189b2012-06-20 16:38:30 -07003057 }
3058 }
3059 break;
3060
3061 case eLIM_QUIET_RUNNING:
3062 case eLIM_QUIET_INIT:
3063 case eLIM_QUIET_END:
3064 default:
3065 //
3066 // As of now, nothing to be done
3067 //
3068 break;
3069 }
3070}
3071
3072/**
3073 * limProcessQuietBssTimeout
3074 *
3075 * FUNCTION:
3076 * This function is active on the AP and STA.
3077 * Handles SIR_LIM_QUIET_BSS_TIMEOUT
3078 *
3079 * LOGIC:
3080 * On the AP -
3081 * When the SIR_LIM_QUIET_BSS_TIMEOUT is triggered, it is
3082 * an indication for the AP to START sending out the
3083 * Quiet BSS IE.
3084 * If 802.11H is enabled, the Quiet BSS IE is sent as per
3085 * the 11H spec
3086 * If 802.11H is not enabled, the Quiet BSS IE is sent as
3087 * a Proprietary IE. This will be understood by all the
3088 * TITAN STA's
3089 * Transitioning gLimQuietState to eLIM_QUIET_BEGIN will
3090 * initiate the SCH to include the Quiet BSS IE in all
3091 * its subsequent Beacons/PR's.
3092 * The Quiet BSS IE will be included in all the Beacons
3093 * & PR's until the next DTIM period
3094 *
3095 * On the STA -
3096 * When gLimQuietState = eLIM_QUIET_RUNNING
3097 * This indicates that the STA was successfully shut-off
3098 * for the specified gLimQuietDuration. This is a trigger
3099 * for the STA to now resume data traffic.
3100 * -> gLimQuietState is set to eLIM_QUIET_INIT
3101 *
3102 * ASSUMPTIONS:
3103 *
3104 * NOTE:
3105 *
3106 * @param pMac - Pointer to Global MAC structure
3107 *
3108 * @return None
3109 */
3110void limProcessQuietBssTimeout( tpAniSirGlobal pMac )
3111{
Jeff Johnsone7245742012-09-05 17:12:55 -07003112 tpPESession psessionEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07003113
Jeff Johnsone7245742012-09-05 17:12:55 -07003114 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimQuietBssTimer.sessionId))== NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 {
3116 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
3117 return;
3118 }
3119
Jeff Johnsone7245742012-09-05 17:12:55 -07003120 PELOG1(limLog(pMac, LOG1, FL("quietState = %d\n"), psessionEntry->gLimSpecMgmt.quietState);)
3121 if (eLIM_AP_ROLE == psessionEntry->limSystemRole)
Jeff Johnson295189b2012-06-20 16:38:30 -07003122 {
3123#ifdef ANI_PRODUCT_TYPE_AP
3124 if (!pMac->sys.gSysEnableLearnMode)
3125 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003126 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_END;
Jeff Johnson295189b2012-06-20 16:38:30 -07003127 return;
3128 }
3129
Jeff Johnsone7245742012-09-05 17:12:55 -07003130 if( eLIM_QUIET_INIT == psessionEntry->gLimSpecMgmt.quietState )
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 {
3132 //QuietCount = 0 is reserved
Jeff Johnsone7245742012-09-05 17:12:55 -07003133 psessionEntry->gLimSpecMgmt.quietCount = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 // In ms.
Jeff Johnsone7245742012-09-05 17:12:55 -07003135 psessionEntry->gLimSpecMgmt.quietDuration =
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 pMac->lim.gpLimMeasReq->measDuration.shortChannelScanDuration;
3137 // TU is in multiples of 1024 (2^10) us.
Jeff Johnsone7245742012-09-05 17:12:55 -07003138 psessionEntry->gLimSpecMgmt.quietDuration_TU =
3139 SYS_MS_TO_TU(psessionEntry->gLimSpecMgmt.quietDuration);
Jeff Johnson295189b2012-06-20 16:38:30 -07003140 // Transition to eLIM_QUIET_BEGIN
3141 limLog( pMac, LOG2, FL("Quiet BSS state = eLIM_QUIET_BEGIN\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003142 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_BEGIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 }
3144#endif
3145 }
3146 else
3147 {
3148 // eLIM_STA_ROLE
Jeff Johnsone7245742012-09-05 17:12:55 -07003149 switch( psessionEntry->gLimSpecMgmt.quietState )
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 {
3151 case eLIM_QUIET_RUNNING:
3152 // Transition to eLIM_QUIET_INIT
Jeff Johnsone7245742012-09-05 17:12:55 -07003153 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003154
3155 if( !pMac->lim.gLimTriggerBackgroundScanDuringQuietBss || (glimTriggerBackgroundScanDuringQuietBss_Status == eSIR_FALSE) )
3156 {
3157 // Resume data traffic only if channel switch is not running in silent mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07003158 if (!((psessionEntry->gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING) &&
3159 (psessionEntry->gLimChannelSwitch.switchMode == eSIR_CHANSW_MODE_SILENT)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 {
3161 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
Jeff Johnsone7245742012-09-05 17:12:55 -07003162 limRestorePreQuietState(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003163 }
3164
3165 /* Reset status flag */
3166 if(glimTriggerBackgroundScanDuringQuietBss_Status == eSIR_FALSE)
3167 glimTriggerBackgroundScanDuringQuietBss_Status = eSIR_TRUE;
3168
3169 limLog( pMac, LOG2,
3170 FL("Quiet BSS: Resuming traffic...\n"));
3171 }
3172 else
3173 {
3174 //
3175 // Nothing specific to be done in this case
3176 // A background scan that was triggered during
3177 // SIR_LIM_QUIET_TIMEOUT will complete on its own
3178 //
3179 limLog( pMac, LOG2,
3180 FL("Background scan should be complete now...\n"));
3181 }
3182 break;
3183
3184 case eLIM_QUIET_INIT:
3185 case eLIM_QUIET_BEGIN:
3186 case eLIM_QUIET_END:
3187 PELOG2(limLog(pMac, LOG2, FL("Quiet state not in RUNNING\n"));)
3188 /* If the quiet period has ended, then resume the frame transmission */
3189 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
Jeff Johnsone7245742012-09-05 17:12:55 -07003190 limRestorePreQuietState(pMac, psessionEntry);
3191 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 break;
3193
3194 default:
3195 //
3196 // As of now, nothing to be done
3197 //
3198 break;
3199 }
3200 }
3201}
3202#ifdef WLAN_SOFTAP_FEATURE
3203/**
3204 * limProcessWPSOverlapTimeout
3205 *
3206 * FUNCTION: This function call limWPSPBCTimeout() to clean WPS PBC probe request entries
3207 *
3208 * LOGIC:
3209 *
3210 * ASSUMPTIONS:
3211 *
3212 * NOTE:
3213 *
3214 * @param pMac - Pointer to Global MAC structure
3215 *
3216 * @return None
3217 */
3218#if 0
3219void limProcessWPSOverlapTimeout(tpAniSirGlobal pMac)
3220{
3221
3222 tpPESession psessionEntry;
3223 tANI_U32 sessionId;
3224
3225 if (tx_timer_activate(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer) != TX_SUCCESS)
3226 {
3227 limLog(pMac, LOGP, FL("tx_timer_activate failed\n"));
3228 }
3229
3230 sessionId = pMac->lim.limTimers.gLimWPSOverlapTimerObj.sessionId;
3231
3232 PELOGE(limLog(pMac, LOGE, FL("WPS overlap timeout, sessionId=%d\n"), sessionId);)
3233
3234 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId)) == NULL)
3235 {
3236 PELOGE(limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));)
3237 return;
3238 }
3239
3240 limWPSPBCTimeout(pMac, psessionEntry);
3241}
3242#endif
3243#endif
3244
3245/**
3246 * limUpdateQuietIEFromBeacon
3247 *
3248 * FUNCTION:
3249 *
3250 * LOGIC:
3251 * When the Quiet BSS IE is encountered when parsing for
3252 * Beacons/PR's, this function is called.
3253 * Based on the configuration of the Quiet Interval -
3254 * a) A TIMER (gLimQuietTimer) is started for the
3255 * specified interval
3256 * b) Upon expiry of the TIMER interval, the STA will
3257 * shut-off Tx/Rx
3258 * c) The STA will then start another TIMER (in this
3259 * case, gLimQuietBssTimer TIMER object), with the
3260 * timeout duration set to the value specified in the
3261 * Quiet BSS IE
3262 *
3263 * 1) To setup the Quiet BSS "interval". In this case,
3264 * this TIMER indicates that the STA has to shut-off its
3265 * Tx/Rx AFTER the specified interval
3266 * Set gLimQuietState = eLIM_QUIET_BEGIN
3267 *
3268 * 2) To setup the Quiet BSS "duration". After the said
3269 * specified "interval", the STA has to shut-off Tx/Rx
3270 * for this duration
3271 * Set gLimQuietState = eLIM_QUIET_RUNNING
3272 *
3273 * ASSUMPTIONS:
3274 *
3275 * NOTE:
3276 *
3277 * @param pMac - Pointer to Global MAC structure
3278 * @param pQuietIE - Pointer to tDot11fIEQuiet
3279 *
3280 * @return None
3281 */
3282void limUpdateQuietIEFromBeacon( struct sAniSirGlobal *pMac,
3283 tDot11fIEQuiet *pQuietIE, tpPESession psessionEntry )
3284{
3285#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
3286 tANI_U16 beaconPeriod;
3287 tANI_U32 val;
3288
3289 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3290 return;
3291
3292 PELOG1(limLog(pMac, LOG1, FL("Quiet state = %d, Quiet Count = %d\n"),
Jeff Johnsone7245742012-09-05 17:12:55 -07003293 psessionEntry->gLimSpecMgmt.quietState, pQuietIE->count);)
3294 if (!psessionEntry->lim11hEnable)
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 return;
3296 // The (Titan) AP is requesting this (Titan) STA to
3297 // honor this Quiet IE REQ and shut-off Tx/Rx. If we're
3298 // receiving this a second time around (because the AP
3299 // could be down-counting the Quiet BSS Count), the STA
3300 // will have to reset the timeout interval accordingly
3301 //
3302
3303 if (pQuietIE->count == 0)
3304 {
3305 PELOG1(limLog(pMac, LOG1, FL("Ignoring quiet count == 0->reserved\n"));)
3306 return;
3307 }
3308
3309 if( eSIR_SUCCESS !=
3310 wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &val ))
3311 beaconPeriod = (tANI_U16) WNI_CFG_BEACON_INTERVAL_APDEF;
3312 else
3313 beaconPeriod = (tANI_U16) val;
3314
3315 /* (qd * 2^10)/1000 */
Jeff Johnsone7245742012-09-05 17:12:55 -07003316 psessionEntry->gLimSpecMgmt.quietDuration_TU = pQuietIE->duration;
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 // The STA needs to shut-off Tx/Rx "for" this interval (in milliSeconds)
3318 /* Need to convert from TU to system TICKS */
Jeff Johnsone7245742012-09-05 17:12:55 -07003319 psessionEntry->gLimSpecMgmt.quietDuration = SYS_MS_TO_TICKS(
3320 SYS_TU_TO_MS(psessionEntry->gLimSpecMgmt.quietDuration_TU));
Jeff Johnson295189b2012-06-20 16:38:30 -07003321
Jeff Johnsone7245742012-09-05 17:12:55 -07003322 if (psessionEntry->gLimSpecMgmt.quietDuration_TU == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 {
3324 PELOG1(limLog(pMac, LOG1, FL("Zero duration in quiet IE\n"));)
3325 return;
3326 }
3327
3328 // The STA needs to shut-off Tx/Rx "after" this interval
Jeff Johnsone7245742012-09-05 17:12:55 -07003329 psessionEntry->gLimSpecMgmt.quietTimeoutValue =
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 (beaconPeriod * pQuietIE->count) + pQuietIE->offset;
3331
3332 limLog( pMac, LOG2,
3333 FL( "STA shut-off will begin in %d milliseconds & last for %d ticks\n"),
Jeff Johnsone7245742012-09-05 17:12:55 -07003334 psessionEntry->gLimSpecMgmt.quietTimeoutValue,
3335 psessionEntry->gLimSpecMgmt.quietDuration );
Jeff Johnson295189b2012-06-20 16:38:30 -07003336
3337 /* Disable, Stop background scan if enabled and running */
3338 limDeactivateAndChangeTimer(pMac, eLIM_BACKGROUND_SCAN_TIMER);
3339
3340 /* Stop heart-beat timer to stop heartbeat disassociation */
3341 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
3342
3343 if(pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE ||
3344 pMac->lim.gLimSmeState == eLIM_SME_CHANNEL_SCAN_STATE)
3345 {
3346 PELOGW(limLog(pMac, LOGW, FL("Posting finish scan as we are in scan state\n"));)
3347 /* Stop ongoing scanning if any */
3348 if (GET_LIM_PROCESS_DEFD_MESGS(pMac))
3349 {
3350 //Set the resume channel to Any valid channel (invalid).
3351 //This will instruct HAL to set it to any previous valid channel.
3352 peSetResumeChannel(pMac, 0, 0);
3353 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
3354 }
3355 else
3356 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003357 limRestorePreQuietState(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003358 }
3359 }
3360 else
3361 {
3362 PELOG1(limLog(pMac, LOG1, FL("Not in scan state, start quiet timer\n"));)
3363 /** We are safe to switch channel at this point */
3364 limStartQuietTimer(pMac, psessionEntry->peSessionId);
3365 }
3366
3367 // Transition to eLIM_QUIET_BEGIN
Jeff Johnsone7245742012-09-05 17:12:55 -07003368 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_BEGIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003369#endif
3370}
3371
3372
3373/**----------------------------------------------
3374\fn limStartQuietTimer
3375\brief Starts the quiet timer.
3376
3377\param pMac
3378\return NONE
3379-----------------------------------------------*/
3380void limStartQuietTimer(tpAniSirGlobal pMac, tANI_U8 sessionId)
3381{
3382 tpPESession psessionEntry;
3383 psessionEntry = peFindSessionBySessionId(pMac , sessionId);
3384
3385 if(psessionEntry == NULL) {
3386 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
3387 return;
3388 }
3389
3390#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
3391
3392 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3393 return;
3394 // First, de-activate Timer, if its already active
3395 limCancelDot11hQuiet(pMac, psessionEntry);
3396
Jeff Johnsone7245742012-09-05 17:12:55 -07003397 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, sessionId, eLIM_QUIET_TIMER));
3398 if( TX_SUCCESS != tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietTimer))
3399 {
3400 limLog( pMac, LOGE,
3401 FL( "Unable to deactivate gLimQuietTimer! Will still attempt to re-activate anyway...\n" ));
3402 }
3403
3404 // Set the NEW timeout value, in ticks
3405 if( TX_SUCCESS != tx_timer_change( &pMac->lim.limTimers.gLimQuietTimer,
3406 SYS_MS_TO_TICKS(psessionEntry->gLimSpecMgmt.quietTimeoutValue), 0))
3407 {
3408 limLog( pMac, LOGE,
3409 FL( "Unable to change gLimQuietTimer! Will still attempt to re-activate anyway...\n" ));
3410 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003411
3412 pMac->lim.limTimers.gLimQuietTimer.sessionId = sessionId;
3413 if( TX_SUCCESS != tx_timer_activate(&pMac->lim.limTimers.gLimQuietTimer))
3414 {
3415 limLog( pMac, LOGE,
3416 FL("Unable to activate gLimQuietTimer! STA cannot honor Quiet BSS!\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003417 limRestorePreQuietState(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003418
Jeff Johnsone7245742012-09-05 17:12:55 -07003419 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 return;
3421 }
3422#endif
3423}
3424
3425#ifdef ANI_PRODUCT_TYPE_AP
3426
3427/**
3428 * computeChannelSwitchCount
3429 *
3430 * FUNCTION:
3431 * Function used by limProcessSmeSwitchChlReq()
3432 * to compute channel switch count.
3433 *
3434 * LOGIC:
3435 * Channel Switch Count is the number of TBTT until AP switches
3436 * to a new channel. The value of Channel Switch Count is computed
3437 * in a way, such that channel switch will always take place after
3438 * a DTIM. By doing so, it is guaranteed that station in power save
3439 * mode can receive the message and switch to new channel accordingly.
3440 * AP can also announce the channel switch several dtims ahead of time.
3441 * by setting the dtimFactor value greater than 1.
3442 *
3443 * ASSUMPTIONS:
3444 *
3445 * NOTE:
3446 *
3447 * @param dtimFactor
3448 * @return channel switch count
3449 */
3450tANI_U32 computeChannelSwitchCount(tpAniSirGlobal pMac, tANI_U32 dtimFactor)
3451{
3452 tANI_U32 dtimPeriod;
3453 tANI_U32 dtimCount;
3454
3455 if (wlan_cfgGetInt(pMac, WNI_CFG_DTIM_PERIOD, &dtimPeriod) != eSIR_SUCCESS)
3456 PELOGE(limLog(pMac, LOGE, FL("wlan_cfgGetInt failed for WNI_CFG_DTIM_PERIOD \n"));)
3457
3458 dtimCount = pMac->pmm.gPmmTim.dtimCount;
3459
3460 if (dtimFactor <= 1)
3461 return (dtimCount + 1);
3462 else
3463 return (((dtimFactor -1)*dtimPeriod) + 1 + dtimCount);
3464}
3465#endif
3466
3467/** ------------------------------------------------------------------------ **/
3468/**
3469 * keep track of the number of ANI peers associated in the BSS
3470 * For the first and last ANI peer, we have to update EDCA params as needed
3471 *
3472 * When the first ANI peer joins the BSS, we notify SCH
3473 * When the last ANI peer leaves the BSS, we notfiy SCH
3474 */
3475void
3476limUtilCountStaAdd(
3477 tpAniSirGlobal pMac,
3478 tpDphHashNode pSta,
3479 tpPESession psessionEntry)
3480{
3481
3482 if ((! pSta) || (! pSta->valid) || (! pSta->aniPeer) || (pSta->fAniCount))
3483 return;
3484
3485 pSta->fAniCount = 1;
3486
3487 if (pMac->lim.gLimNumOfAniSTAs++ != 0)
3488 return;
3489
3490 // get here only if this is the first ANI peer in the BSS
3491 schEdcaProfileUpdate(pMac, psessionEntry);
3492}
3493
3494void
3495limUtilCountStaDel(
3496 tpAniSirGlobal pMac,
3497 tpDphHashNode pSta,
3498 tpPESession psessionEntry)
3499{
3500
3501 if ((pSta == NULL) || (pSta->aniPeer == eHAL_CLEAR) || (! pSta->fAniCount))
3502 return;
3503
3504 /* Only if sta is invalid and the validInDummyState bit is set to 1,
3505 * then go ahead and update the count and profiles. This ensures
3506 * that the "number of ani station" count is properly incremented/decremented.
3507 */
3508 if (pSta->valid == 1)
3509 return;
3510
3511 pSta->fAniCount = 0;
3512
3513 if (pMac->lim.gLimNumOfAniSTAs <= 0)
3514 {
3515 limLog(pMac, LOGE, FL("CountStaDel: ignoring Delete Req when AniPeer count is %d\n"),
3516 pMac->lim.gLimNumOfAniSTAs);
3517 return;
3518 }
3519
3520 pMac->lim.gLimNumOfAniSTAs--;
3521
3522 if (pMac->lim.gLimNumOfAniSTAs != 0)
3523 return;
3524
3525 // get here only if this is the last ANI peer in the BSS
3526 schEdcaProfileUpdate(pMac, psessionEntry);
3527}
3528
Jeff Johnson295189b2012-06-20 16:38:30 -07003529/**
3530 * limSwitchChannelCback()
3531 *
3532 *FUNCTION:
3533 * This is the callback function registered while requesting to switch channel
3534 * after AP indicates a channel switch for spectrum management (11h).
3535 *
3536 *NOTE:
3537 * @param pMac Pointer to Global MAC structure
3538 * @param status Status of channel switch request
3539 * @param data User data
3540 * @param psessionEntry Session information
3541 * @return NONE
3542 */
3543void limSwitchChannelCback(tpAniSirGlobal pMac, eHalStatus status,
3544 tANI_U32 *data, tpPESession psessionEntry)
3545{
3546 tSirMsgQ mmhMsg = {0};
3547 tSirSmeSwitchChannelInd *pSirSmeSwitchChInd;
3548
Jeff Johnson295189b2012-06-20 16:38:30 -07003549 psessionEntry->currentOperChannel = psessionEntry->currentReqChannel;
3550
3551 /* We need to restore pre-channelSwitch state on the STA */
3552 if (limRestorePreChannelSwitchState(pMac, psessionEntry) != eSIR_SUCCESS)
3553 {
3554 limLog(pMac, LOGP, FL("Could not restore pre-channelSwitch (11h) state, resetting the system\n"));
3555 return;
3556 }
3557
3558 mmhMsg.type = eWNI_SME_SWITCH_CHL_REQ;
3559 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pSirSmeSwitchChInd, sizeof(tSirSmeSwitchChannelInd)))
3560 {
3561 limLog(pMac, LOGP, FL("Failed to allocate buffer for buffer descriptor\n"));
3562 return;
3563 }
3564
3565 pSirSmeSwitchChInd->messageType = eWNI_SME_SWITCH_CHL_REQ;
3566 pSirSmeSwitchChInd->length = sizeof(tSirSmeSwitchChannelInd);
Jeff Johnsone7245742012-09-05 17:12:55 -07003567 pSirSmeSwitchChInd->newChannelId = psessionEntry->gLimChannelSwitch.primaryChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 pSirSmeSwitchChInd->sessionId = psessionEntry->smeSessionId;
3569 //BSS ID
3570 palCopyMemory( pMac->hHdd, pSirSmeSwitchChInd->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
3571 mmhMsg.bodyptr = pSirSmeSwitchChInd;
3572 mmhMsg.bodyval = 0;
3573
Jeff Johnsone7245742012-09-05 17:12:55 -07003574 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003575
3576#if defined( FEATURE_WLAN_INTEGRATED_SOC )
3577 SysProcessMmhMsg(pMac, &mmhMsg);
3578#else
3579 if(halMmhPostMsgApi(pMac, &mmhMsg, ePROT) != eSIR_SUCCESS)
3580 {
3581 palFreeMemory(pMac->hHdd, (void *)msg2Hdd);
3582 limLog(pMac, LOGP, FL("Message posting to HAL failed\n"));
3583 }
3584#endif
3585}
3586
3587/**
3588 * limSwitchPrimaryChannel()
3589 *
3590 *FUNCTION:
3591 * This function changes the current operating channel
3592 * and sets the new new channel ID in WNI_CFG_CURRENT_CHANNEL.
3593 *
3594 *NOTE:
3595 * @param pMac Pointer to Global MAC structure
3596 * @param newChannel new chnannel ID
3597 * @return NONE
3598 */
3599void limSwitchPrimaryChannel(tpAniSirGlobal pMac, tANI_U8 newChannel,tpPESession psessionEntry)
3600{
3601#if !defined WLAN_FEATURE_VOWIFI
3602 tANI_U32 localPwrConstraint;
3603#endif
3604
3605 PELOG3(limLog(pMac, LOG3, FL("limSwitchPrimaryChannel: old chnl %d --> new chnl %d \n"),
3606 psessionEntry->currentOperChannel, newChannel);)
3607 psessionEntry->currentReqChannel = newChannel;
3608 psessionEntry->limRFBand = limGetRFBand(newChannel);
3609
3610 psessionEntry->channelChangeReasonCode=LIM_SWITCH_CHANNEL_OPERATION;
3611
3612 pMac->lim.gpchangeChannelCallback = limSwitchChannelCback;
3613 pMac->lim.gpchangeChannelData = NULL;
3614
3615#if defined WLAN_FEATURE_VOWIFI
Jeff Johnsone7245742012-09-05 17:12:55 -07003616 limSendSwitchChnlParams(pMac, newChannel, PHY_SINGLE_CHANNEL_CENTERED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 psessionEntry->maxTxPower, psessionEntry->peSessionId);
3618#else
3619 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS)
3620 {
3621 limLog( pMac, LOGP, FL( "Unable to read Local Power Constraint from cfg\n" ));
3622 return;
3623 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003624 limSendSwitchChnlParams(pMac, newChannel, PHY_SINGLE_CHANNEL_CENTERED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 (tPowerdBm)localPwrConstraint, psessionEntry->peSessionId);
3626#endif
3627 return;
3628}
3629
3630/**
3631 * limSwitchPrimarySecondaryChannel()
3632 *
3633 *FUNCTION:
3634 * This function changes the primary and secondary channel.
3635 * If 11h is enabled and user provides a "new channel ID"
3636 * that is different from the current operating channel,
3637 * then we must set this new channel in WNI_CFG_CURRENT_CHANNEL,
3638 * assign notify LIM of such change.
3639 *
3640 *NOTE:
3641 * @param pMac Pointer to Global MAC structure
3642 * @param newChannel New chnannel ID (or current channel ID)
3643 * @param subband CB secondary info:
3644 * - eANI_CB_SECONDARY_NONE
3645 * - eANI_CB_SECONDARY_UP
3646 * - eANI_CB_SECONDARY_DOWN
3647 * @return NONE
3648 */
Jeff Johnsone7245742012-09-05 17:12:55 -07003649void limSwitchPrimarySecondaryChannel(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 newChannel, ePhyChanBondState subband)
Jeff Johnson295189b2012-06-20 16:38:30 -07003650{
3651#if !defined WLAN_FEATURE_VOWIFI
3652 tANI_U32 localPwrConstraint;
3653#endif
3654
Jeff Johnson295189b2012-06-20 16:38:30 -07003655#if !defined WLAN_FEATURE_VOWIFI
3656 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
3657 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg\n" ));
3658 return;
3659 }
3660#endif
3661
Jeff Johnson295189b2012-06-20 16:38:30 -07003662#if defined WLAN_FEATURE_VOWIFI
Jeff Johnsone7245742012-09-05 17:12:55 -07003663 limSendSwitchChnlParams(pMac, newChannel, subband, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003664#else
Jeff Johnsone7245742012-09-05 17:12:55 -07003665 limSendSwitchChnlParams(pMac, newChannel, subband, (tPowerdBm)localPwrConstraint, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003666#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003667
Jeff Johnsone7245742012-09-05 17:12:55 -07003668 // Store the new primary and secondary channel in session entries if different
3669 if (psessionEntry->currentOperChannel != newChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 {
3671 limLog(pMac, LOGW,
3672 FL("switch old chnl %d --> new chnl %d \n"),
3673 psessionEntry->currentOperChannel, newChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 psessionEntry->currentOperChannel = newChannel;
3675 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003676 if (psessionEntry->htSecondaryChannelOffset != subband)
3677 {
3678 limLog(pMac, LOGW,
3679 FL("switch old sec chnl %d --> new sec chnl %d \n"),
3680 psessionEntry->htSecondaryChannelOffset, subband);
3681 psessionEntry->htSecondaryChannelOffset = subband;
3682 if (psessionEntry->htSecondaryChannelOffset == PHY_SINGLE_CHANNEL_CENTERED)
3683 {
3684 psessionEntry->htSupportedChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3685 }
3686 else
3687 {
3688 psessionEntry->htSupportedChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
3689 }
3690 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
3691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003692
3693 return;
3694}
3695
3696
3697/**
3698 * limActiveScanAllowed()
3699 *
3700 *FUNCTION:
3701 * Checks if active scans are permitted on the given channel
3702 *
3703 *LOGIC:
3704 * The config variable SCAN_CONTROL_LIST contains pairs of (channelNum, activeScanAllowed)
3705 * Need to check if the channelNum matches, then depending on the corresponding
3706 * scan flag, return true (for activeScanAllowed==1) or false (otherwise).
3707 *
3708 *ASSUMPTIONS:
3709 *
3710 *NOTE:
3711 *
3712 * @param pMac Pointer to Global MAC structure
3713 * @param channelNum channel number
3714 * @return None
3715 */
3716
3717tANI_U8 limActiveScanAllowed(
3718 tpAniSirGlobal pMac,
3719 tANI_U8 channelNum)
3720{
3721 tANI_U32 i;
3722 tANI_U8 channelPair[WNI_CFG_SCAN_CONTROL_LIST_LEN];
3723 tANI_U32 len = WNI_CFG_SCAN_CONTROL_LIST_LEN;
3724 if (wlan_cfgGetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, channelPair, &len)
3725 != eSIR_SUCCESS)
3726 {
3727 PELOGE(limLog(pMac, LOGE, FL("Unable to get scan control list\n"));)
3728 return false;
3729 }
3730
3731 if (len > WNI_CFG_SCAN_CONTROL_LIST_LEN)
3732 {
3733 limLog(pMac, LOGE, FL("Invalid scan control list length:%d\n"),
3734 len);
3735 return false;
3736 }
3737
3738 for (i=0; (i+1) < len; i+=2)
3739 {
3740 if (channelPair[i] == channelNum)
3741 return ((channelPair[i+1] == eSIR_ACTIVE_SCAN) ? true : false);
3742 }
3743 return false;
3744}
3745
3746/**
3747 * limTriggerBackgroundScanDuringQuietBss()
3748 *
3749 *FUNCTION:
3750 * This function is applicable to the STA only.
3751 * This function is called by limProcessQuietTimeout(),
3752 * when it is time to honor the Quiet BSS IE from the AP.
3753 *
3754 *LOGIC:
3755 * If 11H is enabled:
3756 * We cannot trigger a background scan. The STA needs to
3757 * shut-off Tx/Rx.
3758 * If 11 is not enabled:
3759 * Determine if the next channel that we are going to
3760 * scan is NOT the same channel (or not) on which the
3761 * Quiet BSS was requested.
3762 * If yes, then we cannot trigger a background scan on
3763 * this channel. Return with a false.
3764 * If no, then trigger a background scan. Return with
3765 * a true.
3766 *
3767 *ASSUMPTIONS:
3768 *
3769 *NOTE:
3770 * This API is redundant if the existing API,
3771 * limTriggerBackgroundScan(), were to return a valid
3772 * response instead of returning void.
3773 * If possible, try to revisit this API
3774 *
3775 * @param pMac Pointer to Global MAC structure
3776 * @return eSIR_TRUE, if a background scan was attempted
3777 * eSIR_FALSE, if not
3778 */
3779tAniBool limTriggerBackgroundScanDuringQuietBss( tpAniSirGlobal pMac )
3780{
3781 tAniBool bScanTriggered = eSIR_FALSE;
3782#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
3783
3784
3785
3786 //TBD-RAJESH HOW TO GET sessionEntry?????
3787 tpPESession psessionEntry = &pMac->lim.gpSession[0];
3788
3789 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3790 return bScanTriggered;
3791
Jeff Johnsone7245742012-09-05 17:12:55 -07003792 if( !psessionEntry->lim11hEnable )
Jeff Johnson295189b2012-06-20 16:38:30 -07003793 {
3794 tSirMacChanNum bgScanChannelList[WNI_CFG_BG_SCAN_CHANNEL_LIST_LEN];
3795 tANI_U32 len = WNI_CFG_BG_SCAN_CHANNEL_LIST_LEN;
3796
3797 // Determine the next scan channel
3798
3799 // Get background scan channel list from CFG
3800 if( eSIR_SUCCESS == wlan_cfgGetStr( pMac,
3801 WNI_CFG_BG_SCAN_CHANNEL_LIST,
3802 (tANI_U8 *) bgScanChannelList,
3803 (tANI_U32 *) &len ))
3804 {
3805 // Ensure that we do not go off scanning on the same
3806 // channel on which the Quiet BSS was requested
3807 if( psessionEntry->currentOperChannel!=
3808 bgScanChannelList[pMac->lim.gLimBackgroundScanChannelId] )
3809 {
3810 // For now, try and attempt a background scan. It will
3811 // be ideal if this API actually returns a success or
3812 // failure instead of having a void return type
3813 limTriggerBackgroundScan( pMac );
3814
3815 bScanTriggered = eSIR_TRUE;
3816 }
3817 else
3818 {
3819 limLog( pMac, LOGW,
3820 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"));
3821 }
3822 }
3823 else
3824 {
3825 limLog( pMac, LOGW,
3826 FL("Unable to retrieve WNI_CFG_VALID_CHANNEL_LIST from CFG! A background scan will not be triggered during this Quiet BSS period...\n"));
3827 }
3828 }
3829#endif
3830 return bScanTriggered;
3831}
3832
3833
3834/**
3835 * limGetHTCapability()
3836 *
3837 *FUNCTION:
3838 * A utility function that returns the "current HT capability state" for the HT
3839 * capability of interest (as requested in the API)
3840 *
3841 *LOGIC:
3842 * This routine will return with the "current" setting of a requested HT
3843 * capability. This state info could be retrieved from -
3844 * a) CFG (for static entries)
3845 * b) Run time info
3846 * - Dynamic state maintained by LIM
3847 * - Configured at radio init time by SME
3848 *
3849 *
3850 *ASSUMPTIONS:
3851 * NA
3852 *
3853 *NOTE:
3854 *
3855 * @param pMac Pointer to Global MAC structure
3856 * @param htCap The HT capability being queried
3857 * @return tANI_U8 The current state of the requested HT capability is returned in a
3858 * tANI_U8 variable
3859 */
3860
3861#ifdef WLAN_SOFTAP_FEATURE
3862tANI_U8 limGetHTCapability( tpAniSirGlobal pMac,
3863 tANI_U32 htCap, tpPESession psessionEntry)
3864#else
3865tANI_U8 limGetHTCapability( tpAniSirGlobal pMac,
3866 tANI_U32 htCap )
3867#endif
3868{
3869tANI_U8 retVal = 0;
3870tANI_U8 *ptr;
3871tANI_U32 cfgValue;
3872tSirMacHTCapabilityInfo macHTCapabilityInfo = {0};
3873tSirMacExtendedHTCapabilityInfo macExtHTCapabilityInfo = {0};
3874tSirMacTxBFCapabilityInfo macTxBFCapabilityInfo = {0};
3875tSirMacASCapabilityInfo macASCapabilityInfo = {0};
3876
3877 //
3878 // Determine which CFG to read from. Not ALL of the HT
3879 // related CFG's need to be read each time this API is
3880 // accessed
3881 //
3882 if( htCap >= eHT_ANTENNA_SELECTION &&
3883 htCap < eHT_SI_GRANULARITY )
3884 {
3885 // Get Antenna Seletion HT Capabilities
3886 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_AS_CAP, &cfgValue ))
3887 cfgValue = 0;
3888 ptr = (tANI_U8 *) &macASCapabilityInfo;
3889 *((tANI_U8 *)ptr) = (tANI_U8) (cfgValue & 0xff);
3890 }
3891 else
3892 {
3893 if( htCap >= eHT_TX_BEAMFORMING &&
3894 htCap < eHT_ANTENNA_SELECTION )
3895 {
3896 // Get Transmit Beam Forming HT Capabilities
3897 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_TX_BF_CAP, &cfgValue ))
3898 cfgValue = 0;
3899 ptr = (tANI_U8 *) &macTxBFCapabilityInfo;
3900 *((tANI_U32 *)ptr) = (tANI_U32) (cfgValue);
3901 }
3902 else
3903 {
3904 if( htCap >= eHT_PCO &&
3905 htCap < eHT_TX_BEAMFORMING )
3906 {
3907 // Get Extended HT Capabilities
3908 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_EXT_HT_CAP_INFO, &cfgValue ))
3909 cfgValue = 0;
3910 ptr = (tANI_U8 *) &macExtHTCapabilityInfo;
3911 *((tANI_U16 *)ptr) = (tANI_U16) (cfgValue & 0xffff);
3912 }
3913 else
3914 {
3915 if( htCap < eHT_MAX_RX_AMPDU_FACTOR )
3916 {
3917 // Get HT Capabilities
3918 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_HT_CAP_INFO, &cfgValue ))
3919 cfgValue = 0;
3920 ptr = (tANI_U8 *) &macHTCapabilityInfo;
3921 // 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
3922 *ptr++ = cfgValue & 0xff;
3923 *ptr = (cfgValue >> 8) & 0xff;
3924 }
3925 }
3926 }
3927 }
3928
3929 switch( htCap )
3930 {
3931 case eHT_LSIG_TXOP_PROTECTION:
3932 retVal = pMac->lim.gHTLsigTXOPProtection;
3933 break;
3934
3935 case eHT_STBC_CONTROL_FRAME:
3936 retVal = (tANI_U8) macHTCapabilityInfo.stbcControlFrame;
3937 break;
3938
3939 case eHT_PSMP:
3940 retVal = pMac->lim.gHTPSMPSupport;
3941 break;
3942
3943 case eHT_DSSS_CCK_MODE_40MHZ:
3944 retVal = pMac->lim.gHTDsssCckRate40MHzSupport;
3945 break;
3946
3947 case eHT_MAX_AMSDU_LENGTH:
3948 retVal = (tANI_U8) macHTCapabilityInfo.maximalAMSDUsize;
3949 break;
3950
3951 case eHT_DELAYED_BA:
3952 retVal = (tANI_U8) macHTCapabilityInfo.delayedBA;
3953 break;
3954
3955 case eHT_RX_STBC:
3956 retVal = (tANI_U8) macHTCapabilityInfo.rxSTBC;
3957 break;
3958
3959 case eHT_TX_STBC:
3960 retVal = (tANI_U8) macHTCapabilityInfo.txSTBC;
3961 break;
3962
3963 case eHT_SHORT_GI_40MHZ:
3964 retVal = (tANI_U8) macHTCapabilityInfo.shortGI40MHz;
3965 break;
3966
3967 case eHT_SHORT_GI_20MHZ:
3968 retVal = (tANI_U8) macHTCapabilityInfo.shortGI20MHz;
3969 break;
3970
3971 case eHT_GREENFIELD:
3972 retVal = (tANI_U8) macHTCapabilityInfo.greenField;
3973 break;
3974
3975 case eHT_MIMO_POWER_SAVE:
3976 retVal = (tANI_U8) pMac->lim.gHTMIMOPSState;
3977 break;
3978
3979 case eHT_SUPPORTED_CHANNEL_WIDTH_SET:
Jeff Johnsone7245742012-09-05 17:12:55 -07003980 retVal = (tANI_U8) psessionEntry->htSupportedChannelWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 break;
3982
3983 case eHT_ADVANCED_CODING:
3984 retVal = (tANI_U8) macHTCapabilityInfo.advCodingCap;
3985 break;
3986
3987 case eHT_MAX_RX_AMPDU_FACTOR:
3988 retVal = pMac->lim.gHTMaxRxAMpduFactor;
3989 break;
3990
3991 case eHT_MPDU_DENSITY:
3992 retVal = pMac->lim.gHTAMpduDensity;
3993 break;
3994
3995 case eHT_PCO:
3996 retVal = (tANI_U8) macExtHTCapabilityInfo.pco;
3997 break;
3998
3999 case eHT_TRANSITION_TIME:
4000 retVal = (tANI_U8) macExtHTCapabilityInfo.transitionTime;
4001 break;
4002
4003 case eHT_MCS_FEEDBACK:
4004 retVal = (tANI_U8) macExtHTCapabilityInfo.mcsFeedback;
4005 break;
4006
4007 case eHT_TX_BEAMFORMING:
4008 retVal = (tANI_U8) macTxBFCapabilityInfo.txBF;
4009 break;
4010
4011 case eHT_ANTENNA_SELECTION:
4012 retVal = (tANI_U8) macASCapabilityInfo.antennaSelection;
4013 break;
4014
4015 case eHT_SI_GRANULARITY:
4016 retVal = pMac->lim.gHTServiceIntervalGranularity;
4017 break;
4018
4019 case eHT_CONTROLLED_ACCESS:
4020 retVal = pMac->lim.gHTControlledAccessOnly;
4021 break;
4022
4023 case eHT_RIFS_MODE:
4024 retVal = psessionEntry->beaconParams.fRIFSMode;
4025 break;
4026
4027 case eHT_RECOMMENDED_TX_WIDTH_SET:
Jeff Johnsone7245742012-09-05 17:12:55 -07004028 retVal = psessionEntry->htRecommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 break;
4030
4031 case eHT_EXTENSION_CHANNEL_OFFSET:
Jeff Johnsone7245742012-09-05 17:12:55 -07004032 retVal = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 break;
4034
4035 case eHT_OP_MODE:
4036#ifdef WLAN_SOFTAP_FEATURE
4037 if(psessionEntry->limSystemRole == eLIM_AP_ROLE )
4038 retVal = psessionEntry->htOperMode;
4039 else
4040#endif
4041 retVal = pMac->lim.gHTOperMode;
4042 break;
4043
4044 case eHT_BASIC_STBC_MCS:
4045 retVal = pMac->lim.gHTSTBCBasicMCS;
4046 break;
4047
4048 case eHT_DUAL_CTS_PROTECTION:
4049 retVal = pMac->lim.gHTDualCTSProtection;
4050 break;
4051
4052 case eHT_LSIG_TXOP_PROTECTION_FULL_SUPPORT:
4053 retVal = psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport;
4054 break;
4055
4056 case eHT_PCO_ACTIVE:
4057 retVal = pMac->lim.gHTPCOActive;
4058 break;
4059
4060 case eHT_PCO_PHASE:
4061 retVal = pMac->lim.gHTPCOPhase;
4062 break;
4063
4064 default:
4065 break;
4066 }
4067
4068 return retVal;
4069}
4070
Jeff Johnson295189b2012-06-20 16:38:30 -07004071void limGetMyMacAddr(tpAniSirGlobal pMac, tANI_U8 *mac)
4072{
4073 palCopyMemory( pMac->hHdd, mac, pMac->lim.gLimMyMacAddr, sizeof(tSirMacAddr));
4074 return;
4075}
4076
4077
4078
4079
4080/** -------------------------------------------------------------
4081\fn limEnable11aProtection
4082\brief based on config setting enables\disables 11a protection.
4083\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4084\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4085\param tpUpdateBeaconParams pBeaconParams
4086\return None
4087 -------------------------------------------------------------*/
4088tSirRetStatus
4089limEnable11aProtection(tpAniSirGlobal pMac, tANI_U8 enable,
4090 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4091{
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07004092 if(NULL == psessionEntry)
4093 {
4094 PELOG3(limLog(pMac, LOG3, FL("psessionEntry is NULL\n"));)
4095 return eSIR_FAILURE;
4096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 //overlapping protection configuration check.
4098 if(overlap)
4099 {
4100#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
4101 if(psessionEntry->limSystemRole == eLIM_AP_ROLE && !pMac->lim.cfgProtection.overlapFromlla)
4102 {
4103 // protection disabled.
4104 PELOG3(limLog(pMac, LOG3, FL("overlap protection from 11a is disabled\n"));)
4105 return eSIR_SUCCESS;
4106 }
4107#endif
4108 }
4109 else
4110 {
4111 //normal protection config check
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07004112 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07004113 (!psessionEntry->cfgProtection.fromlla))
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 {
4115 // protection disabled.
4116 PELOG3(limLog(pMac, LOG3, FL("protection from 11a is disabled\n"));)
4117 return eSIR_SUCCESS;
4118 }
4119 }
4120
4121 if (enable)
4122 {
4123 //If we are AP and HT capable, we need to set the HT OP mode
4124 //appropriately.
4125 if(((eLIM_AP_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole))&&
Jeff Johnsone7245742012-09-05 17:12:55 -07004126 (true == psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 {
4128 if(overlap)
4129 {
4130 pMac->lim.gLimOverlap11aParams.protectionEnabled = true;
4131 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
4132 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
4133 {
4134 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4135 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4136 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4137 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4138 }
4139 }
4140 else
4141 {
4142 psessionEntry->gLim11aParams.protectionEnabled = true;
4143 if(eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode)
4144 {
4145 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_MIXED;
Jeff Johnsone7245742012-09-05 17:12:55 -07004146 psessionEntry->htOperMode = eSIR_HT_OP_MODE_MIXED;
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4148 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4149
4150 }
4151 }
4152 }
4153
4154 //This part is common for staiton as well.
4155 if(false == psessionEntry->beaconParams.llaCoexist)
4156 {
4157 PELOG1(limLog(pMac, LOG1, FL(" => protection from 11A Enabled\n"));)
4158 pBeaconParams->llaCoexist = psessionEntry->beaconParams.llaCoexist = true;
4159 pBeaconParams->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
4160 }
4161 }
4162 else if (true == psessionEntry->beaconParams.llaCoexist)
4163 {
4164 //for AP role.
4165 //we need to take care of HT OP mode change if needed.
4166 //We need to take care of Overlap cases.
4167 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4168 {
4169 if(overlap)
4170 {
4171 //Overlap Legacy protection disabled.
4172 pMac->lim.gLimOverlap11aParams.protectionEnabled = false;
4173
4174 //We need to take care of HT OP mode iff we are HT AP.
Jeff Johnsone7245742012-09-05 17:12:55 -07004175 if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 {
4177 // no HT op mode change if any of the overlap protection enabled.
4178 if(!(pMac->lim.gLimOverlap11aParams.protectionEnabled ||
4179 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4180 pMac->lim.gLimOverlapNonGfParams.protectionEnabled))
4181
4182 {
4183 //Check if there is a need to change HT OP mode.
4184 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
4185 {
4186 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4187 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4188
4189 if(psessionEntry->gLimHt20Params.protectionEnabled)
4190 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4191 else
4192 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4193 }
4194 }
4195 }
4196 }
4197 else
4198 {
4199 //Disable protection from 11A stations.
4200 psessionEntry->gLim11aParams.protectionEnabled = false;
4201 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4202
4203 //Check if any other non-HT protection enabled.
4204 //Right now we are in HT OP Mixed mode.
4205 //Change HT op mode appropriately.
4206
4207 //Change HT OP mode to 01 if any overlap protection enabled
4208 if(pMac->lim.gLimOverlap11aParams.protectionEnabled ||
4209 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4210 pMac->lim.gLimOverlapNonGfParams.protectionEnabled)
4211
4212 {
4213 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
Jeff Johnsone7245742012-09-05 17:12:55 -07004214 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4216 }
4217 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4218 {
4219 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
Jeff Johnsone7245742012-09-05 17:12:55 -07004220 psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4222 }
4223 else
4224 {
4225 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004226 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004227 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4228 }
4229 }
4230 if(!pMac->lim.gLimOverlap11aParams.protectionEnabled &&
4231 !psessionEntry->gLim11aParams.protectionEnabled)
4232 {
4233 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11A Disabled\n"));)
4234 pBeaconParams->llaCoexist = psessionEntry->beaconParams.llaCoexist = false;
4235 pBeaconParams->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
4236 }
4237 }
4238 //for station role
4239 else
4240 {
4241 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11A Disabled\n"));)
4242 pBeaconParams->llaCoexist = psessionEntry->beaconParams.llaCoexist = false;
4243 pBeaconParams->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
4244 }
4245 }
4246
4247 return eSIR_SUCCESS;
4248}
4249
4250/** -------------------------------------------------------------
4251\fn limEnable11gProtection
4252\brief based on config setting enables\disables 11g protection.
4253\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4254\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4255\param tpUpdateBeaconParams pBeaconParams
4256\return None
4257 -------------------------------------------------------------*/
4258
4259tSirRetStatus
4260limEnable11gProtection(tpAniSirGlobal pMac, tANI_U8 enable,
4261 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4262{
4263
4264 //overlapping protection configuration check.
4265 if(overlap)
4266 {
4267#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
4268 if(((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE )) && !pMac->lim.cfgProtection.overlapFromllb)
4269 {
4270 // protection disabled.
4271 PELOG1(limLog(pMac, LOG1, FL("overlap protection from 11b is disabled\n"));)
4272 return eSIR_SUCCESS;
4273 }
4274#endif
4275 }
4276 else
4277 {
4278 //normal protection config check
4279#ifdef WLAN_SOFTAP_FEATURE
4280 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
4281 !psessionEntry->cfgProtection.fromllb)
4282 {
4283 // protection disabled.
4284 PELOG1(limLog(pMac, LOG1, FL("protection from 11b is disabled\n"));)
4285 return eSIR_SUCCESS;
4286 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
4287#endif
4288 {
4289 if(!pMac->lim.cfgProtection.fromllb)
4290 {
4291 // protection disabled.
4292 PELOG1(limLog(pMac, LOG1, FL("protection from 11b is disabled\n"));)
4293 return eSIR_SUCCESS;
4294 }
4295 }
4296 }
4297
4298 if (enable)
4299 {
4300 //If we are AP and HT capable, we need to set the HT OP mode
4301 //appropriately.
4302#ifdef WLAN_SOFTAP_FEATURE
4303 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4304 {
4305 if(overlap)
4306 {
4307 psessionEntry->gLimOlbcParams.protectionEnabled = true;
4308 PELOGE(limLog(pMac, LOGE, FL("protection from olbc is enabled\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004309 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 {
4311 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != psessionEntry->htOperMode) &&
4312 (eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode))
4313 {
4314 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4315 }
4316 //CR-263021: OBSS bit is not switching back to 0 after disabling the overlapping legacy BSS
4317 // This fixes issue of OBSS bit not set after 11b, 11g station leaves
4318 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4319 //Not processing OBSS bit from other APs, as we are already taking care
4320 //of Protection from overlapping BSS based on erp IE or useProtection bit
4321 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams, psessionEntry);
4322 }
4323 }
4324 else
4325 {
4326 psessionEntry->gLim11bParams.protectionEnabled = true;
4327 PELOGE(limLog(pMac, LOGE, FL("protection from 11b is enabled\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004328 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004329 {
4330 if(eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode)
4331 {
4332 psessionEntry->htOperMode = eSIR_HT_OP_MODE_MIXED;
4333 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4334 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4335 }
4336 }
4337 }
4338 }else if ((eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07004339 (true == psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07004340#else
4341 if(((eLIM_AP_ROLE == psessionEntry->limSystemRole)|| (eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07004342 (true == psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07004343#endif
4344 {
4345 if(overlap)
4346 {
4347 psessionEntry->gLimOlbcParams.protectionEnabled = true;
4348 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
4349 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
4350 {
4351 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4352 }
4353 //CR-263021: OBSS bit is not switching back to 0 after disabling the overlapping legacy BSS
4354 // This fixes issue of OBSS bit not set after 11b, 11g station leaves
4355 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4356 //Not processing OBSS bit from other APs, as we are already taking care
4357 //of Protection from overlapping BSS based on erp IE or useProtection bit
4358 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams, psessionEntry);
4359 }
4360 else
4361 {
4362 psessionEntry->gLim11bParams.protectionEnabled = true;
4363 if(eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode)
4364 {
4365 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_MIXED;
4366 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4367 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4368 }
4369 }
4370 }
4371
4372 //This part is common for staiton as well.
4373 if(false == psessionEntry->beaconParams.llbCoexist)
4374 {
4375 PELOG1(limLog(pMac, LOG1, FL("=> 11G Protection Enabled\n"));)
4376 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = true;
4377 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4378 }
4379 }
4380 else if (true == psessionEntry->beaconParams.llbCoexist)
4381 {
4382 //for AP role.
4383 //we need to take care of HT OP mode change if needed.
4384 //We need to take care of Overlap cases.
4385#ifdef WLAN_SOFTAP_FEATURE
4386 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4387 {
4388 if(overlap)
4389 {
4390 //Overlap Legacy protection disabled.
4391 psessionEntry->gLimOlbcParams.protectionEnabled = false;
4392
4393 //We need to take care of HT OP mode if we are HT AP.
Jeff Johnsone7245742012-09-05 17:12:55 -07004394 if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 {
4396 // no HT op mode change if any of the overlap protection enabled.
4397 if(!(psessionEntry->gLimOverlap11gParams.protectionEnabled ||
4398 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4399 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
4400 {
4401 //Check if there is a need to change HT OP mode.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004402 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == psessionEntry->htOperMode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 {
4404 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4405 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4406 if(psessionEntry->gLimHt20Params.protectionEnabled){
4407 //Commenting out beacuse of CR 258588 WFA cert
4408 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4409 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4410 }
4411 else
4412 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4413 }
4414 }
4415 }
4416 }
4417 else
4418 {
4419 //Disable protection from 11B stations.
4420 psessionEntry->gLim11bParams.protectionEnabled = false;
4421 PELOGE(limLog(pMac, LOGE, FL("===> 11B Protection Disabled\n"));)
4422 //Check if any other non-HT protection enabled.
4423 if(!psessionEntry->gLim11gParams.protectionEnabled)
4424 {
4425 //Right now we are in HT OP Mixed mode.
4426 //Change HT op mode appropriately.
4427 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4428
4429 //Change HT OP mode to 01 if any overlap protection enabled
4430 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4431 psessionEntry->gLimOverlap11gParams.protectionEnabled ||
4432 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4433 psessionEntry->gLimOverlapNonGfParams.protectionEnabled)
4434 {
4435 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4436 PELOGE(limLog(pMac, LOGE, FL("===> 11G Protection Disabled\n"));)
4437 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4438 }
4439 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4440 {
4441 //Commenting because of CR 258588 WFA cert
4442 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4443 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4444 PELOGE(limLog(pMac, LOGE, FL("===> 11G Protection Disabled\n"));)
4445 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4446 }
4447 else
4448 {
4449 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4450 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4451 }
4452 }
4453 }
4454 if(!psessionEntry->gLimOlbcParams.protectionEnabled &&
4455 !psessionEntry->gLim11bParams.protectionEnabled)
4456 {
4457 PELOGE(limLog(pMac, LOGE, FL("===> 11G Protection Disabled\n"));)
4458 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
4459 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4460 }
4461 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
4462#else
4463 if((eLIM_AP_ROLE == psessionEntry->limSystemRole)||((eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)))
4464#endif
4465 {
4466 if(overlap)
4467 {
4468 //Overlap Legacy protection disabled.
4469 psessionEntry->gLimOlbcParams.protectionEnabled = false;
4470
4471 //We need to take care of HT OP mode iff we are HT AP.
Jeff Johnsone7245742012-09-05 17:12:55 -07004472 if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 {
4474 // no HT op mode change if any of the overlap protection enabled.
4475 if(!(pMac->lim.gLimOverlap11gParams.protectionEnabled ||
4476 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4477 pMac->lim.gLimOverlapNonGfParams.protectionEnabled))
4478
4479 {
4480 //Check if there is a need to change HT OP mode.
4481 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
4482 {
4483 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4484 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4485 if(psessionEntry->gLimHt20Params.protectionEnabled)
4486 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4487 else
4488 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4489 }
4490 }
4491 }
4492 }
4493 else
4494 {
4495 //Disable protection from 11B stations.
4496 psessionEntry->gLim11bParams.protectionEnabled = false;
4497 //Check if any other non-HT protection enabled.
4498 if(!psessionEntry->gLim11gParams.protectionEnabled)
4499 {
4500 //Right now we are in HT OP Mixed mode.
4501 //Change HT op mode appropriately.
4502 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4503
4504 //Change HT OP mode to 01 if any overlap protection enabled
4505 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4506 pMac->lim.gLimOverlap11gParams.protectionEnabled ||
4507 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4508 pMac->lim.gLimOverlapNonGfParams.protectionEnabled)
4509
4510 {
4511 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4512 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4513 }
4514 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4515 {
4516 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4517 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4518 }
4519 else
4520 {
4521 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4522 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4523 }
4524 }
4525 }
4526 if(!psessionEntry->gLimOlbcParams.protectionEnabled &&
4527 !psessionEntry->gLim11bParams.protectionEnabled)
4528 {
4529 PELOG1(limLog(pMac, LOG1, FL("===> 11G Protection Disabled\n"));)
4530 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
4531 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4532 }
4533 }
4534 //for station role
4535 else
4536 {
4537 PELOG1(limLog(pMac, LOG1, FL("===> 11G Protection Disabled\n"));)
4538 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
4539 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4540 }
4541 }
4542 return eSIR_SUCCESS;
4543}
4544
4545/** -------------------------------------------------------------
4546\fn limEnableHtProtectionFrom11g
4547\brief based on cofig enables\disables protection from 11g.
4548\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4549\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4550\param tpUpdateBeaconParams pBeaconParams
4551\return None
4552 -------------------------------------------------------------*/
4553tSirRetStatus
4554limEnableHtProtectionFrom11g(tpAniSirGlobal pMac, tANI_U8 enable,
4555 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4556{
Jeff Johnsone7245742012-09-05 17:12:55 -07004557 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 return eSIR_SUCCESS; // protection from 11g is only for HT stations.
4559
4560 //overlapping protection configuration check.
4561 if(overlap)
4562 {
4563#ifdef WLAN_SOFTAP_FEATURE
4564 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) && (!psessionEntry->cfgProtection.overlapFromllg))
4565 {
4566 // protection disabled.
4567 PELOG3(limLog(pMac, LOG3, FL("overlap protection from 11g is disabled\n")););
4568 return eSIR_SUCCESS;
4569 }else if ((psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) && (!pMac->lim.cfgProtection.overlapFromllg))
4570#else
4571 if(((psessionEntry->limSystemRole == eLIM_AP_ROLE ) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) && (!pMac->lim.cfgProtection.overlapFromllg))
4572#endif
4573 {
4574 // protection disabled.
4575 PELOG3(limLog(pMac, LOG3, FL("overlap protection from 11g is disabled\n")););
4576 return eSIR_SUCCESS;
4577 }
4578 }
4579 else
4580 {
4581 //normal protection config check
4582#ifdef WLAN_SOFTAP_FEATURE
4583 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
4584 !psessionEntry->cfgProtection.fromllg){
4585 // protection disabled.
4586 PELOG3(limLog(pMac, LOG3, FL("protection from 11g is disabled\n"));)
4587 return eSIR_SUCCESS;
4588 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
4589#endif
4590 {
4591 if(!pMac->lim.cfgProtection.fromllg)
4592 {
4593 // protection disabled.
4594 PELOG3(limLog(pMac, LOG3, FL("protection from 11g is disabled\n"));)
4595 return eSIR_SUCCESS;
4596 }
4597 }
4598 }
4599 if (enable)
4600 {
4601 //If we are AP and HT capable, we need to set the HT OP mode
4602 //appropriately.
4603
4604#ifdef WLAN_SOFTAP_FEATURE
4605 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4606 {
4607 if(overlap)
4608 {
4609 psessionEntry->gLimOverlap11gParams.protectionEnabled = true;
4610 //11g exists in overlap BSS.
4611 //need not to change the operating mode to overlap_legacy
4612 //if higher or same protection operating mode is enabled right now.
4613 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != psessionEntry->htOperMode) &&
4614 (eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode))
4615 {
4616 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4617 }
4618 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4619 limEnableHtOBSSProtection(pMac, true , overlap, pBeaconParams, psessionEntry);
4620 }
4621 else
4622 {
4623 //11g is associated to an AP operating in 11n mode.
4624 //Change the HT operating mode to 'mixed mode'.
4625 psessionEntry->gLim11gParams.protectionEnabled = true;
4626 if(eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode)
4627 {
4628 psessionEntry->htOperMode = eSIR_HT_OP_MODE_MIXED;
4629 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4630 limEnableHtOBSSProtection(pMac, true , overlap, pBeaconParams,psessionEntry);
4631 }
4632 }
4633 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
4634#else
4635 if((eLIM_AP_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole))
4636#endif
4637 {
4638 if(overlap)
4639 {
4640 pMac->lim.gLimOverlap11gParams.protectionEnabled = true;
4641 //11g exists in overlap BSS.
4642 //need not to change the operating mode to overlap_legacy
4643 //if higher or same protection operating mode is enabled right now.
4644 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
4645 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
4646 {
4647 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4648 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4649 }
4650 }
4651 else
4652 {
4653 //11g is associated to an AP operating in 11n mode.
4654 //Change the HT operating mode to 'mixed mode'.
4655 psessionEntry->gLim11gParams.protectionEnabled = true;
4656 if(eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode)
4657 {
4658 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_MIXED;
4659 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4660 limEnableHtOBSSProtection(pMac, true , overlap, pBeaconParams,psessionEntry);
4661 }
4662 }
4663 }
4664
4665 //This part is common for staiton as well.
4666 if(false == psessionEntry->beaconParams.llgCoexist)
4667 {
4668 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = true;
4669 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4670 }
4671#ifdef WLAN_SOFTAP_FEATURE
4672 else if (true == psessionEntry->gLimOverlap11gParams.protectionEnabled)
4673 {
4674 // As operating mode changed after G station assoc some way to update beacon
4675 // This addresses the issue of mode not changing to - 11 in beacon when OBSS overlap is enabled
4676 //pMac->sch.schObject.fBeaconChanged = 1;
4677 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4678 }
4679#endif
4680 }
4681 else if (true == psessionEntry->beaconParams.llgCoexist)
4682 {
4683 //for AP role.
4684 //we need to take care of HT OP mode change if needed.
4685 //We need to take care of Overlap cases.
4686
4687#ifdef WLAN_SOFTAP_FEATURE
4688 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4689 {
4690 if(overlap)
4691 {
4692 //Overlap Legacy protection disabled.
4693 if (psessionEntry->gLim11gParams.numSta == 0)
4694 psessionEntry->gLimOverlap11gParams.protectionEnabled = false;
4695
4696 // no HT op mode change if any of the overlap protection enabled.
4697 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
4698 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4699 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
4700 {
4701 //Check if there is a need to change HT OP mode.
4702 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == psessionEntry->htOperMode)
4703 {
4704 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4705 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4706
4707 if(psessionEntry->gLimHt20Params.protectionEnabled){
4708 //Commenting because of CR 258588 WFA cert
4709 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4710 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4711 }
4712 else
4713 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4714 }
4715 }
4716 }
4717 else
4718 {
4719 //Disable protection from 11G stations.
4720 psessionEntry->gLim11gParams.protectionEnabled = false;
4721 //Check if any other non-HT protection enabled.
4722 if(!psessionEntry->gLim11bParams.protectionEnabled)
4723 {
4724
4725 //Right now we are in HT OP Mixed mode.
4726 //Change HT op mode appropriately.
4727 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4728
4729 //Change HT OP mode to 01 if any overlap protection enabled
4730 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4731 psessionEntry->gLimOverlap11gParams.protectionEnabled ||
4732 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4733 psessionEntry->gLimOverlapNonGfParams.protectionEnabled)
4734
4735 {
4736 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4737 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4738 }
4739 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4740 {
4741 //Commenting because of CR 258588 WFA cert
4742 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4743 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4744 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4745 }
4746 else
4747 {
4748 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4749 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4750 }
4751 }
4752 }
4753 if(!psessionEntry->gLimOverlap11gParams.protectionEnabled &&
4754 !psessionEntry->gLim11gParams.protectionEnabled)
4755 {
4756 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11G Disabled\n"));)
4757 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = false;
4758 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4759 }
4760 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
4761#else
4762 if((eLIM_AP_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole))
4763#endif
4764 {
4765 if(overlap)
4766 {
4767 //Overlap Legacy protection disabled.
4768 pMac->lim.gLimOverlap11gParams.protectionEnabled = false;
4769
4770 // no HT op mode change if any of the overlap protection enabled.
4771 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
4772 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4773 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
4774 {
4775 //Check if there is a need to change HT OP mode.
4776 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
4777 {
4778 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4779 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4780
4781 if(psessionEntry->gLimHt20Params.protectionEnabled)
4782 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4783 else
4784 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4785 }
4786 }
4787 }
4788 else
4789 {
4790 //Disable protection from 11G stations.
4791 psessionEntry->gLim11gParams.protectionEnabled = false;
4792 //Check if any other non-HT protection enabled.
4793 if(!psessionEntry->gLim11bParams.protectionEnabled)
4794 {
4795
4796 //Right now we are in HT OP Mixed mode.
4797 //Change HT op mode appropriately.
4798 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4799
4800 //Change HT OP mode to 01 if any overlap protection enabled
4801 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4802 pMac->lim.gLimOverlap11gParams.protectionEnabled ||
4803 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4804 pMac->lim.gLimOverlapNonGfParams.protectionEnabled)
4805
4806 {
4807 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4808 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4809 }
4810 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4811 {
4812 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4813 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4814 }
4815 else
4816 {
4817 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4818 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4819 }
4820 }
4821 }
4822 if(!pMac->lim.gLimOverlap11gParams.protectionEnabled &&
4823 !psessionEntry->gLim11gParams.protectionEnabled)
4824 {
4825 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11G Disabled\n"));)
4826 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = false;
4827 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4828 }
4829 }
4830 //for station role
4831 else
4832 {
4833 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11G Disabled\n"));)
4834 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = false;
4835 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4836 }
4837 }
4838 return eSIR_SUCCESS;
4839}
4840//FIXME_PROTECTION : need to check for no APSD whenever we want to enable this protection.
4841//This check will be done at the caller.
4842
4843/** -------------------------------------------------------------
4844\fn limEnableHtObssProtection
4845\brief based on cofig enables\disables obss protection.
4846\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4847\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4848\param tpUpdateBeaconParams pBeaconParams
4849\return None
4850 -------------------------------------------------------------*/
4851tSirRetStatus
4852limEnableHtOBSSProtection(tpAniSirGlobal pMac, tANI_U8 enable,
4853 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4854{
4855
4856
Jeff Johnsone7245742012-09-05 17:12:55 -07004857 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 return eSIR_SUCCESS; // this protection is only for HT stations.
4859
4860 //overlapping protection configuration check.
4861 if(overlap)
4862 {
4863 //overlapping protection configuration check.
4864 #if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
4865 if((psessionEntry->limSystemRole == eLIM_AP_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) && !pMac->lim.cfgProtection.overlapOBSS)
4866 { // ToDo Update this field
4867 // protection disabled.
4868 PELOG1(limLog(pMac, LOG1, FL("overlap protection from Obss is disabled\n"));)
4869 return eSIR_SUCCESS;
4870 }
4871 #endif
4872 }
4873 else
4874 {
4875 //normal protection config check
4876#ifdef WLAN_SOFTAP_FEATURE
4877 if((psessionEntry->limSystemRole == eLIM_AP_ROLE) && !psessionEntry->cfgProtection.obss)
4878 { //ToDo Update this field
4879 // protection disabled.
4880 PELOG1(limLog(pMac, LOG1, FL("protection from Obss is disabled\n"));)
4881 return eSIR_SUCCESS;
4882 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
4883#endif
4884 {
4885 if(!pMac->lim.cfgProtection.obss)
4886 { //ToDo Update this field
4887 // protection disabled.
4888 PELOG1(limLog(pMac, LOG1, FL("protection from Obss is disabled\n"));)
4889 return eSIR_SUCCESS;
4890 }
4891 }
4892 }
4893
4894
4895#ifdef WLAN_SOFTAP_FEATURE
4896 if (eLIM_AP_ROLE == psessionEntry->limSystemRole){
4897 if ((enable) && (false == psessionEntry->beaconParams.gHTObssMode) )
4898 {
4899 PELOG1(limLog(pMac, LOG1, FL("=>obss protection enabled\n"));)
4900 psessionEntry->beaconParams.gHTObssMode = true;
4901 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED; // UPDATE AN ENUM FOR OBSS MODE <todo>
4902
4903 }
4904 else if (!enable && (true == psessionEntry->beaconParams.gHTObssMode))
4905 {
4906 PELOG1(limLog(pMac, LOG1, FL("===> obss Protection disabled\n"));)
4907 psessionEntry->beaconParams.gHTObssMode = false;
4908 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED;
4909
4910 }
4911//CR-263021: OBSS bit is not switching back to 0 after disabling the overlapping legacy BSS
4912 if (!enable && !overlap)
4913 {
4914 psessionEntry->gLimOverlap11gParams.protectionEnabled = false;
4915 }
4916 } else
4917#endif
4918 {
4919 if ((enable) && (false == psessionEntry->beaconParams.gHTObssMode) )
4920 {
4921 PELOG1(limLog(pMac, LOG1, FL("=>obss protection enabled\n"));)
4922 psessionEntry->beaconParams.gHTObssMode = true;
4923 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED; // UPDATE AN ENUM FOR OBSS MODE <todo>
4924
4925 }
4926 else if (!enable && (true == psessionEntry->beaconParams.gHTObssMode))
4927 {
4928
4929 PELOG1(limLog(pMac, LOG1, FL("===> obss Protection disabled\n"));)
4930 psessionEntry->beaconParams.gHTObssMode = false;
4931 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED;
4932
4933 }
4934 }
4935 return eSIR_SUCCESS;
4936}
4937/** -------------------------------------------------------------
4938\fn limEnableHT20Protection
4939\brief based on cofig enables\disables protection from Ht20.
4940\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4941\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4942\param tpUpdateBeaconParams pBeaconParams
4943\return None
4944 -------------------------------------------------------------*/
4945tSirRetStatus
4946limEnableHT20Protection(tpAniSirGlobal pMac, tANI_U8 enable,
4947 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4948{
Jeff Johnsone7245742012-09-05 17:12:55 -07004949 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 return eSIR_SUCCESS; // this protection is only for HT stations.
4951
4952 //overlapping protection configuration check.
4953 if(overlap)
4954 {
4955#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
4956 if(((psessionEntry->limSystemRole == eLIM_AP_ROLE )||(psessionEntry->limSystemRoleS == eLIM_BT_AMP_AP_ROLE ))&& !pMac->lim.cfgProtection.overlapHt20)
4957 {
4958 // protection disabled.
4959 PELOG3(limLog(pMac, LOG3, FL("overlap protection from HT 20 is disabled\n"));)
4960 return eSIR_SUCCESS;
4961 }
4962#endif
4963 }
4964 else
4965 {
4966 //normal protection config check
4967#ifdef WLAN_SOFTAP_FEATURE
4968 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
4969 !psessionEntry->cfgProtection.ht20)
4970 {
4971 // protection disabled.
4972 PELOG3(limLog(pMac, LOG3, FL("protection from HT20 is disabled\n"));)
4973 return eSIR_SUCCESS;
4974 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
4975#endif
4976 {
4977 if(!pMac->lim.cfgProtection.ht20)
4978 {
4979 // protection disabled.
4980 PELOG3(limLog(pMac, LOG3, FL("protection from HT20 is disabled\n"));)
4981 return eSIR_SUCCESS;
4982 }
4983 }
4984 }
4985
4986 if (enable)
4987 {
4988 //If we are AP and HT capable, we need to set the HT OP mode
4989 //appropriately.
4990
4991#ifdef WLAN_SOFTAP_FEATURE
4992 if(eLIM_AP_ROLE == psessionEntry->limSystemRole){
4993 if(overlap)
4994 {
4995 psessionEntry->gLimOverlapHt20Params.protectionEnabled = true;
4996 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != psessionEntry->htOperMode) &&
4997 (eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode))
4998 {
4999 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
5000 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
5001 }
5002 }
5003 else
5004 {
5005 psessionEntry->gLimHt20Params.protectionEnabled = true;
5006 if(eSIR_HT_OP_MODE_PURE == psessionEntry->htOperMode)
5007 {
5008 //Commenting because of CR 258588 WFA cert
5009 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
5010 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
5011 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5012 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5013 }
5014 }
5015 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
5016#else
5017 if((eLIM_AP_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole))
5018#endif
5019 {
5020 if(overlap)
5021 {
5022 pMac->lim.gLimOverlapHt20Params.protectionEnabled = true;
5023 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
5024 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
5025 {
5026 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
5027 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
5028 }
5029 }
5030 else
5031 {
5032 psessionEntry->gLimHt20Params.protectionEnabled = true;
5033 if(eSIR_HT_OP_MODE_PURE == pMac->lim.gHTOperMode)
5034 {
5035 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
5036 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5037 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5038 }
5039 }
5040 }
5041
5042 //This part is common for staiton as well.
5043 if(false == psessionEntry->beaconParams.ht20Coexist)
5044 {
5045 PELOG1(limLog(pMac, LOG1, FL("=> Prtection from HT20 Enabled\n"));)
5046 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = true;
5047 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
5048 }
5049 }
5050 else if (true == psessionEntry->beaconParams.ht20Coexist)
5051 {
5052 //for AP role.
5053 //we need to take care of HT OP mode change if needed.
5054 //We need to take care of Overlap cases.
5055#ifdef WLAN_SOFTAP_FEATURE
5056 if(eLIM_AP_ROLE == psessionEntry->limSystemRole){
5057 if(overlap)
5058 {
5059 //Overlap Legacy protection disabled.
5060 psessionEntry->gLimOverlapHt20Params.protectionEnabled = false;
5061
5062 // no HT op mode change if any of the overlap protection enabled.
5063 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
5064 psessionEntry->gLimOverlap11gParams.protectionEnabled ||
5065 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
5066 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
5067 {
5068
5069 //Check if there is a need to change HT OP mode.
5070 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == psessionEntry->htOperMode)
5071 {
5072 if(psessionEntry->gLimHt20Params.protectionEnabled)
5073 {
5074 //Commented beacuse of CR 258588 for WFA Cert
5075 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
5076 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
5077 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5078 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5079 }
5080 else
5081 {
5082 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
5083 }
5084 }
5085 }
5086 }
5087 else
5088 {
5089 //Disable protection from 11G stations.
5090 psessionEntry->gLimHt20Params.protectionEnabled = false;
5091
5092 //Change HT op mode appropriately.
5093 if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == psessionEntry->htOperMode)
5094 {
5095 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
5096 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5097 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5098 }
5099 }
5100 PELOG1(limLog(pMac, LOG1, FL("===> Protection from HT 20 Disabled\n"));)
5101 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = false;
5102 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
5103 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
5104#else
5105 if((eLIM_AP_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole))
5106#endif
5107 {
5108 if(overlap)
5109 {
5110 //Overlap Legacy protection disabled.
5111 pMac->lim.gLimOverlapHt20Params.protectionEnabled = false;
5112
5113 // no HT op mode change if any of the overlap protection enabled.
5114 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
5115 pMac->lim.gLimOverlap11gParams.protectionEnabled ||
5116 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
5117 pMac->lim.gLimOverlapNonGfParams.protectionEnabled))
5118 {
5119
5120 //Check if there is a need to change HT OP mode.
5121 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
5122 {
5123 if(psessionEntry->gLimHt20Params.protectionEnabled)
5124 {
5125 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
5126 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5127 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5128 }
5129 else
5130 {
5131 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
5132 }
5133 }
5134 }
5135 }
5136 else
5137 {
5138 //Disable protection from 11G stations.
5139 psessionEntry->gLimHt20Params.protectionEnabled = false;
5140
5141 //Change HT op mode appropriately.
5142 if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == pMac->lim.gHTOperMode)
5143 {
5144 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
5145 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5146 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5147 }
5148 }
5149 PELOG1(limLog(pMac, LOG1, FL("===> Protection from HT 20 Disabled\n"));)
5150 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = false;
5151 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
5152 }
5153 //for station role
5154 else
5155 {
5156 PELOG1(limLog(pMac, LOG1, FL("===> Protection from HT20 Disabled\n"));)
5157 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = false;
5158 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
5159 }
5160 }
5161
5162 return eSIR_SUCCESS;
5163}
5164
5165/** -------------------------------------------------------------
5166\fn limEnableHTNonGfProtection
5167\brief based on cofig enables\disables protection from NonGf.
5168\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
5169\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
5170\param tpUpdateBeaconParams pBeaconParams
5171\return None
5172 -------------------------------------------------------------*/
5173tSirRetStatus
5174limEnableHTNonGfProtection(tpAniSirGlobal pMac, tANI_U8 enable,
5175 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
5176{
Jeff Johnsone7245742012-09-05 17:12:55 -07005177 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07005178 return eSIR_SUCCESS; // this protection is only for HT stations.
5179
5180 //overlapping protection configuration check.
5181 if(overlap)
5182 {
5183#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
5184 if(((psessionEntry->limSystemRole == eLIM_AP_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) && !pMac->lim.cfgProtection.overlapNonGf)
5185 {
5186 // protection disabled.
5187 PELOG3(limLog(pMac, LOG3, FL("overlap protection from NonGf is disabled\n"));)
5188 return eSIR_SUCCESS;
5189 }
5190#endif
5191 }
5192 else
5193 {
5194#ifdef WLAN_SOFTAP_FEATURE
5195 //normal protection config check
5196 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
5197 !psessionEntry->cfgProtection.nonGf)
5198 {
5199 // protection disabled.
5200 PELOG3(limLog(pMac, LOG3, FL("protection from NonGf is disabled\n"));)
5201 return eSIR_SUCCESS;
5202 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
5203#endif
5204 {
5205 //normal protection config check
5206 if(!pMac->lim.cfgProtection.nonGf)
5207 {
5208 // protection disabled.
5209 PELOG3(limLog(pMac, LOG3, FL("protection from NonGf is disabled\n"));)
5210 return eSIR_SUCCESS;
5211 }
5212 }
5213 }
5214#ifdef WLAN_SOFTAP_FEATURE
5215 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
5216 if ((enable) && (false == psessionEntry->beaconParams.llnNonGFCoexist))
5217 {
5218 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from non GF Enabled\n"));)
5219 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = true;
5220 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
5221 }
5222 else if (!enable && (true == psessionEntry->beaconParams.llnNonGFCoexist))
5223 {
5224 PELOG1(limLog(pMac, LOG1, FL("===> Protection from Non GF Disabled\n"));)
5225 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = false;
5226 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
5227 }
5228 }else
5229#endif
5230 {
5231 if ((enable) && (false == psessionEntry->beaconParams.llnNonGFCoexist))
5232 {
5233 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from non GF Enabled\n"));)
5234 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = true;
5235 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
5236 }
5237 else if (!enable && (true == psessionEntry->beaconParams.llnNonGFCoexist))
5238 {
5239 PELOG1(limLog(pMac, LOG1, FL("===> Protection from Non GF Disabled\n"));)
5240 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = false;
5241 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
5242 }
5243 }
5244
5245 return eSIR_SUCCESS;
5246}
5247
5248/** -------------------------------------------------------------
5249\fn limEnableHTLsigTxopProtection
5250\brief based on cofig enables\disables LsigTxop protection.
5251\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
5252\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
5253\param tpUpdateBeaconParams pBeaconParams
5254\return None
5255 -------------------------------------------------------------*/
5256tSirRetStatus
5257limEnableHTLsigTxopProtection(tpAniSirGlobal pMac, tANI_U8 enable,
5258 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
5259{
Jeff Johnsone7245742012-09-05 17:12:55 -07005260 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07005261 return eSIR_SUCCESS; // this protection is only for HT stations.
5262
5263 //overlapping protection configuration check.
5264 if(overlap)
5265 {
5266#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
5267 if(((psessionEntry->limSystemRole == eLIM_AP_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) && !pMac->lim.cfgProtection.overlapLsigTxop)
5268 {
5269 // protection disabled.
5270 PELOG3(limLog(pMac, LOG3, FL(" overlap protection from LsigTxop not supported is disabled\n"));)
5271 return eSIR_SUCCESS;
5272 }
5273#endif
5274 }
5275 else
5276 {
5277#ifdef WLAN_SOFTAP_FEATURE
5278 //normal protection config check
5279 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
5280 !psessionEntry->cfgProtection.lsigTxop)
5281 {
5282 // protection disabled.
5283 PELOG3(limLog(pMac, LOG3, FL(" protection from LsigTxop not supported is disabled\n"));)
5284 return eSIR_SUCCESS;
5285 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
5286#endif
5287 {
5288 //normal protection config check
5289 if(!pMac->lim.cfgProtection.lsigTxop)
5290 {
5291 // protection disabled.
5292 PELOG3(limLog(pMac, LOG3, FL(" protection from LsigTxop not supported is disabled\n"));)
5293 return eSIR_SUCCESS;
5294 }
5295 }
5296 }
5297
5298
5299#ifdef WLAN_SOFTAP_FEATURE
5300 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
5301 if ((enable) && (false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
5302 {
5303 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from LsigTxop Enabled\n"));)
5304 pBeaconParams->fLsigTXOPProtectionFullSupport = psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = true;
5305 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
5306 }
5307 else if (!enable && (true == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
5308 {
5309 PELOG1(limLog(pMac, LOG1, FL("===> Protection from LsigTxop Disabled\n"));)
5310 pBeaconParams->fLsigTXOPProtectionFullSupport= psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = false;
5311 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
5312 }
5313 }else
5314#endif
5315 {
5316 if ((enable) && (false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
5317 {
5318 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from LsigTxop Enabled\n"));)
5319 pBeaconParams->fLsigTXOPProtectionFullSupport = psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = true;
5320 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
5321 }
5322 else if (!enable && (true == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
5323 {
5324 PELOG1(limLog(pMac, LOG1, FL("===> Protection from LsigTxop Disabled\n"));)
5325 pBeaconParams->fLsigTXOPProtectionFullSupport= psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = false;
5326 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
5327 }
5328 }
5329 return eSIR_SUCCESS;
5330}
5331//FIXME_PROTECTION : need to check for no APSD whenever we want to enable this protection.
5332//This check will be done at the caller.
5333/** -------------------------------------------------------------
5334\fn limEnableHtRifsProtection
5335\brief based on cofig enables\disables Rifs protection.
5336\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
5337\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
5338\param tpUpdateBeaconParams pBeaconParams
5339\return None
5340 -------------------------------------------------------------*/
5341tSirRetStatus
5342limEnableHtRifsProtection(tpAniSirGlobal pMac, tANI_U8 enable,
5343 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
5344{
Jeff Johnsone7245742012-09-05 17:12:55 -07005345 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07005346 return eSIR_SUCCESS; // this protection is only for HT stations.
5347
5348
5349 //overlapping protection configuration check.
5350 if(overlap)
5351 {
5352#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
5353 if(((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||(psessionEntry == eLIM_BT_AMP_AP_ROLE))&& !pMac->lim.cfgProtection.overlapRifs)
5354 {
5355 // protection disabled.
5356 PELOG3(limLog(pMac, LOG3, FL(" overlap protection from Rifs is disabled\n"));)
5357 return eSIR_SUCCESS;
5358 }
5359#endif
5360 }
5361 else
5362 {
5363#ifdef WLAN_SOFTAP_FEATURE
5364 //normal protection config check
5365 if((psessionEntry->limSystemRole == eLIM_AP_ROLE) &&
5366 !psessionEntry->cfgProtection.rifs)
5367 {
5368 // protection disabled.
5369 PELOG3(limLog(pMac, LOG3, FL(" protection from Rifs is disabled\n"));)
5370 return eSIR_SUCCESS;
5371 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
5372#endif
5373 {
5374 //normal protection config check
5375 if(!pMac->lim.cfgProtection.rifs)
5376 {
5377 // protection disabled.
5378 PELOG3(limLog(pMac, LOG3, FL(" protection from Rifs is disabled\n"));)
5379 return eSIR_SUCCESS;
5380 }
5381 }
5382 }
5383
5384#ifdef WLAN_SOFTAP_FEATURE
5385 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
5386 // Disabling the RIFS Protection means Enable the RIFS mode of operation in the BSS
5387 if ((!enable) && (false == psessionEntry->beaconParams.fRIFSMode))
5388 {
5389 PELOG1(limLog(pMac, LOG1, FL(" => Rifs protection Disabled\n"));)
5390 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = true;
5391 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
5392 }
5393 // Enabling the RIFS Protection means Disable the RIFS mode of operation in the BSS
5394 else if (enable && (true == psessionEntry->beaconParams.fRIFSMode))
5395 {
5396 PELOG1(limLog(pMac, LOG1, FL("===> Rifs Protection Enabled\n"));)
5397 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = false;
5398 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
5399 }
5400 }else
5401#endif
5402 {
5403 // Disabling the RIFS Protection means Enable the RIFS mode of operation in the BSS
5404 if ((!enable) && (false == psessionEntry->beaconParams.fRIFSMode))
5405 {
5406 PELOG1(limLog(pMac, LOG1, FL(" => Rifs protection Disabled\n"));)
5407 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = true;
5408 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
5409 }
5410 // Enabling the RIFS Protection means Disable the RIFS mode of operation in the BSS
5411 else if (enable && (true == psessionEntry->beaconParams.fRIFSMode))
5412 {
5413 PELOG1(limLog(pMac, LOG1, FL("===> Rifs Protection Enabled\n"));)
5414 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = false;
5415 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
5416 }
5417 }
5418 return eSIR_SUCCESS;
5419}
5420
5421// ---------------------------------------------------------------------
5422/**
5423 * limEnableShortPreamble
5424 *
5425 * FUNCTION:
5426 * Enable/Disable short preamble
5427 *
5428 * LOGIC:
5429 *
5430 * ASSUMPTIONS:
5431 *
5432 * NOTE:
5433 *
5434 * @param enable Flag to enable/disable short preamble
5435 * @return None
5436 */
5437
5438tSirRetStatus
5439limEnableShortPreamble(tpAniSirGlobal pMac, tANI_U8 enable, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
5440{
5441 tANI_U32 val;
5442
5443 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val) != eSIR_SUCCESS)
5444 {
5445 /* Could not get short preamble enabled flag from CFG. Log error. */
5446 limLog(pMac, LOGP, FL("could not retrieve short preamble flag\n"));
5447 return eSIR_FAILURE;
5448 }
5449
5450 if (!val)
5451 return eSIR_SUCCESS;
5452
5453 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_PREAMBLE_ENABLED, &val) != eSIR_SUCCESS)
5454 {
5455 limLog(pMac, LOGP, FL("could not retrieve 11G short preamble switching enabled flag\n"));
5456 return eSIR_FAILURE;
5457 }
5458
5459 if (!val) // 11G short preamble switching is disabled.
5460 return eSIR_SUCCESS;
5461
5462 if ( psessionEntry->limSystemRole == eLIM_AP_ROLE )
5463 {
5464 if (enable && (psessionEntry->beaconParams.fShortPreamble == 0))
5465 {
5466 PELOG1(limLog(pMac, LOG1, FL("===> Short Preamble Enabled\n"));)
5467 psessionEntry->beaconParams.fShortPreamble = true;
5468 pBeaconParams->fShortPreamble = (tANI_U8) psessionEntry->beaconParams.fShortPreamble;
5469 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_PREAMBLE_CHANGED;
5470 }
5471 else if (!enable && (psessionEntry->beaconParams.fShortPreamble == 1))
5472 {
5473 PELOG1(limLog(pMac, LOG1, FL("===> Short Preamble Disabled\n"));)
5474 psessionEntry->beaconParams.fShortPreamble = false;
5475 pBeaconParams->fShortPreamble = (tANI_U8) psessionEntry->beaconParams.fShortPreamble;
5476 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_PREAMBLE_CHANGED;
5477 }
5478 }
5479
5480 return eSIR_SUCCESS;
5481 }
5482
5483/**
5484 * limTxComplete
5485 *
5486 * Function:
5487 * This is LIM's very own "TX MGMT frame complete" completion routine.
5488 *
5489 * Logic:
5490 * LIM wants to send a MGMT frame (broadcast or unicast)
5491 * LIM allocates memory using palPktAlloc( ..., **pData, **pPacket )
5492 * LIM transmits the MGMT frame using the API:
5493 * halTxFrame( ... pPacket, ..., (void *) limTxComplete, pData )
5494 * HDD, via halTxFrame/DXE, "transfers" the packet over to BMU
5495 * HDD, if it determines that a TX completion routine (in this case
5496 * limTxComplete) has been provided, will invoke this callback
5497 * LIM will try to free the TX MGMT packet that was earlier allocated, in order
5498 * to send this MGMT frame, using the PAL API palPktFree( ... pData, pPacket )
5499 *
5500 * Assumptions:
5501 * Presently, this is ONLY being used for MGMT frames/packets
5502 * TODO:
5503 * Would it do good for LIM to have some sort of "signature" validation to
5504 * ensure that the pData argument passed in was a buffer that was actually
5505 * allocated by LIM and/or is not corrupted?
5506 *
5507 * Note: FIXME and TODO
5508 * Looks like palPktFree() is interested in pPacket. But, when this completion
5509 * routine is called, only pData is made available to LIM!!
5510 *
5511 * @param void A pointer to pData. Shouldn't it be pPacket?!
5512 *
5513 * @return none
5514 */
5515void limTxComplete( tHalHandle hHal, void *pData )
5516{
5517 tpAniSirGlobal pMac;
5518 pMac = (tpAniSirGlobal)hHal;
5519
5520#ifdef FIXME_PRIMA
5521 /* the trace logic needs to be fixed for Prima. Refer to CR 306075 */
5522#ifdef TRACE_RECORD
5523 {
5524 tpSirMacMgmtHdr mHdr;
5525 v_U8_t *pRxBd;
5526 vos_pkt_t *pVosPkt;
5527 VOS_STATUS vosStatus;
5528
5529
5530
5531 pVosPkt = (vos_pkt_t *)pData;
5532 vosStatus = vos_pkt_peek_data( pVosPkt, 0, (v_PVOID_t *)&pRxBd, WLANHAL_RX_BD_HEADER_SIZE);
5533
5534 if(VOS_IS_STATUS_SUCCESS(vosStatus))
5535 {
5536 mHdr = WDA_GET_RX_MAC_HEADER(pRxBd);
Jeff Johnsone7245742012-09-05 17:12:55 -07005537 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE, NO_SESSION, mHdr->fc.subType);)
Jeff Johnson295189b2012-06-20 16:38:30 -07005538
5539 }
5540 }
5541#endif
5542#endif
5543
5544 palPktFree( pMac->hHdd,
5545 HAL_TXRX_FRM_802_11_MGMT,
5546 (void *) NULL, // this is ignored and will likely be removed from this API
5547 (void *) pData ); // lim passed in pPacket in the pData pointer that is given in this completion routine
5548}
5549
5550/**
5551 * \brief This function updates lim global structure, if CB parameters in the BSS
5552 * have changed, and sends an indication to HAL also with the
5553 * updated HT Parameters.
5554 * This function does not detect the change in the primary channel, that is done as part
5555 * of channel Swtich IE processing.
5556 * If STA is configured with '20Mhz only' mode, then this function does not do anything
5557 * This function changes the CB mode, only if the self capability is set to '20 as well as 40Mhz'
5558 *
5559 *
5560 * \param pMac Pointer to global MAC structure
5561 *
5562 * \param pRcvdHTInfo Pointer to HT Info IE obtained from a Beacon or
5563 * Probe Response
5564 *
5565 * \param bssIdx BSS Index of the Bss to which Station is associated.
5566 *
5567 *
5568 */
5569
5570void limUpdateStaRunTimeHTSwitchChnlParams( tpAniSirGlobal pMac,
5571 tDot11fIEHTInfo *pHTInfo,
5572 tANI_U8 bssIdx,
5573 tpPESession psessionEntry)
5574{
Jeff Johnsone7245742012-09-05 17:12:55 -07005575 ePhyChanBondState secondaryChnlOffset = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07005576#if !defined WLAN_FEATURE_VOWIFI
5577 tANI_U32 localPwrConstraint;
5578#endif
5579
5580 //If self capability is set to '20Mhz only', then do not change the CB mode.
5581#ifdef WLAN_SOFTAP_FEATURE
5582 if( !limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry ))
5583#else
5584 if( !limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET ))
5585#endif
5586 return;
5587
5588#if !defined WLAN_FEATURE_VOWIFI
5589 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
5590 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg\n" ));
5591 return;
5592 }
5593#endif
5594
Jeff Johnsone7245742012-09-05 17:12:55 -07005595 if ( psessionEntry->htSecondaryChannelOffset != ( tANI_U8 ) pHTInfo->secondaryChannelOffset ||
5596 psessionEntry->htRecommendedTxWidthSet != ( tANI_U8 ) pHTInfo->recommendedTxWidthSet )
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005598 psessionEntry->htSecondaryChannelOffset = ( ePhyChanBondState ) pHTInfo->secondaryChannelOffset;
5599 psessionEntry->htRecommendedTxWidthSet = ( tANI_U8 ) pHTInfo->recommendedTxWidthSet;
5600 if ( eHT_CHANNEL_WIDTH_40MHZ == psessionEntry->htRecommendedTxWidthSet )
5601 secondaryChnlOffset = (ePhyChanBondState)pHTInfo->secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07005602
5603 // Notify HAL
5604 limLog( pMac, LOGW, FL( "Channel Information in HT IE change"
5605 "d; sending notification to HAL.\n" ) );
5606 limLog( pMac, LOGW, FL( "Primary Channel: %d, Secondary Chan"
5607 "nel Offset: %d, Channel Width: %d\n" ),
5608 pHTInfo->primaryChannel, secondaryChnlOffset,
Jeff Johnsone7245742012-09-05 17:12:55 -07005609 psessionEntry->htRecommendedTxWidthSet );
Madan Mohan Koyyalamudifd322a02012-10-05 12:01:26 -07005610 psessionEntry->channelChangeReasonCode=LIM_SWITCH_CHANNEL_OPERATION;
5611 pMac->lim.gpchangeChannelCallback = NULL;
5612 pMac->lim.gpchangeChannelData = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005613
5614#if defined WLAN_FEATURE_VOWIFI
5615 limSendSwitchChnlParams( pMac, ( tANI_U8 ) pHTInfo->primaryChannel,
5616 secondaryChnlOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
5617#else
5618 limSendSwitchChnlParams( pMac, ( tANI_U8 ) pHTInfo->primaryChannel,
5619 secondaryChnlOffset, (tPowerdBm)localPwrConstraint, psessionEntry->peSessionId);
5620#endif
5621
5622 //In case of IBSS, if STA should update HT Info IE in its beacons.
5623 if (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole)
5624 {
5625 schSetFixedBeaconFields(pMac,psessionEntry);
5626 }
5627
5628 }
5629} // End limUpdateStaRunTimeHTParams.
5630
5631/**
5632 * \brief This function updates the lim global structure, if any of the
5633 * HT Capabilities have changed.
5634 *
5635 *
5636 * \param pMac Pointer to Global MAC structure
5637 *
5638 * \param pHTCapability Pointer to HT Capability Information Element
5639 * obtained from a Beacon or Probe Response
5640 *
5641 *
5642 *
5643 */
5644
5645void limUpdateStaRunTimeHTCapability( tpAniSirGlobal pMac,
5646 tDot11fIEHTCaps *pHTCaps )
5647{
5648
5649 if ( pMac->lim.gHTLsigTXOPProtection != ( tANI_U8 ) pHTCaps->lsigTXOPProtection )
5650 {
5651 pMac->lim.gHTLsigTXOPProtection = ( tANI_U8 ) pHTCaps->lsigTXOPProtection;
5652 // Send change notification to HAL
5653 }
5654
5655 if ( pMac->lim.gHTAMpduDensity != ( tANI_U8 ) pHTCaps->mpduDensity )
5656 {
5657 pMac->lim.gHTAMpduDensity = ( tANI_U8 ) pHTCaps->mpduDensity;
5658 // Send change notification to HAL
5659 }
5660
5661 if ( pMac->lim.gHTMaxRxAMpduFactor != ( tANI_U8 ) pHTCaps->maxRxAMPDUFactor )
5662 {
5663 pMac->lim.gHTMaxRxAMpduFactor = ( tANI_U8 ) pHTCaps->maxRxAMPDUFactor;
5664 // Send change notification to HAL
5665 }
5666
5667
5668} // End limUpdateStaRunTimeHTCapability.
5669
5670/**
5671 * \brief This function updates lim global structure, if any of the HT
5672 * Info Parameters have changed.
5673 *
5674 *
5675 * \param pMac Pointer to the global MAC structure
5676 *
5677 * \param pHTInfo Pointer to the HT Info IE obtained from a Beacon or
5678 * Probe Response
5679 *
5680 *
5681 */
5682
5683void limUpdateStaRunTimeHTInfo( tpAniSirGlobal pMac,
5684 tDot11fIEHTInfo *pHTInfo , tpPESession psessionEntry)
5685{
Jeff Johnsone7245742012-09-05 17:12:55 -07005686 if ( psessionEntry->htRecommendedTxWidthSet != ( tANI_U8 )pHTInfo->recommendedTxWidthSet )
Jeff Johnson295189b2012-06-20 16:38:30 -07005687 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005688 psessionEntry->htRecommendedTxWidthSet = ( tANI_U8 )pHTInfo->recommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 // Send change notification to HAL
5690 }
5691
5692 if ( psessionEntry->beaconParams.fRIFSMode != ( tANI_U8 )pHTInfo->rifsMode )
5693 {
5694 psessionEntry->beaconParams.fRIFSMode = ( tANI_U8 )pHTInfo->rifsMode;
5695 // Send change notification to HAL
5696 }
5697
5698 if ( pMac->lim.gHTServiceIntervalGranularity != ( tANI_U8 )pHTInfo->serviceIntervalGranularity )
5699 {
5700 pMac->lim.gHTServiceIntervalGranularity = ( tANI_U8 )pHTInfo->serviceIntervalGranularity;
5701 // Send change notification to HAL
5702 }
5703
5704 if ( pMac->lim.gHTOperMode != ( tSirMacHTOperatingMode )pHTInfo->opMode )
5705 {
5706 pMac->lim.gHTOperMode = ( tSirMacHTOperatingMode )pHTInfo->opMode;
5707 // Send change notification to HAL
5708 }
5709
5710 if ( psessionEntry->beaconParams.llnNonGFCoexist != pHTInfo->nonGFDevicesPresent )
5711 {
5712 psessionEntry->beaconParams.llnNonGFCoexist = ( tANI_U8 )pHTInfo->nonGFDevicesPresent;
5713 }
5714
5715 if ( pMac->lim.gHTSTBCBasicMCS != ( tANI_U8 )pHTInfo->basicSTBCMCS )
5716 {
5717 pMac->lim.gHTSTBCBasicMCS = ( tANI_U8 )pHTInfo->basicSTBCMCS;
5718 // Send change notification to HAL
5719 }
5720
5721 if ( pMac->lim.gHTDualCTSProtection != ( tANI_U8 )pHTInfo->dualCTSProtection )
5722 {
5723 pMac->lim.gHTDualCTSProtection = ( tANI_U8 )pHTInfo->dualCTSProtection;
5724 // Send change notification to HAL
5725 }
5726
5727 if ( pMac->lim.gHTSecondaryBeacon != ( tANI_U8 )pHTInfo->secondaryBeacon )
5728 {
5729 pMac->lim.gHTSecondaryBeacon = ( tANI_U8 )pHTInfo->secondaryBeacon;
5730 // Send change notification to HAL
5731 }
5732
5733 if ( psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport != ( tANI_U8 )pHTInfo->lsigTXOPProtectionFullSupport )
5734 {
5735 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = ( tANI_U8 )pHTInfo->lsigTXOPProtectionFullSupport;
5736 // Send change notification to HAL
5737 }
5738
5739 if ( pMac->lim.gHTPCOActive != ( tANI_U8 )pHTInfo->pcoActive )
5740 {
5741 pMac->lim.gHTPCOActive = ( tANI_U8 )pHTInfo->pcoActive;
5742 // Send change notification to HAL
5743 }
5744
5745 if ( pMac->lim.gHTPCOPhase != ( tANI_U8 )pHTInfo->pcoPhase )
5746 {
5747 pMac->lim.gHTPCOPhase = ( tANI_U8 )pHTInfo->pcoPhase;
5748 // Send change notification to HAL
5749 }
5750
5751} // End limUpdateStaRunTimeHTInfo.
5752
5753
5754/** -------------------------------------------------------------
5755\fn limProcessHalIndMessages
5756\brief callback function for HAL indication
5757\param tpAniSirGlobal pMac
5758\param tANI_U32 mesgId
5759\param void *mesgParam
5760\return tSirRetStatu - status
5761 -------------------------------------------------------------*/
5762
5763tSirRetStatus limProcessHalIndMessages(tpAniSirGlobal pMac, tANI_U32 msgId, void *msgParam )
5764{
5765 //its PE's responsibility to free msgparam when its done extracting the message parameters.
5766 tSirMsgQ msg;
5767
5768 switch(msgId)
5769 {
5770 case SIR_LIM_DEL_TS_IND:
5771 case SIR_LIM_ADD_BA_IND:
5772 case SIR_LIM_DEL_BA_ALL_IND:
5773 case SIR_LIM_DELETE_STA_CONTEXT_IND:
5774 case SIR_LIM_BEACON_GEN_IND:
5775 msg.type = (tANI_U16) msgId;
5776 msg.bodyptr = msgParam;
5777 msg.bodyval = 0;
5778 break;
5779
5780 default:
5781 palFreeMemory(pMac->hHdd, msgParam);
5782 limLog(pMac, LOGP, FL("invalid message id = %d received\n"), msgId);
5783 return eSIR_FAILURE;
5784 }
5785
5786 if (limPostMsgApi(pMac, &msg) != eSIR_SUCCESS)
5787 {
5788 palFreeMemory(pMac->hHdd, msgParam);
5789 limLog(pMac, LOGP, FL("limPostMsgApi failed for msgid = %d"), msg.type);
5790 return eSIR_FAILURE;
5791 }
5792 return eSIR_SUCCESS;
5793}
5794
5795/** -------------------------------------------------------------
5796\fn limValidateDeltsReq
5797\brief Validates DelTs req originated by SME or by HAL and also sends halMsg_DelTs to HAL
5798\param tpAniSirGlobal pMac
5799\param tpSirDeltsReq pDeltsReq
5800\param tSirMacAddr peerMacAddr
5801\return eSirRetStatus - status
5802 -------------------------------------------------------------*/
5803
5804tSirRetStatus
5805limValidateDeltsReq(tpAniSirGlobal pMac, tpSirDeltsReq pDeltsReq, tSirMacAddr peerMacAddr,tpPESession psessionEntry)
5806{
5807 tpDphHashNode pSta;
5808 tANI_U8 tsStatus;
5809 tSirMacTSInfo *tsinfo;
5810 tANI_U32 i;
5811 tANI_U8 tspecIdx;
5812 /* if sta
5813 * - verify assoc state
5814 * - del tspec locally
5815 * if ap,
5816 * - verify sta is in assoc state
5817 * - del sta tspec locally
5818 */
5819 if(pDeltsReq == NULL)
5820 {
5821 PELOGE(limLog(pMac, LOGE, FL("Delete TS request pointer is NULL\n"));)
5822 return eSIR_FAILURE;
5823 }
5824
5825 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
5826 {
5827 tANI_U32 val;
5828
5829 // station always talks to the AP
5830 pSta = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
5831
5832 val = sizeof(tSirMacAddr);
5833 #if 0
5834 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMacAddr, &val) != eSIR_SUCCESS)
5835 {
5836 /// Could not get BSSID from CFG. Log error.
5837 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
5838 return eSIR_FAILURE;
5839 }
5840 #endif// TO SUPPORT BT-AMP
5841 sirCopyMacAddr(peerMacAddr,psessionEntry->bssId);
5842
5843 }
5844 else
5845 {
5846 tANI_U16 assocId;
5847 tANI_U8 *macaddr = (tANI_U8 *) peerMacAddr;
5848
5849 assocId = pDeltsReq->aid;
5850 if (assocId != 0)
5851 pSta = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
5852 else
5853 pSta = dphLookupHashEntry(pMac, pDeltsReq->macAddr, &assocId, &psessionEntry->dph.dphHashTable);
5854
5855 if (pSta != NULL)
5856 // TBD: check sta assoc state as well
5857 for (i =0; i < sizeof(tSirMacAddr); i++)
5858 macaddr[i] = pSta->staAddr[i];
5859 }
5860
5861 if (pSta == NULL)
5862 {
5863 PELOGE(limLog(pMac, LOGE, "Cannot find station context for delts req\n");)
5864 return eSIR_FAILURE;
5865 }
5866
5867 if ((! pSta->valid) ||
5868 (pSta->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE))
5869 {
5870 PELOGE(limLog(pMac, LOGE, "Invalid Sta (or state) for DelTsReq\n");)
5871 return eSIR_FAILURE;
5872 }
5873
5874 pDeltsReq->req.wsmTspecPresent = 0;
5875 pDeltsReq->req.wmeTspecPresent = 0;
5876 pDeltsReq->req.lleTspecPresent = 0;
5877
5878 if ((pSta->wsmEnabled) &&
5879 (pDeltsReq->req.tspec.tsinfo.traffic.accessPolicy != SIR_MAC_ACCESSPOLICY_EDCA))
5880 pDeltsReq->req.wsmTspecPresent = 1;
5881 else if (pSta->wmeEnabled)
5882 pDeltsReq->req.wmeTspecPresent = 1;
5883 else if (pSta->lleEnabled)
5884 pDeltsReq->req.lleTspecPresent = 1;
5885 else
5886 {
5887 PELOGW(limLog(pMac, LOGW, FL("DELTS_REQ ignore - qos is disabled\n"));)
5888 return eSIR_FAILURE;
5889 }
5890
5891 tsinfo = pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.tsinfo
5892 : &pDeltsReq->req.tsinfo;
5893 PELOG1(limLog(pMac, LOG1,
5894 FL("received DELTS_REQ message (wmeTspecPresent = %d, lleTspecPresent = %d, wsmTspecPresent = %d, tsid %d, up %d, direction = %d)\n"),
5895 pDeltsReq->req.wmeTspecPresent, pDeltsReq->req.lleTspecPresent, pDeltsReq->req.wsmTspecPresent,
5896 tsinfo->traffic.tsid, tsinfo->traffic.userPrio, tsinfo->traffic.direction);)
5897
5898 // if no Access Control, ignore the request
5899#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
5900 if ((tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_EDCA))
5901 if (((psessionEntry->limSystemRole == eLIM_AP_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))&&
5902 (! psessionEntry->gLimEdcaParamsBC[upToAc(tsinfo->traffic.userPrio)].aci.acm))
5903 || (((psessionEntry->limSystemRole != eLIM_AP_ROLE) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
5904 (! psessionEntry->gLimEdcaParams[upToAc(tsinfo->traffic.userPrio)].aci.acm)))
5905 {
5906 limLog(pMac, LOGW, FL("DelTs with acecssPolicy = %d and UP %d , AC = %d has no AC - ignoring request\n"),
5907 tsinfo->traffic.accessPolicy, tsinfo->traffic.userPrio, upToAc(tsinfo->traffic.userPrio));
5908 return eSIR_FAILURE;
5909 }
5910#endif
5911
5912 if (limAdmitControlDeleteTS(pMac, pSta->assocId, tsinfo, &tsStatus, &tspecIdx)
5913 != eSIR_SUCCESS)
5914 {
5915 PELOGE(limLog(pMac, LOGE, "ERROR DELTS request for sta assocId %d (tsid %d, up %d)\n",
5916 pSta->assocId, tsinfo->traffic.tsid, tsinfo->traffic.userPrio);)
5917 return eSIR_FAILURE;
5918 }
5919 else if ((tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
5920 (tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH))
5921 {
5922 //edca only now.
5923 }
5924 else
5925 {
5926 if((tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_EDCA) &&
5927 psessionEntry->gLimEdcaParams[upToAc(tsinfo->traffic.userPrio)].aci.acm)
5928 {
5929 //send message to HAL to delete TS
Jeff Johnsone7245742012-09-05 17:12:55 -07005930 if(eSIR_SUCCESS != limSendHalMsgDelTs(pMac, pSta->staIndex, tspecIdx, pDeltsReq->req, psessionEntry->peSessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 {
5932 limLog(pMac, LOGW, FL("DelTs with UP %d failed in limSendHalMsgDelTs - ignoring request\n"),
5933 tsinfo->traffic.userPrio);
5934 return eSIR_FAILURE;
5935 }
5936 }
5937 }
5938 return eSIR_SUCCESS;
5939}
5940
5941/** -------------------------------------------------------------
5942\fn limRegisterHalIndCallBack
5943\brief registers callback function to HAL for any indication.
5944\param tpAniSirGlobal pMac
5945\return none.
5946 -------------------------------------------------------------*/
5947void
5948limRegisterHalIndCallBack(tpAniSirGlobal pMac)
5949{
5950 tSirMsgQ msg;
5951 tpHalIndCB pHalCB;
5952
5953 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pHalCB, sizeof(tHalIndCB)))
5954 {
5955 limLog(pMac, LOGP, FL("palAllocateMemory() failed\n"));
5956 return;
5957 }
5958
5959 pHalCB->pHalIndCB = limProcessHalIndMessages;
5960
5961 msg.type = WDA_REGISTER_PE_CALLBACK;
5962 msg.bodyptr = pHalCB;
5963 msg.bodyval = 0;
5964
Jeff Johnsone7245742012-09-05 17:12:55 -07005965 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5967 {
5968 palFreeMemory(pMac->hHdd, pHalCB);
5969 limLog(pMac, LOGP, FL("wdaPostCtrlMsg() failed\n"));
5970 }
5971
5972 return;
5973}
5974
5975
5976/** -------------------------------------------------------------
5977\fn limProcessAddBaInd
5978
5979\brief handles the BA activity check timeout indication coming from HAL.
5980 Validates the request, posts request for sending addBaReq message for every candidate in the list.
5981\param tpAniSirGlobal pMac
5982\param tSirMsgQ limMsg
5983\return None
5984-------------------------------------------------------------*/
5985void
5986limProcessAddBaInd(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
5987{
5988 tANI_U8 i;
5989 tANI_U8 tid;
5990 tANI_U16 assocId;
5991 tpDphHashNode pSta;
5992 tpAddBaCandidate pBaCandidate;
5993 tANI_U32 baCandidateCnt;
5994 tpBaActivityInd pBaActivityInd;
5995 tpPESession psessionEntry;
5996 tANI_U8 sessionId;
5997
5998
5999
6000 if(limMsg->bodyptr == NULL)
6001 return;
6002
6003 pBaActivityInd = (tpBaActivityInd)limMsg->bodyptr;
6004 baCandidateCnt = pBaActivityInd->baCandidateCnt;
6005
6006 if((psessionEntry = peFindSessionByBssid(pMac,pBaActivityInd->bssId,&sessionId))== NULL)
6007 {
6008 limLog(pMac, LOGE,FL("session does not exist for given BSSId\n"));
6009 palFreeMemory(pMac->hHdd, limMsg->bodyptr);
6010 return;
6011 }
6012
6013 //if we are not HT capable we don't need to handle BA timeout indication from HAL.
Jeff Johnsone7245742012-09-05 17:12:55 -07006014 if( (baCandidateCnt > pMac->lim.maxStation) || !psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 {
6016 palFreeMemory(pMac->hHdd, limMsg->bodyptr);
6017 return;
6018 }
6019
6020 //delete the complete dialoguetoken linked list
6021 limDeleteDialogueTokenList(pMac);
6022 pBaCandidate = (tpAddBaCandidate) (((tANI_U8*)pBaActivityInd) + sizeof(tBaActivityInd));
6023
6024 for(i=0; i<baCandidateCnt; i++, pBaCandidate++)
6025 {
6026 pSta = dphLookupHashEntry(pMac, pBaCandidate->staAddr, &assocId, &psessionEntry->dph.dphHashTable);
6027 if( (NULL == pSta) || (!pSta->valid))
6028 continue;
6029
6030 for (tid=0; tid<STACFG_MAX_TC; tid++)
6031 {
6032 if( (eBA_DISABLE == pSta->tcCfg[tid].fUseBATx) &&
6033 (pBaCandidate->baInfo[tid].fBaEnable))
6034 {
6035 PELOG2(limLog(pMac, LOG2, FL("BA setup for staId = %d, TID: %d, SSN:%d.\n"),
6036 pSta->staIndex, tid, pBaCandidate->baInfo[tid].startingSeqNum);)
6037 limPostMlmAddBAReq(pMac, pSta, tid, pBaCandidate->baInfo[tid].startingSeqNum,psessionEntry);
6038 }
6039 }
6040 }
6041 palFreeMemory(pMac->hHdd, limMsg->bodyptr);
6042 return;
6043}
6044
6045
6046/** -------------------------------------------------------------
6047\fn limDelAllBASessions
6048\brief Deletes all the exisitng BA sessions.
6049\ Note : This API is provided for Mac OSx only. The reason for this is that Mac OSx may not
6050\ restart after CFG update.
6051\param tpAniSirGlobal pMac
6052\return None
6053-------------------------------------------------------------*/
6054
6055void
6056limDelAllBASessions(tpAniSirGlobal pMac)
6057{
6058 tANI_U32 i;
6059 tANI_U8 tid;
6060 tpDphHashNode pSta;
6061
6062 tpPESession psessionEntry = &pMac->lim.gpSession[0]; //TBD-RAJESH HOW TO GET sessionEntry?????
6063 for(tid = 0; tid < STACFG_MAX_TC; tid++)
6064 {
6065 if((eLIM_AP_ROLE == psessionEntry->limSystemRole) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)||
6066 (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole))
6067 {
6068 for(i = 0; i < pMac->lim.maxStation; i++)
6069 {
6070 pSta = psessionEntry->dph.dphHashTable.pDphNodeArray + i;
6071 if (pSta && pSta->added)
6072 {
6073 if(eBA_ENABLE == pSta->tcCfg[tid].fUseBATx)
6074 {
6075 limPostMlmDelBAReq(pMac, pSta, eBA_INITIATOR, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
6076 }
6077 else if(eBA_ENABLE == pSta->tcCfg[tid].fUseBARx)
6078 {
6079 limPostMlmDelBAReq(pMac, pSta, eBA_RECIPIENT, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
6080 }
6081 }
6082 }
6083 }
6084 else if((eLIM_STA_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_STA_ROLE == psessionEntry->limSystemRole))
6085 {
6086 pSta = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
6087 if (pSta && pSta->added)
6088 {
6089 if(eBA_ENABLE == pSta->tcCfg[tid].fUseBATx)
6090 {
6091 limPostMlmDelBAReq(pMac, pSta, eBA_INITIATOR, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
6092 }
6093 if(eBA_ENABLE == pSta->tcCfg[tid].fUseBARx)
6094 {
6095 limPostMlmDelBAReq(pMac, pSta, eBA_RECIPIENT, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
6096 }
6097 }
6098 }
6099 }
6100}
6101/** -------------------------------------------------------------
6102\fn limProcessDelTsInd
6103\brief handles the DeleteTS indication coming from HAL or generated by PE itself in some error cases.
6104 Validates the request, sends the DelTs action frame to the Peer and sends DelTs indicatoin to HDD.
6105\param tpAniSirGlobal pMac
6106\param tSirMsgQ limMsg
6107\return None
6108-------------------------------------------------------------*/
6109void
6110limProcessDelTsInd(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
6111{
6112 tpDphHashNode pSta;
6113 tpDelTsParams pDelTsParam = (tpDelTsParams) (limMsg->bodyptr);
6114 tpSirDeltsReq pDelTsReq = NULL;
6115 tSirMacAddr peerMacAddr;
6116 tpSirDeltsReqInfo pDelTsReqInfo;
6117 tpLimTspecInfo pTspecInfo;
6118 tpPESession psessionEntry;
6119 tANI_U8 sessionId;
6120
6121if((psessionEntry = peFindSessionByBssid(pMac,pDelTsParam->bssId,&sessionId))== NULL)
6122 {
6123 limLog(pMac, LOGE,FL("session does not exist for given BssId\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07006124 palFreeMemory(pMac->hHdd, (void *)(limMsg->bodyptr));
Jeff Johnson295189b2012-06-20 16:38:30 -07006125 return;
6126 }
6127
6128 pTspecInfo = &(pMac->lim.tspecInfo[pDelTsParam->tspecIdx]);
6129 if(pTspecInfo->inuse == false)
6130 {
6131 PELOGE(limLog(pMac, LOGE, FL("tspec entry with index %d is not in use\n"), pDelTsParam->tspecIdx);)
6132 goto error1;
6133 }
6134
6135 pSta = dphGetHashEntry(pMac, pTspecInfo->assocId, &psessionEntry->dph.dphHashTable);
6136 if(pSta == NULL)
6137 {
6138 limLog(pMac, LOGE, FL("Could not find entry in DPH table for assocId = %d\n"),
6139 pTspecInfo->assocId);
6140 goto error1;
6141 }
6142
6143 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pDelTsReq, sizeof(tSirDeltsReq)))
6144 {
6145 PELOGE(limLog(pMac, LOGE, FL("palAllocateMemory() failed\n"));)
6146 goto error1;
6147 }
6148
6149 palZeroMemory( pMac->hHdd, (tANI_U8 *)pDelTsReq, sizeof(tSirDeltsReq));
6150
6151 if(pSta->wmeEnabled)
6152 palCopyMemory(pMac->hHdd, &(pDelTsReq->req.tspec), &(pTspecInfo->tspec), sizeof(tSirMacTspecIE));
6153 else
6154 palCopyMemory(pMac->hHdd, &(pDelTsReq->req.tsinfo), &(pTspecInfo->tspec.tsinfo), sizeof(tSirMacTSInfo));
6155
6156
6157 //validate the req
6158 if (eSIR_SUCCESS != limValidateDeltsReq(pMac, pDelTsReq, peerMacAddr,psessionEntry))
6159 {
6160 PELOGE(limLog(pMac, LOGE, FL("limValidateDeltsReq failed\n"));)
6161 goto error2;
6162 }
6163 PELOG1(limLog(pMac, LOG1, "Sent DELTS request to station with assocId = %d MacAddr = %x:%x:%x:%x:%x:%x\n",
6164 pDelTsReq->aid, peerMacAddr[0], peerMacAddr[1], peerMacAddr[2],
6165 peerMacAddr[3], peerMacAddr[4], peerMacAddr[5]);)
6166
6167 limSendDeltsReqActionFrame(pMac, peerMacAddr, pDelTsReq->req.wmeTspecPresent, &pDelTsReq->req.tsinfo, &pDelTsReq->req.tspec,
6168 psessionEntry);
6169
6170 // prepare and send an sme indication to HDD
6171 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pDelTsReqInfo, sizeof(tSirDeltsReqInfo)))
6172 {
6173 PELOGE(limLog(pMac, LOGE, FL("palAllocateMemory() failed\n"));)
6174 goto error3;
6175 }
6176 palZeroMemory( pMac->hHdd, (tANI_U8 *)pDelTsReqInfo, sizeof(tSirDeltsReqInfo));
6177
6178 if(pSta->wmeEnabled)
6179 palCopyMemory(pMac->hHdd, &(pDelTsReqInfo->tspec), &(pTspecInfo->tspec), sizeof(tSirMacTspecIE));
6180 else
6181 palCopyMemory(pMac->hHdd, &(pDelTsReqInfo->tsinfo), &(pTspecInfo->tspec.tsinfo), sizeof(tSirMacTSInfo));
6182
6183 limSendSmeDeltsInd(pMac, pDelTsReqInfo, pDelTsReq->aid,psessionEntry);
6184
6185error3:
6186 palFreeMemory(pMac->hHdd, (void *) pDelTsReqInfo);
6187error2:
6188 palFreeMemory(pMac->hHdd, (void *) pDelTsReq);
6189error1:
6190 palFreeMemory(pMac->hHdd, (void *)(limMsg->bodyptr));
6191 return;
6192}
6193
6194/**
6195 * \brief Setup an A-MPDU/BA session
6196 *
6197 * \sa limPostMlmAddBAReq
6198 *
6199 * \param pMac The global tpAniSirGlobal object
6200 *
6201 * \param pStaDs DPH Hash Node object of peer STA
6202 *
6203 * \param tid TID for which a BA is being setup.
6204 * If this is set to 0xFFFF, then we retrieve
6205 * the default TID from the CFG
6206 *
6207 * \return eSIR_SUCCESS if setup completes successfully
6208 * eSIR_FAILURE is some problem is encountered
6209 */
6210tSirRetStatus limPostMlmAddBAReq( tpAniSirGlobal pMac,
6211 tpDphHashNode pStaDs,
6212 tANI_U8 tid, tANI_U16 startingSeqNum,tpPESession psessionEntry)
6213{
6214 tSirRetStatus status = eSIR_SUCCESS;
6215 tpLimMlmAddBAReq pMlmAddBAReq;
6216 tpDialogueToken dialogueTokenNode;
6217 tANI_U32 val = 0;
6218
6219 // Check if the peer is a 11n capable STA
6220 // FIXME - Need a 11n peer indication in DPH.
6221 // For now, using the taurusPeer attribute
6222 //if( 0 == pStaDs->taurusPeer == )
6223 //return eSIR_SUCCESS;
6224
6225 // Allocate for LIM_MLM_ADDBA_REQ
6226 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
6227 (void **) &pMlmAddBAReq,
6228 sizeof( tLimMlmAddBAReq )))
6229 {
6230 limLog( pMac, LOGP, FL("palAllocateMemory failed\n"));
6231 status = eSIR_MEM_ALLOC_FAILED;
6232 goto returnFailure;
6233 }
6234
6235 palZeroMemory( pMac->hHdd, (void *) pMlmAddBAReq, sizeof( tLimMlmAddBAReq ));
6236
6237 // Copy the peer MAC
6238 palCopyMemory( pMac->hHdd,
6239 pMlmAddBAReq->peerMacAddr,
6240 pStaDs->staAddr,
6241 sizeof( tSirMacAddr ));
6242
6243 // Update the TID
6244 pMlmAddBAReq->baTID = tid;
6245
6246 // Determine the supported BA policy of local STA
6247 // for the TID of interest
6248 pMlmAddBAReq->baPolicy = (pStaDs->baPolicyFlag >> tid) & 0x1;
6249
6250 // BA Buffer Size
6251 // Requesting the ADDBA recipient to populate the size.
6252 // If ADDBA is accepted, a non-zero buffer size should
6253 // be returned in the ADDBA Rsp
6254 pMlmAddBAReq->baBufferSize = 0;
6255
6256 limLog( pMac, LOGW,
6257 FL( "Requesting an ADDBA to setup a %s BA session with STA %d for TID %d\n" ),
6258 (pMlmAddBAReq->baPolicy ? "Immediate": "Delayed"),
6259 pStaDs->staIndex,
6260 tid );
6261
6262 // BA Timeout
6263 // pMlmAddBAReq->baTimeout = pMac->hal.halMac.baTimeout; // In TU's
6264 if (wlan_cfgGetInt(pMac, WNI_CFG_BA_TIMEOUT, &val) != eSIR_SUCCESS)
6265 {
6266 limLog(pMac, LOGE, FL("could not retrieve BA TIME OUT Param CFG\n"));
6267 status = eSIR_FAILURE;
6268 goto returnFailure;
6269 }
6270 pMlmAddBAReq->baTimeout = val; // In TU's
6271
6272 // ADDBA Failure Timeout
6273 // FIXME_AMPDU - Need to retrieve this from CFG.
6274 //right now we are not checking for response timeout. so this field is dummy just to be compliant with the spec.
6275 pMlmAddBAReq->addBAFailureTimeout = 2000; // In TU's
6276
6277 // BA Starting Sequence Number
6278 pMlmAddBAReq->baSSN = startingSeqNum;
6279
6280 /* Update PE session Id*/
6281 pMlmAddBAReq->sessionId = psessionEntry->peSessionId;
6282
6283 LIM_SET_STA_BA_STATE(pStaDs, tid, eLIM_BA_STATE_WT_ADD_RSP);
6284
6285 if( NULL == (dialogueTokenNode = limAssignDialogueToken(pMac)))
6286 goto returnFailure;
6287
6288 pMlmAddBAReq->baDialogToken = dialogueTokenNode->token;
6289 //set assocId and tid information in the lim linked list
6290 dialogueTokenNode->assocId = pStaDs->assocId;
6291 dialogueTokenNode->tid = tid;
6292 // Send ADDBA Req to MLME
6293 limPostMlmMessage( pMac,
6294 LIM_MLM_ADDBA_REQ,
6295 (tANI_U32 *) pMlmAddBAReq );
6296
6297returnFailure:
6298
6299 return status;
6300}
6301
6302/**
6303 * \brief Post LIM_MLM_ADDBA_RSP to MLME. MLME
6304 * will then send an ADDBA Rsp to peer MAC entity
6305 * with the appropriate ADDBA status code
6306 *
6307 * \sa limPostMlmAddBARsp
6308 *
6309 * \param pMac The global tpAniSirGlobal object
6310 *
6311 * \param peerMacAddr MAC address of peer entity that will
6312 * be the recipient of this ADDBA Rsp
6313 *
6314 * \param baStatusCode ADDBA Rsp status code
6315 *
6316 * \param baDialogToken ADDBA Rsp dialog token
6317 *
6318 * \param baTID TID of interest
6319 *
6320 * \param baPolicy The BA policy
6321 *
6322 * \param baBufferSize The BA buffer size
6323 *
6324 * \param baTimeout BA timeout in TU's
6325 *
6326 * \return eSIR_SUCCESS if setup completes successfully
6327 * eSIR_FAILURE is some problem is encountered
6328 */
6329tSirRetStatus limPostMlmAddBARsp( tpAniSirGlobal pMac,
6330 tSirMacAddr peerMacAddr,
6331 tSirMacStatusCodes baStatusCode,
6332 tANI_U8 baDialogToken,
6333 tANI_U8 baTID,
6334 tANI_U8 baPolicy,
6335 tANI_U16 baBufferSize,
6336 tANI_U16 baTimeout,
6337 tpPESession psessionEntry)
6338{
6339tSirRetStatus status = eSIR_SUCCESS;
6340tpLimMlmAddBARsp pMlmAddBARsp;
6341
6342 // Allocate for LIM_MLM_ADDBA_RSP
6343 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
6344 (void **) &pMlmAddBARsp,
6345 sizeof( tLimMlmAddBARsp )))
6346 {
6347 limLog( pMac, LOGE,
6348 FL("palAllocateMemory failed with error code %d\n"),
6349 status );
6350
6351 status = eSIR_MEM_ALLOC_FAILED;
6352 goto returnFailure;
6353 }
6354
6355 palZeroMemory( pMac->hHdd, (void *) pMlmAddBARsp, sizeof( tLimMlmAddBARsp ));
6356
6357 // Copy the peer MAC
6358 palCopyMemory( pMac->hHdd,
6359 pMlmAddBARsp->peerMacAddr,
6360 peerMacAddr,
6361 sizeof( tSirMacAddr ));
6362
6363 pMlmAddBARsp->baDialogToken = baDialogToken;
6364 pMlmAddBARsp->addBAResultCode = baStatusCode;
6365 pMlmAddBARsp->baTID = baTID;
6366 pMlmAddBARsp->baPolicy = baPolicy;
6367 pMlmAddBARsp->baBufferSize = baBufferSize;
6368 pMlmAddBARsp->baTimeout = baTimeout;
6369
6370 /* UPdate PE session ID*/
6371 pMlmAddBARsp->sessionId = psessionEntry->peSessionId;
6372
6373 // Send ADDBA Rsp to MLME
6374 limPostMlmMessage( pMac,
6375 LIM_MLM_ADDBA_RSP,
6376 (tANI_U32 *) pMlmAddBARsp );
6377
6378returnFailure:
6379
6380 return status;
6381}
6382
6383/**
6384 * \brief Post LIM_MLM_DELBA_REQ to MLME. MLME
6385 * will then send an DELBA Ind to peer MAC entity
6386 * with the appropriate DELBA status code
6387 *
6388 * \sa limPostMlmDelBAReq
6389 *
6390 * \param pMac The global tpAniSirGlobal object
6391 *
6392 * \param pSta DPH Hash Node object of peer MAC entity
6393 * for which the BA session is being deleted
6394 *
6395 * \param baDirection DELBA direction
6396 *
6397 * \param baTID TID for which the BA session is being deleted
6398 *
6399 * \param baReasonCode DELBA Req reason code
6400 *
6401 * \return eSIR_SUCCESS if setup completes successfully
6402 * eSIR_FAILURE is some problem is encountered
6403 */
6404tSirRetStatus limPostMlmDelBAReq( tpAniSirGlobal pMac,
6405 tpDphHashNode pSta,
6406 tANI_U8 baDirection,
6407 tANI_U8 baTID,
6408 tSirMacReasonCodes baReasonCode,
6409 tpPESession psessionEntry)
6410{
6411tSirRetStatus status = eSIR_SUCCESS;
6412tpLimMlmDelBAReq pMlmDelBAReq;
6413tLimBAState curBaState;
6414
6415if(NULL == pSta)
6416 return eSIR_FAILURE;
6417
6418LIM_GET_STA_BA_STATE(pSta, baTID, &curBaState);
6419
6420 // Need to validate the current BA State.
6421 if( eLIM_BA_STATE_IDLE != curBaState)
6422 {
6423 limLog( pMac, LOGE,
6424 FL( "Received unexpected DELBA REQ when STA BA state for tid = %d is %d\n" ),
6425 baTID,
6426 curBaState);
6427
6428 status = eSIR_FAILURE;
6429 goto returnFailure;
6430 }
6431
6432 // Allocate for LIM_MLM_DELBA_REQ
6433 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
6434 (void **) &pMlmDelBAReq,
6435 sizeof( tLimMlmDelBAReq )))
6436 {
6437 limLog( pMac, LOGE,
6438 FL("palAllocateMemory failed with error code %d\n"),
6439 status );
6440
6441 status = eSIR_MEM_ALLOC_FAILED;
6442 goto returnFailure;
6443 }
6444
6445 palZeroMemory( pMac->hHdd, (void *) pMlmDelBAReq, sizeof( tLimMlmDelBAReq ));
6446
6447 // Copy the peer MAC
6448 palCopyMemory( pMac->hHdd,
6449 pMlmDelBAReq->peerMacAddr,
6450 pSta->staAddr,
6451 sizeof( tSirMacAddr ));
6452
6453 pMlmDelBAReq->baDirection = baDirection;
6454 pMlmDelBAReq->baTID = baTID;
6455 pMlmDelBAReq->delBAReasonCode = baReasonCode;
6456
6457 /* Update PE session ID*/
6458 pMlmDelBAReq->sessionId = psessionEntry->peSessionId;
6459
6460 //we don't have valid BA session for the given direction.
6461 // HDD wants to get the BA session deleted on PEER in this case.
6462 // in this case we just need to send DelBA to the peer.
6463 if(((eBA_RECIPIENT == baDirection) && (eBA_DISABLE == pSta->tcCfg[baTID].fUseBARx)) ||
6464 ((eBA_INITIATOR == baDirection) && (eBA_DISABLE == pSta->tcCfg[baTID].fUseBATx)))
6465 {
6466 // Send DELBA Ind over the air
6467 if( eSIR_SUCCESS !=
6468 (status = limSendDelBAInd( pMac, pMlmDelBAReq,psessionEntry)))
6469 status = eSIR_FAILURE;
6470
6471 palFreeMemory(pMac->hHdd, (void*) pMlmDelBAReq);
6472 return status;
6473 }
6474
6475
6476 // Update the BA state in STA
6477 LIM_SET_STA_BA_STATE(pSta, pMlmDelBAReq->baTID, eLIM_BA_STATE_WT_DEL_RSP);
6478
6479 // Send DELBA Req to MLME
6480 limPostMlmMessage( pMac,
6481 LIM_MLM_DELBA_REQ,
6482 (tANI_U32 *) pMlmDelBAReq );
6483
6484returnFailure:
6485
6486 return status;
6487}
6488
6489/**
6490 * \brief Send WDA_ADDBA_REQ to HAL, in order
6491 * to setup a new BA session with a peer
6492 *
6493 * \sa limPostMsgAddBAReq
6494 *
6495 * \param pMac The global tpAniSirGlobal object
6496 *
6497 * \param pSta Runtime, STA-related configuration cached
6498 * in the HashNode object
6499 *
6500 * \param baDialogToken The Action Frame dialog token
6501 *
6502 * \param baTID TID for which the BA session is being setup
6503 *
6504 * \param baPolicy BA Policy
6505 *
6506 * \param baBufferSize The requested BA buffer size
6507 *
6508 * \param baTimeout BA Timeout. 0 indicates no BA timeout enforced
6509 *
6510 * \param baSSN Starting Sequence Number for this BA session
6511 *
6512 * \param baDirection BA Direction: 1 - Initiator, 0 - Recipient
6513 *
6514 * \return none
6515 *
6516 */
6517tSirRetStatus limPostMsgAddBAReq( tpAniSirGlobal pMac,
6518 tpDphHashNode pSta,
6519 tANI_U8 baDialogToken,
6520 tANI_U8 baTID,
6521 tANI_U8 baPolicy,
6522 tANI_U16 baBufferSize,
6523 tANI_U16 baTimeout,
6524 tANI_U16 baSSN,
6525 tANI_U8 baDirection,
6526 tpPESession psessionEntry)
6527{
6528tpAddBAParams pAddBAParams = NULL;
6529tSirRetStatus retCode = eSIR_SUCCESS;
6530eHalStatus status;
6531tSirMsgQ msgQ;
6532
6533#ifdef WLAN_SOFTAP_VSTA_FEATURE
6534 // we can only do BA on "hard" STAs
6535 if (!(IS_HWSTA_IDX(pSta->staIndex)))
6536 {
6537 retCode = eHAL_STATUS_FAILURE;
6538 goto returnFailure;
6539 }
6540#endif //WLAN_SOFTAP_VSTA_FEATURE
6541
6542 // Allocate for WDA_ADDBA_REQ
6543 if( eHAL_STATUS_SUCCESS !=
6544 (status = palAllocateMemory( pMac->hHdd,
6545 (void **) &pAddBAParams,
6546 sizeof( tAddBAParams ))))
6547 {
6548 limLog( pMac, LOGE,
6549 FL("palAllocateMemory failed with error code %d\n"),
6550 status );
6551
6552 retCode = eSIR_MEM_ALLOC_FAILED;
6553 goto returnFailure;
6554 }
6555
6556 palZeroMemory( pMac->hHdd, (void *) pAddBAParams, sizeof( tAddBAParams ));
6557
6558 // Copy the peer MAC address
6559 palCopyMemory( pMac->hHdd,
6560 (void *) pAddBAParams->peerMacAddr,
6561 (void *) pSta->staAddr,
6562 sizeof( tSirMacAddr ));
6563
6564 // Populate the REQ parameters
6565 pAddBAParams->staIdx = pSta->staIndex;
6566 pAddBAParams->baDialogToken = baDialogToken;
6567 pAddBAParams->baTID = baTID;
6568 pAddBAParams->baPolicy = baPolicy;
6569 pAddBAParams->baBufferSize = baBufferSize;
6570 pAddBAParams->baTimeout = baTimeout;
6571 pAddBAParams->baSSN = baSSN;
6572 pAddBAParams->baDirection = baDirection;
6573 pAddBAParams->respReqd = 1;
6574
6575 /* UPdate PE session ID */
6576 pAddBAParams->sessionId = psessionEntry->peSessionId;
6577
6578 // Post WDA_ADDBA_REQ to HAL.
6579 msgQ.type = WDA_ADDBA_REQ;
6580 //
6581 // FIXME_AMPDU
6582 // A global counter (dialog token) is required to keep track of
6583 // all PE <-> HAL communication(s)
6584 //
6585 msgQ.reserved = 0;
6586 msgQ.bodyptr = pAddBAParams;
6587 msgQ.bodyval = 0;
6588
6589 limLog( pMac, LOGW,
6590 FL( "Sending WDA_ADDBA_REQ..." ));
6591
6592 //defer any other message until we get response back.
6593 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
6594
Jeff Johnsone7245742012-09-05 17:12:55 -07006595 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006596#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
6597 limDiagEventReport(pMac, WLAN_PE_DIAG_HAL_ADDBA_REQ_EVENT, psessionEntry, 0, 0);
6598#endif //FEATURE_WLAN_DIAG_SUPPORT
6599
6600 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
6601 limLog( pMac, LOGE,
6602 FL("Posting WDA_ADDBA_REQ to HAL failed! Reason = %d\n"),
6603 retCode );
6604 else
6605 return retCode;
6606
6607returnFailure:
6608
6609 // Clean-up...
6610 if( NULL != pAddBAParams )
6611 palFreeMemory( pMac->hHdd, (void *) pAddBAParams );
6612
6613 return retCode;
6614
6615}
6616
6617/**
6618 * \brief Send WDA_DELBA_IND to HAL, in order
6619 * to delete an existing BA session with peer
6620 *
6621 * \sa limPostMsgDelBAInd
6622 *
6623 * \param pMac The global tpAniSirGlobal object
6624 *
6625 * \param pSta Runtime, STA-related configuration cached
6626 * in the HashNode object
6627 *
6628 * \param baTID TID for which the BA session is being setup
6629 *
6630 * \param baDirection Identifies whether the DELBA Ind was
6631 * sent by the BA initiator or recipient
6632 *
6633 * \return none
6634 *
6635 */
6636tSirRetStatus limPostMsgDelBAInd( tpAniSirGlobal pMac,
6637 tpDphHashNode pSta,
6638 tANI_U8 baTID,
6639 tANI_U8 baDirection,
6640 tpPESession psessionEntry)
6641{
6642tpDelBAParams pDelBAParams = NULL;
6643tSirRetStatus retCode = eSIR_SUCCESS;
6644eHalStatus status;
6645tSirMsgQ msgQ;
6646
6647 // Allocate for SIR_HAL_DELBA_IND
6648 if( eHAL_STATUS_SUCCESS !=
6649 (status = palAllocateMemory( pMac->hHdd,
6650 (void **) &pDelBAParams,
6651 sizeof( tDelBAParams ))))
6652 {
6653 limLog( pMac, LOGE,
6654 FL("palAllocateMemory failed with error code %d\n"),
6655 status );
6656
6657 retCode = eSIR_MEM_ALLOC_FAILED;
6658 goto returnFailure;
6659 }
6660
6661 palZeroMemory( pMac->hHdd, (void *) pDelBAParams, sizeof( tDelBAParams ));
6662
6663 // Populate the REQ parameters
6664 pDelBAParams->staIdx = pSta->staIndex;
6665 pDelBAParams->baTID = baTID;
6666 pDelBAParams->baDirection = baDirection;
6667
6668 /* Update PE session ID */
6669
6670
6671 //TBD-RAJESH Updating of the session ID is requird for SIR_HAL_DELBA_IND?????
6672 //pDelBAParams->sessionId = psessionEntry->peSessionId;
6673
6674 // Post WDA_DELBA_IND to HAL.
6675 msgQ.type = WDA_DELBA_IND;
6676 //
6677 // FIXME:
6678 // A global counter (dialog token) is required to keep track of
6679 // all PE <-> HAL communication(s)
6680 //
6681 msgQ.reserved = 0;
6682 msgQ.bodyptr = pDelBAParams;
6683 msgQ.bodyval = 0;
6684
6685 limLog( pMac, LOGW,
6686 FL( "Sending SIR_HAL_DELBA_IND..." ));
6687
Jeff Johnsone7245742012-09-05 17:12:55 -07006688 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006689#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
6690 limDiagEventReport(pMac, WLAN_PE_DIAG_HAL_DELBA_IND_EVENT, psessionEntry, 0, 0);
6691#endif //FEATURE_WLAN_DIAG_SUPPORT
6692
6693 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
6694 limLog( pMac, LOGE,
6695 FL("Posting WDA_DELBA_IND to HAL failed! Reason = %d\n"),
6696 retCode );
6697 else
6698 {
6699 // Update LIM's internal cache...
6700 if( eBA_INITIATOR == baDirection)
6701 {
6702 pSta->tcCfg[baTID].fUseBATx = 0;
6703 pSta->tcCfg[baTID].txBufSize = 0;
6704 }
6705 else
6706 {
6707 pSta->tcCfg[baTID].fUseBARx = 0;
6708 pSta->tcCfg[baTID].rxBufSize = 0;
6709 }
6710
6711 return retCode;
6712 }
6713
6714returnFailure:
6715
6716 // Clean-up...
6717 if( NULL != pDelBAParams )
6718 palFreeMemory( pMac->hHdd, (void *) pDelBAParams );
6719
6720 return retCode;
6721
6722}
6723
6724/**
6725 * @function : limPostSMStateUpdate()
6726 *
6727 * @brief : This function Updates the HAL and Softmac about the change in the STA's SMPS state.
6728 *
6729 * LOGIC:
6730 *
6731 * ASSUMPTIONS:
6732 * NA
6733 *
6734 * NOTE:
6735 * NA
6736 *
6737 * @param pMac - Pointer to Global MAC structure
6738 * @param limMsg - Lim Message structure object with the MimoPSparam in body
6739 * @return None
6740 */
6741tSirRetStatus
6742limPostSMStateUpdate(tpAniSirGlobal pMac,
6743 tANI_U16 staIdx, tSirMacHTMIMOPowerSaveState state)
6744{
6745 tSirRetStatus retCode = eSIR_SUCCESS;
6746 tSirMsgQ msgQ;
6747 eHalStatus status;
6748 tpSetMIMOPS pMIMO_PSParams;
6749
6750 msgQ.reserved = 0;
6751 msgQ.type = WDA_SET_MIMOPS_REQ;
6752
6753 // Allocate for WDA_SET_MIMOPS_REQ
6754 status = palAllocateMemory( pMac->hHdd, (void **) &pMIMO_PSParams, sizeof( tSetMIMOPS));
6755 if( eHAL_STATUS_SUCCESS != status) {
6756 limLog( pMac, LOGP,FL(" palAllocateMemory failed with error code %d\n"), status );
6757 return eSIR_MEM_ALLOC_FAILED;
6758 }
6759
6760 pMIMO_PSParams->htMIMOPSState = state;
6761 pMIMO_PSParams->staIdx = staIdx;
6762 pMIMO_PSParams->fsendRsp = true;
6763 msgQ.bodyptr = pMIMO_PSParams;
6764 msgQ.bodyval = 0;
6765
6766 limLog( pMac, LOG2, FL( "Sending WDA_SET_MIMOPS_REQ..." ));
6767
Jeff Johnsone7245742012-09-05 17:12:55 -07006768 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 retCode = wdaPostCtrlMsg( pMac, &msgQ );
6770 if (eSIR_SUCCESS != retCode)
6771 {
6772 limLog( pMac, LOGP, FL("Posting WDA_SET_MIMOPS_REQ to HAL failed! Reason = %d\n"), retCode );
6773 palFreeMemory(pMac->hHdd, (void *) pMIMO_PSParams);
6774 return retCode;
6775 }
6776
6777 return retCode;
6778}
6779
6780void limPktFree (
6781 tpAniSirGlobal pMac,
6782 eFrameType frmType,
6783 tANI_U8 *pRxPacketInfo,
6784 void *pBody)
6785{
6786 (void) pMac; (void) frmType; (void) pRxPacketInfo; (void) pBody;
6787#if defined ANI_OS_TYPE_LINUX || defined ANI_OS_TYPE_OSX
6788 // Free up allocated SK BUF
6789 palPktFree( pMac->hHdd, frmType, pRxPacketInfo, pBody) ;
6790#endif
6791}
6792
6793/**
6794 * limGetBDfromRxPacket()
6795 *
6796 *FUNCTION:
6797 * This function is called to get pointer to Polaris
6798 * Buffer Descriptor containing MAC header & other control
6799 * info from the body of the message posted to LIM.
6800 *
6801 *LOGIC:
6802 * NA
6803 *
6804 *ASSUMPTIONS:
6805 * NA
6806 *
6807 *NOTE:
6808 * NA
6809 *
6810 * @param body - Received message body
6811 * @param pRxPacketInfo - Pointer to received BD
6812 * @return None
6813 */
6814
6815void
6816limGetBDfromRxPacket(tpAniSirGlobal pMac, void *body, tANI_U32 **pRxPacketInfo)
6817{
6818#if defined (ANI_OS_TYPE_LINUX) || defined (ANI_OS_TYPE_OSX)
6819#ifndef GEN6_ONWARDS
6820 palGetPacketDataPtr( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, (void *) body, (void **) pRxPacketInfo );
6821#endif //GEN6_ONWARDS
6822#else
6823 *pRxPacketInfo = (tANI_U32 *) body;
6824#endif
6825} /*** end limGetBDfromRxPacket() ***/
6826
6827
6828
6829
6830
6831void limRessetScanChannelInfo(tpAniSirGlobal pMac)
6832{
6833 palZeroMemory(pMac->hHdd, &pMac->lim.scanChnInfo, sizeof(tLimScanChnInfo));
6834}
6835
6836
6837void limAddScanChannelInfo(tpAniSirGlobal pMac, tANI_U8 channelId)
6838{
6839 tANI_U8 i;
6840 tANI_BOOLEAN fFound = eANI_BOOLEAN_FALSE;
6841
6842 for(i = 0; i < pMac->lim.scanChnInfo.numChnInfo; i++)
6843 {
6844 if(pMac->lim.scanChnInfo.scanChn[i].channelId == channelId)
6845 {
6846 pMac->lim.scanChnInfo.scanChn[i].numTimeScan++;
6847 fFound = eANI_BOOLEAN_TRUE;
6848 break;
6849 }
6850 }
6851 if(eANI_BOOLEAN_FALSE == fFound)
6852 {
6853 if(pMac->lim.scanChnInfo.numChnInfo < SIR_MAX_SUPPORTED_CHANNEL_LIST)
6854 {
6855 pMac->lim.scanChnInfo.scanChn[pMac->lim.scanChnInfo.numChnInfo].channelId = channelId;
6856 pMac->lim.scanChnInfo.scanChn[pMac->lim.scanChnInfo.numChnInfo++].numTimeScan = 1;
6857 }
6858 else
6859 {
6860 PELOGW(limLog(pMac, LOGW, FL(" -- number of channels exceed mac\n"));)
6861 }
6862 }
6863}
6864
6865
6866/**
6867 * @function : limIsChannelValidForChannelSwitch()
6868 *
6869 * @brief : This function checks if the channel to which AP
6870 * is expecting us to switch, is a valid channel for us.
6871 * LOGIC:
6872 *
6873 * ASSUMPTIONS:
6874 * NA
6875 *
6876 * NOTE:
6877 * NA
6878 *
6879 * @param pMac - Pointer to Global MAC structure
6880 * @param channel - New channel to which we are expected to move
6881 * @return None
6882 */
6883tAniBool
6884limIsChannelValidForChannelSwitch(tpAniSirGlobal pMac, tANI_U8 channel)
6885{
6886 tANI_U8 index;
6887 tANI_U32 validChannelListLen = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6888 tSirMacChanNum validChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6889
6890 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
6891 (tANI_U8 *)validChannelList,
6892 (tANI_U32 *)&validChannelListLen) != eSIR_SUCCESS)
6893 {
6894 PELOGE(limLog(pMac, LOGE, FL("could not retrieve valid channel list\n"));)
6895 return (eSIR_FALSE);
6896 }
6897
6898 for(index = 0; index < validChannelListLen; index++)
6899 {
6900 if(validChannelList[index] == channel)
6901 return (eSIR_TRUE);
6902 }
6903
6904 /* channel does not belong to list of valid channels */
6905 return (eSIR_FALSE);
6906}
6907
6908/**------------------------------------------------------
6909\fn __limFillTxControlParams
6910\brief Fill the message for stopping/resuming tx.
6911
6912\param pMac
6913\param pTxCtrlMsg - Pointer to tx control message.
6914\param type - Which way we want to stop/ resume tx.
6915\param mode - To stop/resume.
6916 -------------------------------------------------------*/
6917static eHalStatus
6918__limFillTxControlParams(tpAniSirGlobal pMac, tpTxControlParams pTxCtrlMsg,
6919 tLimQuietTxMode type, tLimControlTx mode)
6920{
6921
6922 //TBD-RAJESH HOW TO GET sessionEntry?????
6923 tpPESession psessionEntry = &pMac->lim.gpSession[0];
6924
6925 if (mode == eLIM_STOP_TX)
6926 pTxCtrlMsg->stopTx = eANI_BOOLEAN_TRUE;
6927 else
6928 pTxCtrlMsg->stopTx = eANI_BOOLEAN_FALSE;
6929
6930 switch (type)
6931 {
6932 case eLIM_TX_ALL:
6933 /** Stops/resumes transmission completely */
6934 pTxCtrlMsg->fCtrlGlobal = 1;
6935 break;
6936
6937 case eLIM_TX_BSS_BUT_BEACON:
6938 /** Stops/resumes transmission on a particular BSS. Stopping BSS, doesnt
6939 * stop beacon transmission.
6940 */
6941 pTxCtrlMsg->ctrlBss = 1;
6942 pTxCtrlMsg->bssBitmap |= (1 << psessionEntry->bssIdx);
6943 break;
6944
6945 case eLIM_TX_STA:
6946 /** Memory for station bitmap is allocated dynamically in caller of this
6947 * so decode properly here and fill the bitmap. Now not implemented,
6948 * fall through.
6949 */
6950 case eLIM_TX_BSS:
6951 //Fall thru...
6952 default:
6953 PELOGW(limLog(pMac, LOGW, FL("Invalid case: Not Handled\n"));)
6954 return eHAL_STATUS_FAILURE;
6955 }
6956
6957 return eHAL_STATUS_SUCCESS;
6958}
6959
6960/**
6961 * @function : limFrameTransmissionControl()
6962 *
6963 * @brief : This API is called by the user to halt/resume any frame
6964 * transmission from the device. If stopped, all frames will be
6965 * queued starting from hardware. Then back-pressure
6966 * is built till the driver.
6967 * LOGIC:
6968 *
6969 * ASSUMPTIONS:
6970 * NA
6971 *
6972 * NOTE:
6973 * NA
6974 *
6975 * @param pMac - Pointer to Global MAC structure
6976 * @return None
6977 */
6978void limFrameTransmissionControl(tpAniSirGlobal pMac, tLimQuietTxMode type, tLimControlTx mode)
6979{
6980
6981 eHalStatus status = eHAL_STATUS_FAILURE;
6982 tpTxControlParams pTxCtrlMsg;
6983 tSirMsgQ msgQ;
6984 tANI_U8 nBytes = 0; // No of bytes required for station bitmap.
6985
6986 /** Allocate only required number of bytes for station bitmap
6987 * Make it to align to 4 byte boundary */
6988 nBytes = (tANI_U8)HALMSG_NUMBYTES_STATION_BITMAP(pMac->lim.maxStation);
6989
6990 status = palAllocateMemory(pMac->hHdd, (void **) &pTxCtrlMsg,
6991 (sizeof(*pTxCtrlMsg) + nBytes));
6992 if (status != eHAL_STATUS_SUCCESS)
6993 {
6994 limLog(pMac, LOGP, FL("palAllocateMemory() failed\n"));
6995 return;
6996 }
6997
6998 status = palZeroMemory(pMac->hHdd, (void *) pTxCtrlMsg,
6999 (sizeof(*pTxCtrlMsg) + nBytes));
7000 if (status != eHAL_STATUS_SUCCESS)
7001 {
7002 palFreeMemory(pMac->hHdd, (void *) pTxCtrlMsg);
7003 limLog(pMac, LOGP, FL("palZeroMemory() failed, status = %d\n"), status);
7004 return;
7005 }
7006
7007 status = __limFillTxControlParams(pMac, pTxCtrlMsg, type, mode);
7008 if (status != eHAL_STATUS_SUCCESS)
7009 {
7010 palFreeMemory(pMac->hHdd, (void *) pTxCtrlMsg);
7011 limLog(pMac, LOGP, FL("__limFillTxControlParams failed, status = %d\n"), status);
7012 return;
7013 }
7014
7015 msgQ.bodyptr = (void *) pTxCtrlMsg;
7016 msgQ.bodyval = 0;
7017 msgQ.reserved = 0;
7018 msgQ.type = WDA_TRANSMISSION_CONTROL_IND;
7019
Jeff Johnsone7245742012-09-05 17:12:55 -07007020 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 if(wdaPostCtrlMsg( pMac, &msgQ) != eSIR_SUCCESS)
7022 {
7023 palFreeMemory(pMac->hHdd, (void *) pTxCtrlMsg);
7024 limLog( pMac, LOGP, FL("Posting Message to HAL failed\n"));
7025 return;
7026 }
7027
7028 if (mode == eLIM_STOP_TX)
7029 {
7030 PELOG1(limLog(pMac, LOG1, FL("Stopping the transmission of all packets, indicated softmac\n"));)
7031 }
7032 else
7033 {
7034 PELOG1(limLog(pMac, LOG1, FL("Resuming the transmission of all packets, indicated softmac\n"));)
7035 }
7036 return;
7037}
7038
7039
7040/**
7041 * @function : limRestorePreChannelSwitchState()
7042 *
7043 * @brief : This API is called by the user to undo any
7044 * specific changes done on the device during
7045 * channel switch.
7046 * LOGIC:
7047 *
7048 * ASSUMPTIONS:
7049 * NA
7050 *
7051 * NOTE:
7052 * NA
7053 *
7054 * @param pMac - Pointer to Global MAC structure
7055 * @return None
7056 */
7057
7058tSirRetStatus
7059limRestorePreChannelSwitchState(tpAniSirGlobal pMac, tpPESession psessionEntry)
7060{
7061
7062 tSirRetStatus retCode = eSIR_SUCCESS;
7063#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
7064 tANI_U32 val = 0;
7065
7066 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
7067 return retCode;
7068
7069 /* Channel switch should be ready for the next time */
Jeff Johnsone7245742012-09-05 17:12:55 -07007070 psessionEntry->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07007071
7072 /* Restore the frame transmission, all the time. */
7073 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
7074
7075 /* Free to enter BMPS */
7076 limSendSmePostChannelSwitchInd(pMac);
7077
7078 //Background scan is now enabled by SME
7079 if(pMac->lim.gLimBackgroundScanTerminate == FALSE)
7080 {
7081 /* Enable background scan if already enabled, else don't bother */
7082 if ((retCode = wlan_cfgGetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD,
7083 &val)) != eSIR_SUCCESS)
7084
7085 {
7086 limLog(pMac, LOGP, FL("could not retrieve Background scan period value\n"));
7087 return (retCode);
7088 }
7089
7090 if (val > 0 && TX_TIMER_VALID(pMac->lim.limTimers.gLimBackgroundScanTimer))
7091 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007092 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_BACKGROUND_SCAN_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 if(tx_timer_activate(&pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
7094 {
7095 limLog(pMac, LOGP, FL("Could not restart background scan timer, doing LOGP"));
7096 return (eSIR_FAILURE);
7097 }
7098
7099 }
7100 }
7101
7102 /* Enable heartbeat timer */
7103 if (TX_TIMER_VALID(pMac->lim.limTimers.gLimHeartBeatTimer))
7104 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007105 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_HEART_BEAT_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07007106 if(limActivateHearBeatTimer(pMac) != TX_SUCCESS)
7107 {
7108 limLog(pMac, LOGP, FL("Could not restart heartbeat timer, doing LOGP"));
7109 return (eSIR_FAILURE);
7110 }
7111 }
7112#endif
7113 return (retCode);
7114}
7115
7116
7117/**--------------------------------------------
7118\fn limRestorePreQuietState
7119\brief Restore the pre quiet state
7120
7121\param pMac
7122\return NONE
7123---------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07007124tSirRetStatus limRestorePreQuietState(tpAniSirGlobal pMac, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07007125{
7126
7127 tSirRetStatus retCode = eSIR_SUCCESS;
7128#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
7129 tANI_U32 val = 0;
7130
7131 if (pMac->lim.gLimSystemRole != eLIM_STA_ROLE)
7132 return retCode;
7133
7134 /* Quiet should be ready for the next time */
Jeff Johnsone7245742012-09-05 17:12:55 -07007135 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07007136
7137 /* Restore the frame transmission, all the time. */
Jeff Johnsone7245742012-09-05 17:12:55 -07007138 if (psessionEntry->gLimSpecMgmt.quietState == eLIM_QUIET_RUNNING)
Jeff Johnson295189b2012-06-20 16:38:30 -07007139 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
7140
7141
7142 //Background scan is now enabled by SME
7143 if(pMac->lim.gLimBackgroundScanTerminate == FALSE)
7144 {
7145 /* Enable background scan if already enabled, else don't bother */
7146 if ((retCode = wlan_cfgGetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD,
7147 &val)) != eSIR_SUCCESS)
7148
7149 {
7150 limLog(pMac, LOGP, FL("could not retrieve Background scan period value\n"));
7151 return (retCode);
7152 }
7153
7154 if (val > 0 && TX_TIMER_VALID(pMac->lim.limTimers.gLimBackgroundScanTimer))
7155 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007156 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_BACKGROUND_SCAN_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07007157 if(tx_timer_activate(&pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
7158 {
7159 limLog(pMac, LOGP, FL("Could not restart background scan timer, doing LOGP"));
7160 return (eSIR_FAILURE);
7161 }
7162
7163 }
7164 }
7165
7166 /* Enable heartbeat timer */
7167 if (TX_TIMER_VALID(pMac->lim.limTimers.gLimHeartBeatTimer))
7168 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007169 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_HEART_BEAT_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07007170 if(limActivateHearBeatTimer(pMac) != TX_SUCCESS)
7171 {
7172 limLog(pMac, LOGP, FL("Could not restart heartbeat timer, doing LOGP"));
7173 return (eSIR_FAILURE);
7174 }
7175 }
7176#endif
7177 return (retCode);
7178}
7179
7180
7181/**
7182 * @function: limPrepareFor11hChannelSwitch()
7183 *
7184 * @brief : This API is called by the user to prepare for
7185 * 11h channel switch. As of now, the API does
7186 * very minimal work. User can add more into the
7187 * same API if needed.
7188 * LOGIC:
7189 *
7190 * ASSUMPTIONS:
7191 * NA
7192 *
7193 * NOTE:
7194 * NA
7195 *
7196 * @param pMac - Pointer to Global MAC structure
7197 * @param psessionEntry
7198 * @return None
7199 */
7200void
7201limPrepareFor11hChannelSwitch(tpAniSirGlobal pMac, tpPESession psessionEntry)
7202{
7203#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
7204 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
7205 return;
7206
7207 /* Flag to indicate 11h channel switch in progress */
Jeff Johnsone7245742012-09-05 17:12:55 -07007208 psessionEntry->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_RUNNING;
Jeff Johnson295189b2012-06-20 16:38:30 -07007209
7210 /* Disable, Stop background scan if enabled and running */
7211 limDeactivateAndChangeTimer(pMac, eLIM_BACKGROUND_SCAN_TIMER);
7212
7213 /* Stop heart-beat timer to stop heartbeat disassociation */
7214 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
7215
7216 if(pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE ||
7217 pMac->lim.gLimSmeState == eLIM_SME_CHANNEL_SCAN_STATE)
7218 {
7219 PELOGE(limLog(pMac, LOGE, FL("Posting finish scan as we are in scan state\n"));)
7220 /* Stop ongoing scanning if any */
7221 if (GET_LIM_PROCESS_DEFD_MESGS(pMac))
7222 {
7223 //Set the resume channel to Any valid channel (invalid).
7224 //This will instruct HAL to set it to any previous valid channel.
7225 peSetResumeChannel(pMac, 0, 0);
7226 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
7227 }
7228 else
7229 {
7230 limRestorePreChannelSwitchState(pMac, psessionEntry);
7231 }
7232 return;
7233 }
7234 else
7235 {
7236 PELOGE(limLog(pMac, LOGE, FL("Not in scan state, start channel switch timer\n"));)
7237 /** We are safe to switch channel at this point */
7238 limStopTxAndSwitchChannel(pMac, psessionEntry->peSessionId);
7239 }
7240#endif
7241}
7242
7243
7244
7245/**----------------------------------------------------
7246\fn limGetNwType
7247
7248\brief Get type of the network from data packet or beacon
7249\param pMac
7250\param channelNum - Channel number
7251\param type - Type of packet.
7252\param pBeacon - Pointer to beacon or probe response
7253
7254\return Network type a/b/g.
7255-----------------------------------------------------*/
7256tSirNwType limGetNwType(tpAniSirGlobal pMac, tANI_U8 channelNum, tANI_U32 type, tpSchBeaconStruct pBeacon)
7257{
7258 tSirNwType nwType = eSIR_11B_NW_TYPE;
7259
7260 if (type == SIR_MAC_DATA_FRAME)
7261 {
7262 if ((channelNum > 0) && (channelNum < 15))
7263 {
7264 nwType = eSIR_11G_NW_TYPE;
7265 }
7266 else
7267 {
7268 nwType = eSIR_11A_NW_TYPE;
7269 }
7270 }
7271 else
7272 {
7273 if ((channelNum > 0) && (channelNum < 15))
7274 {
7275 int i;
7276 // 11b or 11g packet
7277 // 11g iff extended Rate IE is present or
7278 // if there is an A rate in suppRate IE
7279 for (i = 0; i < pBeacon->supportedRates.numRates; i++)
7280 {
7281 if (sirIsArate(pBeacon->supportedRates.rate[i] & 0x7f))
7282 {
7283 nwType = eSIR_11G_NW_TYPE;
7284 break;
7285 }
7286 }
7287 if (pBeacon->extendedRatesPresent)
7288 {
7289 PELOG3(limLog(pMac, LOG3, FL("Beacon, nwtype=G\n"));)
7290 nwType = eSIR_11G_NW_TYPE;
7291 }
7292 }
7293 else
7294 {
7295 // 11a packet
7296 PELOG3(limLog(pMac, LOG3,FL("Beacon, nwtype=A\n"));)
7297 nwType = eSIR_11A_NW_TYPE;
7298 }
7299 }
7300 return nwType;
7301}
7302
7303
7304/**---------------------------------------------------------
7305\fn limGetChannelFromBeacon
7306\brief To extract channel number from beacon
7307
7308\param pMac
7309\param pBeacon - Pointer to beacon or probe rsp
7310\return channel number
7311-----------------------------------------------------------*/
7312tANI_U8 limGetChannelFromBeacon(tpAniSirGlobal pMac, tpSchBeaconStruct pBeacon)
7313{
7314 tANI_U8 channelNum = 0;
7315
7316 if (pBeacon->dsParamsPresent)
7317 channelNum = pBeacon->channelNumber;
7318 else if(pBeacon->HTInfo.present)
7319 channelNum = pBeacon->HTInfo.primaryChannel;
7320 else
7321 channelNum = pBeacon->channelNumber;
7322
7323 return channelNum;
7324}
7325
7326
7327/** ---------------------------------------------------------
7328\fn limSetTspecUapsdMask
7329\brief This function sets the PE global variable:
7330\ 1) gUapsdPerAcTriggerEnableMask and
7331\ 2) gUapsdPerAcDeliveryEnableMask
7332\ based on the user priority field and direction field
7333\ in the TS Info Fields.
7334\
7335\ An AC is a trigger-enabled AC if the PSB subfield
7336\ is set to 1 in the uplink direction.
7337\ An AC is a delivery-enabled AC if the PSB subfield
7338\ is set to 1 in the down-link direction.
7339\
7340\param tpAniSirGlobal pMac
7341\param tSirMacTSInfo pTsInfo
7342\param tANI_U32 action
7343\return None
7344 ------------------------------------------------------------*/
7345void limSetTspecUapsdMask(tpAniSirGlobal pMac, tSirMacTSInfo *pTsInfo, tANI_U32 action)
7346{
7347 tANI_U8 userPrio = (tANI_U8)pTsInfo->traffic.userPrio;
7348 tANI_U16 direction = pTsInfo->traffic.direction;
7349 tANI_U8 ac = upToAc(userPrio);
7350
7351 PELOG1(limLog(pMac, LOG1, FL(" Set UAPSD mask for AC %d, direction %d, action=%d (1=set,0=clear) \n"),ac, direction, action );)
7352
7353 /* Converting AC to appropriate Uapsd Bit Mask
7354 * AC_BE(0) --> UAPSD_BITOFFSET_ACVO(3)
7355 * AC_BK(1) --> UAPSD_BITOFFSET_ACVO(2)
7356 * AC_VI(2) --> UAPSD_BITOFFSET_ACVO(1)
7357 * AC_VO(3) --> UAPSD_BITOFFSET_ACVO(0)
7358 */
7359 ac = ((~ac) & 0x3);
7360
7361 if (action == CLEAR_UAPSD_MASK)
7362 {
7363 if (direction == SIR_MAC_DIRECTION_UPLINK)
7364 pMac->lim.gUapsdPerAcTriggerEnableMask &= ~(1 << ac);
7365 else if (direction == SIR_MAC_DIRECTION_DNLINK)
7366 pMac->lim.gUapsdPerAcDeliveryEnableMask &= ~(1 << ac);
7367 else if (direction == SIR_MAC_DIRECTION_BIDIR)
7368 {
7369 pMac->lim.gUapsdPerAcTriggerEnableMask &= ~(1 << ac);
7370 pMac->lim.gUapsdPerAcDeliveryEnableMask &= ~(1 << ac);
7371 }
7372 }
7373 else if (action == SET_UAPSD_MASK)
7374 {
7375 if (direction == SIR_MAC_DIRECTION_UPLINK)
7376 pMac->lim.gUapsdPerAcTriggerEnableMask |= (1 << ac);
7377 else if (direction == SIR_MAC_DIRECTION_DNLINK)
7378 pMac->lim.gUapsdPerAcDeliveryEnableMask |= (1 << ac);
7379 else if (direction == SIR_MAC_DIRECTION_BIDIR)
7380 {
7381 pMac->lim.gUapsdPerAcTriggerEnableMask |= (1 << ac);
7382 pMac->lim.gUapsdPerAcDeliveryEnableMask |= (1 << ac);
7383 }
7384 }
7385
7386 limLog(pMac, LOGE, FL("New pMac->lim.gUapsdPerAcTriggerEnableMask = 0x%x \n"), pMac->lim.gUapsdPerAcTriggerEnableMask );
7387 limLog(pMac, LOGE, FL("New pMac->lim.gUapsdPerAcDeliveryEnableMask = 0x%x \n"), pMac->lim.gUapsdPerAcDeliveryEnableMask );
7388
7389 return;
7390}
7391
7392
7393
7394void limHandleHeartBeatTimeout(tpAniSirGlobal pMac )
7395{
7396
7397 tANI_U8 i;
7398 for(i =0;i < pMac->lim.maxBssId;i++)
7399 {
7400 if(pMac->lim.gpSession[i].valid == TRUE )
7401 {
7402 if(pMac->lim.gpSession[i].bssType == eSIR_IBSS_MODE)
7403 {
7404 limIbssHeartBeatHandle(pMac,&pMac->lim.gpSession[i]);
7405 break;
7406 }
7407
7408 if((pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) &&
7409 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_ROLE))
7410 {
7411 limHandleHeartBeatFailure(pMac,&pMac->lim.gpSession[i]);
7412 }
7413 }
7414 }
7415 for(i=0; i< pMac->lim.maxBssId; i++)
7416 {
7417 if(pMac->lim.gpSession[i].valid == TRUE )
7418 {
7419 if((pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) &&
7420 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_ROLE))
7421 {
7422 if(pMac->lim.gpSession[i].LimHBFailureStatus == eANI_BOOLEAN_TRUE)
7423 {
7424 /* Activate Probe After HeartBeat Timer incase HB Failure detected */
7425 PELOGW(limLog(pMac, LOGW,FL("Sending Probe for Session: %d\n"),
7426 i);)
7427 limDeactivateAndChangeTimer(pMac, eLIM_PROBE_AFTER_HB_TIMER);
7428 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0, eLIM_PROBE_AFTER_HB_TIMER));
7429 if (tx_timer_activate(&pMac->lim.limTimers.gLimProbeAfterHBTimer) != TX_SUCCESS)
7430 {
7431 limLog(pMac, LOGP, FL("Fail to re-activate Probe-after-heartbeat timer\n"));
7432 limReactivateHeartBeatTimer(pMac, &pMac->lim.gpSession[i]);
7433 }
7434 break;
7435 }
7436 }
7437 }
7438 }
7439}
7440
7441tANI_U8 limGetCurrentOperatingChannel(tpAniSirGlobal pMac)
7442{
7443 tANI_U8 i;
7444 for(i =0;i < pMac->lim.maxBssId;i++)
7445 {
7446 if(pMac->lim.gpSession[i].valid == TRUE )
7447 {
7448 if((pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) &&
7449 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_ROLE))
7450 {
7451 return pMac->lim.gpSession[i].currentOperChannel;
7452 }
7453 }
7454 }
7455 return 0;
7456}
7457
7458void limProcessAddStaRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ)
7459{
7460
7461 tpPESession psessionEntry;
7462// tANI_U8 sessionId;
7463 tpAddStaParams pAddStaParams;
7464
7465 pAddStaParams = (tpAddStaParams)limMsgQ->bodyptr;
7466
7467 if((psessionEntry = peFindSessionBySessionId(pMac,pAddStaParams->sessionId))==NULL)
7468 {
7469 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07007470 palFreeMemory(pMac, pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07007471 return;
7472 }
7473 if (psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
7474 (void) limIbssAddStaRsp(pMac, limMsgQ->bodyptr,psessionEntry);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007475#ifdef FEATURE_WLAN_TDLS
7476 else if(pMac->lim.gLimAddStaTdls)
7477 {
7478 limProcessTdlsAddStaRsp(pMac, limMsgQ->bodyptr, psessionEntry) ;
7479 pMac->lim.gLimAddStaTdls = FALSE ;
7480 }
7481#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007482 else
7483 limProcessMlmAddStaRsp(pMac, limMsgQ,psessionEntry);
7484
7485}
7486
7487
7488void limUpdateBeacon(tpAniSirGlobal pMac)
7489{
7490 tANI_U8 i;
7491
7492 for(i =0;i < pMac->lim.maxBssId;i++)
7493 {
7494 if(pMac->lim.gpSession[i].valid == TRUE )
7495 {
7496 if( ( (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) ||
7497 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_IN_IBSS_ROLE) )
7498 && (eLIM_SME_NORMAL_STATE == pMac->lim.gpSession[i].limSmeState)
7499 )
7500 {
7501 schSetFixedBeaconFields(pMac,&pMac->lim.gpSession[i]);
7502 limSendBeaconInd(pMac, &pMac->lim.gpSession[i]);
7503 }
7504 else
7505 {
7506 if( (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)||
7507 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE))
7508 {
7509
7510 if(pMac->lim.gpSession[i].statypeForBss == STA_ENTRY_SELF)
7511 {
7512 schSetFixedBeaconFields(pMac,&pMac->lim.gpSession[i]);
7513 }
7514 }
7515 }
7516 }
7517 }
7518}
7519
7520void limHandleHeartBeatFailureTimeout(tpAniSirGlobal pMac)
7521{
7522 tANI_U8 i;
7523 tpPESession psessionEntry;
7524 /* Probe response is not received after HB failure. This is handled by LMM sub module. */
7525 for(i =0; i < pMac->lim.maxBssId; i++)
7526 {
7527 if(pMac->lim.gpSession[i].valid == TRUE)
7528 {
7529 psessionEntry = &pMac->lim.gpSession[i];
7530 if(psessionEntry->LimHBFailureStatus == eANI_BOOLEAN_TRUE)
7531 {
7532 limLog(pMac, LOGE, FL("Probe_hb_failure: SME %d, MLME %d, HB-Count %d\n"),psessionEntry->limSmeState,
7533 psessionEntry->limMlmState, psessionEntry->LimRxedBeaconCntDuringHB);
7534 if (psessionEntry->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)
7535 {
7536 if (!LIM_IS_CONNECTION_ACTIVE(psessionEntry))
7537 {
7538 limLog(pMac, LOGE, FL("Probe_hb_failure: for session:%d \n" ),psessionEntry->peSessionId);
7539 /* AP did not respond to Probe Request. Tear down link with it.*/
7540 limTearDownLinkWithAp(pMac,
7541 psessionEntry->peSessionId,
7542 eSIR_BEACON_MISSED);
7543 pMac->lim.gLimProbeFailureAfterHBfailedCnt++ ;
7544 }
7545 else // restart heartbeat timer
7546 {
7547 limReactivateHeartBeatTimer(pMac, psessionEntry);
7548 }
7549 }
7550 else
7551 {
7552 limLog(pMac, LOGE, FL("Unexpected wt-probe-timeout in state \n"));
7553 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
7554 limReactivateHeartBeatTimer(pMac, psessionEntry);
7555 }
7556
7557 }
7558 }
7559 }
7560 /* Deactivate Timer ProbeAfterHB Timer -> As its a oneshot timer, need not deactivate the timer */
7561 // tx_timer_deactivate(&pMac->lim.limTimers.gLimProbeAfterHBTimer);
7562}
7563
7564
7565/*
7566* This function assumes there will not be more than one IBSS session active at any time.
7567*/
7568tpPESession limIsIBSSSessionActive(tpAniSirGlobal pMac)
7569{
7570 tANI_U8 i;
7571
7572 for(i =0;i < pMac->lim.maxBssId;i++)
7573 {
7574 if( (pMac->lim.gpSession[i].valid) &&
7575 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_IN_IBSS_ROLE))
7576 return (&pMac->lim.gpSession[i]);
7577 }
7578
7579 return NULL;
7580}
7581
7582tpPESession limIsApSessionActive(tpAniSirGlobal pMac)
7583{
7584 tANI_U8 i;
7585
7586 for(i =0;i < pMac->lim.maxBssId;i++)
7587 {
7588 if( (pMac->lim.gpSession[i].valid) &&
7589 ( (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) ||
7590 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)))
7591 return (&pMac->lim.gpSession[i]);
7592 }
7593
7594 return NULL;
7595}
7596
7597/**---------------------------------------------------------
7598\fn limHandleDeferMsgError
7599\brief handles error scenario, when the msg can not be deferred.
7600\param pMac
7601\param pLimMsg LIM msg, which could not be deferred.
7602\return void
7603-----------------------------------------------------------*/
7604
7605void limHandleDeferMsgError(tpAniSirGlobal pMac, tpSirMsgQ pLimMsg)
7606{
7607 if(SIR_BB_XPORT_MGMT_MSG == pLimMsg->type)
7608 {
7609 vos_pkt_return_packet((vos_pkt_t*)pLimMsg->bodyptr);
7610 }
7611 else if(pLimMsg->bodyptr != NULL)
7612 palFreeMemory( pMac->hHdd, (tANI_U8 *) pLimMsg->bodyptr);
7613
7614}
7615
7616
7617#ifdef FEATURE_WLAN_DIAG_SUPPORT
7618/**---------------------------------------------------------
7619\fn limDiagEventReport
7620\brief This function reports Diag event
7621\param pMac
7622\param eventType
7623\param bssid
7624\param status
7625\param reasonCode
7626\return void
7627-----------------------------------------------------------*/
7628void limDiagEventReport(tpAniSirGlobal pMac, tANI_U16 eventType, tpPESession pSessionEntry, tANI_U16 status, tANI_U16 reasonCode)
7629{
7630 tSirMacAddr nullBssid = { 0, 0, 0, 0, 0, 0 };
7631 WLAN_VOS_DIAG_EVENT_DEF(peEvent, vos_event_wlan_pe_payload_type);
7632
7633 palZeroMemory(pMac->hHdd, &peEvent, sizeof(vos_event_wlan_pe_payload_type));
7634
7635 if (NULL == pSessionEntry)
7636 {
7637 palCopyMemory(pMac->hHdd, peEvent.bssid, nullBssid, sizeof(tSirMacAddr));
7638 peEvent.sme_state = (tANI_U16)pMac->lim.gLimSmeState;
7639 peEvent.mlm_state = (tANI_U16)pMac->lim.gLimMlmState;
7640
7641 }
7642 else
7643 {
7644 palCopyMemory(pMac->hHdd, peEvent.bssid, pSessionEntry->bssId, sizeof(tSirMacAddr));
7645 peEvent.sme_state = (tANI_U16)pSessionEntry->limSmeState;
7646 peEvent.mlm_state = (tANI_U16)pSessionEntry->limMlmState;
7647 }
7648 peEvent.event_type = eventType;
7649 peEvent.status = status;
7650 peEvent.reason_code = reasonCode;
7651
7652 WLAN_VOS_DIAG_EVENT_REPORT(&peEvent, EVENT_WLAN_PE);
7653 return;
7654}
7655
7656#endif /* FEATURE_WLAN_DIAG_SUPPORT */
7657
7658void limProcessAddStaSelfRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ)
7659{
7660
7661 tpAddStaSelfParams pAddStaSelfParams;
7662 tSirMsgQ mmhMsg;
7663 tpSirSmeAddStaSelfRsp pRsp;
7664
7665
7666 pAddStaSelfParams = (tpAddStaSelfParams)limMsgQ->bodyptr;
7667
7668 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pRsp, sizeof(tSirSmeAddStaSelfRsp)))
7669 {
7670 /// Buffer not available. Log error
7671 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for Add Sta self RSP\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07007672 palFreeMemory( pMac->hHdd, (tANI_U8 *)pAddStaSelfParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07007673 return;
7674 }
7675
7676 palZeroMemory(pMac, (tANI_U8*)pRsp, sizeof(tSirSmeAddStaSelfRsp));
7677
7678 pRsp->mesgType = eWNI_SME_ADD_STA_SELF_RSP;
7679 pRsp->mesgLen = (tANI_U16) sizeof(tSirSmeAddStaSelfRsp);
7680 pRsp->status = pAddStaSelfParams->status;
7681
7682 palCopyMemory( pMac->hHdd, pRsp->selfMacAddr, pAddStaSelfParams->selfMacAddr, sizeof(tSirMacAddr) );
7683
7684 palFreeMemory( pMac->hHdd, (tANI_U8 *)pAddStaSelfParams);
7685
7686 mmhMsg.type = eWNI_SME_ADD_STA_SELF_RSP;
7687 mmhMsg.bodyptr = pRsp;
7688 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007689 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
7691
7692}
7693
7694void limProcessDelStaSelfRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ)
7695{
7696
7697 tpDelStaSelfParams pDelStaSelfParams;
7698 tSirMsgQ mmhMsg;
7699 tpSirSmeDelStaSelfRsp pRsp;
7700
7701
7702 pDelStaSelfParams = (tpDelStaSelfParams)limMsgQ->bodyptr;
7703
7704 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pRsp, sizeof(tSirSmeDelStaSelfRsp)))
7705 {
7706 /// Buffer not available. Log error
7707 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for Add Sta self RSP\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07007708 palFreeMemory( pMac->hHdd, (tANI_U8 *)pDelStaSelfParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 return;
7710 }
7711
7712 palZeroMemory(pMac, (tANI_U8*)pRsp, sizeof(tSirSmeDelStaSelfRsp));
7713
7714 pRsp->mesgType = eWNI_SME_DEL_STA_SELF_RSP;
7715 pRsp->mesgLen = (tANI_U16) sizeof(tSirSmeDelStaSelfRsp);
7716 pRsp->status = pDelStaSelfParams->status;
7717
7718 palCopyMemory( pMac->hHdd, pRsp->selfMacAddr, pDelStaSelfParams->selfMacAddr, sizeof(tSirMacAddr) );
7719
7720 palFreeMemory( pMac->hHdd, (tANI_U8 *)pDelStaSelfParams);
7721
7722 mmhMsg.type = eWNI_SME_DEL_STA_SELF_RSP;
7723 mmhMsg.bodyptr = pRsp;
7724 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007725 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07007726 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
7727
7728}
7729
7730/***************************************************************
7731* tANI_U8 limUnmapChannel(tANI_U8 mapChannel)
7732* To unmap the channel to reverse the effect of mapping
7733* a band channel in hal .Mapping was done hal to overcome the
7734* limitation of the rxbd which use only 4 bit for channel number.
7735*****************************************************************/
7736tANI_U8 limUnmapChannel(tANI_U8 mapChannel)
7737{
7738 if( mapChannel > 0 && mapChannel < 25 )
7739 return abChannel[mapChannel -1];
7740 else
7741 return 0;
7742}
7743
7744
7745v_U8_t* limGetIEPtr(tpAniSirGlobal pMac, v_U8_t *pIes, int length, v_U8_t eid,eSizeOfLenField size_of_len_field)
7746{
7747 int left = length;
7748 v_U8_t *ptr = pIes;
7749 v_U8_t elem_id;
7750 v_U16_t elem_len;
7751
7752 while(left >= (size_of_len_field+1))
7753 {
7754 elem_id = ptr[0];
7755 if (size_of_len_field == TWO_BYTE)
7756 {
7757 elem_len = ((v_U16_t) ptr[1]) | (ptr[2]<<8);
7758 }
7759 else
7760 {
7761 elem_len = ptr[1];
7762 }
7763
7764
7765 left -= (size_of_len_field+1);
7766 if(elem_len > left)
7767 {
7768 limLog(pMac, LOGE,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07007769 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07007770 eid,elem_len,left);
7771 return NULL;
7772 }
7773 if (elem_id == eid)
7774 {
7775 return ptr;
7776 }
7777
7778 left -= elem_len;
7779 ptr += (elem_len + (size_of_len_field+1));
7780 }
7781 return NULL;
7782}
7783
7784/* return NULL if oui is not found in ie
7785 return !NULL pointer to vendor IE (starting from 0xDD) if oui is found
7786 */
7787v_U8_t* limGetVendorIEOuiPtr(tpAniSirGlobal pMac, tANI_U8 *oui, tANI_U8 oui_size, tANI_U8 *ie, tANI_U16 ie_len)
7788{
7789 int left = ie_len;
7790 v_U8_t *ptr = ie;
7791 v_U8_t elem_id, elem_len;
7792
7793 while(left >= 2)
7794 {
7795 elem_id = ptr[0];
7796 elem_len = ptr[1];
7797 left -= 2;
7798 if(elem_len > left)
7799 {
7800 limLog( pMac, LOGE,
7801 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****\n"),
7802 elem_id,elem_len,left);
7803 return NULL;
7804 }
7805 if (SIR_MAC_EID_VENDOR == elem_id)
7806 {
7807 if(memcmp(&ptr[2], oui, oui_size)==0)
7808 return ptr;
7809 }
7810
7811 left -= elem_len;
7812 ptr += (elem_len + 2);
7813 }
7814 return NULL;
7815}
7816
7817#ifdef WLAN_FEATURE_P2P
7818//Returns length of P2P stream and Pointer ie passed to this function is filled with noa stream
7819
7820v_U8_t limBuildP2pIe(tpAniSirGlobal pMac, tANI_U8 *ie, tANI_U8 *data, tANI_U8 ie_len)
7821{
7822 int length = 0;
7823 tANI_U8 *ptr = ie;
7824
7825 ptr[length++] = SIR_MAC_EID_VENDOR;
7826 ptr[length++] = ie_len + SIR_MAC_P2P_OUI_SIZE;
7827 palCopyMemory( pMac->hHdd, &ptr[length], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
7828 palCopyMemory( pMac->hHdd, &ptr[length + SIR_MAC_P2P_OUI_SIZE], data, ie_len);
7829 return (ie_len + SIR_P2P_IE_HEADER_LEN);
7830}
7831
7832//Returns length of NoA stream and Pointer pNoaStream passed to this function is filled with noa stream
7833
7834v_U8_t limGetNoaAttrStreamInMultP2pIes(tpAniSirGlobal pMac,v_U8_t* noaStream,v_U8_t noaLen,v_U8_t overFlowLen)
7835{
7836 v_U8_t overFlowP2pStream[SIR_MAX_NOA_ATTR_LEN];
7837 palCopyMemory( pMac->hHdd, overFlowP2pStream, noaStream + noaLen - overFlowLen, overFlowLen);
7838 noaStream[noaLen - overFlowLen] = SIR_MAC_EID_VENDOR;
7839 noaStream[noaLen - overFlowLen+1] = overFlowLen + SIR_MAC_P2P_OUI_SIZE;
7840 palCopyMemory( pMac->hHdd, noaStream+ noaLen - overFlowLen+2,SIR_MAC_P2P_OUI,SIR_MAC_P2P_OUI_SIZE);
7841
7842 palCopyMemory( pMac->hHdd, noaStream+ noaLen - overFlowLen+2+SIR_MAC_P2P_OUI_SIZE,overFlowP2pStream,overFlowLen);
7843 return (noaLen + SIR_P2P_IE_HEADER_LEN);
7844
7845}
7846
7847//Returns length of NoA stream and Pointer pNoaStream passed to this function is filled with noa stream
7848v_U8_t limGetNoaAttrStream(tpAniSirGlobal pMac, v_U8_t*pNoaStream,tpPESession psessionEntry)
7849{
7850 v_U8_t len=0;
7851
7852 v_U8_t *pBody = pNoaStream;
7853
7854
7855 if ( (psessionEntry != NULL) && (psessionEntry->valid) &&
7856 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
7857 {
7858 if ((!(psessionEntry->p2pGoPsUpdate.uNoa1Duration)) && (!(psessionEntry->p2pGoPsUpdate.uNoa2Duration))
7859 && (!psessionEntry->p2pGoPsUpdate.oppPsFlag)
7860 )
7861 return 0; //No NoA Descriptor then return 0
7862
7863
7864 pBody[0] = SIR_P2P_NOA_ATTR;
7865
7866 pBody[3] = psessionEntry->p2pGoPsUpdate.index;
7867 pBody[4] = psessionEntry->p2pGoPsUpdate.ctWin | (psessionEntry->p2pGoPsUpdate.oppPsFlag<<7);
7868 len = 5;
7869 pBody += len;
7870
7871
7872 if (psessionEntry->p2pGoPsUpdate.uNoa1Duration)
7873 {
7874 *pBody = psessionEntry->p2pGoPsUpdate.uNoa1IntervalCnt;
7875 pBody += 1;
7876 len +=1;
7877
7878 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa1Duration);
7879 pBody += sizeof(tANI_U32);
7880 len +=4;
7881
7882 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa1Interval);
7883 pBody += sizeof(tANI_U32);
7884 len +=4;
7885
7886 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa1StartTime);
7887 pBody += sizeof(tANI_U32);
7888 len +=4;
7889
7890 }
7891
7892 if (psessionEntry->p2pGoPsUpdate.uNoa2Duration)
7893 {
7894 *pBody = psessionEntry->p2pGoPsUpdate.uNoa2IntervalCnt;
7895 pBody += 1;
7896 len +=1;
7897
7898 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa2Duration);
7899 pBody += sizeof(tANI_U32);
7900 len +=4;
7901
7902 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa2Interval);
7903 pBody += sizeof(tANI_U32);
7904 len +=4;
7905
7906 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa2StartTime);
7907 pBody += sizeof(tANI_U32);
7908 len +=4;
7909
7910 }
7911
7912
7913 pBody = pNoaStream + 1;
7914 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(len-3);/*one byte for Attr and 2 bytes for length*/
7915
7916 return (len);
7917
7918 }
7919 return 0;
7920
7921}
Jeff Johnsone7245742012-09-05 17:12:55 -07007922
7923void peSetResumeChannel(tpAniSirGlobal pMac, tANI_U16 channel, ePhyChanBondState phyCbState)
Jeff Johnson295189b2012-06-20 16:38:30 -07007924{
7925
7926 pMac->lim.gResumeChannel = channel;
Jeff Johnsone7245742012-09-05 17:12:55 -07007927 pMac->lim.gResumePhyCbState = phyCbState;
Jeff Johnson295189b2012-06-20 16:38:30 -07007928}
Jeff Johnsone7245742012-09-05 17:12:55 -07007929
Jeff Johnson295189b2012-06-20 16:38:30 -07007930/*--------------------------------------------------------------------------
7931
7932 \brief peGetResumeChannel() - Returns the channel number for scanning, from a valid session.
7933
Jeff Johnsone7245742012-09-05 17:12:55 -07007934 This function returns the channel to resume to during link resume. channel id of 0 means HAL will
7935 resume to previous channel before link suspend
Jeff Johnson295189b2012-06-20 16:38:30 -07007936
7937 \param pMac - pointer to global adapter context
7938 \return - channel to scan from valid session else zero.
7939
7940 \sa
7941
7942 --------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07007943void peGetResumeChannel(tpAniSirGlobal pMac, tANI_U8* resumeChannel, ePhyChanBondState* resumePhyCbState)
Jeff Johnson295189b2012-06-20 16:38:30 -07007944{
7945
7946 //Rationale - this could be the suspend/resume for assoc and it is essential that
7947 //the new BSS is active for some time. Other BSS was anyway suspended.
7948 //TODO: Comeup with a better alternative. Sending NULL with PM=0 on other BSS means
7949 //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 -07007950 //and hence should be ok. Need to discuss this further
7951 if( !limIsInMCC(pMac) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007952 {
7953 //Get current active session channel
Jeff Johnsone7245742012-09-05 17:12:55 -07007954 peGetActiveSessionChannel(pMac, resumeChannel, resumePhyCbState);
Jeff Johnson295189b2012-06-20 16:38:30 -07007955 }
7956 else
7957 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007958 *resumeChannel = pMac->lim.gResumeChannel;
7959 *resumePhyCbState = pMac->lim.gResumePhyCbState;
Jeff Johnson295189b2012-06-20 16:38:30 -07007960 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007961 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007962}
7963
Jeff Johnsone7245742012-09-05 17:12:55 -07007964
Jeff Johnson295189b2012-06-20 16:38:30 -07007965#endif
7966
7967tANI_BOOLEAN limIsconnectedOnDFSChannel(tANI_U8 currentChannel)
7968{
7969 if(NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(currentChannel))
7970 {
7971 return eANI_BOOLEAN_TRUE;
7972 }
7973 else
7974 {
7975 return eANI_BOOLEAN_FALSE;
7976 }
7977}
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07007978
Mohit Khanna4a70d262012-09-11 16:30:12 -07007979#ifdef WLAN_FEATURE_11AC
7980tANI_BOOLEAN limCheckVHTOpModeChange( tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 chanWidth, tANI_U8 staId)
7981{
7982 tUpdateVHTOpMode tempParam;
7983
7984 tempParam.opMode = chanWidth;
7985 tempParam.staId = staId;
7986
7987 limSendModeUpdate( pMac, &tempParam, psessionEntry );
7988
7989 return eANI_BOOLEAN_TRUE;
7990}
Madan Mohan Koyyalamudi6db7ad12012-10-29 16:14:41 -07007991#endif
7992
7993tANI_U8 limGetShortSlotFromPhyMode(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U32 phyMode)
7994{
7995 tANI_U8 val=0;
7996
7997 if (phyMode == WNI_CFG_PHY_MODE_11A)
7998 {
7999 // 11a mode always uses short slot
8000 // Check this since some APs in 11a mode broadcast long slot in their beacons. As per standard, always use what PHY mandates.
8001 val = true;
8002 }
8003 else if (phyMode == WNI_CFG_PHY_MODE_11G)
8004 {
8005 if ((psessionEntry->pePersona == VOS_STA_SAP_MODE) ||
8006 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
8007 {
8008 val = true;
8009 }
8010
8011 // Program Polaris based on AP capability
8012
8013 if (psessionEntry->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE)
8014 // Joining BSS.
8015 val = SIR_MAC_GET_SHORT_SLOT_TIME( psessionEntry->limCurrentBssCaps);
8016 else if (psessionEntry->limMlmState == eLIM_MLM_WT_REASSOC_RSP_STATE)
8017 // Reassociating with AP.
8018 val = SIR_MAC_GET_SHORT_SLOT_TIME( psessionEntry->limReassocBssCaps);
8019 }
8020 else // if (phyMode == WNI_CFG_PHY_MODE_11B) - use this if another phymode is added later ON
8021 {
8022 // Will reach here in 11b case
8023 val = false;
8024 }
8025 limLog(pMac, LOG1, FL("phyMode = %u shortslotsupported = %u\n"), phyMode, val);
8026 return val;
8027}