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