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