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