blob: 8499365c62ac7a9b7182e7a3b2db0dc29bee992c [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;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002754#ifdef WLAN_FEATURE_11AC
2755 tDot11fIEWiderBWChanSwitchAnn *pWiderChnlSwitch;
2756#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002757
Jeff Johnsone7245742012-09-05 17:12:55 -07002758 beaconPeriod = psessionEntry->beaconParams.beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002759
2760 /* STA either received proprietary channel switch IE or 802.11h
2761 * standard channel switch IE.
2762 */
2763 if (pBeacon->propIEinfo.propChannelSwitchPresent)
2764 {
2765 pPropChnlSwitch = &(pBeacon->propIEinfo.channelSwitch);
2766
2767 /* Add logic to determine which change this is: */
2768 /* primary, secondary, both. For now assume both. */
Jeff Johnsone7245742012-09-05 17:12:55 -07002769 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2770 psessionEntry->gLimChannelSwitch.primaryChannel = pPropChnlSwitch->primaryChannel;
2771 psessionEntry->gLimChannelSwitch.secondarySubBand = (ePhyChanBondState)pPropChnlSwitch->subBand;
2772 psessionEntry->gLimChannelSwitch.switchCount = pPropChnlSwitch->channelSwitchCount;
2773 psessionEntry->gLimChannelSwitch.switchTimeoutValue =
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 SYS_MS_TO_TICKS(beaconPeriod)* (pPropChnlSwitch->channelSwitchCount);
Jeff Johnsone7245742012-09-05 17:12:55 -07002775 psessionEntry->gLimChannelSwitch.switchMode = pPropChnlSwitch->mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 }
2777 else
2778 {
2779 pChnlSwitch = &(pBeacon->channelSwitchIE);
Jeff Johnsone7245742012-09-05 17:12:55 -07002780 psessionEntry->gLimChannelSwitch.primaryChannel = pChnlSwitch->newChannel;
2781 psessionEntry->gLimChannelSwitch.switchCount = pChnlSwitch->switchCount;
2782 psessionEntry->gLimChannelSwitch.switchTimeoutValue =
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 SYS_MS_TO_TICKS(beaconPeriod)* (pChnlSwitch->switchCount);
Jeff Johnsone7245742012-09-05 17:12:55 -07002784 psessionEntry->gLimChannelSwitch.switchMode = pChnlSwitch->switchMode;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002785#ifdef WLAN_FEATURE_11AC
2786 pWiderChnlSwitch = &(pBeacon->WiderBWChanSwitchAnn);
2787 if(pBeacon->WiderBWChanSwitchAnnPresent)
2788 {
2789 psessionEntry->gLimWiderBWChannelSwitch.newChanWidth = pWiderChnlSwitch->newChanWidth;
2790 psessionEntry->gLimWiderBWChannelSwitch.newCenterChanFreq0 = pWiderChnlSwitch->newCenterChanFreq0;
2791 psessionEntry->gLimWiderBWChannelSwitch.newCenterChanFreq1 = pWiderChnlSwitch->newCenterChanFreq1;
2792 }
2793#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002794
2795 /* Only primary channel switch element is present */
Jeff Johnsone7245742012-09-05 17:12:55 -07002796 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2797 psessionEntry->gLimChannelSwitch.secondarySubBand = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07002798
2799 /* Do not bother to look and operate on extended channel switch element
2800 * if our own channel-bonding state is not enabled
2801 */
Jeff Johnsone7245742012-09-05 17:12:55 -07002802 if (psessionEntry->htSupportedChannelWidthSet)
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 {
2804 if (pBeacon->extChannelSwitchPresent)
2805 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002806 if ((pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_LOW_PRIMARY) ||
2807 (pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY))
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002809 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2810 psessionEntry->gLimChannelSwitch.secondarySubBand = pBeacon->extChannelSwitchIE.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 }
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002812#ifdef WLAN_FEATURE_11AC
2813 if(psessionEntry->vhtCapability && pBeacon->WiderBWChanSwitchAnnPresent)
2814 {
2815 if (pWiderChnlSwitch->newChanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ)
2816 {
2817 if(pBeacon->extChannelSwitchPresent)
2818 {
2819 if ((pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_LOW_PRIMARY) ||
2820 (pBeacon->extChannelSwitchIE.secondaryChannelOffset == PHY_DOUBLE_CHANNEL_HIGH_PRIMARY))
2821 {
2822 psessionEntry->gLimChannelSwitch.state = eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2823 psessionEntry->gLimChannelSwitch.secondarySubBand = limGet11ACPhyCBState(pMac,
2824 psessionEntry->gLimChannelSwitch.primaryChannel,
2825 pBeacon->extChannelSwitchIE.secondaryChannelOffset,
2826 pWiderChnlSwitch->newCenterChanFreq0,
2827 psessionEntry);
2828 }
2829 }
2830 }
2831 }
2832#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002833 }
2834 }
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002835 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 if (eSIR_SUCCESS != limStartChannelSwitch(pMac, psessionEntry))
2837 {
2838 PELOGW(limLog(pMac, LOGW, FL("Could not start Channel Switch\n"));)
2839 }
2840
2841 limLog(pMac, LOGW,
Jeff Johnsone7245742012-09-05 17:12:55 -07002842 FL("session %d primary chl %d, subband %d, count %d (%d ticks) \n"),
2843 psessionEntry->peSessionId,
2844 psessionEntry->gLimChannelSwitch.primaryChannel,
2845 psessionEntry->gLimChannelSwitch.secondarySubBand,
2846 psessionEntry->gLimChannelSwitch.switchCount,
2847 psessionEntry->gLimChannelSwitch.switchTimeoutValue);
Jeff Johnson295189b2012-06-20 16:38:30 -07002848 return;
2849}
2850
2851/**
2852 * limCancelDot11hChannelSwitch
2853 *
2854 *FUNCTION:
2855 * This function is called when STA does not send updated channel-swith IE
2856 * after indicating channel-switch start. This will cancel the channel-swith
2857 * timer which is already running.
2858 *
2859 *LOGIC:
2860 *
2861 *ASSUMPTIONS:
2862 *
2863 *NOTE:
2864 *
2865 * @param pMac - Pointer to Global MAC structure
2866 *
2867 * @return None
2868 */
2869void limCancelDot11hChannelSwitch(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
2875 PELOGW(limLog(pMac, LOGW, FL("Received a beacon without channel switch IE\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07002876 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_CHANNEL_SWITCH_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002877
2878 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimChannelSwitchTimer) != eSIR_SUCCESS)
2879 {
2880 PELOGE(limLog(pMac, LOGE, FL("tx_timer_deactivate failed!\n"));)
2881 }
2882
2883 /* We need to restore pre-channelSwitch state on the STA */
2884 if (limRestorePreChannelSwitchState(pMac, psessionEntry) != eSIR_SUCCESS)
2885 {
2886 PELOGE(limLog(pMac, LOGE, FL("LIM: Could not restore pre-channelSwitch (11h) state, reseting the system\n"));)
2887
2888 }
2889#endif
2890}
2891
2892/**----------------------------------------------
2893\fn limCancelDot11hQuiet
2894\brief Cancel the quieting on Station if latest
2895 beacon doesn't contain quiet IE in it.
2896
2897\param pMac
2898\return NONE
2899-----------------------------------------------*/
2900void limCancelDot11hQuiet(tpAniSirGlobal pMac, tpPESession psessionEntry)
2901{
2902#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
2903 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
2904 return;
2905
Jeff Johnsone7245742012-09-05 17:12:55 -07002906 if (psessionEntry->gLimSpecMgmt.quietState == eLIM_QUIET_BEGIN)
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002908 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_QUIET_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002909 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietTimer) != TX_SUCCESS)
2910 {
2911 PELOGE(limLog(pMac, LOGE, FL("tx_timer_deactivate failed\n"));)
2912 }
2913 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002914 else if (psessionEntry->gLimSpecMgmt.quietState == eLIM_QUIET_RUNNING)
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002916 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_QUIET_BSS_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 if (tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietBssTimer) != TX_SUCCESS)
2918 {
2919 PELOGE(limLog(pMac, LOGE, FL("tx_timer_deactivate failed\n"));)
2920 }
2921 /**
2922 * If the channel switch is already running in silent mode, dont resume the
2923 * transmission. Channel switch timer when timeout, transmission will be resumed.
2924 */
Jeff Johnsone7245742012-09-05 17:12:55 -07002925 if(!((psessionEntry->gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING) &&
2926 (psessionEntry->gLimChannelSwitch.switchMode == eSIR_CHANSW_MODE_SILENT)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002927 {
2928 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
Jeff Johnsone7245742012-09-05 17:12:55 -07002929 limRestorePreQuietState(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07002930 }
2931 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002932 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002933#endif
2934}
2935
2936/**
2937 * limProcessQuietTimeout
2938 *
2939 * FUNCTION:
2940 * This function is active only on the STA.
2941 * Handles SIR_LIM_QUIET_TIMEOUT
2942 *
2943 * LOGIC:
2944 * This timeout can occur under only one circumstance:
2945 *
2946 * 1) When gLimQuietState = eLIM_QUIET_BEGIN
2947 * This indicates that the timeout "interval" has
2948 * expired. This is a trigger for the STA to now
2949 * shut-off Tx/Rx for the specified gLimQuietDuration
2950 * -> The TIMER object gLimQuietBssTimer is
2951 * activated
2952 * -> With timeout = gLimQuietDuration
2953 * -> gLimQuietState is set to eLIM_QUIET_RUNNING
2954 *
2955 * ASSUMPTIONS:
2956 * Using two TIMER objects -
2957 * gLimQuietTimer & gLimQuietBssTimer
2958 *
2959 * NOTE:
2960 *
2961 * @param pMac - Pointer to Global MAC structure
2962 *
2963 * @return None
2964 */
2965void limProcessQuietTimeout(tpAniSirGlobal pMac)
2966{
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 //fetch the sessionEntry based on the sessionId
2968 //priority - MEDIUM
Jeff Johnsone7245742012-09-05 17:12:55 -07002969 tpPESession psessionEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07002970
Jeff Johnsone7245742012-09-05 17:12:55 -07002971 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimQuietTimer.sessionId))== NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002973 limLog(pMac, LOGE,FL("Session Does not exist for given sessionID\n"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 return;
2975 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002976
Jeff Johnsone7245742012-09-05 17:12:55 -07002977 PELOG1(limLog(pMac, LOG1, FL("quietState = %d\n"), psessionEntry->gLimSpecMgmt.quietState);)
2978 switch( psessionEntry->gLimSpecMgmt.quietState )
Jeff Johnson295189b2012-06-20 16:38:30 -07002979 {
2980 case eLIM_QUIET_BEGIN:
2981 // Time to Stop data traffic for quietDuration
Jeff Johnsone7245742012-09-05 17:12:55 -07002982 //limDeactivateAndChangeTimer(pMac, eLIM_QUIET_BSS_TIMER);
2983 if (TX_SUCCESS !=
2984 tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietBssTimer))
2985 {
2986 limLog( pMac, LOGE,
2987 FL("Unable to de-activate gLimQuietBssTimer! Will attempt to activate anyway...\n"));
2988 }
2989
2990 // gLimQuietDuration appears to be in units of ticks
2991 // Use it as is
2992 if (TX_SUCCESS !=
2993 tx_timer_change( &pMac->lim.limTimers.gLimQuietBssTimer,
2994 psessionEntry->gLimSpecMgmt.quietDuration,
2995 0))
2996 {
2997 limLog( pMac, LOGE,
2998 FL("Unable to change gLimQuietBssTimer! Will still attempt to activate anyway...\n"));
2999 }
3000 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_QUIET_BSS_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07003001#ifdef GEN6_TODO
3002 /* revisit this piece of code to assign the appropriate sessionId below
3003 * priority - HIGH
3004 */
3005 pMac->lim.limTimers.gLimQuietBssTimer.sessionId = sessionId;
3006#endif
3007 if( TX_SUCCESS !=
3008 tx_timer_activate( &pMac->lim.limTimers.gLimQuietBssTimer ))
3009 {
3010 limLog( pMac, LOGW,
3011 FL("Unable to activate gLimQuietBssTimer! The STA will be unable to honor Quiet BSS...\n"));
3012 }
3013 else
3014 {
3015 // Transition to eLIM_QUIET_RUNNING
Jeff Johnsone7245742012-09-05 17:12:55 -07003016 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_RUNNING;
Jeff Johnson295189b2012-06-20 16:38:30 -07003017
3018 /* If we have sta bk scan triggered and trigger bk scan actually started successfully, */
3019 /* print message, otherwise, stop data traffic and stay quiet */
3020 if( pMac->lim.gLimTriggerBackgroundScanDuringQuietBss &&
3021 (eSIR_TRUE == (glimTriggerBackgroundScanDuringQuietBss_Status = limTriggerBackgroundScanDuringQuietBss( pMac ))) )
3022 {
3023 limLog( pMac, LOG2,
3024 FL("Attempting to trigger a background scan...\n"));
3025 }
3026 else
3027 {
3028 // Shut-off Tx/Rx for gLimSpecMgmt.quietDuration
3029 /* freeze the transmission */
3030 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_STOP_TX);
3031
3032 limLog( pMac, LOG2,
3033 FL("Quiet BSS: STA shutting down for %d ticks\n"),
Jeff Johnsone7245742012-09-05 17:12:55 -07003034 psessionEntry->gLimSpecMgmt.quietDuration );
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 }
3036 }
3037 break;
3038
3039 case eLIM_QUIET_RUNNING:
3040 case eLIM_QUIET_INIT:
3041 case eLIM_QUIET_END:
3042 default:
3043 //
3044 // As of now, nothing to be done
3045 //
3046 break;
3047 }
3048}
3049
3050/**
3051 * limProcessQuietBssTimeout
3052 *
3053 * FUNCTION:
3054 * This function is active on the AP and STA.
3055 * Handles SIR_LIM_QUIET_BSS_TIMEOUT
3056 *
3057 * LOGIC:
3058 * On the AP -
3059 * When the SIR_LIM_QUIET_BSS_TIMEOUT is triggered, it is
3060 * an indication for the AP to START sending out the
3061 * Quiet BSS IE.
3062 * If 802.11H is enabled, the Quiet BSS IE is sent as per
3063 * the 11H spec
3064 * If 802.11H is not enabled, the Quiet BSS IE is sent as
3065 * a Proprietary IE. This will be understood by all the
3066 * TITAN STA's
3067 * Transitioning gLimQuietState to eLIM_QUIET_BEGIN will
3068 * initiate the SCH to include the Quiet BSS IE in all
3069 * its subsequent Beacons/PR's.
3070 * The Quiet BSS IE will be included in all the Beacons
3071 * & PR's until the next DTIM period
3072 *
3073 * On the STA -
3074 * When gLimQuietState = eLIM_QUIET_RUNNING
3075 * This indicates that the STA was successfully shut-off
3076 * for the specified gLimQuietDuration. This is a trigger
3077 * for the STA to now resume data traffic.
3078 * -> gLimQuietState is set to eLIM_QUIET_INIT
3079 *
3080 * ASSUMPTIONS:
3081 *
3082 * NOTE:
3083 *
3084 * @param pMac - Pointer to Global MAC structure
3085 *
3086 * @return None
3087 */
3088void limProcessQuietBssTimeout( tpAniSirGlobal pMac )
3089{
Jeff Johnsone7245742012-09-05 17:12:55 -07003090 tpPESession psessionEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07003091
Jeff Johnsone7245742012-09-05 17:12:55 -07003092 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gLimQuietBssTimer.sessionId))== NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 {
3094 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
3095 return;
3096 }
3097
Jeff Johnsone7245742012-09-05 17:12:55 -07003098 PELOG1(limLog(pMac, LOG1, FL("quietState = %d\n"), psessionEntry->gLimSpecMgmt.quietState);)
3099 if (eLIM_AP_ROLE == psessionEntry->limSystemRole)
Jeff Johnson295189b2012-06-20 16:38:30 -07003100 {
3101#ifdef ANI_PRODUCT_TYPE_AP
3102 if (!pMac->sys.gSysEnableLearnMode)
3103 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003104 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_END;
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 return;
3106 }
3107
Jeff Johnsone7245742012-09-05 17:12:55 -07003108 if( eLIM_QUIET_INIT == psessionEntry->gLimSpecMgmt.quietState )
Jeff Johnson295189b2012-06-20 16:38:30 -07003109 {
3110 //QuietCount = 0 is reserved
Jeff Johnsone7245742012-09-05 17:12:55 -07003111 psessionEntry->gLimSpecMgmt.quietCount = 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 // In ms.
Jeff Johnsone7245742012-09-05 17:12:55 -07003113 psessionEntry->gLimSpecMgmt.quietDuration =
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 pMac->lim.gpLimMeasReq->measDuration.shortChannelScanDuration;
3115 // TU is in multiples of 1024 (2^10) us.
Jeff Johnsone7245742012-09-05 17:12:55 -07003116 psessionEntry->gLimSpecMgmt.quietDuration_TU =
3117 SYS_MS_TO_TU(psessionEntry->gLimSpecMgmt.quietDuration);
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 // Transition to eLIM_QUIET_BEGIN
3119 limLog( pMac, LOG2, FL("Quiet BSS state = eLIM_QUIET_BEGIN\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003120 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_BEGIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 }
3122#endif
3123 }
3124 else
3125 {
3126 // eLIM_STA_ROLE
Jeff Johnsone7245742012-09-05 17:12:55 -07003127 switch( psessionEntry->gLimSpecMgmt.quietState )
Jeff Johnson295189b2012-06-20 16:38:30 -07003128 {
3129 case eLIM_QUIET_RUNNING:
3130 // Transition to eLIM_QUIET_INIT
Jeff Johnsone7245742012-09-05 17:12:55 -07003131 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003132
3133 if( !pMac->lim.gLimTriggerBackgroundScanDuringQuietBss || (glimTriggerBackgroundScanDuringQuietBss_Status == eSIR_FALSE) )
3134 {
3135 // Resume data traffic only if channel switch is not running in silent mode.
Jeff Johnsone7245742012-09-05 17:12:55 -07003136 if (!((psessionEntry->gLimSpecMgmt.dot11hChanSwState == eLIM_11H_CHANSW_RUNNING) &&
3137 (psessionEntry->gLimChannelSwitch.switchMode == eSIR_CHANSW_MODE_SILENT)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 {
3139 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
Jeff Johnsone7245742012-09-05 17:12:55 -07003140 limRestorePreQuietState(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003141 }
3142
3143 /* Reset status flag */
3144 if(glimTriggerBackgroundScanDuringQuietBss_Status == eSIR_FALSE)
3145 glimTriggerBackgroundScanDuringQuietBss_Status = eSIR_TRUE;
3146
3147 limLog( pMac, LOG2,
3148 FL("Quiet BSS: Resuming traffic...\n"));
3149 }
3150 else
3151 {
3152 //
3153 // Nothing specific to be done in this case
3154 // A background scan that was triggered during
3155 // SIR_LIM_QUIET_TIMEOUT will complete on its own
3156 //
3157 limLog( pMac, LOG2,
3158 FL("Background scan should be complete now...\n"));
3159 }
3160 break;
3161
3162 case eLIM_QUIET_INIT:
3163 case eLIM_QUIET_BEGIN:
3164 case eLIM_QUIET_END:
3165 PELOG2(limLog(pMac, LOG2, FL("Quiet state not in RUNNING\n"));)
3166 /* If the quiet period has ended, then resume the frame transmission */
3167 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
Jeff Johnsone7245742012-09-05 17:12:55 -07003168 limRestorePreQuietState(pMac, psessionEntry);
3169 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003170 break;
3171
3172 default:
3173 //
3174 // As of now, nothing to be done
3175 //
3176 break;
3177 }
3178 }
3179}
3180#ifdef WLAN_SOFTAP_FEATURE
3181/**
3182 * limProcessWPSOverlapTimeout
3183 *
3184 * FUNCTION: This function call limWPSPBCTimeout() to clean WPS PBC probe request entries
3185 *
3186 * LOGIC:
3187 *
3188 * ASSUMPTIONS:
3189 *
3190 * NOTE:
3191 *
3192 * @param pMac - Pointer to Global MAC structure
3193 *
3194 * @return None
3195 */
3196#if 0
3197void limProcessWPSOverlapTimeout(tpAniSirGlobal pMac)
3198{
3199
3200 tpPESession psessionEntry;
3201 tANI_U32 sessionId;
3202
3203 if (tx_timer_activate(&pMac->lim.limTimers.gLimWPSOverlapTimerObj.gLimWPSOverlapTimer) != TX_SUCCESS)
3204 {
3205 limLog(pMac, LOGP, FL("tx_timer_activate failed\n"));
3206 }
3207
3208 sessionId = pMac->lim.limTimers.gLimWPSOverlapTimerObj.sessionId;
3209
3210 PELOGE(limLog(pMac, LOGE, FL("WPS overlap timeout, sessionId=%d\n"), sessionId);)
3211
3212 if((psessionEntry = peFindSessionBySessionId(pMac, sessionId)) == NULL)
3213 {
3214 PELOGE(limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));)
3215 return;
3216 }
3217
3218 limWPSPBCTimeout(pMac, psessionEntry);
3219}
3220#endif
3221#endif
3222
3223/**
3224 * limUpdateQuietIEFromBeacon
3225 *
3226 * FUNCTION:
3227 *
3228 * LOGIC:
3229 * When the Quiet BSS IE is encountered when parsing for
3230 * Beacons/PR's, this function is called.
3231 * Based on the configuration of the Quiet Interval -
3232 * a) A TIMER (gLimQuietTimer) is started for the
3233 * specified interval
3234 * b) Upon expiry of the TIMER interval, the STA will
3235 * shut-off Tx/Rx
3236 * c) The STA will then start another TIMER (in this
3237 * case, gLimQuietBssTimer TIMER object), with the
3238 * timeout duration set to the value specified in the
3239 * Quiet BSS IE
3240 *
3241 * 1) To setup the Quiet BSS "interval". In this case,
3242 * this TIMER indicates that the STA has to shut-off its
3243 * Tx/Rx AFTER the specified interval
3244 * Set gLimQuietState = eLIM_QUIET_BEGIN
3245 *
3246 * 2) To setup the Quiet BSS "duration". After the said
3247 * specified "interval", the STA has to shut-off Tx/Rx
3248 * for this duration
3249 * Set gLimQuietState = eLIM_QUIET_RUNNING
3250 *
3251 * ASSUMPTIONS:
3252 *
3253 * NOTE:
3254 *
3255 * @param pMac - Pointer to Global MAC structure
3256 * @param pQuietIE - Pointer to tDot11fIEQuiet
3257 *
3258 * @return None
3259 */
3260void limUpdateQuietIEFromBeacon( struct sAniSirGlobal *pMac,
3261 tDot11fIEQuiet *pQuietIE, tpPESession psessionEntry )
3262{
3263#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
3264 tANI_U16 beaconPeriod;
3265 tANI_U32 val;
3266
3267 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3268 return;
3269
3270 PELOG1(limLog(pMac, LOG1, FL("Quiet state = %d, Quiet Count = %d\n"),
Jeff Johnsone7245742012-09-05 17:12:55 -07003271 psessionEntry->gLimSpecMgmt.quietState, pQuietIE->count);)
3272 if (!psessionEntry->lim11hEnable)
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 return;
3274 // The (Titan) AP is requesting this (Titan) STA to
3275 // honor this Quiet IE REQ and shut-off Tx/Rx. If we're
3276 // receiving this a second time around (because the AP
3277 // could be down-counting the Quiet BSS Count), the STA
3278 // will have to reset the timeout interval accordingly
3279 //
3280
3281 if (pQuietIE->count == 0)
3282 {
3283 PELOG1(limLog(pMac, LOG1, FL("Ignoring quiet count == 0->reserved\n"));)
3284 return;
3285 }
3286
3287 if( eSIR_SUCCESS !=
3288 wlan_cfgGetInt( pMac, WNI_CFG_BEACON_INTERVAL, &val ))
3289 beaconPeriod = (tANI_U16) WNI_CFG_BEACON_INTERVAL_APDEF;
3290 else
3291 beaconPeriod = (tANI_U16) val;
3292
3293 /* (qd * 2^10)/1000 */
Jeff Johnsone7245742012-09-05 17:12:55 -07003294 psessionEntry->gLimSpecMgmt.quietDuration_TU = pQuietIE->duration;
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 // The STA needs to shut-off Tx/Rx "for" this interval (in milliSeconds)
3296 /* Need to convert from TU to system TICKS */
Jeff Johnsone7245742012-09-05 17:12:55 -07003297 psessionEntry->gLimSpecMgmt.quietDuration = SYS_MS_TO_TICKS(
3298 SYS_TU_TO_MS(psessionEntry->gLimSpecMgmt.quietDuration_TU));
Jeff Johnson295189b2012-06-20 16:38:30 -07003299
Jeff Johnsone7245742012-09-05 17:12:55 -07003300 if (psessionEntry->gLimSpecMgmt.quietDuration_TU == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003301 {
3302 PELOG1(limLog(pMac, LOG1, FL("Zero duration in quiet IE\n"));)
3303 return;
3304 }
3305
3306 // The STA needs to shut-off Tx/Rx "after" this interval
Jeff Johnsone7245742012-09-05 17:12:55 -07003307 psessionEntry->gLimSpecMgmt.quietTimeoutValue =
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 (beaconPeriod * pQuietIE->count) + pQuietIE->offset;
3309
3310 limLog( pMac, LOG2,
3311 FL( "STA shut-off will begin in %d milliseconds & last for %d ticks\n"),
Jeff Johnsone7245742012-09-05 17:12:55 -07003312 psessionEntry->gLimSpecMgmt.quietTimeoutValue,
3313 psessionEntry->gLimSpecMgmt.quietDuration );
Jeff Johnson295189b2012-06-20 16:38:30 -07003314
3315 /* Disable, Stop background scan if enabled and running */
3316 limDeactivateAndChangeTimer(pMac, eLIM_BACKGROUND_SCAN_TIMER);
3317
3318 /* Stop heart-beat timer to stop heartbeat disassociation */
3319 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
3320
3321 if(pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE ||
3322 pMac->lim.gLimSmeState == eLIM_SME_CHANNEL_SCAN_STATE)
3323 {
3324 PELOGW(limLog(pMac, LOGW, FL("Posting finish scan as we are in scan state\n"));)
3325 /* Stop ongoing scanning if any */
3326 if (GET_LIM_PROCESS_DEFD_MESGS(pMac))
3327 {
3328 //Set the resume channel to Any valid channel (invalid).
3329 //This will instruct HAL to set it to any previous valid channel.
3330 peSetResumeChannel(pMac, 0, 0);
3331 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
3332 }
3333 else
3334 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003335 limRestorePreQuietState(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003336 }
3337 }
3338 else
3339 {
3340 PELOG1(limLog(pMac, LOG1, FL("Not in scan state, start quiet timer\n"));)
3341 /** We are safe to switch channel at this point */
3342 limStartQuietTimer(pMac, psessionEntry->peSessionId);
3343 }
3344
3345 // Transition to eLIM_QUIET_BEGIN
Jeff Johnsone7245742012-09-05 17:12:55 -07003346 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_BEGIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003347#endif
3348}
3349
3350
3351/**----------------------------------------------
3352\fn limStartQuietTimer
3353\brief Starts the quiet timer.
3354
3355\param pMac
3356\return NONE
3357-----------------------------------------------*/
3358void limStartQuietTimer(tpAniSirGlobal pMac, tANI_U8 sessionId)
3359{
3360 tpPESession psessionEntry;
3361 psessionEntry = peFindSessionBySessionId(pMac , sessionId);
3362
3363 if(psessionEntry == NULL) {
3364 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
3365 return;
3366 }
3367
3368#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
3369
3370 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3371 return;
3372 // First, de-activate Timer, if its already active
3373 limCancelDot11hQuiet(pMac, psessionEntry);
3374
Jeff Johnsone7245742012-09-05 17:12:55 -07003375 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, sessionId, eLIM_QUIET_TIMER));
3376 if( TX_SUCCESS != tx_timer_deactivate(&pMac->lim.limTimers.gLimQuietTimer))
3377 {
3378 limLog( pMac, LOGE,
3379 FL( "Unable to deactivate gLimQuietTimer! Will still attempt to re-activate anyway...\n" ));
3380 }
3381
3382 // Set the NEW timeout value, in ticks
3383 if( TX_SUCCESS != tx_timer_change( &pMac->lim.limTimers.gLimQuietTimer,
3384 SYS_MS_TO_TICKS(psessionEntry->gLimSpecMgmt.quietTimeoutValue), 0))
3385 {
3386 limLog( pMac, LOGE,
3387 FL( "Unable to change gLimQuietTimer! Will still attempt to re-activate anyway...\n" ));
3388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003389
3390 pMac->lim.limTimers.gLimQuietTimer.sessionId = sessionId;
3391 if( TX_SUCCESS != tx_timer_activate(&pMac->lim.limTimers.gLimQuietTimer))
3392 {
3393 limLog( pMac, LOGE,
3394 FL("Unable to activate gLimQuietTimer! STA cannot honor Quiet BSS!\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07003395 limRestorePreQuietState(pMac, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003396
Jeff Johnsone7245742012-09-05 17:12:55 -07003397 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 return;
3399 }
3400#endif
3401}
3402
3403#ifdef ANI_PRODUCT_TYPE_AP
3404
3405/**
3406 * computeChannelSwitchCount
3407 *
3408 * FUNCTION:
3409 * Function used by limProcessSmeSwitchChlReq()
3410 * to compute channel switch count.
3411 *
3412 * LOGIC:
3413 * Channel Switch Count is the number of TBTT until AP switches
3414 * to a new channel. The value of Channel Switch Count is computed
3415 * in a way, such that channel switch will always take place after
3416 * a DTIM. By doing so, it is guaranteed that station in power save
3417 * mode can receive the message and switch to new channel accordingly.
3418 * AP can also announce the channel switch several dtims ahead of time.
3419 * by setting the dtimFactor value greater than 1.
3420 *
3421 * ASSUMPTIONS:
3422 *
3423 * NOTE:
3424 *
3425 * @param dtimFactor
3426 * @return channel switch count
3427 */
3428tANI_U32 computeChannelSwitchCount(tpAniSirGlobal pMac, tANI_U32 dtimFactor)
3429{
3430 tANI_U32 dtimPeriod;
3431 tANI_U32 dtimCount;
3432
3433 if (wlan_cfgGetInt(pMac, WNI_CFG_DTIM_PERIOD, &dtimPeriod) != eSIR_SUCCESS)
3434 PELOGE(limLog(pMac, LOGE, FL("wlan_cfgGetInt failed for WNI_CFG_DTIM_PERIOD \n"));)
3435
3436 dtimCount = pMac->pmm.gPmmTim.dtimCount;
3437
3438 if (dtimFactor <= 1)
3439 return (dtimCount + 1);
3440 else
3441 return (((dtimFactor -1)*dtimPeriod) + 1 + dtimCount);
3442}
3443#endif
3444
3445/** ------------------------------------------------------------------------ **/
3446/**
3447 * keep track of the number of ANI peers associated in the BSS
3448 * For the first and last ANI peer, we have to update EDCA params as needed
3449 *
3450 * When the first ANI peer joins the BSS, we notify SCH
3451 * When the last ANI peer leaves the BSS, we notfiy SCH
3452 */
3453void
3454limUtilCountStaAdd(
3455 tpAniSirGlobal pMac,
3456 tpDphHashNode pSta,
3457 tpPESession psessionEntry)
3458{
3459
3460 if ((! pSta) || (! pSta->valid) || (! pSta->aniPeer) || (pSta->fAniCount))
3461 return;
3462
3463 pSta->fAniCount = 1;
3464
3465 if (pMac->lim.gLimNumOfAniSTAs++ != 0)
3466 return;
3467
3468 // get here only if this is the first ANI peer in the BSS
3469 schEdcaProfileUpdate(pMac, psessionEntry);
3470}
3471
3472void
3473limUtilCountStaDel(
3474 tpAniSirGlobal pMac,
3475 tpDphHashNode pSta,
3476 tpPESession psessionEntry)
3477{
3478
3479 if ((pSta == NULL) || (pSta->aniPeer == eHAL_CLEAR) || (! pSta->fAniCount))
3480 return;
3481
3482 /* Only if sta is invalid and the validInDummyState bit is set to 1,
3483 * then go ahead and update the count and profiles. This ensures
3484 * that the "number of ani station" count is properly incremented/decremented.
3485 */
3486 if (pSta->valid == 1)
3487 return;
3488
3489 pSta->fAniCount = 0;
3490
3491 if (pMac->lim.gLimNumOfAniSTAs <= 0)
3492 {
3493 limLog(pMac, LOGE, FL("CountStaDel: ignoring Delete Req when AniPeer count is %d\n"),
3494 pMac->lim.gLimNumOfAniSTAs);
3495 return;
3496 }
3497
3498 pMac->lim.gLimNumOfAniSTAs--;
3499
3500 if (pMac->lim.gLimNumOfAniSTAs != 0)
3501 return;
3502
3503 // get here only if this is the last ANI peer in the BSS
3504 schEdcaProfileUpdate(pMac, psessionEntry);
3505}
3506
Jeff Johnson295189b2012-06-20 16:38:30 -07003507/**
3508 * limSwitchChannelCback()
3509 *
3510 *FUNCTION:
3511 * This is the callback function registered while requesting to switch channel
3512 * after AP indicates a channel switch for spectrum management (11h).
3513 *
3514 *NOTE:
3515 * @param pMac Pointer to Global MAC structure
3516 * @param status Status of channel switch request
3517 * @param data User data
3518 * @param psessionEntry Session information
3519 * @return NONE
3520 */
3521void limSwitchChannelCback(tpAniSirGlobal pMac, eHalStatus status,
3522 tANI_U32 *data, tpPESession psessionEntry)
3523{
3524 tSirMsgQ mmhMsg = {0};
3525 tSirSmeSwitchChannelInd *pSirSmeSwitchChInd;
3526
Jeff Johnson295189b2012-06-20 16:38:30 -07003527 psessionEntry->currentOperChannel = psessionEntry->currentReqChannel;
3528
3529 /* We need to restore pre-channelSwitch state on the STA */
3530 if (limRestorePreChannelSwitchState(pMac, psessionEntry) != eSIR_SUCCESS)
3531 {
3532 limLog(pMac, LOGP, FL("Could not restore pre-channelSwitch (11h) state, resetting the system\n"));
3533 return;
3534 }
3535
3536 mmhMsg.type = eWNI_SME_SWITCH_CHL_REQ;
3537 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pSirSmeSwitchChInd, sizeof(tSirSmeSwitchChannelInd)))
3538 {
3539 limLog(pMac, LOGP, FL("Failed to allocate buffer for buffer descriptor\n"));
3540 return;
3541 }
3542
3543 pSirSmeSwitchChInd->messageType = eWNI_SME_SWITCH_CHL_REQ;
3544 pSirSmeSwitchChInd->length = sizeof(tSirSmeSwitchChannelInd);
Jeff Johnsone7245742012-09-05 17:12:55 -07003545 pSirSmeSwitchChInd->newChannelId = psessionEntry->gLimChannelSwitch.primaryChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 pSirSmeSwitchChInd->sessionId = psessionEntry->smeSessionId;
3547 //BSS ID
3548 palCopyMemory( pMac->hHdd, pSirSmeSwitchChInd->bssId, psessionEntry->bssId, sizeof(tSirMacAddr));
3549 mmhMsg.bodyptr = pSirSmeSwitchChInd;
3550 mmhMsg.bodyval = 0;
3551
Jeff Johnsone7245742012-09-05 17:12:55 -07003552 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003553
3554#if defined( FEATURE_WLAN_INTEGRATED_SOC )
3555 SysProcessMmhMsg(pMac, &mmhMsg);
3556#else
3557 if(halMmhPostMsgApi(pMac, &mmhMsg, ePROT) != eSIR_SUCCESS)
3558 {
3559 palFreeMemory(pMac->hHdd, (void *)msg2Hdd);
3560 limLog(pMac, LOGP, FL("Message posting to HAL failed\n"));
3561 }
3562#endif
3563}
3564
3565/**
3566 * limSwitchPrimaryChannel()
3567 *
3568 *FUNCTION:
3569 * This function changes the current operating channel
3570 * and sets the new new channel ID in WNI_CFG_CURRENT_CHANNEL.
3571 *
3572 *NOTE:
3573 * @param pMac Pointer to Global MAC structure
3574 * @param newChannel new chnannel ID
3575 * @return NONE
3576 */
3577void limSwitchPrimaryChannel(tpAniSirGlobal pMac, tANI_U8 newChannel,tpPESession psessionEntry)
3578{
3579#if !defined WLAN_FEATURE_VOWIFI
3580 tANI_U32 localPwrConstraint;
3581#endif
3582
3583 PELOG3(limLog(pMac, LOG3, FL("limSwitchPrimaryChannel: old chnl %d --> new chnl %d \n"),
3584 psessionEntry->currentOperChannel, newChannel);)
3585 psessionEntry->currentReqChannel = newChannel;
3586 psessionEntry->limRFBand = limGetRFBand(newChannel);
3587
3588 psessionEntry->channelChangeReasonCode=LIM_SWITCH_CHANNEL_OPERATION;
3589
3590 pMac->lim.gpchangeChannelCallback = limSwitchChannelCback;
3591 pMac->lim.gpchangeChannelData = NULL;
3592
3593#if defined WLAN_FEATURE_VOWIFI
Jeff Johnsone7245742012-09-05 17:12:55 -07003594 limSendSwitchChnlParams(pMac, newChannel, PHY_SINGLE_CHANNEL_CENTERED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003595 psessionEntry->maxTxPower, psessionEntry->peSessionId);
3596#else
3597 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS)
3598 {
3599 limLog( pMac, LOGP, FL( "Unable to read Local Power Constraint from cfg\n" ));
3600 return;
3601 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003602 limSendSwitchChnlParams(pMac, newChannel, PHY_SINGLE_CHANNEL_CENTERED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 (tPowerdBm)localPwrConstraint, psessionEntry->peSessionId);
3604#endif
3605 return;
3606}
3607
3608/**
3609 * limSwitchPrimarySecondaryChannel()
3610 *
3611 *FUNCTION:
3612 * This function changes the primary and secondary channel.
3613 * If 11h is enabled and user provides a "new channel ID"
3614 * that is different from the current operating channel,
3615 * then we must set this new channel in WNI_CFG_CURRENT_CHANNEL,
3616 * assign notify LIM of such change.
3617 *
3618 *NOTE:
3619 * @param pMac Pointer to Global MAC structure
3620 * @param newChannel New chnannel ID (or current channel ID)
3621 * @param subband CB secondary info:
3622 * - eANI_CB_SECONDARY_NONE
3623 * - eANI_CB_SECONDARY_UP
3624 * - eANI_CB_SECONDARY_DOWN
3625 * @return NONE
3626 */
Jeff Johnsone7245742012-09-05 17:12:55 -07003627void limSwitchPrimarySecondaryChannel(tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 newChannel, ePhyChanBondState subband)
Jeff Johnson295189b2012-06-20 16:38:30 -07003628{
3629#if !defined WLAN_FEATURE_VOWIFI
3630 tANI_U32 localPwrConstraint;
3631#endif
3632
Jeff Johnson295189b2012-06-20 16:38:30 -07003633#if !defined WLAN_FEATURE_VOWIFI
3634 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
3635 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg\n" ));
3636 return;
3637 }
3638#endif
3639
Jeff Johnson295189b2012-06-20 16:38:30 -07003640#if defined WLAN_FEATURE_VOWIFI
Jeff Johnsone7245742012-09-05 17:12:55 -07003641 limSendSwitchChnlParams(pMac, newChannel, subband, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003642#else
Jeff Johnsone7245742012-09-05 17:12:55 -07003643 limSendSwitchChnlParams(pMac, newChannel, subband, (tPowerdBm)localPwrConstraint, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003644#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003645
Jeff Johnsone7245742012-09-05 17:12:55 -07003646 // Store the new primary and secondary channel in session entries if different
3647 if (psessionEntry->currentOperChannel != newChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 {
3649 limLog(pMac, LOGW,
3650 FL("switch old chnl %d --> new chnl %d \n"),
3651 psessionEntry->currentOperChannel, newChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 psessionEntry->currentOperChannel = newChannel;
3653 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003654 if (psessionEntry->htSecondaryChannelOffset != subband)
3655 {
3656 limLog(pMac, LOGW,
3657 FL("switch old sec chnl %d --> new sec chnl %d \n"),
3658 psessionEntry->htSecondaryChannelOffset, subband);
3659 psessionEntry->htSecondaryChannelOffset = subband;
3660 if (psessionEntry->htSecondaryChannelOffset == PHY_SINGLE_CHANNEL_CENTERED)
3661 {
3662 psessionEntry->htSupportedChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3663 }
3664 else
3665 {
3666 psessionEntry->htSupportedChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
3667 }
3668 psessionEntry->htRecommendedTxWidthSet = psessionEntry->htSupportedChannelWidthSet;
3669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003670
3671 return;
3672}
3673
3674
3675/**
3676 * limActiveScanAllowed()
3677 *
3678 *FUNCTION:
3679 * Checks if active scans are permitted on the given channel
3680 *
3681 *LOGIC:
3682 * The config variable SCAN_CONTROL_LIST contains pairs of (channelNum, activeScanAllowed)
3683 * Need to check if the channelNum matches, then depending on the corresponding
3684 * scan flag, return true (for activeScanAllowed==1) or false (otherwise).
3685 *
3686 *ASSUMPTIONS:
3687 *
3688 *NOTE:
3689 *
3690 * @param pMac Pointer to Global MAC structure
3691 * @param channelNum channel number
3692 * @return None
3693 */
3694
3695tANI_U8 limActiveScanAllowed(
3696 tpAniSirGlobal pMac,
3697 tANI_U8 channelNum)
3698{
3699 tANI_U32 i;
3700 tANI_U8 channelPair[WNI_CFG_SCAN_CONTROL_LIST_LEN];
3701 tANI_U32 len = WNI_CFG_SCAN_CONTROL_LIST_LEN;
3702 if (wlan_cfgGetStr(pMac, WNI_CFG_SCAN_CONTROL_LIST, channelPair, &len)
3703 != eSIR_SUCCESS)
3704 {
3705 PELOGE(limLog(pMac, LOGE, FL("Unable to get scan control list\n"));)
3706 return false;
3707 }
3708
3709 if (len > WNI_CFG_SCAN_CONTROL_LIST_LEN)
3710 {
3711 limLog(pMac, LOGE, FL("Invalid scan control list length:%d\n"),
3712 len);
3713 return false;
3714 }
3715
3716 for (i=0; (i+1) < len; i+=2)
3717 {
3718 if (channelPair[i] == channelNum)
3719 return ((channelPair[i+1] == eSIR_ACTIVE_SCAN) ? true : false);
3720 }
3721 return false;
3722}
3723
3724/**
3725 * limTriggerBackgroundScanDuringQuietBss()
3726 *
3727 *FUNCTION:
3728 * This function is applicable to the STA only.
3729 * This function is called by limProcessQuietTimeout(),
3730 * when it is time to honor the Quiet BSS IE from the AP.
3731 *
3732 *LOGIC:
3733 * If 11H is enabled:
3734 * We cannot trigger a background scan. The STA needs to
3735 * shut-off Tx/Rx.
3736 * If 11 is not enabled:
3737 * Determine if the next channel that we are going to
3738 * scan is NOT the same channel (or not) on which the
3739 * Quiet BSS was requested.
3740 * If yes, then we cannot trigger a background scan on
3741 * this channel. Return with a false.
3742 * If no, then trigger a background scan. Return with
3743 * a true.
3744 *
3745 *ASSUMPTIONS:
3746 *
3747 *NOTE:
3748 * This API is redundant if the existing API,
3749 * limTriggerBackgroundScan(), were to return a valid
3750 * response instead of returning void.
3751 * If possible, try to revisit this API
3752 *
3753 * @param pMac Pointer to Global MAC structure
3754 * @return eSIR_TRUE, if a background scan was attempted
3755 * eSIR_FALSE, if not
3756 */
3757tAniBool limTriggerBackgroundScanDuringQuietBss( tpAniSirGlobal pMac )
3758{
3759 tAniBool bScanTriggered = eSIR_FALSE;
3760#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
3761
3762
3763
3764 //TBD-RAJESH HOW TO GET sessionEntry?????
3765 tpPESession psessionEntry = &pMac->lim.gpSession[0];
3766
3767 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
3768 return bScanTriggered;
3769
Jeff Johnsone7245742012-09-05 17:12:55 -07003770 if( !psessionEntry->lim11hEnable )
Jeff Johnson295189b2012-06-20 16:38:30 -07003771 {
3772 tSirMacChanNum bgScanChannelList[WNI_CFG_BG_SCAN_CHANNEL_LIST_LEN];
3773 tANI_U32 len = WNI_CFG_BG_SCAN_CHANNEL_LIST_LEN;
3774
3775 // Determine the next scan channel
3776
3777 // Get background scan channel list from CFG
3778 if( eSIR_SUCCESS == wlan_cfgGetStr( pMac,
3779 WNI_CFG_BG_SCAN_CHANNEL_LIST,
3780 (tANI_U8 *) bgScanChannelList,
3781 (tANI_U32 *) &len ))
3782 {
3783 // Ensure that we do not go off scanning on the same
3784 // channel on which the Quiet BSS was requested
3785 if( psessionEntry->currentOperChannel!=
3786 bgScanChannelList[pMac->lim.gLimBackgroundScanChannelId] )
3787 {
3788 // For now, try and attempt a background scan. It will
3789 // be ideal if this API actually returns a success or
3790 // failure instead of having a void return type
3791 limTriggerBackgroundScan( pMac );
3792
3793 bScanTriggered = eSIR_TRUE;
3794 }
3795 else
3796 {
3797 limLog( pMac, LOGW,
3798 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"));
3799 }
3800 }
3801 else
3802 {
3803 limLog( pMac, LOGW,
3804 FL("Unable to retrieve WNI_CFG_VALID_CHANNEL_LIST from CFG! A background scan will not be triggered during this Quiet BSS period...\n"));
3805 }
3806 }
3807#endif
3808 return bScanTriggered;
3809}
3810
3811
3812/**
3813 * limGetHTCapability()
3814 *
3815 *FUNCTION:
3816 * A utility function that returns the "current HT capability state" for the HT
3817 * capability of interest (as requested in the API)
3818 *
3819 *LOGIC:
3820 * This routine will return with the "current" setting of a requested HT
3821 * capability. This state info could be retrieved from -
3822 * a) CFG (for static entries)
3823 * b) Run time info
3824 * - Dynamic state maintained by LIM
3825 * - Configured at radio init time by SME
3826 *
3827 *
3828 *ASSUMPTIONS:
3829 * NA
3830 *
3831 *NOTE:
3832 *
3833 * @param pMac Pointer to Global MAC structure
3834 * @param htCap The HT capability being queried
3835 * @return tANI_U8 The current state of the requested HT capability is returned in a
3836 * tANI_U8 variable
3837 */
3838
3839#ifdef WLAN_SOFTAP_FEATURE
3840tANI_U8 limGetHTCapability( tpAniSirGlobal pMac,
3841 tANI_U32 htCap, tpPESession psessionEntry)
3842#else
3843tANI_U8 limGetHTCapability( tpAniSirGlobal pMac,
3844 tANI_U32 htCap )
3845#endif
3846{
3847tANI_U8 retVal = 0;
3848tANI_U8 *ptr;
3849tANI_U32 cfgValue;
3850tSirMacHTCapabilityInfo macHTCapabilityInfo = {0};
3851tSirMacExtendedHTCapabilityInfo macExtHTCapabilityInfo = {0};
3852tSirMacTxBFCapabilityInfo macTxBFCapabilityInfo = {0};
3853tSirMacASCapabilityInfo macASCapabilityInfo = {0};
3854
3855 //
3856 // Determine which CFG to read from. Not ALL of the HT
3857 // related CFG's need to be read each time this API is
3858 // accessed
3859 //
3860 if( htCap >= eHT_ANTENNA_SELECTION &&
3861 htCap < eHT_SI_GRANULARITY )
3862 {
3863 // Get Antenna Seletion HT Capabilities
3864 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_AS_CAP, &cfgValue ))
3865 cfgValue = 0;
3866 ptr = (tANI_U8 *) &macASCapabilityInfo;
3867 *((tANI_U8 *)ptr) = (tANI_U8) (cfgValue & 0xff);
3868 }
3869 else
3870 {
3871 if( htCap >= eHT_TX_BEAMFORMING &&
3872 htCap < eHT_ANTENNA_SELECTION )
3873 {
3874 // Get Transmit Beam Forming HT Capabilities
3875 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_TX_BF_CAP, &cfgValue ))
3876 cfgValue = 0;
3877 ptr = (tANI_U8 *) &macTxBFCapabilityInfo;
3878 *((tANI_U32 *)ptr) = (tANI_U32) (cfgValue);
3879 }
3880 else
3881 {
3882 if( htCap >= eHT_PCO &&
3883 htCap < eHT_TX_BEAMFORMING )
3884 {
3885 // Get Extended HT Capabilities
3886 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_EXT_HT_CAP_INFO, &cfgValue ))
3887 cfgValue = 0;
3888 ptr = (tANI_U8 *) &macExtHTCapabilityInfo;
3889 *((tANI_U16 *)ptr) = (tANI_U16) (cfgValue & 0xffff);
3890 }
3891 else
3892 {
3893 if( htCap < eHT_MAX_RX_AMPDU_FACTOR )
3894 {
3895 // Get HT Capabilities
3896 if( eSIR_SUCCESS != wlan_cfgGetInt( pMac, WNI_CFG_HT_CAP_INFO, &cfgValue ))
3897 cfgValue = 0;
3898 ptr = (tANI_U8 *) &macHTCapabilityInfo;
3899 // 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
3900 *ptr++ = cfgValue & 0xff;
3901 *ptr = (cfgValue >> 8) & 0xff;
3902 }
3903 }
3904 }
3905 }
3906
3907 switch( htCap )
3908 {
3909 case eHT_LSIG_TXOP_PROTECTION:
3910 retVal = pMac->lim.gHTLsigTXOPProtection;
3911 break;
3912
3913 case eHT_STBC_CONTROL_FRAME:
3914 retVal = (tANI_U8) macHTCapabilityInfo.stbcControlFrame;
3915 break;
3916
3917 case eHT_PSMP:
3918 retVal = pMac->lim.gHTPSMPSupport;
3919 break;
3920
3921 case eHT_DSSS_CCK_MODE_40MHZ:
3922 retVal = pMac->lim.gHTDsssCckRate40MHzSupport;
3923 break;
3924
3925 case eHT_MAX_AMSDU_LENGTH:
3926 retVal = (tANI_U8) macHTCapabilityInfo.maximalAMSDUsize;
3927 break;
3928
3929 case eHT_DELAYED_BA:
3930 retVal = (tANI_U8) macHTCapabilityInfo.delayedBA;
3931 break;
3932
3933 case eHT_RX_STBC:
3934 retVal = (tANI_U8) macHTCapabilityInfo.rxSTBC;
3935 break;
3936
3937 case eHT_TX_STBC:
3938 retVal = (tANI_U8) macHTCapabilityInfo.txSTBC;
3939 break;
3940
3941 case eHT_SHORT_GI_40MHZ:
3942 retVal = (tANI_U8) macHTCapabilityInfo.shortGI40MHz;
3943 break;
3944
3945 case eHT_SHORT_GI_20MHZ:
3946 retVal = (tANI_U8) macHTCapabilityInfo.shortGI20MHz;
3947 break;
3948
3949 case eHT_GREENFIELD:
3950 retVal = (tANI_U8) macHTCapabilityInfo.greenField;
3951 break;
3952
3953 case eHT_MIMO_POWER_SAVE:
3954 retVal = (tANI_U8) pMac->lim.gHTMIMOPSState;
3955 break;
3956
3957 case eHT_SUPPORTED_CHANNEL_WIDTH_SET:
Jeff Johnsone7245742012-09-05 17:12:55 -07003958 retVal = (tANI_U8) psessionEntry->htSupportedChannelWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 break;
3960
3961 case eHT_ADVANCED_CODING:
3962 retVal = (tANI_U8) macHTCapabilityInfo.advCodingCap;
3963 break;
3964
3965 case eHT_MAX_RX_AMPDU_FACTOR:
3966 retVal = pMac->lim.gHTMaxRxAMpduFactor;
3967 break;
3968
3969 case eHT_MPDU_DENSITY:
3970 retVal = pMac->lim.gHTAMpduDensity;
3971 break;
3972
3973 case eHT_PCO:
3974 retVal = (tANI_U8) macExtHTCapabilityInfo.pco;
3975 break;
3976
3977 case eHT_TRANSITION_TIME:
3978 retVal = (tANI_U8) macExtHTCapabilityInfo.transitionTime;
3979 break;
3980
3981 case eHT_MCS_FEEDBACK:
3982 retVal = (tANI_U8) macExtHTCapabilityInfo.mcsFeedback;
3983 break;
3984
3985 case eHT_TX_BEAMFORMING:
3986 retVal = (tANI_U8) macTxBFCapabilityInfo.txBF;
3987 break;
3988
3989 case eHT_ANTENNA_SELECTION:
3990 retVal = (tANI_U8) macASCapabilityInfo.antennaSelection;
3991 break;
3992
3993 case eHT_SI_GRANULARITY:
3994 retVal = pMac->lim.gHTServiceIntervalGranularity;
3995 break;
3996
3997 case eHT_CONTROLLED_ACCESS:
3998 retVal = pMac->lim.gHTControlledAccessOnly;
3999 break;
4000
4001 case eHT_RIFS_MODE:
4002 retVal = psessionEntry->beaconParams.fRIFSMode;
4003 break;
4004
4005 case eHT_RECOMMENDED_TX_WIDTH_SET:
Jeff Johnsone7245742012-09-05 17:12:55 -07004006 retVal = psessionEntry->htRecommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 break;
4008
4009 case eHT_EXTENSION_CHANNEL_OFFSET:
Jeff Johnsone7245742012-09-05 17:12:55 -07004010 retVal = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 break;
4012
4013 case eHT_OP_MODE:
4014#ifdef WLAN_SOFTAP_FEATURE
4015 if(psessionEntry->limSystemRole == eLIM_AP_ROLE )
4016 retVal = psessionEntry->htOperMode;
4017 else
4018#endif
4019 retVal = pMac->lim.gHTOperMode;
4020 break;
4021
4022 case eHT_BASIC_STBC_MCS:
4023 retVal = pMac->lim.gHTSTBCBasicMCS;
4024 break;
4025
4026 case eHT_DUAL_CTS_PROTECTION:
4027 retVal = pMac->lim.gHTDualCTSProtection;
4028 break;
4029
4030 case eHT_LSIG_TXOP_PROTECTION_FULL_SUPPORT:
4031 retVal = psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport;
4032 break;
4033
4034 case eHT_PCO_ACTIVE:
4035 retVal = pMac->lim.gHTPCOActive;
4036 break;
4037
4038 case eHT_PCO_PHASE:
4039 retVal = pMac->lim.gHTPCOPhase;
4040 break;
4041
4042 default:
4043 break;
4044 }
4045
4046 return retVal;
4047}
4048
Jeff Johnson295189b2012-06-20 16:38:30 -07004049void limGetMyMacAddr(tpAniSirGlobal pMac, tANI_U8 *mac)
4050{
4051 palCopyMemory( pMac->hHdd, mac, pMac->lim.gLimMyMacAddr, sizeof(tSirMacAddr));
4052 return;
4053}
4054
4055
4056
4057
4058/** -------------------------------------------------------------
4059\fn limEnable11aProtection
4060\brief based on config setting enables\disables 11a protection.
4061\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4062\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4063\param tpUpdateBeaconParams pBeaconParams
4064\return None
4065 -------------------------------------------------------------*/
4066tSirRetStatus
4067limEnable11aProtection(tpAniSirGlobal pMac, tANI_U8 enable,
4068 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4069{
4070
4071 //overlapping protection configuration check.
4072 if(overlap)
4073 {
4074#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
4075 if(psessionEntry->limSystemRole == eLIM_AP_ROLE && !pMac->lim.cfgProtection.overlapFromlla)
4076 {
4077 // protection disabled.
4078 PELOG3(limLog(pMac, LOG3, FL("overlap protection from 11a is disabled\n"));)
4079 return eSIR_SUCCESS;
4080 }
4081#endif
4082 }
4083 else
4084 {
4085 //normal protection config check
Jeff Johnsone7245742012-09-05 17:12:55 -07004086 if (( psessionEntry != NULL ) && (psessionEntry->limSystemRole == eLIM_AP_ROLE) &&
4087 (!psessionEntry->cfgProtection.fromlla))
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 {
4089 // protection disabled.
4090 PELOG3(limLog(pMac, LOG3, FL("protection from 11a is disabled\n"));)
4091 return eSIR_SUCCESS;
4092 }
4093 }
4094
4095 if (enable)
4096 {
4097 //If we are AP and HT capable, we need to set the HT OP mode
4098 //appropriately.
4099 if(((eLIM_AP_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole))&&
Jeff Johnsone7245742012-09-05 17:12:55 -07004100 (true == psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 {
4102 if(overlap)
4103 {
4104 pMac->lim.gLimOverlap11aParams.protectionEnabled = true;
4105 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
4106 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
4107 {
4108 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4109 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4110 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4111 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4112 }
4113 }
4114 else
4115 {
4116 psessionEntry->gLim11aParams.protectionEnabled = true;
4117 if(eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode)
4118 {
4119 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_MIXED;
Jeff Johnsone7245742012-09-05 17:12:55 -07004120 psessionEntry->htOperMode = eSIR_HT_OP_MODE_MIXED;
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4122 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4123
4124 }
4125 }
4126 }
4127
4128 //This part is common for staiton as well.
4129 if(false == psessionEntry->beaconParams.llaCoexist)
4130 {
4131 PELOG1(limLog(pMac, LOG1, FL(" => protection from 11A Enabled\n"));)
4132 pBeaconParams->llaCoexist = psessionEntry->beaconParams.llaCoexist = true;
4133 pBeaconParams->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
4134 }
4135 }
4136 else if (true == psessionEntry->beaconParams.llaCoexist)
4137 {
4138 //for AP role.
4139 //we need to take care of HT OP mode change if needed.
4140 //We need to take care of Overlap cases.
4141 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4142 {
4143 if(overlap)
4144 {
4145 //Overlap Legacy protection disabled.
4146 pMac->lim.gLimOverlap11aParams.protectionEnabled = false;
4147
4148 //We need to take care of HT OP mode iff we are HT AP.
Jeff Johnsone7245742012-09-05 17:12:55 -07004149 if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 {
4151 // no HT op mode change if any of the overlap protection enabled.
4152 if(!(pMac->lim.gLimOverlap11aParams.protectionEnabled ||
4153 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4154 pMac->lim.gLimOverlapNonGfParams.protectionEnabled))
4155
4156 {
4157 //Check if there is a need to change HT OP mode.
4158 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
4159 {
4160 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4161 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4162
4163 if(psessionEntry->gLimHt20Params.protectionEnabled)
4164 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4165 else
4166 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4167 }
4168 }
4169 }
4170 }
4171 else
4172 {
4173 //Disable protection from 11A stations.
4174 psessionEntry->gLim11aParams.protectionEnabled = false;
4175 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4176
4177 //Check if any other non-HT protection enabled.
4178 //Right now we are in HT OP Mixed mode.
4179 //Change HT op mode appropriately.
4180
4181 //Change HT OP mode to 01 if any overlap protection enabled
4182 if(pMac->lim.gLimOverlap11aParams.protectionEnabled ||
4183 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4184 pMac->lim.gLimOverlapNonGfParams.protectionEnabled)
4185
4186 {
4187 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
Jeff Johnsone7245742012-09-05 17:12:55 -07004188 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004189 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4190 }
4191 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4192 {
4193 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
Jeff Johnsone7245742012-09-05 17:12:55 -07004194 psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4196 }
4197 else
4198 {
4199 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004200 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004201 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4202 }
4203 }
4204 if(!pMac->lim.gLimOverlap11aParams.protectionEnabled &&
4205 !psessionEntry->gLim11aParams.protectionEnabled)
4206 {
4207 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11A Disabled\n"));)
4208 pBeaconParams->llaCoexist = psessionEntry->beaconParams.llaCoexist = false;
4209 pBeaconParams->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
4210 }
4211 }
4212 //for station role
4213 else
4214 {
4215 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11A Disabled\n"));)
4216 pBeaconParams->llaCoexist = psessionEntry->beaconParams.llaCoexist = false;
4217 pBeaconParams->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
4218 }
4219 }
4220
4221 return eSIR_SUCCESS;
4222}
4223
4224/** -------------------------------------------------------------
4225\fn limEnable11gProtection
4226\brief based on config setting enables\disables 11g protection.
4227\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4228\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4229\param tpUpdateBeaconParams pBeaconParams
4230\return None
4231 -------------------------------------------------------------*/
4232
4233tSirRetStatus
4234limEnable11gProtection(tpAniSirGlobal pMac, tANI_U8 enable,
4235 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4236{
4237
4238 //overlapping protection configuration check.
4239 if(overlap)
4240 {
4241#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
4242 if(((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE )) && !pMac->lim.cfgProtection.overlapFromllb)
4243 {
4244 // protection disabled.
4245 PELOG1(limLog(pMac, LOG1, FL("overlap protection from 11b is disabled\n"));)
4246 return eSIR_SUCCESS;
4247 }
4248#endif
4249 }
4250 else
4251 {
4252 //normal protection config check
4253#ifdef WLAN_SOFTAP_FEATURE
4254 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
4255 !psessionEntry->cfgProtection.fromllb)
4256 {
4257 // protection disabled.
4258 PELOG1(limLog(pMac, LOG1, FL("protection from 11b is disabled\n"));)
4259 return eSIR_SUCCESS;
4260 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
4261#endif
4262 {
4263 if(!pMac->lim.cfgProtection.fromllb)
4264 {
4265 // protection disabled.
4266 PELOG1(limLog(pMac, LOG1, FL("protection from 11b is disabled\n"));)
4267 return eSIR_SUCCESS;
4268 }
4269 }
4270 }
4271
4272 if (enable)
4273 {
4274 //If we are AP and HT capable, we need to set the HT OP mode
4275 //appropriately.
4276#ifdef WLAN_SOFTAP_FEATURE
4277 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4278 {
4279 if(overlap)
4280 {
4281 psessionEntry->gLimOlbcParams.protectionEnabled = true;
4282 PELOGE(limLog(pMac, LOGE, FL("protection from olbc is enabled\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004283 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 {
4285 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != psessionEntry->htOperMode) &&
4286 (eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode))
4287 {
4288 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4289 }
4290 //CR-263021: OBSS bit is not switching back to 0 after disabling the overlapping legacy BSS
4291 // This fixes issue of OBSS bit not set after 11b, 11g station leaves
4292 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4293 //Not processing OBSS bit from other APs, as we are already taking care
4294 //of Protection from overlapping BSS based on erp IE or useProtection bit
4295 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams, psessionEntry);
4296 }
4297 }
4298 else
4299 {
4300 psessionEntry->gLim11bParams.protectionEnabled = true;
4301 PELOGE(limLog(pMac, LOGE, FL("protection from 11b is enabled\n"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07004302 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004303 {
4304 if(eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode)
4305 {
4306 psessionEntry->htOperMode = eSIR_HT_OP_MODE_MIXED;
4307 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4308 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4309 }
4310 }
4311 }
4312 }else if ((eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07004313 (true == psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07004314#else
4315 if(((eLIM_AP_ROLE == psessionEntry->limSystemRole)|| (eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)) &&
Jeff Johnsone7245742012-09-05 17:12:55 -07004316 (true == psessionEntry->htCapability))
Jeff Johnson295189b2012-06-20 16:38:30 -07004317#endif
4318 {
4319 if(overlap)
4320 {
4321 psessionEntry->gLimOlbcParams.protectionEnabled = true;
4322 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
4323 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
4324 {
4325 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4326 }
4327 //CR-263021: OBSS bit is not switching back to 0 after disabling the overlapping legacy BSS
4328 // This fixes issue of OBSS bit not set after 11b, 11g station leaves
4329 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4330 //Not processing OBSS bit from other APs, as we are already taking care
4331 //of Protection from overlapping BSS based on erp IE or useProtection bit
4332 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams, psessionEntry);
4333 }
4334 else
4335 {
4336 psessionEntry->gLim11bParams.protectionEnabled = true;
4337 if(eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode)
4338 {
4339 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_MIXED;
4340 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4341 limEnableHtOBSSProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4342 }
4343 }
4344 }
4345
4346 //This part is common for staiton as well.
4347 if(false == psessionEntry->beaconParams.llbCoexist)
4348 {
4349 PELOG1(limLog(pMac, LOG1, FL("=> 11G Protection Enabled\n"));)
4350 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = true;
4351 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4352 }
4353 }
4354 else if (true == psessionEntry->beaconParams.llbCoexist)
4355 {
4356 //for AP role.
4357 //we need to take care of HT OP mode change if needed.
4358 //We need to take care of Overlap cases.
4359#ifdef WLAN_SOFTAP_FEATURE
4360 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4361 {
4362 if(overlap)
4363 {
4364 //Overlap Legacy protection disabled.
4365 psessionEntry->gLimOlbcParams.protectionEnabled = false;
4366
4367 //We need to take care of HT OP mode if we are HT AP.
Jeff Johnsone7245742012-09-05 17:12:55 -07004368 if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 {
4370 // no HT op mode change if any of the overlap protection enabled.
4371 if(!(psessionEntry->gLimOverlap11gParams.protectionEnabled ||
4372 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4373 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
4374 {
4375 //Check if there is a need to change HT OP mode.
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004376 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == psessionEntry->htOperMode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 {
4378 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4379 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4380 if(psessionEntry->gLimHt20Params.protectionEnabled){
4381 //Commenting out beacuse of CR 258588 WFA cert
4382 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4383 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4384 }
4385 else
4386 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4387 }
4388 }
4389 }
4390 }
4391 else
4392 {
4393 //Disable protection from 11B stations.
4394 psessionEntry->gLim11bParams.protectionEnabled = false;
4395 PELOGE(limLog(pMac, LOGE, FL("===> 11B Protection Disabled\n"));)
4396 //Check if any other non-HT protection enabled.
4397 if(!psessionEntry->gLim11gParams.protectionEnabled)
4398 {
4399 //Right now we are in HT OP Mixed mode.
4400 //Change HT op mode appropriately.
4401 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4402
4403 //Change HT OP mode to 01 if any overlap protection enabled
4404 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4405 psessionEntry->gLimOverlap11gParams.protectionEnabled ||
4406 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4407 psessionEntry->gLimOverlapNonGfParams.protectionEnabled)
4408 {
4409 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4410 PELOGE(limLog(pMac, LOGE, FL("===> 11G Protection Disabled\n"));)
4411 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4412 }
4413 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4414 {
4415 //Commenting because of CR 258588 WFA cert
4416 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4417 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4418 PELOGE(limLog(pMac, LOGE, FL("===> 11G Protection Disabled\n"));)
4419 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4420 }
4421 else
4422 {
4423 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4424 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4425 }
4426 }
4427 }
4428 if(!psessionEntry->gLimOlbcParams.protectionEnabled &&
4429 !psessionEntry->gLim11bParams.protectionEnabled)
4430 {
4431 PELOGE(limLog(pMac, LOGE, FL("===> 11G Protection Disabled\n"));)
4432 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
4433 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4434 }
4435 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
4436#else
4437 if((eLIM_AP_ROLE == psessionEntry->limSystemRole)||((eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)))
4438#endif
4439 {
4440 if(overlap)
4441 {
4442 //Overlap Legacy protection disabled.
4443 psessionEntry->gLimOlbcParams.protectionEnabled = false;
4444
4445 //We need to take care of HT OP mode iff we are HT AP.
Jeff Johnsone7245742012-09-05 17:12:55 -07004446 if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 {
4448 // no HT op mode change if any of the overlap protection enabled.
4449 if(!(pMac->lim.gLimOverlap11gParams.protectionEnabled ||
4450 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4451 pMac->lim.gLimOverlapNonGfParams.protectionEnabled))
4452
4453 {
4454 //Check if there is a need to change HT OP mode.
4455 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
4456 {
4457 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4458 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4459 if(psessionEntry->gLimHt20Params.protectionEnabled)
4460 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4461 else
4462 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4463 }
4464 }
4465 }
4466 }
4467 else
4468 {
4469 //Disable protection from 11B stations.
4470 psessionEntry->gLim11bParams.protectionEnabled = false;
4471 //Check if any other non-HT protection enabled.
4472 if(!psessionEntry->gLim11gParams.protectionEnabled)
4473 {
4474 //Right now we are in HT OP Mixed mode.
4475 //Change HT op mode appropriately.
4476 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4477
4478 //Change HT OP mode to 01 if any overlap protection enabled
4479 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4480 pMac->lim.gLimOverlap11gParams.protectionEnabled ||
4481 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4482 pMac->lim.gLimOverlapNonGfParams.protectionEnabled)
4483
4484 {
4485 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4486 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4487 }
4488 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4489 {
4490 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4491 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4492 }
4493 else
4494 {
4495 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4496 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4497 }
4498 }
4499 }
4500 if(!psessionEntry->gLimOlbcParams.protectionEnabled &&
4501 !psessionEntry->gLim11bParams.protectionEnabled)
4502 {
4503 PELOG1(limLog(pMac, LOG1, FL("===> 11G Protection Disabled\n"));)
4504 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
4505 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4506 }
4507 }
4508 //for station role
4509 else
4510 {
4511 PELOG1(limLog(pMac, LOG1, FL("===> 11G Protection Disabled\n"));)
4512 pBeaconParams->llbCoexist = psessionEntry->beaconParams.llbCoexist = false;
4513 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
4514 }
4515 }
4516 return eSIR_SUCCESS;
4517}
4518
4519/** -------------------------------------------------------------
4520\fn limEnableHtProtectionFrom11g
4521\brief based on cofig enables\disables protection from 11g.
4522\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4523\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4524\param tpUpdateBeaconParams pBeaconParams
4525\return None
4526 -------------------------------------------------------------*/
4527tSirRetStatus
4528limEnableHtProtectionFrom11g(tpAniSirGlobal pMac, tANI_U8 enable,
4529 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4530{
Jeff Johnsone7245742012-09-05 17:12:55 -07004531 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 return eSIR_SUCCESS; // protection from 11g is only for HT stations.
4533
4534 //overlapping protection configuration check.
4535 if(overlap)
4536 {
4537#ifdef WLAN_SOFTAP_FEATURE
4538 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) && (!psessionEntry->cfgProtection.overlapFromllg))
4539 {
4540 // protection disabled.
4541 PELOG3(limLog(pMac, LOG3, FL("overlap protection from 11g is disabled\n")););
4542 return eSIR_SUCCESS;
4543 }else if ((psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE) && (!pMac->lim.cfgProtection.overlapFromllg))
4544#else
4545 if(((psessionEntry->limSystemRole == eLIM_AP_ROLE ) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) && (!pMac->lim.cfgProtection.overlapFromllg))
4546#endif
4547 {
4548 // protection disabled.
4549 PELOG3(limLog(pMac, LOG3, FL("overlap protection from 11g is disabled\n")););
4550 return eSIR_SUCCESS;
4551 }
4552 }
4553 else
4554 {
4555 //normal protection config check
4556#ifdef WLAN_SOFTAP_FEATURE
4557 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
4558 !psessionEntry->cfgProtection.fromllg){
4559 // protection disabled.
4560 PELOG3(limLog(pMac, LOG3, FL("protection from 11g is disabled\n"));)
4561 return eSIR_SUCCESS;
4562 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
4563#endif
4564 {
4565 if(!pMac->lim.cfgProtection.fromllg)
4566 {
4567 // protection disabled.
4568 PELOG3(limLog(pMac, LOG3, FL("protection from 11g is disabled\n"));)
4569 return eSIR_SUCCESS;
4570 }
4571 }
4572 }
4573 if (enable)
4574 {
4575 //If we are AP and HT capable, we need to set the HT OP mode
4576 //appropriately.
4577
4578#ifdef WLAN_SOFTAP_FEATURE
4579 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4580 {
4581 if(overlap)
4582 {
4583 psessionEntry->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 != psessionEntry->htOperMode) &&
4588 (eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode))
4589 {
4590 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4591 }
4592 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4593 limEnableHtOBSSProtection(pMac, true , overlap, pBeaconParams, psessionEntry);
4594 }
4595 else
4596 {
4597 //11g is associated to an AP operating in 11n mode.
4598 //Change the HT operating mode to 'mixed mode'.
4599 psessionEntry->gLim11gParams.protectionEnabled = true;
4600 if(eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode)
4601 {
4602 psessionEntry->htOperMode = eSIR_HT_OP_MODE_MIXED;
4603 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4604 limEnableHtOBSSProtection(pMac, true , overlap, pBeaconParams,psessionEntry);
4605 }
4606 }
4607 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
4608#else
4609 if((eLIM_AP_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole))
4610#endif
4611 {
4612 if(overlap)
4613 {
4614 pMac->lim.gLimOverlap11gParams.protectionEnabled = true;
4615 //11g exists in overlap BSS.
4616 //need not to change the operating mode to overlap_legacy
4617 //if higher or same protection operating mode is enabled right now.
4618 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
4619 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
4620 {
4621 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4622 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4623 }
4624 }
4625 else
4626 {
4627 //11g is associated to an AP operating in 11n mode.
4628 //Change the HT operating mode to 'mixed mode'.
4629 psessionEntry->gLim11gParams.protectionEnabled = true;
4630 if(eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode)
4631 {
4632 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_MIXED;
4633 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4634 limEnableHtOBSSProtection(pMac, true , overlap, pBeaconParams,psessionEntry);
4635 }
4636 }
4637 }
4638
4639 //This part is common for staiton as well.
4640 if(false == psessionEntry->beaconParams.llgCoexist)
4641 {
4642 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = true;
4643 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4644 }
4645#ifdef WLAN_SOFTAP_FEATURE
4646 else if (true == psessionEntry->gLimOverlap11gParams.protectionEnabled)
4647 {
4648 // As operating mode changed after G station assoc some way to update beacon
4649 // This addresses the issue of mode not changing to - 11 in beacon when OBSS overlap is enabled
4650 //pMac->sch.schObject.fBeaconChanged = 1;
4651 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4652 }
4653#endif
4654 }
4655 else if (true == psessionEntry->beaconParams.llgCoexist)
4656 {
4657 //for AP role.
4658 //we need to take care of HT OP mode change if needed.
4659 //We need to take care of Overlap cases.
4660
4661#ifdef WLAN_SOFTAP_FEATURE
4662 if(eLIM_AP_ROLE == psessionEntry->limSystemRole)
4663 {
4664 if(overlap)
4665 {
4666 //Overlap Legacy protection disabled.
4667 if (psessionEntry->gLim11gParams.numSta == 0)
4668 psessionEntry->gLimOverlap11gParams.protectionEnabled = false;
4669
4670 // no HT op mode change if any of the overlap protection enabled.
4671 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
4672 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4673 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
4674 {
4675 //Check if there is a need to change HT OP mode.
4676 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == psessionEntry->htOperMode)
4677 {
4678 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4679 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4680
4681 if(psessionEntry->gLimHt20Params.protectionEnabled){
4682 //Commenting because of CR 258588 WFA cert
4683 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4684 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4685 }
4686 else
4687 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4688 }
4689 }
4690 }
4691 else
4692 {
4693 //Disable protection from 11G stations.
4694 psessionEntry->gLim11gParams.protectionEnabled = false;
4695 //Check if any other non-HT protection enabled.
4696 if(!psessionEntry->gLim11bParams.protectionEnabled)
4697 {
4698
4699 //Right now we are in HT OP Mixed mode.
4700 //Change HT op mode appropriately.
4701 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4702
4703 //Change HT OP mode to 01 if any overlap protection enabled
4704 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4705 psessionEntry->gLimOverlap11gParams.protectionEnabled ||
4706 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4707 psessionEntry->gLimOverlapNonGfParams.protectionEnabled)
4708
4709 {
4710 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4711 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4712 }
4713 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4714 {
4715 //Commenting because of CR 258588 WFA cert
4716 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4717 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4718 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4719 }
4720 else
4721 {
4722 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4723 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4724 }
4725 }
4726 }
4727 if(!psessionEntry->gLimOverlap11gParams.protectionEnabled &&
4728 !psessionEntry->gLim11gParams.protectionEnabled)
4729 {
4730 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11G Disabled\n"));)
4731 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = false;
4732 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4733 }
4734 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
4735#else
4736 if((eLIM_AP_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole))
4737#endif
4738 {
4739 if(overlap)
4740 {
4741 //Overlap Legacy protection disabled.
4742 pMac->lim.gLimOverlap11gParams.protectionEnabled = false;
4743
4744 // no HT op mode change if any of the overlap protection enabled.
4745 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
4746 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
4747 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
4748 {
4749 //Check if there is a need to change HT OP mode.
4750 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
4751 {
4752 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4753 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4754
4755 if(psessionEntry->gLimHt20Params.protectionEnabled)
4756 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4757 else
4758 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4759 }
4760 }
4761 }
4762 else
4763 {
4764 //Disable protection from 11G stations.
4765 psessionEntry->gLim11gParams.protectionEnabled = false;
4766 //Check if any other non-HT protection enabled.
4767 if(!psessionEntry->gLim11bParams.protectionEnabled)
4768 {
4769
4770 //Right now we are in HT OP Mixed mode.
4771 //Change HT op mode appropriately.
4772 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4773
4774 //Change HT OP mode to 01 if any overlap protection enabled
4775 if(psessionEntry->gLimOlbcParams.protectionEnabled ||
4776 pMac->lim.gLimOverlap11gParams.protectionEnabled ||
4777 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
4778 pMac->lim.gLimOverlapNonGfParams.protectionEnabled)
4779
4780 {
4781 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4782 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4783 }
4784 else if(psessionEntry->gLimHt20Params.protectionEnabled)
4785 {
4786 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4787 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4788 }
4789 else
4790 {
4791 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
4792 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4793 }
4794 }
4795 }
4796 if(!pMac->lim.gLimOverlap11gParams.protectionEnabled &&
4797 !psessionEntry->gLim11gParams.protectionEnabled)
4798 {
4799 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11G Disabled\n"));)
4800 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = false;
4801 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4802 }
4803 }
4804 //for station role
4805 else
4806 {
4807 PELOG1(limLog(pMac, LOG1, FL("===> Protection from 11G Disabled\n"));)
4808 pBeaconParams->llgCoexist = psessionEntry->beaconParams.llgCoexist = false;
4809 pBeaconParams->paramChangeBitmap |= PARAM_llGCOEXIST_CHANGED;
4810 }
4811 }
4812 return eSIR_SUCCESS;
4813}
4814//FIXME_PROTECTION : need to check for no APSD whenever we want to enable this protection.
4815//This check will be done at the caller.
4816
4817/** -------------------------------------------------------------
4818\fn limEnableHtObssProtection
4819\brief based on cofig enables\disables obss protection.
4820\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4821\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4822\param tpUpdateBeaconParams pBeaconParams
4823\return None
4824 -------------------------------------------------------------*/
4825tSirRetStatus
4826limEnableHtOBSSProtection(tpAniSirGlobal pMac, tANI_U8 enable,
4827 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4828{
4829
4830
Jeff Johnsone7245742012-09-05 17:12:55 -07004831 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004832 return eSIR_SUCCESS; // this protection is only for HT stations.
4833
4834 //overlapping protection configuration check.
4835 if(overlap)
4836 {
4837 //overlapping protection configuration check.
4838 #if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
4839 if((psessionEntry->limSystemRole == eLIM_AP_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) && !pMac->lim.cfgProtection.overlapOBSS)
4840 { // ToDo Update this field
4841 // protection disabled.
4842 PELOG1(limLog(pMac, LOG1, FL("overlap protection from Obss is disabled\n"));)
4843 return eSIR_SUCCESS;
4844 }
4845 #endif
4846 }
4847 else
4848 {
4849 //normal protection config check
4850#ifdef WLAN_SOFTAP_FEATURE
4851 if((psessionEntry->limSystemRole == eLIM_AP_ROLE) && !psessionEntry->cfgProtection.obss)
4852 { //ToDo Update this field
4853 // protection disabled.
4854 PELOG1(limLog(pMac, LOG1, FL("protection from Obss is disabled\n"));)
4855 return eSIR_SUCCESS;
4856 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
4857#endif
4858 {
4859 if(!pMac->lim.cfgProtection.obss)
4860 { //ToDo Update this field
4861 // protection disabled.
4862 PELOG1(limLog(pMac, LOG1, FL("protection from Obss is disabled\n"));)
4863 return eSIR_SUCCESS;
4864 }
4865 }
4866 }
4867
4868
4869#ifdef WLAN_SOFTAP_FEATURE
4870 if (eLIM_AP_ROLE == psessionEntry->limSystemRole){
4871 if ((enable) && (false == psessionEntry->beaconParams.gHTObssMode) )
4872 {
4873 PELOG1(limLog(pMac, LOG1, FL("=>obss protection enabled\n"));)
4874 psessionEntry->beaconParams.gHTObssMode = true;
4875 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED; // UPDATE AN ENUM FOR OBSS MODE <todo>
4876
4877 }
4878 else if (!enable && (true == psessionEntry->beaconParams.gHTObssMode))
4879 {
4880 PELOG1(limLog(pMac, LOG1, FL("===> obss Protection disabled\n"));)
4881 psessionEntry->beaconParams.gHTObssMode = false;
4882 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED;
4883
4884 }
4885//CR-263021: OBSS bit is not switching back to 0 after disabling the overlapping legacy BSS
4886 if (!enable && !overlap)
4887 {
4888 psessionEntry->gLimOverlap11gParams.protectionEnabled = false;
4889 }
4890 } else
4891#endif
4892 {
4893 if ((enable) && (false == psessionEntry->beaconParams.gHTObssMode) )
4894 {
4895 PELOG1(limLog(pMac, LOG1, FL("=>obss protection enabled\n"));)
4896 psessionEntry->beaconParams.gHTObssMode = true;
4897 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED; // UPDATE AN ENUM FOR OBSS MODE <todo>
4898
4899 }
4900 else if (!enable && (true == psessionEntry->beaconParams.gHTObssMode))
4901 {
4902
4903 PELOG1(limLog(pMac, LOG1, FL("===> obss Protection disabled\n"));)
4904 psessionEntry->beaconParams.gHTObssMode = false;
4905 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED;
4906
4907 }
4908 }
4909 return eSIR_SUCCESS;
4910}
4911/** -------------------------------------------------------------
4912\fn limEnableHT20Protection
4913\brief based on cofig enables\disables protection from Ht20.
4914\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
4915\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
4916\param tpUpdateBeaconParams pBeaconParams
4917\return None
4918 -------------------------------------------------------------*/
4919tSirRetStatus
4920limEnableHT20Protection(tpAniSirGlobal pMac, tANI_U8 enable,
4921 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
4922{
Jeff Johnsone7245742012-09-05 17:12:55 -07004923 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07004924 return eSIR_SUCCESS; // this protection is only for HT stations.
4925
4926 //overlapping protection configuration check.
4927 if(overlap)
4928 {
4929#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
4930 if(((psessionEntry->limSystemRole == eLIM_AP_ROLE )||(psessionEntry->limSystemRoleS == eLIM_BT_AMP_AP_ROLE ))&& !pMac->lim.cfgProtection.overlapHt20)
4931 {
4932 // protection disabled.
4933 PELOG3(limLog(pMac, LOG3, FL("overlap protection from HT 20 is disabled\n"));)
4934 return eSIR_SUCCESS;
4935 }
4936#endif
4937 }
4938 else
4939 {
4940 //normal protection config check
4941#ifdef WLAN_SOFTAP_FEATURE
4942 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
4943 !psessionEntry->cfgProtection.ht20)
4944 {
4945 // protection disabled.
4946 PELOG3(limLog(pMac, LOG3, FL("protection from HT20 is disabled\n"));)
4947 return eSIR_SUCCESS;
4948 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
4949#endif
4950 {
4951 if(!pMac->lim.cfgProtection.ht20)
4952 {
4953 // protection disabled.
4954 PELOG3(limLog(pMac, LOG3, FL("protection from HT20 is disabled\n"));)
4955 return eSIR_SUCCESS;
4956 }
4957 }
4958 }
4959
4960 if (enable)
4961 {
4962 //If we are AP and HT capable, we need to set the HT OP mode
4963 //appropriately.
4964
4965#ifdef WLAN_SOFTAP_FEATURE
4966 if(eLIM_AP_ROLE == psessionEntry->limSystemRole){
4967 if(overlap)
4968 {
4969 psessionEntry->gLimOverlapHt20Params.protectionEnabled = true;
4970 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != psessionEntry->htOperMode) &&
4971 (eSIR_HT_OP_MODE_MIXED != psessionEntry->htOperMode))
4972 {
4973 psessionEntry->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
4974 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
4975 }
4976 }
4977 else
4978 {
4979 psessionEntry->gLimHt20Params.protectionEnabled = true;
4980 if(eSIR_HT_OP_MODE_PURE == psessionEntry->htOperMode)
4981 {
4982 //Commenting because of CR 258588 WFA cert
4983 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
4984 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
4985 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4986 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
4987 }
4988 }
4989 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
4990#else
4991 if((eLIM_AP_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole))
4992#endif
4993 {
4994 if(overlap)
4995 {
4996 pMac->lim.gLimOverlapHt20Params.protectionEnabled = true;
4997 if((eSIR_HT_OP_MODE_OVERLAP_LEGACY != pMac->lim.gHTOperMode) &&
4998 (eSIR_HT_OP_MODE_MIXED != pMac->lim.gHTOperMode))
4999 {
5000 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
5001 limEnableHtRifsProtection(pMac, true, overlap, pBeaconParams,psessionEntry);
5002 }
5003 }
5004 else
5005 {
5006 psessionEntry->gLimHt20Params.protectionEnabled = true;
5007 if(eSIR_HT_OP_MODE_PURE == pMac->lim.gHTOperMode)
5008 {
5009 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
5010 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5011 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5012 }
5013 }
5014 }
5015
5016 //This part is common for staiton as well.
5017 if(false == psessionEntry->beaconParams.ht20Coexist)
5018 {
5019 PELOG1(limLog(pMac, LOG1, FL("=> Prtection from HT20 Enabled\n"));)
5020 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = true;
5021 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
5022 }
5023 }
5024 else if (true == psessionEntry->beaconParams.ht20Coexist)
5025 {
5026 //for AP role.
5027 //we need to take care of HT OP mode change if needed.
5028 //We need to take care of Overlap cases.
5029#ifdef WLAN_SOFTAP_FEATURE
5030 if(eLIM_AP_ROLE == psessionEntry->limSystemRole){
5031 if(overlap)
5032 {
5033 //Overlap Legacy protection disabled.
5034 psessionEntry->gLimOverlapHt20Params.protectionEnabled = false;
5035
5036 // no HT op mode change if any of the overlap protection enabled.
5037 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
5038 psessionEntry->gLimOverlap11gParams.protectionEnabled ||
5039 psessionEntry->gLimOverlapHt20Params.protectionEnabled ||
5040 psessionEntry->gLimOverlapNonGfParams.protectionEnabled))
5041 {
5042
5043 //Check if there is a need to change HT OP mode.
5044 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == psessionEntry->htOperMode)
5045 {
5046 if(psessionEntry->gLimHt20Params.protectionEnabled)
5047 {
5048 //Commented beacuse of CR 258588 for WFA Cert
5049 //psessionEntry->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
5050 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
5051 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5052 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5053 }
5054 else
5055 {
5056 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
5057 }
5058 }
5059 }
5060 }
5061 else
5062 {
5063 //Disable protection from 11G stations.
5064 psessionEntry->gLimHt20Params.protectionEnabled = false;
5065
5066 //Change HT op mode appropriately.
5067 if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == psessionEntry->htOperMode)
5068 {
5069 psessionEntry->htOperMode = eSIR_HT_OP_MODE_PURE;
5070 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5071 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5072 }
5073 }
5074 PELOG1(limLog(pMac, LOG1, FL("===> Protection from HT 20 Disabled\n"));)
5075 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = false;
5076 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
5077 }else if(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole)
5078#else
5079 if((eLIM_AP_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_AP_ROLE == psessionEntry->limSystemRole))
5080#endif
5081 {
5082 if(overlap)
5083 {
5084 //Overlap Legacy protection disabled.
5085 pMac->lim.gLimOverlapHt20Params.protectionEnabled = false;
5086
5087 // no HT op mode change if any of the overlap protection enabled.
5088 if(!(psessionEntry->gLimOlbcParams.protectionEnabled ||
5089 pMac->lim.gLimOverlap11gParams.protectionEnabled ||
5090 pMac->lim.gLimOverlapHt20Params.protectionEnabled ||
5091 pMac->lim.gLimOverlapNonGfParams.protectionEnabled))
5092 {
5093
5094 //Check if there is a need to change HT OP mode.
5095 if(eSIR_HT_OP_MODE_OVERLAP_LEGACY == pMac->lim.gHTOperMode)
5096 {
5097 if(psessionEntry->gLimHt20Params.protectionEnabled)
5098 {
5099 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
5100 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5101 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5102 }
5103 else
5104 {
5105 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
5106 }
5107 }
5108 }
5109 }
5110 else
5111 {
5112 //Disable protection from 11G stations.
5113 psessionEntry->gLimHt20Params.protectionEnabled = false;
5114
5115 //Change HT op mode appropriately.
5116 if(eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == pMac->lim.gHTOperMode)
5117 {
5118 pMac->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
5119 limEnableHtRifsProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5120 limEnableHtOBSSProtection(pMac, false, overlap, pBeaconParams,psessionEntry);
5121 }
5122 }
5123 PELOG1(limLog(pMac, LOG1, FL("===> Protection from HT 20 Disabled\n"));)
5124 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = false;
5125 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
5126 }
5127 //for station role
5128 else
5129 {
5130 PELOG1(limLog(pMac, LOG1, FL("===> Protection from HT20 Disabled\n"));)
5131 pBeaconParams->ht20MhzCoexist = psessionEntry->beaconParams.ht20Coexist = false;
5132 pBeaconParams->paramChangeBitmap |= PARAM_HT20MHZCOEXIST_CHANGED;
5133 }
5134 }
5135
5136 return eSIR_SUCCESS;
5137}
5138
5139/** -------------------------------------------------------------
5140\fn limEnableHTNonGfProtection
5141\brief based on cofig enables\disables protection from NonGf.
5142\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
5143\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
5144\param tpUpdateBeaconParams pBeaconParams
5145\return None
5146 -------------------------------------------------------------*/
5147tSirRetStatus
5148limEnableHTNonGfProtection(tpAniSirGlobal pMac, tANI_U8 enable,
5149 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
5150{
Jeff Johnsone7245742012-09-05 17:12:55 -07005151 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07005152 return eSIR_SUCCESS; // this protection is only for HT stations.
5153
5154 //overlapping protection configuration check.
5155 if(overlap)
5156 {
5157#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
5158 if(((psessionEntry->limSystemRole == eLIM_AP_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) && !pMac->lim.cfgProtection.overlapNonGf)
5159 {
5160 // protection disabled.
5161 PELOG3(limLog(pMac, LOG3, FL("overlap protection from NonGf is disabled\n"));)
5162 return eSIR_SUCCESS;
5163 }
5164#endif
5165 }
5166 else
5167 {
5168#ifdef WLAN_SOFTAP_FEATURE
5169 //normal protection config check
5170 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
5171 !psessionEntry->cfgProtection.nonGf)
5172 {
5173 // protection disabled.
5174 PELOG3(limLog(pMac, LOG3, FL("protection from NonGf is disabled\n"));)
5175 return eSIR_SUCCESS;
5176 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
5177#endif
5178 {
5179 //normal protection config check
5180 if(!pMac->lim.cfgProtection.nonGf)
5181 {
5182 // protection disabled.
5183 PELOG3(limLog(pMac, LOG3, FL("protection from NonGf is disabled\n"));)
5184 return eSIR_SUCCESS;
5185 }
5186 }
5187 }
5188#ifdef WLAN_SOFTAP_FEATURE
5189 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
5190 if ((enable) && (false == psessionEntry->beaconParams.llnNonGFCoexist))
5191 {
5192 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from non GF Enabled\n"));)
5193 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = true;
5194 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
5195 }
5196 else if (!enable && (true == psessionEntry->beaconParams.llnNonGFCoexist))
5197 {
5198 PELOG1(limLog(pMac, LOG1, FL("===> Protection from Non GF Disabled\n"));)
5199 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = false;
5200 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
5201 }
5202 }else
5203#endif
5204 {
5205 if ((enable) && (false == psessionEntry->beaconParams.llnNonGFCoexist))
5206 {
5207 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from non GF Enabled\n"));)
5208 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = true;
5209 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
5210 }
5211 else if (!enable && (true == psessionEntry->beaconParams.llnNonGFCoexist))
5212 {
5213 PELOG1(limLog(pMac, LOG1, FL("===> Protection from Non GF Disabled\n"));)
5214 pBeaconParams->llnNonGFCoexist = psessionEntry->beaconParams.llnNonGFCoexist = false;
5215 pBeaconParams->paramChangeBitmap |= PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
5216 }
5217 }
5218
5219 return eSIR_SUCCESS;
5220}
5221
5222/** -------------------------------------------------------------
5223\fn limEnableHTLsigTxopProtection
5224\brief based on cofig enables\disables LsigTxop protection.
5225\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
5226\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
5227\param tpUpdateBeaconParams pBeaconParams
5228\return None
5229 -------------------------------------------------------------*/
5230tSirRetStatus
5231limEnableHTLsigTxopProtection(tpAniSirGlobal pMac, tANI_U8 enable,
5232 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
5233{
Jeff Johnsone7245742012-09-05 17:12:55 -07005234 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 return eSIR_SUCCESS; // this protection is only for HT stations.
5236
5237 //overlapping protection configuration check.
5238 if(overlap)
5239 {
5240#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
5241 if(((psessionEntry->limSystemRole == eLIM_AP_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) && !pMac->lim.cfgProtection.overlapLsigTxop)
5242 {
5243 // protection disabled.
5244 PELOG3(limLog(pMac, LOG3, FL(" overlap protection from LsigTxop not supported is disabled\n"));)
5245 return eSIR_SUCCESS;
5246 }
5247#endif
5248 }
5249 else
5250 {
5251#ifdef WLAN_SOFTAP_FEATURE
5252 //normal protection config check
5253 if((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
5254 !psessionEntry->cfgProtection.lsigTxop)
5255 {
5256 // protection disabled.
5257 PELOG3(limLog(pMac, LOG3, FL(" protection from LsigTxop not supported is disabled\n"));)
5258 return eSIR_SUCCESS;
5259 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE)
5260#endif
5261 {
5262 //normal protection config check
5263 if(!pMac->lim.cfgProtection.lsigTxop)
5264 {
5265 // protection disabled.
5266 PELOG3(limLog(pMac, LOG3, FL(" protection from LsigTxop not supported is disabled\n"));)
5267 return eSIR_SUCCESS;
5268 }
5269 }
5270 }
5271
5272
5273#ifdef WLAN_SOFTAP_FEATURE
5274 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
5275 if ((enable) && (false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
5276 {
5277 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from LsigTxop Enabled\n"));)
5278 pBeaconParams->fLsigTXOPProtectionFullSupport = psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = true;
5279 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
5280 }
5281 else if (!enable && (true == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
5282 {
5283 PELOG1(limLog(pMac, LOG1, FL("===> Protection from LsigTxop Disabled\n"));)
5284 pBeaconParams->fLsigTXOPProtectionFullSupport= psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = false;
5285 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
5286 }
5287 }else
5288#endif
5289 {
5290 if ((enable) && (false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
5291 {
5292 PELOG1(limLog(pMac, LOG1, FL(" => Prtection from LsigTxop Enabled\n"));)
5293 pBeaconParams->fLsigTXOPProtectionFullSupport = psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = true;
5294 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
5295 }
5296 else if (!enable && (true == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport))
5297 {
5298 PELOG1(limLog(pMac, LOG1, FL("===> Protection from LsigTxop Disabled\n"));)
5299 pBeaconParams->fLsigTXOPProtectionFullSupport= psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = false;
5300 pBeaconParams->paramChangeBitmap |= PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
5301 }
5302 }
5303 return eSIR_SUCCESS;
5304}
5305//FIXME_PROTECTION : need to check for no APSD whenever we want to enable this protection.
5306//This check will be done at the caller.
5307/** -------------------------------------------------------------
5308\fn limEnableHtRifsProtection
5309\brief based on cofig enables\disables Rifs protection.
5310\param tANI_U8 enable : 1=> enable protection, 0=> disable protection.
5311\param tANI_U8 overlap: 1=> called from overlap context, 0 => called from assoc context.
5312\param tpUpdateBeaconParams pBeaconParams
5313\return None
5314 -------------------------------------------------------------*/
5315tSirRetStatus
5316limEnableHtRifsProtection(tpAniSirGlobal pMac, tANI_U8 enable,
5317 tANI_U8 overlap, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
5318{
Jeff Johnsone7245742012-09-05 17:12:55 -07005319 if(!psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 return eSIR_SUCCESS; // this protection is only for HT stations.
5321
5322
5323 //overlapping protection configuration check.
5324 if(overlap)
5325 {
5326#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
5327 if(((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||(psessionEntry == eLIM_BT_AMP_AP_ROLE))&& !pMac->lim.cfgProtection.overlapRifs)
5328 {
5329 // protection disabled.
5330 PELOG3(limLog(pMac, LOG3, FL(" overlap protection from Rifs is disabled\n"));)
5331 return eSIR_SUCCESS;
5332 }
5333#endif
5334 }
5335 else
5336 {
5337#ifdef WLAN_SOFTAP_FEATURE
5338 //normal protection config check
5339 if((psessionEntry->limSystemRole == eLIM_AP_ROLE) &&
5340 !psessionEntry->cfgProtection.rifs)
5341 {
5342 // protection disabled.
5343 PELOG3(limLog(pMac, LOG3, FL(" protection from Rifs is disabled\n"));)
5344 return eSIR_SUCCESS;
5345 }else if(psessionEntry->limSystemRole != eLIM_AP_ROLE )
5346#endif
5347 {
5348 //normal protection config check
5349 if(!pMac->lim.cfgProtection.rifs)
5350 {
5351 // protection disabled.
5352 PELOG3(limLog(pMac, LOG3, FL(" protection from Rifs is disabled\n"));)
5353 return eSIR_SUCCESS;
5354 }
5355 }
5356 }
5357
5358#ifdef WLAN_SOFTAP_FEATURE
5359 if(psessionEntry->limSystemRole == eLIM_AP_ROLE){
5360 // Disabling the RIFS Protection means Enable the RIFS mode of operation in the BSS
5361 if ((!enable) && (false == psessionEntry->beaconParams.fRIFSMode))
5362 {
5363 PELOG1(limLog(pMac, LOG1, FL(" => Rifs protection Disabled\n"));)
5364 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = true;
5365 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
5366 }
5367 // Enabling the RIFS Protection means Disable the RIFS mode of operation in the BSS
5368 else if (enable && (true == psessionEntry->beaconParams.fRIFSMode))
5369 {
5370 PELOG1(limLog(pMac, LOG1, FL("===> Rifs Protection Enabled\n"));)
5371 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = false;
5372 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
5373 }
5374 }else
5375#endif
5376 {
5377 // Disabling the RIFS Protection means Enable the RIFS mode of operation in the BSS
5378 if ((!enable) && (false == psessionEntry->beaconParams.fRIFSMode))
5379 {
5380 PELOG1(limLog(pMac, LOG1, FL(" => Rifs protection Disabled\n"));)
5381 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = true;
5382 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
5383 }
5384 // Enabling the RIFS Protection means Disable the RIFS mode of operation in the BSS
5385 else if (enable && (true == psessionEntry->beaconParams.fRIFSMode))
5386 {
5387 PELOG1(limLog(pMac, LOG1, FL("===> Rifs Protection Enabled\n"));)
5388 pBeaconParams->fRIFSMode = psessionEntry->beaconParams.fRIFSMode = false;
5389 pBeaconParams->paramChangeBitmap |= PARAM_RIFS_MODE_CHANGED;
5390 }
5391 }
5392 return eSIR_SUCCESS;
5393}
5394
5395// ---------------------------------------------------------------------
5396/**
5397 * limEnableShortPreamble
5398 *
5399 * FUNCTION:
5400 * Enable/Disable short preamble
5401 *
5402 * LOGIC:
5403 *
5404 * ASSUMPTIONS:
5405 *
5406 * NOTE:
5407 *
5408 * @param enable Flag to enable/disable short preamble
5409 * @return None
5410 */
5411
5412tSirRetStatus
5413limEnableShortPreamble(tpAniSirGlobal pMac, tANI_U8 enable, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
5414{
5415 tANI_U32 val;
5416
5417 if (wlan_cfgGetInt(pMac, WNI_CFG_SHORT_PREAMBLE, &val) != eSIR_SUCCESS)
5418 {
5419 /* Could not get short preamble enabled flag from CFG. Log error. */
5420 limLog(pMac, LOGP, FL("could not retrieve short preamble flag\n"));
5421 return eSIR_FAILURE;
5422 }
5423
5424 if (!val)
5425 return eSIR_SUCCESS;
5426
5427 if (wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_PREAMBLE_ENABLED, &val) != eSIR_SUCCESS)
5428 {
5429 limLog(pMac, LOGP, FL("could not retrieve 11G short preamble switching enabled flag\n"));
5430 return eSIR_FAILURE;
5431 }
5432
5433 if (!val) // 11G short preamble switching is disabled.
5434 return eSIR_SUCCESS;
5435
5436 if ( psessionEntry->limSystemRole == eLIM_AP_ROLE )
5437 {
5438 if (enable && (psessionEntry->beaconParams.fShortPreamble == 0))
5439 {
5440 PELOG1(limLog(pMac, LOG1, FL("===> Short Preamble Enabled\n"));)
5441 psessionEntry->beaconParams.fShortPreamble = true;
5442 pBeaconParams->fShortPreamble = (tANI_U8) psessionEntry->beaconParams.fShortPreamble;
5443 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_PREAMBLE_CHANGED;
5444 }
5445 else if (!enable && (psessionEntry->beaconParams.fShortPreamble == 1))
5446 {
5447 PELOG1(limLog(pMac, LOG1, FL("===> Short Preamble Disabled\n"));)
5448 psessionEntry->beaconParams.fShortPreamble = false;
5449 pBeaconParams->fShortPreamble = (tANI_U8) psessionEntry->beaconParams.fShortPreamble;
5450 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_PREAMBLE_CHANGED;
5451 }
5452 }
5453
5454 return eSIR_SUCCESS;
5455 }
5456
5457/**
5458 * limTxComplete
5459 *
5460 * Function:
5461 * This is LIM's very own "TX MGMT frame complete" completion routine.
5462 *
5463 * Logic:
5464 * LIM wants to send a MGMT frame (broadcast or unicast)
5465 * LIM allocates memory using palPktAlloc( ..., **pData, **pPacket )
5466 * LIM transmits the MGMT frame using the API:
5467 * halTxFrame( ... pPacket, ..., (void *) limTxComplete, pData )
5468 * HDD, via halTxFrame/DXE, "transfers" the packet over to BMU
5469 * HDD, if it determines that a TX completion routine (in this case
5470 * limTxComplete) has been provided, will invoke this callback
5471 * LIM will try to free the TX MGMT packet that was earlier allocated, in order
5472 * to send this MGMT frame, using the PAL API palPktFree( ... pData, pPacket )
5473 *
5474 * Assumptions:
5475 * Presently, this is ONLY being used for MGMT frames/packets
5476 * TODO:
5477 * Would it do good for LIM to have some sort of "signature" validation to
5478 * ensure that the pData argument passed in was a buffer that was actually
5479 * allocated by LIM and/or is not corrupted?
5480 *
5481 * Note: FIXME and TODO
5482 * Looks like palPktFree() is interested in pPacket. But, when this completion
5483 * routine is called, only pData is made available to LIM!!
5484 *
5485 * @param void A pointer to pData. Shouldn't it be pPacket?!
5486 *
5487 * @return none
5488 */
5489void limTxComplete( tHalHandle hHal, void *pData )
5490{
5491 tpAniSirGlobal pMac;
5492 pMac = (tpAniSirGlobal)hHal;
5493
5494#ifdef FIXME_PRIMA
5495 /* the trace logic needs to be fixed for Prima. Refer to CR 306075 */
5496#ifdef TRACE_RECORD
5497 {
5498 tpSirMacMgmtHdr mHdr;
5499 v_U8_t *pRxBd;
5500 vos_pkt_t *pVosPkt;
5501 VOS_STATUS vosStatus;
5502
5503
5504
5505 pVosPkt = (vos_pkt_t *)pData;
5506 vosStatus = vos_pkt_peek_data( pVosPkt, 0, (v_PVOID_t *)&pRxBd, WLANHAL_RX_BD_HEADER_SIZE);
5507
5508 if(VOS_IS_STATUS_SUCCESS(vosStatus))
5509 {
5510 mHdr = WDA_GET_RX_MAC_HEADER(pRxBd);
Jeff Johnsone7245742012-09-05 17:12:55 -07005511 MTRACE(macTrace(pMac, TRACE_CODE_TX_COMPLETE, NO_SESSION, mHdr->fc.subType);)
Jeff Johnson295189b2012-06-20 16:38:30 -07005512
5513 }
5514 }
5515#endif
5516#endif
5517
5518 palPktFree( pMac->hHdd,
5519 HAL_TXRX_FRM_802_11_MGMT,
5520 (void *) NULL, // this is ignored and will likely be removed from this API
5521 (void *) pData ); // lim passed in pPacket in the pData pointer that is given in this completion routine
5522}
5523
5524/**
5525 * \brief This function updates lim global structure, if CB parameters in the BSS
5526 * have changed, and sends an indication to HAL also with the
5527 * updated HT Parameters.
5528 * This function does not detect the change in the primary channel, that is done as part
5529 * of channel Swtich IE processing.
5530 * If STA is configured with '20Mhz only' mode, then this function does not do anything
5531 * This function changes the CB mode, only if the self capability is set to '20 as well as 40Mhz'
5532 *
5533 *
5534 * \param pMac Pointer to global MAC structure
5535 *
5536 * \param pRcvdHTInfo Pointer to HT Info IE obtained from a Beacon or
5537 * Probe Response
5538 *
5539 * \param bssIdx BSS Index of the Bss to which Station is associated.
5540 *
5541 *
5542 */
5543
5544void limUpdateStaRunTimeHTSwitchChnlParams( tpAniSirGlobal pMac,
5545 tDot11fIEHTInfo *pHTInfo,
5546 tANI_U8 bssIdx,
5547 tpPESession psessionEntry)
5548{
Jeff Johnsone7245742012-09-05 17:12:55 -07005549 ePhyChanBondState secondaryChnlOffset = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07005550#if !defined WLAN_FEATURE_VOWIFI
5551 tANI_U32 localPwrConstraint;
5552#endif
5553
5554 //If self capability is set to '20Mhz only', then do not change the CB mode.
5555#ifdef WLAN_SOFTAP_FEATURE
5556 if( !limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry ))
5557#else
5558 if( !limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET ))
5559#endif
5560 return;
5561
5562#if !defined WLAN_FEATURE_VOWIFI
5563 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
5564 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg\n" ));
5565 return;
5566 }
5567#endif
5568
Jeff Johnsone7245742012-09-05 17:12:55 -07005569 if ( psessionEntry->htSecondaryChannelOffset != ( tANI_U8 ) pHTInfo->secondaryChannelOffset ||
5570 psessionEntry->htRecommendedTxWidthSet != ( tANI_U8 ) pHTInfo->recommendedTxWidthSet )
Jeff Johnson295189b2012-06-20 16:38:30 -07005571 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005572 psessionEntry->htSecondaryChannelOffset = ( ePhyChanBondState ) pHTInfo->secondaryChannelOffset;
5573 psessionEntry->htRecommendedTxWidthSet = ( tANI_U8 ) pHTInfo->recommendedTxWidthSet;
5574 if ( eHT_CHANNEL_WIDTH_40MHZ == psessionEntry->htRecommendedTxWidthSet )
5575 secondaryChnlOffset = (ePhyChanBondState)pHTInfo->secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07005576
5577 // Notify HAL
5578 limLog( pMac, LOGW, FL( "Channel Information in HT IE change"
5579 "d; sending notification to HAL.\n" ) );
5580 limLog( pMac, LOGW, FL( "Primary Channel: %d, Secondary Chan"
5581 "nel Offset: %d, Channel Width: %d\n" ),
5582 pHTInfo->primaryChannel, secondaryChnlOffset,
Jeff Johnsone7245742012-09-05 17:12:55 -07005583 psessionEntry->htRecommendedTxWidthSet );
Jeff Johnson295189b2012-06-20 16:38:30 -07005584
5585#if defined WLAN_FEATURE_VOWIFI
5586 limSendSwitchChnlParams( pMac, ( tANI_U8 ) pHTInfo->primaryChannel,
5587 secondaryChnlOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
5588#else
5589 limSendSwitchChnlParams( pMac, ( tANI_U8 ) pHTInfo->primaryChannel,
5590 secondaryChnlOffset, (tPowerdBm)localPwrConstraint, psessionEntry->peSessionId);
5591#endif
5592
5593 //In case of IBSS, if STA should update HT Info IE in its beacons.
5594 if (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole)
5595 {
5596 schSetFixedBeaconFields(pMac,psessionEntry);
5597 }
5598
5599 }
5600} // End limUpdateStaRunTimeHTParams.
5601
5602/**
5603 * \brief This function updates the lim global structure, if any of the
5604 * HT Capabilities have changed.
5605 *
5606 *
5607 * \param pMac Pointer to Global MAC structure
5608 *
5609 * \param pHTCapability Pointer to HT Capability Information Element
5610 * obtained from a Beacon or Probe Response
5611 *
5612 *
5613 *
5614 */
5615
5616void limUpdateStaRunTimeHTCapability( tpAniSirGlobal pMac,
5617 tDot11fIEHTCaps *pHTCaps )
5618{
5619
5620 if ( pMac->lim.gHTLsigTXOPProtection != ( tANI_U8 ) pHTCaps->lsigTXOPProtection )
5621 {
5622 pMac->lim.gHTLsigTXOPProtection = ( tANI_U8 ) pHTCaps->lsigTXOPProtection;
5623 // Send change notification to HAL
5624 }
5625
5626 if ( pMac->lim.gHTAMpduDensity != ( tANI_U8 ) pHTCaps->mpduDensity )
5627 {
5628 pMac->lim.gHTAMpduDensity = ( tANI_U8 ) pHTCaps->mpduDensity;
5629 // Send change notification to HAL
5630 }
5631
5632 if ( pMac->lim.gHTMaxRxAMpduFactor != ( tANI_U8 ) pHTCaps->maxRxAMPDUFactor )
5633 {
5634 pMac->lim.gHTMaxRxAMpduFactor = ( tANI_U8 ) pHTCaps->maxRxAMPDUFactor;
5635 // Send change notification to HAL
5636 }
5637
5638
5639} // End limUpdateStaRunTimeHTCapability.
5640
5641/**
5642 * \brief This function updates lim global structure, if any of the HT
5643 * Info Parameters have changed.
5644 *
5645 *
5646 * \param pMac Pointer to the global MAC structure
5647 *
5648 * \param pHTInfo Pointer to the HT Info IE obtained from a Beacon or
5649 * Probe Response
5650 *
5651 *
5652 */
5653
5654void limUpdateStaRunTimeHTInfo( tpAniSirGlobal pMac,
5655 tDot11fIEHTInfo *pHTInfo , tpPESession psessionEntry)
5656{
Jeff Johnsone7245742012-09-05 17:12:55 -07005657 if ( psessionEntry->htSecondaryChannelOffset != ( tANI_U8)pHTInfo->secondaryChannelOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005659 psessionEntry->htSecondaryChannelOffset = ( ePhyChanBondState )pHTInfo->secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07005660 // Send change notification to HAL
5661 }
5662
Jeff Johnsone7245742012-09-05 17:12:55 -07005663 if ( psessionEntry->htRecommendedTxWidthSet != ( tANI_U8 )pHTInfo->recommendedTxWidthSet )
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005665 psessionEntry->htRecommendedTxWidthSet = ( tANI_U8 )pHTInfo->recommendedTxWidthSet;
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 // Send change notification to HAL
5667 }
5668
5669 if ( psessionEntry->beaconParams.fRIFSMode != ( tANI_U8 )pHTInfo->rifsMode )
5670 {
5671 psessionEntry->beaconParams.fRIFSMode = ( tANI_U8 )pHTInfo->rifsMode;
5672 // Send change notification to HAL
5673 }
5674
5675 if ( pMac->lim.gHTServiceIntervalGranularity != ( tANI_U8 )pHTInfo->serviceIntervalGranularity )
5676 {
5677 pMac->lim.gHTServiceIntervalGranularity = ( tANI_U8 )pHTInfo->serviceIntervalGranularity;
5678 // Send change notification to HAL
5679 }
5680
5681 if ( pMac->lim.gHTOperMode != ( tSirMacHTOperatingMode )pHTInfo->opMode )
5682 {
5683 pMac->lim.gHTOperMode = ( tSirMacHTOperatingMode )pHTInfo->opMode;
5684 // Send change notification to HAL
5685 }
5686
5687 if ( psessionEntry->beaconParams.llnNonGFCoexist != pHTInfo->nonGFDevicesPresent )
5688 {
5689 psessionEntry->beaconParams.llnNonGFCoexist = ( tANI_U8 )pHTInfo->nonGFDevicesPresent;
5690 }
5691
5692 if ( pMac->lim.gHTSTBCBasicMCS != ( tANI_U8 )pHTInfo->basicSTBCMCS )
5693 {
5694 pMac->lim.gHTSTBCBasicMCS = ( tANI_U8 )pHTInfo->basicSTBCMCS;
5695 // Send change notification to HAL
5696 }
5697
5698 if ( pMac->lim.gHTDualCTSProtection != ( tANI_U8 )pHTInfo->dualCTSProtection )
5699 {
5700 pMac->lim.gHTDualCTSProtection = ( tANI_U8 )pHTInfo->dualCTSProtection;
5701 // Send change notification to HAL
5702 }
5703
5704 if ( pMac->lim.gHTSecondaryBeacon != ( tANI_U8 )pHTInfo->secondaryBeacon )
5705 {
5706 pMac->lim.gHTSecondaryBeacon = ( tANI_U8 )pHTInfo->secondaryBeacon;
5707 // Send change notification to HAL
5708 }
5709
5710 if ( psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport != ( tANI_U8 )pHTInfo->lsigTXOPProtectionFullSupport )
5711 {
5712 psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport = ( tANI_U8 )pHTInfo->lsigTXOPProtectionFullSupport;
5713 // Send change notification to HAL
5714 }
5715
5716 if ( pMac->lim.gHTPCOActive != ( tANI_U8 )pHTInfo->pcoActive )
5717 {
5718 pMac->lim.gHTPCOActive = ( tANI_U8 )pHTInfo->pcoActive;
5719 // Send change notification to HAL
5720 }
5721
5722 if ( pMac->lim.gHTPCOPhase != ( tANI_U8 )pHTInfo->pcoPhase )
5723 {
5724 pMac->lim.gHTPCOPhase = ( tANI_U8 )pHTInfo->pcoPhase;
5725 // Send change notification to HAL
5726 }
5727
5728} // End limUpdateStaRunTimeHTInfo.
5729
5730
5731/** -------------------------------------------------------------
5732\fn limProcessHalIndMessages
5733\brief callback function for HAL indication
5734\param tpAniSirGlobal pMac
5735\param tANI_U32 mesgId
5736\param void *mesgParam
5737\return tSirRetStatu - status
5738 -------------------------------------------------------------*/
5739
5740tSirRetStatus limProcessHalIndMessages(tpAniSirGlobal pMac, tANI_U32 msgId, void *msgParam )
5741{
5742 //its PE's responsibility to free msgparam when its done extracting the message parameters.
5743 tSirMsgQ msg;
5744
5745 switch(msgId)
5746 {
5747 case SIR_LIM_DEL_TS_IND:
5748 case SIR_LIM_ADD_BA_IND:
5749 case SIR_LIM_DEL_BA_ALL_IND:
5750 case SIR_LIM_DELETE_STA_CONTEXT_IND:
5751 case SIR_LIM_BEACON_GEN_IND:
5752 msg.type = (tANI_U16) msgId;
5753 msg.bodyptr = msgParam;
5754 msg.bodyval = 0;
5755 break;
5756
5757 default:
5758 palFreeMemory(pMac->hHdd, msgParam);
5759 limLog(pMac, LOGP, FL("invalid message id = %d received\n"), msgId);
5760 return eSIR_FAILURE;
5761 }
5762
5763 if (limPostMsgApi(pMac, &msg) != eSIR_SUCCESS)
5764 {
5765 palFreeMemory(pMac->hHdd, msgParam);
5766 limLog(pMac, LOGP, FL("limPostMsgApi failed for msgid = %d"), msg.type);
5767 return eSIR_FAILURE;
5768 }
5769 return eSIR_SUCCESS;
5770}
5771
5772/** -------------------------------------------------------------
5773\fn limValidateDeltsReq
5774\brief Validates DelTs req originated by SME or by HAL and also sends halMsg_DelTs to HAL
5775\param tpAniSirGlobal pMac
5776\param tpSirDeltsReq pDeltsReq
5777\param tSirMacAddr peerMacAddr
5778\return eSirRetStatus - status
5779 -------------------------------------------------------------*/
5780
5781tSirRetStatus
5782limValidateDeltsReq(tpAniSirGlobal pMac, tpSirDeltsReq pDeltsReq, tSirMacAddr peerMacAddr,tpPESession psessionEntry)
5783{
5784 tpDphHashNode pSta;
5785 tANI_U8 tsStatus;
5786 tSirMacTSInfo *tsinfo;
5787 tANI_U32 i;
5788 tANI_U8 tspecIdx;
5789 /* if sta
5790 * - verify assoc state
5791 * - del tspec locally
5792 * if ap,
5793 * - verify sta is in assoc state
5794 * - del sta tspec locally
5795 */
5796 if(pDeltsReq == NULL)
5797 {
5798 PELOGE(limLog(pMac, LOGE, FL("Delete TS request pointer is NULL\n"));)
5799 return eSIR_FAILURE;
5800 }
5801
5802 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
5803 {
5804 tANI_U32 val;
5805
5806 // station always talks to the AP
5807 pSta = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
5808
5809 val = sizeof(tSirMacAddr);
5810 #if 0
5811 if (wlan_cfgGetStr(pMac, WNI_CFG_BSSID, peerMacAddr, &val) != eSIR_SUCCESS)
5812 {
5813 /// Could not get BSSID from CFG. Log error.
5814 limLog(pMac, LOGP, FL("could not retrieve BSSID\n"));
5815 return eSIR_FAILURE;
5816 }
5817 #endif// TO SUPPORT BT-AMP
5818 sirCopyMacAddr(peerMacAddr,psessionEntry->bssId);
5819
5820 }
5821 else
5822 {
5823 tANI_U16 assocId;
5824 tANI_U8 *macaddr = (tANI_U8 *) peerMacAddr;
5825
5826 assocId = pDeltsReq->aid;
5827 if (assocId != 0)
5828 pSta = dphGetHashEntry(pMac, assocId, &psessionEntry->dph.dphHashTable);
5829 else
5830 pSta = dphLookupHashEntry(pMac, pDeltsReq->macAddr, &assocId, &psessionEntry->dph.dphHashTable);
5831
5832 if (pSta != NULL)
5833 // TBD: check sta assoc state as well
5834 for (i =0; i < sizeof(tSirMacAddr); i++)
5835 macaddr[i] = pSta->staAddr[i];
5836 }
5837
5838 if (pSta == NULL)
5839 {
5840 PELOGE(limLog(pMac, LOGE, "Cannot find station context for delts req\n");)
5841 return eSIR_FAILURE;
5842 }
5843
5844 if ((! pSta->valid) ||
5845 (pSta->mlmStaContext.mlmState != eLIM_MLM_LINK_ESTABLISHED_STATE))
5846 {
5847 PELOGE(limLog(pMac, LOGE, "Invalid Sta (or state) for DelTsReq\n");)
5848 return eSIR_FAILURE;
5849 }
5850
5851 pDeltsReq->req.wsmTspecPresent = 0;
5852 pDeltsReq->req.wmeTspecPresent = 0;
5853 pDeltsReq->req.lleTspecPresent = 0;
5854
5855 if ((pSta->wsmEnabled) &&
5856 (pDeltsReq->req.tspec.tsinfo.traffic.accessPolicy != SIR_MAC_ACCESSPOLICY_EDCA))
5857 pDeltsReq->req.wsmTspecPresent = 1;
5858 else if (pSta->wmeEnabled)
5859 pDeltsReq->req.wmeTspecPresent = 1;
5860 else if (pSta->lleEnabled)
5861 pDeltsReq->req.lleTspecPresent = 1;
5862 else
5863 {
5864 PELOGW(limLog(pMac, LOGW, FL("DELTS_REQ ignore - qos is disabled\n"));)
5865 return eSIR_FAILURE;
5866 }
5867
5868 tsinfo = pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.tsinfo
5869 : &pDeltsReq->req.tsinfo;
5870 PELOG1(limLog(pMac, LOG1,
5871 FL("received DELTS_REQ message (wmeTspecPresent = %d, lleTspecPresent = %d, wsmTspecPresent = %d, tsid %d, up %d, direction = %d)\n"),
5872 pDeltsReq->req.wmeTspecPresent, pDeltsReq->req.lleTspecPresent, pDeltsReq->req.wsmTspecPresent,
5873 tsinfo->traffic.tsid, tsinfo->traffic.userPrio, tsinfo->traffic.direction);)
5874
5875 // if no Access Control, ignore the request
5876#if (defined(ANI_PRODUCT_TYPE_AP) || defined(ANI_PRODUCT_TYPE_AP_SDK))
5877 if ((tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_EDCA))
5878 if (((psessionEntry->limSystemRole == eLIM_AP_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))&&
5879 (! psessionEntry->gLimEdcaParamsBC[upToAc(tsinfo->traffic.userPrio)].aci.acm))
5880 || (((psessionEntry->limSystemRole != eLIM_AP_ROLE) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
5881 (! psessionEntry->gLimEdcaParams[upToAc(tsinfo->traffic.userPrio)].aci.acm)))
5882 {
5883 limLog(pMac, LOGW, FL("DelTs with acecssPolicy = %d and UP %d , AC = %d has no AC - ignoring request\n"),
5884 tsinfo->traffic.accessPolicy, tsinfo->traffic.userPrio, upToAc(tsinfo->traffic.userPrio));
5885 return eSIR_FAILURE;
5886 }
5887#endif
5888
5889 if (limAdmitControlDeleteTS(pMac, pSta->assocId, tsinfo, &tsStatus, &tspecIdx)
5890 != eSIR_SUCCESS)
5891 {
5892 PELOGE(limLog(pMac, LOGE, "ERROR DELTS request for sta assocId %d (tsid %d, up %d)\n",
5893 pSta->assocId, tsinfo->traffic.tsid, tsinfo->traffic.userPrio);)
5894 return eSIR_FAILURE;
5895 }
5896 else if ((tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA) ||
5897 (tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_BOTH))
5898 {
5899 //edca only now.
5900 }
5901 else
5902 {
5903 if((tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_EDCA) &&
5904 psessionEntry->gLimEdcaParams[upToAc(tsinfo->traffic.userPrio)].aci.acm)
5905 {
5906 //send message to HAL to delete TS
Jeff Johnsone7245742012-09-05 17:12:55 -07005907 if(eSIR_SUCCESS != limSendHalMsgDelTs(pMac, pSta->staIndex, tspecIdx, pDeltsReq->req, psessionEntry->peSessionId))
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 {
5909 limLog(pMac, LOGW, FL("DelTs with UP %d failed in limSendHalMsgDelTs - ignoring request\n"),
5910 tsinfo->traffic.userPrio);
5911 return eSIR_FAILURE;
5912 }
5913 }
5914 }
5915 return eSIR_SUCCESS;
5916}
5917
5918/** -------------------------------------------------------------
5919\fn limRegisterHalIndCallBack
5920\brief registers callback function to HAL for any indication.
5921\param tpAniSirGlobal pMac
5922\return none.
5923 -------------------------------------------------------------*/
5924void
5925limRegisterHalIndCallBack(tpAniSirGlobal pMac)
5926{
5927 tSirMsgQ msg;
5928 tpHalIndCB pHalCB;
5929
5930 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pHalCB, sizeof(tHalIndCB)))
5931 {
5932 limLog(pMac, LOGP, FL("palAllocateMemory() failed\n"));
5933 return;
5934 }
5935
5936 pHalCB->pHalIndCB = limProcessHalIndMessages;
5937
5938 msg.type = WDA_REGISTER_PE_CALLBACK;
5939 msg.bodyptr = pHalCB;
5940 msg.bodyval = 0;
5941
Jeff Johnsone7245742012-09-05 17:12:55 -07005942 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 if(eSIR_SUCCESS != wdaPostCtrlMsg(pMac, &msg))
5944 {
5945 palFreeMemory(pMac->hHdd, pHalCB);
5946 limLog(pMac, LOGP, FL("wdaPostCtrlMsg() failed\n"));
5947 }
5948
5949 return;
5950}
5951
5952
5953/** -------------------------------------------------------------
5954\fn limProcessAddBaInd
5955
5956\brief handles the BA activity check timeout indication coming from HAL.
5957 Validates the request, posts request for sending addBaReq message for every candidate in the list.
5958\param tpAniSirGlobal pMac
5959\param tSirMsgQ limMsg
5960\return None
5961-------------------------------------------------------------*/
5962void
5963limProcessAddBaInd(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
5964{
5965 tANI_U8 i;
5966 tANI_U8 tid;
5967 tANI_U16 assocId;
5968 tpDphHashNode pSta;
5969 tpAddBaCandidate pBaCandidate;
5970 tANI_U32 baCandidateCnt;
5971 tpBaActivityInd pBaActivityInd;
5972 tpPESession psessionEntry;
5973 tANI_U8 sessionId;
5974
5975
5976
5977 if(limMsg->bodyptr == NULL)
5978 return;
5979
5980 pBaActivityInd = (tpBaActivityInd)limMsg->bodyptr;
5981 baCandidateCnt = pBaActivityInd->baCandidateCnt;
5982
5983 if((psessionEntry = peFindSessionByBssid(pMac,pBaActivityInd->bssId,&sessionId))== NULL)
5984 {
5985 limLog(pMac, LOGE,FL("session does not exist for given BSSId\n"));
5986 palFreeMemory(pMac->hHdd, limMsg->bodyptr);
5987 return;
5988 }
5989
5990 //if we are not HT capable we don't need to handle BA timeout indication from HAL.
Jeff Johnsone7245742012-09-05 17:12:55 -07005991 if( (baCandidateCnt > pMac->lim.maxStation) || !psessionEntry->htCapability )
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 {
5993 palFreeMemory(pMac->hHdd, limMsg->bodyptr);
5994 return;
5995 }
5996
5997 //delete the complete dialoguetoken linked list
5998 limDeleteDialogueTokenList(pMac);
5999 pBaCandidate = (tpAddBaCandidate) (((tANI_U8*)pBaActivityInd) + sizeof(tBaActivityInd));
6000
6001 for(i=0; i<baCandidateCnt; i++, pBaCandidate++)
6002 {
6003 pSta = dphLookupHashEntry(pMac, pBaCandidate->staAddr, &assocId, &psessionEntry->dph.dphHashTable);
6004 if( (NULL == pSta) || (!pSta->valid))
6005 continue;
6006
6007 for (tid=0; tid<STACFG_MAX_TC; tid++)
6008 {
6009 if( (eBA_DISABLE == pSta->tcCfg[tid].fUseBATx) &&
6010 (pBaCandidate->baInfo[tid].fBaEnable))
6011 {
6012 PELOG2(limLog(pMac, LOG2, FL("BA setup for staId = %d, TID: %d, SSN:%d.\n"),
6013 pSta->staIndex, tid, pBaCandidate->baInfo[tid].startingSeqNum);)
6014 limPostMlmAddBAReq(pMac, pSta, tid, pBaCandidate->baInfo[tid].startingSeqNum,psessionEntry);
6015 }
6016 }
6017 }
6018 palFreeMemory(pMac->hHdd, limMsg->bodyptr);
6019 return;
6020}
6021
6022
6023/** -------------------------------------------------------------
6024\fn limDelAllBASessions
6025\brief Deletes all the exisitng BA sessions.
6026\ Note : This API is provided for Mac OSx only. The reason for this is that Mac OSx may not
6027\ restart after CFG update.
6028\param tpAniSirGlobal pMac
6029\return None
6030-------------------------------------------------------------*/
6031
6032void
6033limDelAllBASessions(tpAniSirGlobal pMac)
6034{
6035 tANI_U32 i;
6036 tANI_U8 tid;
6037 tpDphHashNode pSta;
6038
6039 tpPESession psessionEntry = &pMac->lim.gpSession[0]; //TBD-RAJESH HOW TO GET sessionEntry?????
6040 for(tid = 0; tid < STACFG_MAX_TC; tid++)
6041 {
6042 if((eLIM_AP_ROLE == psessionEntry->limSystemRole) ||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)||
6043 (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole))
6044 {
6045 for(i = 0; i < pMac->lim.maxStation; i++)
6046 {
6047 pSta = psessionEntry->dph.dphHashTable.pDphNodeArray + i;
6048 if (pSta && pSta->added)
6049 {
6050 if(eBA_ENABLE == pSta->tcCfg[tid].fUseBATx)
6051 {
6052 limPostMlmDelBAReq(pMac, pSta, eBA_INITIATOR, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
6053 }
6054 else if(eBA_ENABLE == pSta->tcCfg[tid].fUseBARx)
6055 {
6056 limPostMlmDelBAReq(pMac, pSta, eBA_RECIPIENT, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
6057 }
6058 }
6059 }
6060 }
6061 else if((eLIM_STA_ROLE == psessionEntry->limSystemRole)||(eLIM_BT_AMP_STA_ROLE == psessionEntry->limSystemRole))
6062 {
6063 pSta = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
6064 if (pSta && pSta->added)
6065 {
6066 if(eBA_ENABLE == pSta->tcCfg[tid].fUseBATx)
6067 {
6068 limPostMlmDelBAReq(pMac, pSta, eBA_INITIATOR, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
6069 }
6070 if(eBA_ENABLE == pSta->tcCfg[tid].fUseBARx)
6071 {
6072 limPostMlmDelBAReq(pMac, pSta, eBA_RECIPIENT, tid, eSIR_MAC_UNSPEC_FAILURE_REASON,psessionEntry);
6073 }
6074 }
6075 }
6076 }
6077}
6078/** -------------------------------------------------------------
6079\fn limProcessDelTsInd
6080\brief handles the DeleteTS indication coming from HAL or generated by PE itself in some error cases.
6081 Validates the request, sends the DelTs action frame to the Peer and sends DelTs indicatoin to HDD.
6082\param tpAniSirGlobal pMac
6083\param tSirMsgQ limMsg
6084\return None
6085-------------------------------------------------------------*/
6086void
6087limProcessDelTsInd(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
6088{
6089 tpDphHashNode pSta;
6090 tpDelTsParams pDelTsParam = (tpDelTsParams) (limMsg->bodyptr);
6091 tpSirDeltsReq pDelTsReq = NULL;
6092 tSirMacAddr peerMacAddr;
6093 tpSirDeltsReqInfo pDelTsReqInfo;
6094 tpLimTspecInfo pTspecInfo;
6095 tpPESession psessionEntry;
6096 tANI_U8 sessionId;
6097
6098if((psessionEntry = peFindSessionByBssid(pMac,pDelTsParam->bssId,&sessionId))== NULL)
6099 {
6100 limLog(pMac, LOGE,FL("session does not exist for given BssId\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07006101 palFreeMemory(pMac->hHdd, (void *)(limMsg->bodyptr));
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 return;
6103 }
6104
6105 pTspecInfo = &(pMac->lim.tspecInfo[pDelTsParam->tspecIdx]);
6106 if(pTspecInfo->inuse == false)
6107 {
6108 PELOGE(limLog(pMac, LOGE, FL("tspec entry with index %d is not in use\n"), pDelTsParam->tspecIdx);)
6109 goto error1;
6110 }
6111
6112 pSta = dphGetHashEntry(pMac, pTspecInfo->assocId, &psessionEntry->dph.dphHashTable);
6113 if(pSta == NULL)
6114 {
6115 limLog(pMac, LOGE, FL("Could not find entry in DPH table for assocId = %d\n"),
6116 pTspecInfo->assocId);
6117 goto error1;
6118 }
6119
6120 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pDelTsReq, sizeof(tSirDeltsReq)))
6121 {
6122 PELOGE(limLog(pMac, LOGE, FL("palAllocateMemory() failed\n"));)
6123 goto error1;
6124 }
6125
6126 palZeroMemory( pMac->hHdd, (tANI_U8 *)pDelTsReq, sizeof(tSirDeltsReq));
6127
6128 if(pSta->wmeEnabled)
6129 palCopyMemory(pMac->hHdd, &(pDelTsReq->req.tspec), &(pTspecInfo->tspec), sizeof(tSirMacTspecIE));
6130 else
6131 palCopyMemory(pMac->hHdd, &(pDelTsReq->req.tsinfo), &(pTspecInfo->tspec.tsinfo), sizeof(tSirMacTSInfo));
6132
6133
6134 //validate the req
6135 if (eSIR_SUCCESS != limValidateDeltsReq(pMac, pDelTsReq, peerMacAddr,psessionEntry))
6136 {
6137 PELOGE(limLog(pMac, LOGE, FL("limValidateDeltsReq failed\n"));)
6138 goto error2;
6139 }
6140 PELOG1(limLog(pMac, LOG1, "Sent DELTS request to station with assocId = %d MacAddr = %x:%x:%x:%x:%x:%x\n",
6141 pDelTsReq->aid, peerMacAddr[0], peerMacAddr[1], peerMacAddr[2],
6142 peerMacAddr[3], peerMacAddr[4], peerMacAddr[5]);)
6143
6144 limSendDeltsReqActionFrame(pMac, peerMacAddr, pDelTsReq->req.wmeTspecPresent, &pDelTsReq->req.tsinfo, &pDelTsReq->req.tspec,
6145 psessionEntry);
6146
6147 // prepare and send an sme indication to HDD
6148 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pDelTsReqInfo, sizeof(tSirDeltsReqInfo)))
6149 {
6150 PELOGE(limLog(pMac, LOGE, FL("palAllocateMemory() failed\n"));)
6151 goto error3;
6152 }
6153 palZeroMemory( pMac->hHdd, (tANI_U8 *)pDelTsReqInfo, sizeof(tSirDeltsReqInfo));
6154
6155 if(pSta->wmeEnabled)
6156 palCopyMemory(pMac->hHdd, &(pDelTsReqInfo->tspec), &(pTspecInfo->tspec), sizeof(tSirMacTspecIE));
6157 else
6158 palCopyMemory(pMac->hHdd, &(pDelTsReqInfo->tsinfo), &(pTspecInfo->tspec.tsinfo), sizeof(tSirMacTSInfo));
6159
6160 limSendSmeDeltsInd(pMac, pDelTsReqInfo, pDelTsReq->aid,psessionEntry);
6161
6162error3:
6163 palFreeMemory(pMac->hHdd, (void *) pDelTsReqInfo);
6164error2:
6165 palFreeMemory(pMac->hHdd, (void *) pDelTsReq);
6166error1:
6167 palFreeMemory(pMac->hHdd, (void *)(limMsg->bodyptr));
6168 return;
6169}
6170
6171/**
6172 * \brief Setup an A-MPDU/BA session
6173 *
6174 * \sa limPostMlmAddBAReq
6175 *
6176 * \param pMac The global tpAniSirGlobal object
6177 *
6178 * \param pStaDs DPH Hash Node object of peer STA
6179 *
6180 * \param tid TID for which a BA is being setup.
6181 * If this is set to 0xFFFF, then we retrieve
6182 * the default TID from the CFG
6183 *
6184 * \return eSIR_SUCCESS if setup completes successfully
6185 * eSIR_FAILURE is some problem is encountered
6186 */
6187tSirRetStatus limPostMlmAddBAReq( tpAniSirGlobal pMac,
6188 tpDphHashNode pStaDs,
6189 tANI_U8 tid, tANI_U16 startingSeqNum,tpPESession psessionEntry)
6190{
6191 tSirRetStatus status = eSIR_SUCCESS;
6192 tpLimMlmAddBAReq pMlmAddBAReq;
6193 tpDialogueToken dialogueTokenNode;
6194 tANI_U32 val = 0;
6195
6196 // Check if the peer is a 11n capable STA
6197 // FIXME - Need a 11n peer indication in DPH.
6198 // For now, using the taurusPeer attribute
6199 //if( 0 == pStaDs->taurusPeer == )
6200 //return eSIR_SUCCESS;
6201
6202 // Allocate for LIM_MLM_ADDBA_REQ
6203 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
6204 (void **) &pMlmAddBAReq,
6205 sizeof( tLimMlmAddBAReq )))
6206 {
6207 limLog( pMac, LOGP, FL("palAllocateMemory failed\n"));
6208 status = eSIR_MEM_ALLOC_FAILED;
6209 goto returnFailure;
6210 }
6211
6212 palZeroMemory( pMac->hHdd, (void *) pMlmAddBAReq, sizeof( tLimMlmAddBAReq ));
6213
6214 // Copy the peer MAC
6215 palCopyMemory( pMac->hHdd,
6216 pMlmAddBAReq->peerMacAddr,
6217 pStaDs->staAddr,
6218 sizeof( tSirMacAddr ));
6219
6220 // Update the TID
6221 pMlmAddBAReq->baTID = tid;
6222
6223 // Determine the supported BA policy of local STA
6224 // for the TID of interest
6225 pMlmAddBAReq->baPolicy = (pStaDs->baPolicyFlag >> tid) & 0x1;
6226
6227 // BA Buffer Size
6228 // Requesting the ADDBA recipient to populate the size.
6229 // If ADDBA is accepted, a non-zero buffer size should
6230 // be returned in the ADDBA Rsp
6231 pMlmAddBAReq->baBufferSize = 0;
6232
6233 limLog( pMac, LOGW,
6234 FL( "Requesting an ADDBA to setup a %s BA session with STA %d for TID %d\n" ),
6235 (pMlmAddBAReq->baPolicy ? "Immediate": "Delayed"),
6236 pStaDs->staIndex,
6237 tid );
6238
6239 // BA Timeout
6240 // pMlmAddBAReq->baTimeout = pMac->hal.halMac.baTimeout; // In TU's
6241 if (wlan_cfgGetInt(pMac, WNI_CFG_BA_TIMEOUT, &val) != eSIR_SUCCESS)
6242 {
6243 limLog(pMac, LOGE, FL("could not retrieve BA TIME OUT Param CFG\n"));
6244 status = eSIR_FAILURE;
6245 goto returnFailure;
6246 }
6247 pMlmAddBAReq->baTimeout = val; // In TU's
6248
6249 // ADDBA Failure Timeout
6250 // FIXME_AMPDU - Need to retrieve this from CFG.
6251 //right now we are not checking for response timeout. so this field is dummy just to be compliant with the spec.
6252 pMlmAddBAReq->addBAFailureTimeout = 2000; // In TU's
6253
6254 // BA Starting Sequence Number
6255 pMlmAddBAReq->baSSN = startingSeqNum;
6256
6257 /* Update PE session Id*/
6258 pMlmAddBAReq->sessionId = psessionEntry->peSessionId;
6259
6260 LIM_SET_STA_BA_STATE(pStaDs, tid, eLIM_BA_STATE_WT_ADD_RSP);
6261
6262 if( NULL == (dialogueTokenNode = limAssignDialogueToken(pMac)))
6263 goto returnFailure;
6264
6265 pMlmAddBAReq->baDialogToken = dialogueTokenNode->token;
6266 //set assocId and tid information in the lim linked list
6267 dialogueTokenNode->assocId = pStaDs->assocId;
6268 dialogueTokenNode->tid = tid;
6269 // Send ADDBA Req to MLME
6270 limPostMlmMessage( pMac,
6271 LIM_MLM_ADDBA_REQ,
6272 (tANI_U32 *) pMlmAddBAReq );
6273
6274returnFailure:
6275
6276 return status;
6277}
6278
6279/**
6280 * \brief Post LIM_MLM_ADDBA_RSP to MLME. MLME
6281 * will then send an ADDBA Rsp to peer MAC entity
6282 * with the appropriate ADDBA status code
6283 *
6284 * \sa limPostMlmAddBARsp
6285 *
6286 * \param pMac The global tpAniSirGlobal object
6287 *
6288 * \param peerMacAddr MAC address of peer entity that will
6289 * be the recipient of this ADDBA Rsp
6290 *
6291 * \param baStatusCode ADDBA Rsp status code
6292 *
6293 * \param baDialogToken ADDBA Rsp dialog token
6294 *
6295 * \param baTID TID of interest
6296 *
6297 * \param baPolicy The BA policy
6298 *
6299 * \param baBufferSize The BA buffer size
6300 *
6301 * \param baTimeout BA timeout in TU's
6302 *
6303 * \return eSIR_SUCCESS if setup completes successfully
6304 * eSIR_FAILURE is some problem is encountered
6305 */
6306tSirRetStatus limPostMlmAddBARsp( tpAniSirGlobal pMac,
6307 tSirMacAddr peerMacAddr,
6308 tSirMacStatusCodes baStatusCode,
6309 tANI_U8 baDialogToken,
6310 tANI_U8 baTID,
6311 tANI_U8 baPolicy,
6312 tANI_U16 baBufferSize,
6313 tANI_U16 baTimeout,
6314 tpPESession psessionEntry)
6315{
6316tSirRetStatus status = eSIR_SUCCESS;
6317tpLimMlmAddBARsp pMlmAddBARsp;
6318
6319 // Allocate for LIM_MLM_ADDBA_RSP
6320 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
6321 (void **) &pMlmAddBARsp,
6322 sizeof( tLimMlmAddBARsp )))
6323 {
6324 limLog( pMac, LOGE,
6325 FL("palAllocateMemory failed with error code %d\n"),
6326 status );
6327
6328 status = eSIR_MEM_ALLOC_FAILED;
6329 goto returnFailure;
6330 }
6331
6332 palZeroMemory( pMac->hHdd, (void *) pMlmAddBARsp, sizeof( tLimMlmAddBARsp ));
6333
6334 // Copy the peer MAC
6335 palCopyMemory( pMac->hHdd,
6336 pMlmAddBARsp->peerMacAddr,
6337 peerMacAddr,
6338 sizeof( tSirMacAddr ));
6339
6340 pMlmAddBARsp->baDialogToken = baDialogToken;
6341 pMlmAddBARsp->addBAResultCode = baStatusCode;
6342 pMlmAddBARsp->baTID = baTID;
6343 pMlmAddBARsp->baPolicy = baPolicy;
6344 pMlmAddBARsp->baBufferSize = baBufferSize;
6345 pMlmAddBARsp->baTimeout = baTimeout;
6346
6347 /* UPdate PE session ID*/
6348 pMlmAddBARsp->sessionId = psessionEntry->peSessionId;
6349
6350 // Send ADDBA Rsp to MLME
6351 limPostMlmMessage( pMac,
6352 LIM_MLM_ADDBA_RSP,
6353 (tANI_U32 *) pMlmAddBARsp );
6354
6355returnFailure:
6356
6357 return status;
6358}
6359
6360/**
6361 * \brief Post LIM_MLM_DELBA_REQ to MLME. MLME
6362 * will then send an DELBA Ind to peer MAC entity
6363 * with the appropriate DELBA status code
6364 *
6365 * \sa limPostMlmDelBAReq
6366 *
6367 * \param pMac The global tpAniSirGlobal object
6368 *
6369 * \param pSta DPH Hash Node object of peer MAC entity
6370 * for which the BA session is being deleted
6371 *
6372 * \param baDirection DELBA direction
6373 *
6374 * \param baTID TID for which the BA session is being deleted
6375 *
6376 * \param baReasonCode DELBA Req reason code
6377 *
6378 * \return eSIR_SUCCESS if setup completes successfully
6379 * eSIR_FAILURE is some problem is encountered
6380 */
6381tSirRetStatus limPostMlmDelBAReq( tpAniSirGlobal pMac,
6382 tpDphHashNode pSta,
6383 tANI_U8 baDirection,
6384 tANI_U8 baTID,
6385 tSirMacReasonCodes baReasonCode,
6386 tpPESession psessionEntry)
6387{
6388tSirRetStatus status = eSIR_SUCCESS;
6389tpLimMlmDelBAReq pMlmDelBAReq;
6390tLimBAState curBaState;
6391
6392if(NULL == pSta)
6393 return eSIR_FAILURE;
6394
6395LIM_GET_STA_BA_STATE(pSta, baTID, &curBaState);
6396
6397 // Need to validate the current BA State.
6398 if( eLIM_BA_STATE_IDLE != curBaState)
6399 {
6400 limLog( pMac, LOGE,
6401 FL( "Received unexpected DELBA REQ when STA BA state for tid = %d is %d\n" ),
6402 baTID,
6403 curBaState);
6404
6405 status = eSIR_FAILURE;
6406 goto returnFailure;
6407 }
6408
6409 // Allocate for LIM_MLM_DELBA_REQ
6410 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
6411 (void **) &pMlmDelBAReq,
6412 sizeof( tLimMlmDelBAReq )))
6413 {
6414 limLog( pMac, LOGE,
6415 FL("palAllocateMemory failed with error code %d\n"),
6416 status );
6417
6418 status = eSIR_MEM_ALLOC_FAILED;
6419 goto returnFailure;
6420 }
6421
6422 palZeroMemory( pMac->hHdd, (void *) pMlmDelBAReq, sizeof( tLimMlmDelBAReq ));
6423
6424 // Copy the peer MAC
6425 palCopyMemory( pMac->hHdd,
6426 pMlmDelBAReq->peerMacAddr,
6427 pSta->staAddr,
6428 sizeof( tSirMacAddr ));
6429
6430 pMlmDelBAReq->baDirection = baDirection;
6431 pMlmDelBAReq->baTID = baTID;
6432 pMlmDelBAReq->delBAReasonCode = baReasonCode;
6433
6434 /* Update PE session ID*/
6435 pMlmDelBAReq->sessionId = psessionEntry->peSessionId;
6436
6437 //we don't have valid BA session for the given direction.
6438 // HDD wants to get the BA session deleted on PEER in this case.
6439 // in this case we just need to send DelBA to the peer.
6440 if(((eBA_RECIPIENT == baDirection) && (eBA_DISABLE == pSta->tcCfg[baTID].fUseBARx)) ||
6441 ((eBA_INITIATOR == baDirection) && (eBA_DISABLE == pSta->tcCfg[baTID].fUseBATx)))
6442 {
6443 // Send DELBA Ind over the air
6444 if( eSIR_SUCCESS !=
6445 (status = limSendDelBAInd( pMac, pMlmDelBAReq,psessionEntry)))
6446 status = eSIR_FAILURE;
6447
6448 palFreeMemory(pMac->hHdd, (void*) pMlmDelBAReq);
6449 return status;
6450 }
6451
6452
6453 // Update the BA state in STA
6454 LIM_SET_STA_BA_STATE(pSta, pMlmDelBAReq->baTID, eLIM_BA_STATE_WT_DEL_RSP);
6455
6456 // Send DELBA Req to MLME
6457 limPostMlmMessage( pMac,
6458 LIM_MLM_DELBA_REQ,
6459 (tANI_U32 *) pMlmDelBAReq );
6460
6461returnFailure:
6462
6463 return status;
6464}
6465
6466/**
6467 * \brief Send WDA_ADDBA_REQ to HAL, in order
6468 * to setup a new BA session with a peer
6469 *
6470 * \sa limPostMsgAddBAReq
6471 *
6472 * \param pMac The global tpAniSirGlobal object
6473 *
6474 * \param pSta Runtime, STA-related configuration cached
6475 * in the HashNode object
6476 *
6477 * \param baDialogToken The Action Frame dialog token
6478 *
6479 * \param baTID TID for which the BA session is being setup
6480 *
6481 * \param baPolicy BA Policy
6482 *
6483 * \param baBufferSize The requested BA buffer size
6484 *
6485 * \param baTimeout BA Timeout. 0 indicates no BA timeout enforced
6486 *
6487 * \param baSSN Starting Sequence Number for this BA session
6488 *
6489 * \param baDirection BA Direction: 1 - Initiator, 0 - Recipient
6490 *
6491 * \return none
6492 *
6493 */
6494tSirRetStatus limPostMsgAddBAReq( tpAniSirGlobal pMac,
6495 tpDphHashNode pSta,
6496 tANI_U8 baDialogToken,
6497 tANI_U8 baTID,
6498 tANI_U8 baPolicy,
6499 tANI_U16 baBufferSize,
6500 tANI_U16 baTimeout,
6501 tANI_U16 baSSN,
6502 tANI_U8 baDirection,
6503 tpPESession psessionEntry)
6504{
6505tpAddBAParams pAddBAParams = NULL;
6506tSirRetStatus retCode = eSIR_SUCCESS;
6507eHalStatus status;
6508tSirMsgQ msgQ;
6509
6510#ifdef WLAN_SOFTAP_VSTA_FEATURE
6511 // we can only do BA on "hard" STAs
6512 if (!(IS_HWSTA_IDX(pSta->staIndex)))
6513 {
6514 retCode = eHAL_STATUS_FAILURE;
6515 goto returnFailure;
6516 }
6517#endif //WLAN_SOFTAP_VSTA_FEATURE
6518
6519 // Allocate for WDA_ADDBA_REQ
6520 if( eHAL_STATUS_SUCCESS !=
6521 (status = palAllocateMemory( pMac->hHdd,
6522 (void **) &pAddBAParams,
6523 sizeof( tAddBAParams ))))
6524 {
6525 limLog( pMac, LOGE,
6526 FL("palAllocateMemory failed with error code %d\n"),
6527 status );
6528
6529 retCode = eSIR_MEM_ALLOC_FAILED;
6530 goto returnFailure;
6531 }
6532
6533 palZeroMemory( pMac->hHdd, (void *) pAddBAParams, sizeof( tAddBAParams ));
6534
6535 // Copy the peer MAC address
6536 palCopyMemory( pMac->hHdd,
6537 (void *) pAddBAParams->peerMacAddr,
6538 (void *) pSta->staAddr,
6539 sizeof( tSirMacAddr ));
6540
6541 // Populate the REQ parameters
6542 pAddBAParams->staIdx = pSta->staIndex;
6543 pAddBAParams->baDialogToken = baDialogToken;
6544 pAddBAParams->baTID = baTID;
6545 pAddBAParams->baPolicy = baPolicy;
6546 pAddBAParams->baBufferSize = baBufferSize;
6547 pAddBAParams->baTimeout = baTimeout;
6548 pAddBAParams->baSSN = baSSN;
6549 pAddBAParams->baDirection = baDirection;
6550 pAddBAParams->respReqd = 1;
6551
6552 /* UPdate PE session ID */
6553 pAddBAParams->sessionId = psessionEntry->peSessionId;
6554
6555 // Post WDA_ADDBA_REQ to HAL.
6556 msgQ.type = WDA_ADDBA_REQ;
6557 //
6558 // FIXME_AMPDU
6559 // A global counter (dialog token) is required to keep track of
6560 // all PE <-> HAL communication(s)
6561 //
6562 msgQ.reserved = 0;
6563 msgQ.bodyptr = pAddBAParams;
6564 msgQ.bodyval = 0;
6565
6566 limLog( pMac, LOGW,
6567 FL( "Sending WDA_ADDBA_REQ..." ));
6568
6569 //defer any other message until we get response back.
6570 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
6571
Jeff Johnsone7245742012-09-05 17:12:55 -07006572 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006573#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
6574 limDiagEventReport(pMac, WLAN_PE_DIAG_HAL_ADDBA_REQ_EVENT, psessionEntry, 0, 0);
6575#endif //FEATURE_WLAN_DIAG_SUPPORT
6576
6577 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
6578 limLog( pMac, LOGE,
6579 FL("Posting WDA_ADDBA_REQ to HAL failed! Reason = %d\n"),
6580 retCode );
6581 else
6582 return retCode;
6583
6584returnFailure:
6585
6586 // Clean-up...
6587 if( NULL != pAddBAParams )
6588 palFreeMemory( pMac->hHdd, (void *) pAddBAParams );
6589
6590 return retCode;
6591
6592}
6593
6594/**
6595 * \brief Send WDA_DELBA_IND to HAL, in order
6596 * to delete an existing BA session with peer
6597 *
6598 * \sa limPostMsgDelBAInd
6599 *
6600 * \param pMac The global tpAniSirGlobal object
6601 *
6602 * \param pSta Runtime, STA-related configuration cached
6603 * in the HashNode object
6604 *
6605 * \param baTID TID for which the BA session is being setup
6606 *
6607 * \param baDirection Identifies whether the DELBA Ind was
6608 * sent by the BA initiator or recipient
6609 *
6610 * \return none
6611 *
6612 */
6613tSirRetStatus limPostMsgDelBAInd( tpAniSirGlobal pMac,
6614 tpDphHashNode pSta,
6615 tANI_U8 baTID,
6616 tANI_U8 baDirection,
6617 tpPESession psessionEntry)
6618{
6619tpDelBAParams pDelBAParams = NULL;
6620tSirRetStatus retCode = eSIR_SUCCESS;
6621eHalStatus status;
6622tSirMsgQ msgQ;
6623
6624 // Allocate for SIR_HAL_DELBA_IND
6625 if( eHAL_STATUS_SUCCESS !=
6626 (status = palAllocateMemory( pMac->hHdd,
6627 (void **) &pDelBAParams,
6628 sizeof( tDelBAParams ))))
6629 {
6630 limLog( pMac, LOGE,
6631 FL("palAllocateMemory failed with error code %d\n"),
6632 status );
6633
6634 retCode = eSIR_MEM_ALLOC_FAILED;
6635 goto returnFailure;
6636 }
6637
6638 palZeroMemory( pMac->hHdd, (void *) pDelBAParams, sizeof( tDelBAParams ));
6639
6640 // Populate the REQ parameters
6641 pDelBAParams->staIdx = pSta->staIndex;
6642 pDelBAParams->baTID = baTID;
6643 pDelBAParams->baDirection = baDirection;
6644
6645 /* Update PE session ID */
6646
6647
6648 //TBD-RAJESH Updating of the session ID is requird for SIR_HAL_DELBA_IND?????
6649 //pDelBAParams->sessionId = psessionEntry->peSessionId;
6650
6651 // Post WDA_DELBA_IND to HAL.
6652 msgQ.type = WDA_DELBA_IND;
6653 //
6654 // FIXME:
6655 // A global counter (dialog token) is required to keep track of
6656 // all PE <-> HAL communication(s)
6657 //
6658 msgQ.reserved = 0;
6659 msgQ.bodyptr = pDelBAParams;
6660 msgQ.bodyval = 0;
6661
6662 limLog( pMac, LOGW,
6663 FL( "Sending SIR_HAL_DELBA_IND..." ));
6664
Jeff Johnsone7245742012-09-05 17:12:55 -07006665 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006666#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM //FEATURE_WLAN_DIAG_SUPPORT
6667 limDiagEventReport(pMac, WLAN_PE_DIAG_HAL_DELBA_IND_EVENT, psessionEntry, 0, 0);
6668#endif //FEATURE_WLAN_DIAG_SUPPORT
6669
6670 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
6671 limLog( pMac, LOGE,
6672 FL("Posting WDA_DELBA_IND to HAL failed! Reason = %d\n"),
6673 retCode );
6674 else
6675 {
6676 // Update LIM's internal cache...
6677 if( eBA_INITIATOR == baDirection)
6678 {
6679 pSta->tcCfg[baTID].fUseBATx = 0;
6680 pSta->tcCfg[baTID].txBufSize = 0;
6681 }
6682 else
6683 {
6684 pSta->tcCfg[baTID].fUseBARx = 0;
6685 pSta->tcCfg[baTID].rxBufSize = 0;
6686 }
6687
6688 return retCode;
6689 }
6690
6691returnFailure:
6692
6693 // Clean-up...
6694 if( NULL != pDelBAParams )
6695 palFreeMemory( pMac->hHdd, (void *) pDelBAParams );
6696
6697 return retCode;
6698
6699}
6700
6701/**
6702 * @function : limPostSMStateUpdate()
6703 *
6704 * @brief : This function Updates the HAL and Softmac about the change in the STA's SMPS state.
6705 *
6706 * LOGIC:
6707 *
6708 * ASSUMPTIONS:
6709 * NA
6710 *
6711 * NOTE:
6712 * NA
6713 *
6714 * @param pMac - Pointer to Global MAC structure
6715 * @param limMsg - Lim Message structure object with the MimoPSparam in body
6716 * @return None
6717 */
6718tSirRetStatus
6719limPostSMStateUpdate(tpAniSirGlobal pMac,
6720 tANI_U16 staIdx, tSirMacHTMIMOPowerSaveState state)
6721{
6722 tSirRetStatus retCode = eSIR_SUCCESS;
6723 tSirMsgQ msgQ;
6724 eHalStatus status;
6725 tpSetMIMOPS pMIMO_PSParams;
6726
6727 msgQ.reserved = 0;
6728 msgQ.type = WDA_SET_MIMOPS_REQ;
6729
6730 // Allocate for WDA_SET_MIMOPS_REQ
6731 status = palAllocateMemory( pMac->hHdd, (void **) &pMIMO_PSParams, sizeof( tSetMIMOPS));
6732 if( eHAL_STATUS_SUCCESS != status) {
6733 limLog( pMac, LOGP,FL(" palAllocateMemory failed with error code %d\n"), status );
6734 return eSIR_MEM_ALLOC_FAILED;
6735 }
6736
6737 pMIMO_PSParams->htMIMOPSState = state;
6738 pMIMO_PSParams->staIdx = staIdx;
6739 pMIMO_PSParams->fsendRsp = true;
6740 msgQ.bodyptr = pMIMO_PSParams;
6741 msgQ.bodyval = 0;
6742
6743 limLog( pMac, LOG2, FL( "Sending WDA_SET_MIMOPS_REQ..." ));
6744
Jeff Johnsone7245742012-09-05 17:12:55 -07006745 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006746 retCode = wdaPostCtrlMsg( pMac, &msgQ );
6747 if (eSIR_SUCCESS != retCode)
6748 {
6749 limLog( pMac, LOGP, FL("Posting WDA_SET_MIMOPS_REQ to HAL failed! Reason = %d\n"), retCode );
6750 palFreeMemory(pMac->hHdd, (void *) pMIMO_PSParams);
6751 return retCode;
6752 }
6753
6754 return retCode;
6755}
6756
6757void limPktFree (
6758 tpAniSirGlobal pMac,
6759 eFrameType frmType,
6760 tANI_U8 *pRxPacketInfo,
6761 void *pBody)
6762{
6763 (void) pMac; (void) frmType; (void) pRxPacketInfo; (void) pBody;
6764#if defined ANI_OS_TYPE_LINUX || defined ANI_OS_TYPE_OSX
6765 // Free up allocated SK BUF
6766 palPktFree( pMac->hHdd, frmType, pRxPacketInfo, pBody) ;
6767#endif
6768}
6769
6770/**
6771 * limGetBDfromRxPacket()
6772 *
6773 *FUNCTION:
6774 * This function is called to get pointer to Polaris
6775 * Buffer Descriptor containing MAC header & other control
6776 * info from the body of the message posted to LIM.
6777 *
6778 *LOGIC:
6779 * NA
6780 *
6781 *ASSUMPTIONS:
6782 * NA
6783 *
6784 *NOTE:
6785 * NA
6786 *
6787 * @param body - Received message body
6788 * @param pRxPacketInfo - Pointer to received BD
6789 * @return None
6790 */
6791
6792void
6793limGetBDfromRxPacket(tpAniSirGlobal pMac, void *body, tANI_U32 **pRxPacketInfo)
6794{
6795#if defined (ANI_OS_TYPE_LINUX) || defined (ANI_OS_TYPE_OSX)
6796#ifndef GEN6_ONWARDS
6797 palGetPacketDataPtr( pMac->hHdd, HAL_TXRX_FRM_802_11_MGMT, (void *) body, (void **) pRxPacketInfo );
6798#endif //GEN6_ONWARDS
6799#else
6800 *pRxPacketInfo = (tANI_U32 *) body;
6801#endif
6802} /*** end limGetBDfromRxPacket() ***/
6803
6804
6805
6806
6807
6808void limRessetScanChannelInfo(tpAniSirGlobal pMac)
6809{
6810 palZeroMemory(pMac->hHdd, &pMac->lim.scanChnInfo, sizeof(tLimScanChnInfo));
6811}
6812
6813
6814void limAddScanChannelInfo(tpAniSirGlobal pMac, tANI_U8 channelId)
6815{
6816 tANI_U8 i;
6817 tANI_BOOLEAN fFound = eANI_BOOLEAN_FALSE;
6818
6819 for(i = 0; i < pMac->lim.scanChnInfo.numChnInfo; i++)
6820 {
6821 if(pMac->lim.scanChnInfo.scanChn[i].channelId == channelId)
6822 {
6823 pMac->lim.scanChnInfo.scanChn[i].numTimeScan++;
6824 fFound = eANI_BOOLEAN_TRUE;
6825 break;
6826 }
6827 }
6828 if(eANI_BOOLEAN_FALSE == fFound)
6829 {
6830 if(pMac->lim.scanChnInfo.numChnInfo < SIR_MAX_SUPPORTED_CHANNEL_LIST)
6831 {
6832 pMac->lim.scanChnInfo.scanChn[pMac->lim.scanChnInfo.numChnInfo].channelId = channelId;
6833 pMac->lim.scanChnInfo.scanChn[pMac->lim.scanChnInfo.numChnInfo++].numTimeScan = 1;
6834 }
6835 else
6836 {
6837 PELOGW(limLog(pMac, LOGW, FL(" -- number of channels exceed mac\n"));)
6838 }
6839 }
6840}
6841
6842
6843/**
6844 * @function : limIsChannelValidForChannelSwitch()
6845 *
6846 * @brief : This function checks if the channel to which AP
6847 * is expecting us to switch, is a valid channel for us.
6848 * LOGIC:
6849 *
6850 * ASSUMPTIONS:
6851 * NA
6852 *
6853 * NOTE:
6854 * NA
6855 *
6856 * @param pMac - Pointer to Global MAC structure
6857 * @param channel - New channel to which we are expected to move
6858 * @return None
6859 */
6860tAniBool
6861limIsChannelValidForChannelSwitch(tpAniSirGlobal pMac, tANI_U8 channel)
6862{
6863 tANI_U8 index;
6864 tANI_U32 validChannelListLen = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6865 tSirMacChanNum validChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6866
6867 if (wlan_cfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
6868 (tANI_U8 *)validChannelList,
6869 (tANI_U32 *)&validChannelListLen) != eSIR_SUCCESS)
6870 {
6871 PELOGE(limLog(pMac, LOGE, FL("could not retrieve valid channel list\n"));)
6872 return (eSIR_FALSE);
6873 }
6874
6875 for(index = 0; index < validChannelListLen; index++)
6876 {
6877 if(validChannelList[index] == channel)
6878 return (eSIR_TRUE);
6879 }
6880
6881 /* channel does not belong to list of valid channels */
6882 return (eSIR_FALSE);
6883}
6884
6885/**------------------------------------------------------
6886\fn __limFillTxControlParams
6887\brief Fill the message for stopping/resuming tx.
6888
6889\param pMac
6890\param pTxCtrlMsg - Pointer to tx control message.
6891\param type - Which way we want to stop/ resume tx.
6892\param mode - To stop/resume.
6893 -------------------------------------------------------*/
6894static eHalStatus
6895__limFillTxControlParams(tpAniSirGlobal pMac, tpTxControlParams pTxCtrlMsg,
6896 tLimQuietTxMode type, tLimControlTx mode)
6897{
6898
6899 //TBD-RAJESH HOW TO GET sessionEntry?????
6900 tpPESession psessionEntry = &pMac->lim.gpSession[0];
6901
6902 if (mode == eLIM_STOP_TX)
6903 pTxCtrlMsg->stopTx = eANI_BOOLEAN_TRUE;
6904 else
6905 pTxCtrlMsg->stopTx = eANI_BOOLEAN_FALSE;
6906
6907 switch (type)
6908 {
6909 case eLIM_TX_ALL:
6910 /** Stops/resumes transmission completely */
6911 pTxCtrlMsg->fCtrlGlobal = 1;
6912 break;
6913
6914 case eLIM_TX_BSS_BUT_BEACON:
6915 /** Stops/resumes transmission on a particular BSS. Stopping BSS, doesnt
6916 * stop beacon transmission.
6917 */
6918 pTxCtrlMsg->ctrlBss = 1;
6919 pTxCtrlMsg->bssBitmap |= (1 << psessionEntry->bssIdx);
6920 break;
6921
6922 case eLIM_TX_STA:
6923 /** Memory for station bitmap is allocated dynamically in caller of this
6924 * so decode properly here and fill the bitmap. Now not implemented,
6925 * fall through.
6926 */
6927 case eLIM_TX_BSS:
6928 //Fall thru...
6929 default:
6930 PELOGW(limLog(pMac, LOGW, FL("Invalid case: Not Handled\n"));)
6931 return eHAL_STATUS_FAILURE;
6932 }
6933
6934 return eHAL_STATUS_SUCCESS;
6935}
6936
6937/**
6938 * @function : limFrameTransmissionControl()
6939 *
6940 * @brief : This API is called by the user to halt/resume any frame
6941 * transmission from the device. If stopped, all frames will be
6942 * queued starting from hardware. Then back-pressure
6943 * is built till the driver.
6944 * LOGIC:
6945 *
6946 * ASSUMPTIONS:
6947 * NA
6948 *
6949 * NOTE:
6950 * NA
6951 *
6952 * @param pMac - Pointer to Global MAC structure
6953 * @return None
6954 */
6955void limFrameTransmissionControl(tpAniSirGlobal pMac, tLimQuietTxMode type, tLimControlTx mode)
6956{
6957
6958 eHalStatus status = eHAL_STATUS_FAILURE;
6959 tpTxControlParams pTxCtrlMsg;
6960 tSirMsgQ msgQ;
6961 tANI_U8 nBytes = 0; // No of bytes required for station bitmap.
6962
6963 /** Allocate only required number of bytes for station bitmap
6964 * Make it to align to 4 byte boundary */
6965 nBytes = (tANI_U8)HALMSG_NUMBYTES_STATION_BITMAP(pMac->lim.maxStation);
6966
6967 status = palAllocateMemory(pMac->hHdd, (void **) &pTxCtrlMsg,
6968 (sizeof(*pTxCtrlMsg) + nBytes));
6969 if (status != eHAL_STATUS_SUCCESS)
6970 {
6971 limLog(pMac, LOGP, FL("palAllocateMemory() failed\n"));
6972 return;
6973 }
6974
6975 status = palZeroMemory(pMac->hHdd, (void *) pTxCtrlMsg,
6976 (sizeof(*pTxCtrlMsg) + nBytes));
6977 if (status != eHAL_STATUS_SUCCESS)
6978 {
6979 palFreeMemory(pMac->hHdd, (void *) pTxCtrlMsg);
6980 limLog(pMac, LOGP, FL("palZeroMemory() failed, status = %d\n"), status);
6981 return;
6982 }
6983
6984 status = __limFillTxControlParams(pMac, pTxCtrlMsg, type, mode);
6985 if (status != eHAL_STATUS_SUCCESS)
6986 {
6987 palFreeMemory(pMac->hHdd, (void *) pTxCtrlMsg);
6988 limLog(pMac, LOGP, FL("__limFillTxControlParams failed, status = %d\n"), status);
6989 return;
6990 }
6991
6992 msgQ.bodyptr = (void *) pTxCtrlMsg;
6993 msgQ.bodyval = 0;
6994 msgQ.reserved = 0;
6995 msgQ.type = WDA_TRANSMISSION_CONTROL_IND;
6996
Jeff Johnsone7245742012-09-05 17:12:55 -07006997 MTRACE(macTraceMsgTx(pMac, NO_SESSION, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07006998 if(wdaPostCtrlMsg( pMac, &msgQ) != eSIR_SUCCESS)
6999 {
7000 palFreeMemory(pMac->hHdd, (void *) pTxCtrlMsg);
7001 limLog( pMac, LOGP, FL("Posting Message to HAL failed\n"));
7002 return;
7003 }
7004
7005 if (mode == eLIM_STOP_TX)
7006 {
7007 PELOG1(limLog(pMac, LOG1, FL("Stopping the transmission of all packets, indicated softmac\n"));)
7008 }
7009 else
7010 {
7011 PELOG1(limLog(pMac, LOG1, FL("Resuming the transmission of all packets, indicated softmac\n"));)
7012 }
7013 return;
7014}
7015
7016
7017/**
7018 * @function : limRestorePreChannelSwitchState()
7019 *
7020 * @brief : This API is called by the user to undo any
7021 * specific changes done on the device during
7022 * channel switch.
7023 * LOGIC:
7024 *
7025 * ASSUMPTIONS:
7026 * NA
7027 *
7028 * NOTE:
7029 * NA
7030 *
7031 * @param pMac - Pointer to Global MAC structure
7032 * @return None
7033 */
7034
7035tSirRetStatus
7036limRestorePreChannelSwitchState(tpAniSirGlobal pMac, tpPESession psessionEntry)
7037{
7038
7039 tSirRetStatus retCode = eSIR_SUCCESS;
7040#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
7041 tANI_U32 val = 0;
7042
7043 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
7044 return retCode;
7045
7046 /* Channel switch should be ready for the next time */
Jeff Johnsone7245742012-09-05 17:12:55 -07007047 psessionEntry->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07007048
7049 /* Restore the frame transmission, all the time. */
7050 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
7051
7052 /* Free to enter BMPS */
7053 limSendSmePostChannelSwitchInd(pMac);
7054
7055 //Background scan is now enabled by SME
7056 if(pMac->lim.gLimBackgroundScanTerminate == FALSE)
7057 {
7058 /* Enable background scan if already enabled, else don't bother */
7059 if ((retCode = wlan_cfgGetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD,
7060 &val)) != eSIR_SUCCESS)
7061
7062 {
7063 limLog(pMac, LOGP, FL("could not retrieve Background scan period value\n"));
7064 return (retCode);
7065 }
7066
7067 if (val > 0 && TX_TIMER_VALID(pMac->lim.limTimers.gLimBackgroundScanTimer))
7068 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007069 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_BACKGROUND_SCAN_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07007070 if(tx_timer_activate(&pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
7071 {
7072 limLog(pMac, LOGP, FL("Could not restart background scan timer, doing LOGP"));
7073 return (eSIR_FAILURE);
7074 }
7075
7076 }
7077 }
7078
7079 /* Enable heartbeat timer */
7080 if (TX_TIMER_VALID(pMac->lim.limTimers.gLimHeartBeatTimer))
7081 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007082 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId, eLIM_HEART_BEAT_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07007083 if(limActivateHearBeatTimer(pMac) != TX_SUCCESS)
7084 {
7085 limLog(pMac, LOGP, FL("Could not restart heartbeat timer, doing LOGP"));
7086 return (eSIR_FAILURE);
7087 }
7088 }
7089#endif
7090 return (retCode);
7091}
7092
7093
7094/**--------------------------------------------
7095\fn limRestorePreQuietState
7096\brief Restore the pre quiet state
7097
7098\param pMac
7099\return NONE
7100---------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07007101tSirRetStatus limRestorePreQuietState(tpAniSirGlobal pMac, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07007102{
7103
7104 tSirRetStatus retCode = eSIR_SUCCESS;
7105#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
7106 tANI_U32 val = 0;
7107
7108 if (pMac->lim.gLimSystemRole != eLIM_STA_ROLE)
7109 return retCode;
7110
7111 /* Quiet should be ready for the next time */
Jeff Johnsone7245742012-09-05 17:12:55 -07007112 psessionEntry->gLimSpecMgmt.quietState = eLIM_QUIET_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07007113
7114 /* Restore the frame transmission, all the time. */
Jeff Johnsone7245742012-09-05 17:12:55 -07007115 if (psessionEntry->gLimSpecMgmt.quietState == eLIM_QUIET_RUNNING)
Jeff Johnson295189b2012-06-20 16:38:30 -07007116 limFrameTransmissionControl(pMac, eLIM_TX_ALL, eLIM_RESUME_TX);
7117
7118
7119 //Background scan is now enabled by SME
7120 if(pMac->lim.gLimBackgroundScanTerminate == FALSE)
7121 {
7122 /* Enable background scan if already enabled, else don't bother */
7123 if ((retCode = wlan_cfgGetInt(pMac, WNI_CFG_BACKGROUND_SCAN_PERIOD,
7124 &val)) != eSIR_SUCCESS)
7125
7126 {
7127 limLog(pMac, LOGP, FL("could not retrieve Background scan period value\n"));
7128 return (retCode);
7129 }
7130
7131 if (val > 0 && TX_TIMER_VALID(pMac->lim.limTimers.gLimBackgroundScanTimer))
7132 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007133 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_BACKGROUND_SCAN_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07007134 if(tx_timer_activate(&pMac->lim.limTimers.gLimBackgroundScanTimer) != TX_SUCCESS)
7135 {
7136 limLog(pMac, LOGP, FL("Could not restart background scan timer, doing LOGP"));
7137 return (eSIR_FAILURE);
7138 }
7139
7140 }
7141 }
7142
7143 /* Enable heartbeat timer */
7144 if (TX_TIMER_VALID(pMac->lim.limTimers.gLimHeartBeatTimer))
7145 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007146 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, NO_SESSION, eLIM_HEART_BEAT_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -07007147 if(limActivateHearBeatTimer(pMac) != TX_SUCCESS)
7148 {
7149 limLog(pMac, LOGP, FL("Could not restart heartbeat timer, doing LOGP"));
7150 return (eSIR_FAILURE);
7151 }
7152 }
7153#endif
7154 return (retCode);
7155}
7156
7157
7158/**
7159 * @function: limPrepareFor11hChannelSwitch()
7160 *
7161 * @brief : This API is called by the user to prepare for
7162 * 11h channel switch. As of now, the API does
7163 * very minimal work. User can add more into the
7164 * same API if needed.
7165 * LOGIC:
7166 *
7167 * ASSUMPTIONS:
7168 * NA
7169 *
7170 * NOTE:
7171 * NA
7172 *
7173 * @param pMac - Pointer to Global MAC structure
7174 * @param psessionEntry
7175 * @return None
7176 */
7177void
7178limPrepareFor11hChannelSwitch(tpAniSirGlobal pMac, tpPESession psessionEntry)
7179{
7180#if defined(ANI_PRODUCT_TYPE_CLIENT) || defined(ANI_AP_CLIENT_SDK)
7181 if (psessionEntry->limSystemRole != eLIM_STA_ROLE)
7182 return;
7183
7184 /* Flag to indicate 11h channel switch in progress */
Jeff Johnsone7245742012-09-05 17:12:55 -07007185 psessionEntry->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_RUNNING;
Jeff Johnson295189b2012-06-20 16:38:30 -07007186
7187 /* Disable, Stop background scan if enabled and running */
7188 limDeactivateAndChangeTimer(pMac, eLIM_BACKGROUND_SCAN_TIMER);
7189
7190 /* Stop heart-beat timer to stop heartbeat disassociation */
7191 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
7192
7193 if(pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE ||
7194 pMac->lim.gLimSmeState == eLIM_SME_CHANNEL_SCAN_STATE)
7195 {
7196 PELOGE(limLog(pMac, LOGE, FL("Posting finish scan as we are in scan state\n"));)
7197 /* Stop ongoing scanning if any */
7198 if (GET_LIM_PROCESS_DEFD_MESGS(pMac))
7199 {
7200 //Set the resume channel to Any valid channel (invalid).
7201 //This will instruct HAL to set it to any previous valid channel.
7202 peSetResumeChannel(pMac, 0, 0);
7203 limSendHalFinishScanReq(pMac, eLIM_HAL_FINISH_SCAN_WAIT_STATE);
7204 }
7205 else
7206 {
7207 limRestorePreChannelSwitchState(pMac, psessionEntry);
7208 }
7209 return;
7210 }
7211 else
7212 {
7213 PELOGE(limLog(pMac, LOGE, FL("Not in scan state, start channel switch timer\n"));)
7214 /** We are safe to switch channel at this point */
7215 limStopTxAndSwitchChannel(pMac, psessionEntry->peSessionId);
7216 }
7217#endif
7218}
7219
7220
7221
7222/**----------------------------------------------------
7223\fn limGetNwType
7224
7225\brief Get type of the network from data packet or beacon
7226\param pMac
7227\param channelNum - Channel number
7228\param type - Type of packet.
7229\param pBeacon - Pointer to beacon or probe response
7230
7231\return Network type a/b/g.
7232-----------------------------------------------------*/
7233tSirNwType limGetNwType(tpAniSirGlobal pMac, tANI_U8 channelNum, tANI_U32 type, tpSchBeaconStruct pBeacon)
7234{
7235 tSirNwType nwType = eSIR_11B_NW_TYPE;
7236
7237 if (type == SIR_MAC_DATA_FRAME)
7238 {
7239 if ((channelNum > 0) && (channelNum < 15))
7240 {
7241 nwType = eSIR_11G_NW_TYPE;
7242 }
7243 else
7244 {
7245 nwType = eSIR_11A_NW_TYPE;
7246 }
7247 }
7248 else
7249 {
7250 if ((channelNum > 0) && (channelNum < 15))
7251 {
7252 int i;
7253 // 11b or 11g packet
7254 // 11g iff extended Rate IE is present or
7255 // if there is an A rate in suppRate IE
7256 for (i = 0; i < pBeacon->supportedRates.numRates; i++)
7257 {
7258 if (sirIsArate(pBeacon->supportedRates.rate[i] & 0x7f))
7259 {
7260 nwType = eSIR_11G_NW_TYPE;
7261 break;
7262 }
7263 }
7264 if (pBeacon->extendedRatesPresent)
7265 {
7266 PELOG3(limLog(pMac, LOG3, FL("Beacon, nwtype=G\n"));)
7267 nwType = eSIR_11G_NW_TYPE;
7268 }
7269 }
7270 else
7271 {
7272 // 11a packet
7273 PELOG3(limLog(pMac, LOG3,FL("Beacon, nwtype=A\n"));)
7274 nwType = eSIR_11A_NW_TYPE;
7275 }
7276 }
7277 return nwType;
7278}
7279
7280
7281/**---------------------------------------------------------
7282\fn limGetChannelFromBeacon
7283\brief To extract channel number from beacon
7284
7285\param pMac
7286\param pBeacon - Pointer to beacon or probe rsp
7287\return channel number
7288-----------------------------------------------------------*/
7289tANI_U8 limGetChannelFromBeacon(tpAniSirGlobal pMac, tpSchBeaconStruct pBeacon)
7290{
7291 tANI_U8 channelNum = 0;
7292
7293 if (pBeacon->dsParamsPresent)
7294 channelNum = pBeacon->channelNumber;
7295 else if(pBeacon->HTInfo.present)
7296 channelNum = pBeacon->HTInfo.primaryChannel;
7297 else
7298 channelNum = pBeacon->channelNumber;
7299
7300 return channelNum;
7301}
7302
7303
7304/** ---------------------------------------------------------
7305\fn limSetTspecUapsdMask
7306\brief This function sets the PE global variable:
7307\ 1) gUapsdPerAcTriggerEnableMask and
7308\ 2) gUapsdPerAcDeliveryEnableMask
7309\ based on the user priority field and direction field
7310\ in the TS Info Fields.
7311\
7312\ An AC is a trigger-enabled AC if the PSB subfield
7313\ is set to 1 in the uplink direction.
7314\ An AC is a delivery-enabled AC if the PSB subfield
7315\ is set to 1 in the down-link direction.
7316\
7317\param tpAniSirGlobal pMac
7318\param tSirMacTSInfo pTsInfo
7319\param tANI_U32 action
7320\return None
7321 ------------------------------------------------------------*/
7322void limSetTspecUapsdMask(tpAniSirGlobal pMac, tSirMacTSInfo *pTsInfo, tANI_U32 action)
7323{
7324 tANI_U8 userPrio = (tANI_U8)pTsInfo->traffic.userPrio;
7325 tANI_U16 direction = pTsInfo->traffic.direction;
7326 tANI_U8 ac = upToAc(userPrio);
7327
7328 PELOG1(limLog(pMac, LOG1, FL(" Set UAPSD mask for AC %d, direction %d, action=%d (1=set,0=clear) \n"),ac, direction, action );)
7329
7330 /* Converting AC to appropriate Uapsd Bit Mask
7331 * AC_BE(0) --> UAPSD_BITOFFSET_ACVO(3)
7332 * AC_BK(1) --> UAPSD_BITOFFSET_ACVO(2)
7333 * AC_VI(2) --> UAPSD_BITOFFSET_ACVO(1)
7334 * AC_VO(3) --> UAPSD_BITOFFSET_ACVO(0)
7335 */
7336 ac = ((~ac) & 0x3);
7337
7338 if (action == CLEAR_UAPSD_MASK)
7339 {
7340 if (direction == SIR_MAC_DIRECTION_UPLINK)
7341 pMac->lim.gUapsdPerAcTriggerEnableMask &= ~(1 << ac);
7342 else if (direction == SIR_MAC_DIRECTION_DNLINK)
7343 pMac->lim.gUapsdPerAcDeliveryEnableMask &= ~(1 << ac);
7344 else if (direction == SIR_MAC_DIRECTION_BIDIR)
7345 {
7346 pMac->lim.gUapsdPerAcTriggerEnableMask &= ~(1 << ac);
7347 pMac->lim.gUapsdPerAcDeliveryEnableMask &= ~(1 << ac);
7348 }
7349 }
7350 else if (action == SET_UAPSD_MASK)
7351 {
7352 if (direction == SIR_MAC_DIRECTION_UPLINK)
7353 pMac->lim.gUapsdPerAcTriggerEnableMask |= (1 << ac);
7354 else if (direction == SIR_MAC_DIRECTION_DNLINK)
7355 pMac->lim.gUapsdPerAcDeliveryEnableMask |= (1 << ac);
7356 else if (direction == SIR_MAC_DIRECTION_BIDIR)
7357 {
7358 pMac->lim.gUapsdPerAcTriggerEnableMask |= (1 << ac);
7359 pMac->lim.gUapsdPerAcDeliveryEnableMask |= (1 << ac);
7360 }
7361 }
7362
7363 limLog(pMac, LOGE, FL("New pMac->lim.gUapsdPerAcTriggerEnableMask = 0x%x \n"), pMac->lim.gUapsdPerAcTriggerEnableMask );
7364 limLog(pMac, LOGE, FL("New pMac->lim.gUapsdPerAcDeliveryEnableMask = 0x%x \n"), pMac->lim.gUapsdPerAcDeliveryEnableMask );
7365
7366 return;
7367}
7368
7369
7370
7371void limHandleHeartBeatTimeout(tpAniSirGlobal pMac )
7372{
7373
7374 tANI_U8 i;
7375 for(i =0;i < pMac->lim.maxBssId;i++)
7376 {
7377 if(pMac->lim.gpSession[i].valid == TRUE )
7378 {
7379 if(pMac->lim.gpSession[i].bssType == eSIR_IBSS_MODE)
7380 {
7381 limIbssHeartBeatHandle(pMac,&pMac->lim.gpSession[i]);
7382 break;
7383 }
7384
7385 if((pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) &&
7386 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_ROLE))
7387 {
7388 limHandleHeartBeatFailure(pMac,&pMac->lim.gpSession[i]);
7389 }
7390 }
7391 }
7392 for(i=0; i< pMac->lim.maxBssId; i++)
7393 {
7394 if(pMac->lim.gpSession[i].valid == TRUE )
7395 {
7396 if((pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) &&
7397 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_ROLE))
7398 {
7399 if(pMac->lim.gpSession[i].LimHBFailureStatus == eANI_BOOLEAN_TRUE)
7400 {
7401 /* Activate Probe After HeartBeat Timer incase HB Failure detected */
7402 PELOGW(limLog(pMac, LOGW,FL("Sending Probe for Session: %d\n"),
7403 i);)
7404 limDeactivateAndChangeTimer(pMac, eLIM_PROBE_AFTER_HB_TIMER);
7405 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_ACTIVATE, 0, eLIM_PROBE_AFTER_HB_TIMER));
7406 if (tx_timer_activate(&pMac->lim.limTimers.gLimProbeAfterHBTimer) != TX_SUCCESS)
7407 {
7408 limLog(pMac, LOGP, FL("Fail to re-activate Probe-after-heartbeat timer\n"));
7409 limReactivateHeartBeatTimer(pMac, &pMac->lim.gpSession[i]);
7410 }
7411 break;
7412 }
7413 }
7414 }
7415 }
7416}
7417
7418tANI_U8 limGetCurrentOperatingChannel(tpAniSirGlobal pMac)
7419{
7420 tANI_U8 i;
7421 for(i =0;i < pMac->lim.maxBssId;i++)
7422 {
7423 if(pMac->lim.gpSession[i].valid == TRUE )
7424 {
7425 if((pMac->lim.gpSession[i].bssType == eSIR_INFRASTRUCTURE_MODE) &&
7426 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_ROLE))
7427 {
7428 return pMac->lim.gpSession[i].currentOperChannel;
7429 }
7430 }
7431 }
7432 return 0;
7433}
7434
7435void limProcessAddStaRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ)
7436{
7437
7438 tpPESession psessionEntry;
7439// tANI_U8 sessionId;
7440 tpAddStaParams pAddStaParams;
7441
7442 pAddStaParams = (tpAddStaParams)limMsgQ->bodyptr;
7443
7444 if((psessionEntry = peFindSessionBySessionId(pMac,pAddStaParams->sessionId))==NULL)
7445 {
7446 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07007447 palFreeMemory(pMac, pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07007448 return;
7449 }
7450 if (psessionEntry->limSystemRole == eLIM_STA_IN_IBSS_ROLE)
7451 (void) limIbssAddStaRsp(pMac, limMsgQ->bodyptr,psessionEntry);
7452
7453 else
7454 limProcessMlmAddStaRsp(pMac, limMsgQ,psessionEntry);
7455
7456}
7457
7458
7459void limUpdateBeacon(tpAniSirGlobal pMac)
7460{
7461 tANI_U8 i;
7462
7463 for(i =0;i < pMac->lim.maxBssId;i++)
7464 {
7465 if(pMac->lim.gpSession[i].valid == TRUE )
7466 {
7467 if( ( (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) ||
7468 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_IN_IBSS_ROLE) )
7469 && (eLIM_SME_NORMAL_STATE == pMac->lim.gpSession[i].limSmeState)
7470 )
7471 {
7472 schSetFixedBeaconFields(pMac,&pMac->lim.gpSession[i]);
7473 limSendBeaconInd(pMac, &pMac->lim.gpSession[i]);
7474 }
7475 else
7476 {
7477 if( (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)||
7478 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_STA_ROLE))
7479 {
7480
7481 if(pMac->lim.gpSession[i].statypeForBss == STA_ENTRY_SELF)
7482 {
7483 schSetFixedBeaconFields(pMac,&pMac->lim.gpSession[i]);
7484 }
7485 }
7486 }
7487 }
7488 }
7489}
7490
7491void limHandleHeartBeatFailureTimeout(tpAniSirGlobal pMac)
7492{
7493 tANI_U8 i;
7494 tpPESession psessionEntry;
7495 /* Probe response is not received after HB failure. This is handled by LMM sub module. */
7496 for(i =0; i < pMac->lim.maxBssId; i++)
7497 {
7498 if(pMac->lim.gpSession[i].valid == TRUE)
7499 {
7500 psessionEntry = &pMac->lim.gpSession[i];
7501 if(psessionEntry->LimHBFailureStatus == eANI_BOOLEAN_TRUE)
7502 {
7503 limLog(pMac, LOGE, FL("Probe_hb_failure: SME %d, MLME %d, HB-Count %d\n"),psessionEntry->limSmeState,
7504 psessionEntry->limMlmState, psessionEntry->LimRxedBeaconCntDuringHB);
7505 if (psessionEntry->limMlmState == eLIM_MLM_LINK_ESTABLISHED_STATE)
7506 {
7507 if (!LIM_IS_CONNECTION_ACTIVE(psessionEntry))
7508 {
7509 limLog(pMac, LOGE, FL("Probe_hb_failure: for session:%d \n" ),psessionEntry->peSessionId);
7510 /* AP did not respond to Probe Request. Tear down link with it.*/
7511 limTearDownLinkWithAp(pMac,
7512 psessionEntry->peSessionId,
7513 eSIR_BEACON_MISSED);
7514 pMac->lim.gLimProbeFailureAfterHBfailedCnt++ ;
7515 }
7516 else // restart heartbeat timer
7517 {
7518 limReactivateHeartBeatTimer(pMac, psessionEntry);
7519 }
7520 }
7521 else
7522 {
7523 limLog(pMac, LOGE, FL("Unexpected wt-probe-timeout in state \n"));
7524 limPrintMlmState(pMac, LOGE, psessionEntry->limMlmState);
7525 limReactivateHeartBeatTimer(pMac, psessionEntry);
7526 }
7527
7528 }
7529 }
7530 }
7531 /* Deactivate Timer ProbeAfterHB Timer -> As its a oneshot timer, need not deactivate the timer */
7532 // tx_timer_deactivate(&pMac->lim.limTimers.gLimProbeAfterHBTimer);
7533}
7534
7535
7536/*
7537* This function assumes there will not be more than one IBSS session active at any time.
7538*/
7539tpPESession limIsIBSSSessionActive(tpAniSirGlobal pMac)
7540{
7541 tANI_U8 i;
7542
7543 for(i =0;i < pMac->lim.maxBssId;i++)
7544 {
7545 if( (pMac->lim.gpSession[i].valid) &&
7546 (pMac->lim.gpSession[i].limSystemRole == eLIM_STA_IN_IBSS_ROLE))
7547 return (&pMac->lim.gpSession[i]);
7548 }
7549
7550 return NULL;
7551}
7552
7553tpPESession limIsApSessionActive(tpAniSirGlobal pMac)
7554{
7555 tANI_U8 i;
7556
7557 for(i =0;i < pMac->lim.maxBssId;i++)
7558 {
7559 if( (pMac->lim.gpSession[i].valid) &&
7560 ( (pMac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE) ||
7561 (pMac->lim.gpSession[i].limSystemRole == eLIM_BT_AMP_AP_ROLE)))
7562 return (&pMac->lim.gpSession[i]);
7563 }
7564
7565 return NULL;
7566}
7567
7568/**---------------------------------------------------------
7569\fn limHandleDeferMsgError
7570\brief handles error scenario, when the msg can not be deferred.
7571\param pMac
7572\param pLimMsg LIM msg, which could not be deferred.
7573\return void
7574-----------------------------------------------------------*/
7575
7576void limHandleDeferMsgError(tpAniSirGlobal pMac, tpSirMsgQ pLimMsg)
7577{
7578 if(SIR_BB_XPORT_MGMT_MSG == pLimMsg->type)
7579 {
7580 vos_pkt_return_packet((vos_pkt_t*)pLimMsg->bodyptr);
7581 }
7582 else if(pLimMsg->bodyptr != NULL)
7583 palFreeMemory( pMac->hHdd, (tANI_U8 *) pLimMsg->bodyptr);
7584
7585}
7586
7587
7588#ifdef FEATURE_WLAN_DIAG_SUPPORT
7589/**---------------------------------------------------------
7590\fn limDiagEventReport
7591\brief This function reports Diag event
7592\param pMac
7593\param eventType
7594\param bssid
7595\param status
7596\param reasonCode
7597\return void
7598-----------------------------------------------------------*/
7599void limDiagEventReport(tpAniSirGlobal pMac, tANI_U16 eventType, tpPESession pSessionEntry, tANI_U16 status, tANI_U16 reasonCode)
7600{
7601 tSirMacAddr nullBssid = { 0, 0, 0, 0, 0, 0 };
7602 WLAN_VOS_DIAG_EVENT_DEF(peEvent, vos_event_wlan_pe_payload_type);
7603
7604 palZeroMemory(pMac->hHdd, &peEvent, sizeof(vos_event_wlan_pe_payload_type));
7605
7606 if (NULL == pSessionEntry)
7607 {
7608 palCopyMemory(pMac->hHdd, peEvent.bssid, nullBssid, sizeof(tSirMacAddr));
7609 peEvent.sme_state = (tANI_U16)pMac->lim.gLimSmeState;
7610 peEvent.mlm_state = (tANI_U16)pMac->lim.gLimMlmState;
7611
7612 }
7613 else
7614 {
7615 palCopyMemory(pMac->hHdd, peEvent.bssid, pSessionEntry->bssId, sizeof(tSirMacAddr));
7616 peEvent.sme_state = (tANI_U16)pSessionEntry->limSmeState;
7617 peEvent.mlm_state = (tANI_U16)pSessionEntry->limMlmState;
7618 }
7619 peEvent.event_type = eventType;
7620 peEvent.status = status;
7621 peEvent.reason_code = reasonCode;
7622
7623 WLAN_VOS_DIAG_EVENT_REPORT(&peEvent, EVENT_WLAN_PE);
7624 return;
7625}
7626
7627#endif /* FEATURE_WLAN_DIAG_SUPPORT */
7628
7629void limProcessAddStaSelfRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ)
7630{
7631
7632 tpAddStaSelfParams pAddStaSelfParams;
7633 tSirMsgQ mmhMsg;
7634 tpSirSmeAddStaSelfRsp pRsp;
7635
7636
7637 pAddStaSelfParams = (tpAddStaSelfParams)limMsgQ->bodyptr;
7638
7639 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pRsp, sizeof(tSirSmeAddStaSelfRsp)))
7640 {
7641 /// Buffer not available. Log error
7642 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for Add Sta self RSP\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07007643 palFreeMemory( pMac->hHdd, (tANI_U8 *)pAddStaSelfParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 return;
7645 }
7646
7647 palZeroMemory(pMac, (tANI_U8*)pRsp, sizeof(tSirSmeAddStaSelfRsp));
7648
7649 pRsp->mesgType = eWNI_SME_ADD_STA_SELF_RSP;
7650 pRsp->mesgLen = (tANI_U16) sizeof(tSirSmeAddStaSelfRsp);
7651 pRsp->status = pAddStaSelfParams->status;
7652
7653 palCopyMemory( pMac->hHdd, pRsp->selfMacAddr, pAddStaSelfParams->selfMacAddr, sizeof(tSirMacAddr) );
7654
7655 palFreeMemory( pMac->hHdd, (tANI_U8 *)pAddStaSelfParams);
7656
7657 mmhMsg.type = eWNI_SME_ADD_STA_SELF_RSP;
7658 mmhMsg.bodyptr = pRsp;
7659 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007660 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07007661 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
7662
7663}
7664
7665void limProcessDelStaSelfRsp(tpAniSirGlobal pMac,tpSirMsgQ limMsgQ)
7666{
7667
7668 tpDelStaSelfParams pDelStaSelfParams;
7669 tSirMsgQ mmhMsg;
7670 tpSirSmeDelStaSelfRsp pRsp;
7671
7672
7673 pDelStaSelfParams = (tpDelStaSelfParams)limMsgQ->bodyptr;
7674
7675 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pRsp, sizeof(tSirSmeDelStaSelfRsp)))
7676 {
7677 /// Buffer not available. Log error
7678 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for Add Sta self RSP\n"));
Jeff Johnsone7245742012-09-05 17:12:55 -07007679 palFreeMemory( pMac->hHdd, (tANI_U8 *)pDelStaSelfParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07007680 return;
7681 }
7682
7683 palZeroMemory(pMac, (tANI_U8*)pRsp, sizeof(tSirSmeDelStaSelfRsp));
7684
7685 pRsp->mesgType = eWNI_SME_DEL_STA_SELF_RSP;
7686 pRsp->mesgLen = (tANI_U16) sizeof(tSirSmeDelStaSelfRsp);
7687 pRsp->status = pDelStaSelfParams->status;
7688
7689 palCopyMemory( pMac->hHdd, pRsp->selfMacAddr, pDelStaSelfParams->selfMacAddr, sizeof(tSirMacAddr) );
7690
7691 palFreeMemory( pMac->hHdd, (tANI_U8 *)pDelStaSelfParams);
7692
7693 mmhMsg.type = eWNI_SME_DEL_STA_SELF_RSP;
7694 mmhMsg.bodyptr = pRsp;
7695 mmhMsg.bodyval = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07007696 MTRACE(macTraceMsgTx(pMac, NO_SESSION, mmhMsg.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07007697 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
7698
7699}
7700
7701/***************************************************************
7702* tANI_U8 limUnmapChannel(tANI_U8 mapChannel)
7703* To unmap the channel to reverse the effect of mapping
7704* a band channel in hal .Mapping was done hal to overcome the
7705* limitation of the rxbd which use only 4 bit for channel number.
7706*****************************************************************/
7707tANI_U8 limUnmapChannel(tANI_U8 mapChannel)
7708{
7709 if( mapChannel > 0 && mapChannel < 25 )
7710 return abChannel[mapChannel -1];
7711 else
7712 return 0;
7713}
7714
7715
7716v_U8_t* limGetIEPtr(tpAniSirGlobal pMac, v_U8_t *pIes, int length, v_U8_t eid,eSizeOfLenField size_of_len_field)
7717{
7718 int left = length;
7719 v_U8_t *ptr = pIes;
7720 v_U8_t elem_id;
7721 v_U16_t elem_len;
7722
7723 while(left >= (size_of_len_field+1))
7724 {
7725 elem_id = ptr[0];
7726 if (size_of_len_field == TWO_BYTE)
7727 {
7728 elem_len = ((v_U16_t) ptr[1]) | (ptr[2]<<8);
7729 }
7730 else
7731 {
7732 elem_len = ptr[1];
7733 }
7734
7735
7736 left -= (size_of_len_field+1);
7737 if(elem_len > left)
7738 {
7739 limLog(pMac, LOGE,
7740 "****Invalid IEs eid = %d elem_len=%d left=%d*****\n",
7741 eid,elem_len,left);
7742 return NULL;
7743 }
7744 if (elem_id == eid)
7745 {
7746 return ptr;
7747 }
7748
7749 left -= elem_len;
7750 ptr += (elem_len + (size_of_len_field+1));
7751 }
7752 return NULL;
7753}
7754
7755/* return NULL if oui is not found in ie
7756 return !NULL pointer to vendor IE (starting from 0xDD) if oui is found
7757 */
7758v_U8_t* limGetVendorIEOuiPtr(tpAniSirGlobal pMac, tANI_U8 *oui, tANI_U8 oui_size, tANI_U8 *ie, tANI_U16 ie_len)
7759{
7760 int left = ie_len;
7761 v_U8_t *ptr = ie;
7762 v_U8_t elem_id, elem_len;
7763
7764 while(left >= 2)
7765 {
7766 elem_id = ptr[0];
7767 elem_len = ptr[1];
7768 left -= 2;
7769 if(elem_len > left)
7770 {
7771 limLog( pMac, LOGE,
7772 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****\n"),
7773 elem_id,elem_len,left);
7774 return NULL;
7775 }
7776 if (SIR_MAC_EID_VENDOR == elem_id)
7777 {
7778 if(memcmp(&ptr[2], oui, oui_size)==0)
7779 return ptr;
7780 }
7781
7782 left -= elem_len;
7783 ptr += (elem_len + 2);
7784 }
7785 return NULL;
7786}
7787
7788#ifdef WLAN_FEATURE_P2P
7789//Returns length of P2P stream and Pointer ie passed to this function is filled with noa stream
7790
7791v_U8_t limBuildP2pIe(tpAniSirGlobal pMac, tANI_U8 *ie, tANI_U8 *data, tANI_U8 ie_len)
7792{
7793 int length = 0;
7794 tANI_U8 *ptr = ie;
7795
7796 ptr[length++] = SIR_MAC_EID_VENDOR;
7797 ptr[length++] = ie_len + SIR_MAC_P2P_OUI_SIZE;
7798 palCopyMemory( pMac->hHdd, &ptr[length], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
7799 palCopyMemory( pMac->hHdd, &ptr[length + SIR_MAC_P2P_OUI_SIZE], data, ie_len);
7800 return (ie_len + SIR_P2P_IE_HEADER_LEN);
7801}
7802
7803//Returns length of NoA stream and Pointer pNoaStream passed to this function is filled with noa stream
7804
7805v_U8_t limGetNoaAttrStreamInMultP2pIes(tpAniSirGlobal pMac,v_U8_t* noaStream,v_U8_t noaLen,v_U8_t overFlowLen)
7806{
7807 v_U8_t overFlowP2pStream[SIR_MAX_NOA_ATTR_LEN];
7808 palCopyMemory( pMac->hHdd, overFlowP2pStream, noaStream + noaLen - overFlowLen, overFlowLen);
7809 noaStream[noaLen - overFlowLen] = SIR_MAC_EID_VENDOR;
7810 noaStream[noaLen - overFlowLen+1] = overFlowLen + SIR_MAC_P2P_OUI_SIZE;
7811 palCopyMemory( pMac->hHdd, noaStream+ noaLen - overFlowLen+2,SIR_MAC_P2P_OUI,SIR_MAC_P2P_OUI_SIZE);
7812
7813 palCopyMemory( pMac->hHdd, noaStream+ noaLen - overFlowLen+2+SIR_MAC_P2P_OUI_SIZE,overFlowP2pStream,overFlowLen);
7814 return (noaLen + SIR_P2P_IE_HEADER_LEN);
7815
7816}
7817
7818//Returns length of NoA stream and Pointer pNoaStream passed to this function is filled with noa stream
7819v_U8_t limGetNoaAttrStream(tpAniSirGlobal pMac, v_U8_t*pNoaStream,tpPESession psessionEntry)
7820{
7821 v_U8_t len=0;
7822
7823 v_U8_t *pBody = pNoaStream;
7824
7825
7826 if ( (psessionEntry != NULL) && (psessionEntry->valid) &&
7827 (psessionEntry->pePersona == VOS_P2P_GO_MODE))
7828 {
7829 if ((!(psessionEntry->p2pGoPsUpdate.uNoa1Duration)) && (!(psessionEntry->p2pGoPsUpdate.uNoa2Duration))
7830 && (!psessionEntry->p2pGoPsUpdate.oppPsFlag)
7831 )
7832 return 0; //No NoA Descriptor then return 0
7833
7834
7835 pBody[0] = SIR_P2P_NOA_ATTR;
7836
7837 pBody[3] = psessionEntry->p2pGoPsUpdate.index;
7838 pBody[4] = psessionEntry->p2pGoPsUpdate.ctWin | (psessionEntry->p2pGoPsUpdate.oppPsFlag<<7);
7839 len = 5;
7840 pBody += len;
7841
7842
7843 if (psessionEntry->p2pGoPsUpdate.uNoa1Duration)
7844 {
7845 *pBody = psessionEntry->p2pGoPsUpdate.uNoa1IntervalCnt;
7846 pBody += 1;
7847 len +=1;
7848
7849 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa1Duration);
7850 pBody += sizeof(tANI_U32);
7851 len +=4;
7852
7853 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa1Interval);
7854 pBody += sizeof(tANI_U32);
7855 len +=4;
7856
7857 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa1StartTime);
7858 pBody += sizeof(tANI_U32);
7859 len +=4;
7860
7861 }
7862
7863 if (psessionEntry->p2pGoPsUpdate.uNoa2Duration)
7864 {
7865 *pBody = psessionEntry->p2pGoPsUpdate.uNoa2IntervalCnt;
7866 pBody += 1;
7867 len +=1;
7868
7869 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa2Duration);
7870 pBody += sizeof(tANI_U32);
7871 len +=4;
7872
7873 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa2Interval);
7874 pBody += sizeof(tANI_U32);
7875 len +=4;
7876
7877 *((tANI_U32 *)(pBody)) = sirSwapU32ifNeeded(psessionEntry->p2pGoPsUpdate.uNoa2StartTime);
7878 pBody += sizeof(tANI_U32);
7879 len +=4;
7880
7881 }
7882
7883
7884 pBody = pNoaStream + 1;
7885 *((tANI_U16 *)(pBody)) = sirSwapU16ifNeeded(len-3);/*one byte for Attr and 2 bytes for length*/
7886
7887 return (len);
7888
7889 }
7890 return 0;
7891
7892}
Jeff Johnsone7245742012-09-05 17:12:55 -07007893
7894void peSetResumeChannel(tpAniSirGlobal pMac, tANI_U16 channel, ePhyChanBondState phyCbState)
Jeff Johnson295189b2012-06-20 16:38:30 -07007895{
7896
7897 pMac->lim.gResumeChannel = channel;
Jeff Johnsone7245742012-09-05 17:12:55 -07007898 pMac->lim.gResumePhyCbState = phyCbState;
Jeff Johnson295189b2012-06-20 16:38:30 -07007899}
Jeff Johnsone7245742012-09-05 17:12:55 -07007900
Jeff Johnson295189b2012-06-20 16:38:30 -07007901/*--------------------------------------------------------------------------
7902
7903 \brief peGetResumeChannel() - Returns the channel number for scanning, from a valid session.
7904
Jeff Johnsone7245742012-09-05 17:12:55 -07007905 This function returns the channel to resume to during link resume. channel id of 0 means HAL will
7906 resume to previous channel before link suspend
Jeff Johnson295189b2012-06-20 16:38:30 -07007907
7908 \param pMac - pointer to global adapter context
7909 \return - channel to scan from valid session else zero.
7910
7911 \sa
7912
7913 --------------------------------------------------------------------------*/
Jeff Johnsone7245742012-09-05 17:12:55 -07007914void peGetResumeChannel(tpAniSirGlobal pMac, tANI_U8* resumeChannel, ePhyChanBondState* resumePhyCbState)
Jeff Johnson295189b2012-06-20 16:38:30 -07007915{
7916
7917 //Rationale - this could be the suspend/resume for assoc and it is essential that
7918 //the new BSS is active for some time. Other BSS was anyway suspended.
7919 //TODO: Comeup with a better alternative. Sending NULL with PM=0 on other BSS means
7920 //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 -07007921 //and hence should be ok. Need to discuss this further
7922 if( !limIsInMCC(pMac) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007923 {
7924 //Get current active session channel
Jeff Johnsone7245742012-09-05 17:12:55 -07007925 peGetActiveSessionChannel(pMac, resumeChannel, resumePhyCbState);
Jeff Johnson295189b2012-06-20 16:38:30 -07007926 }
7927 else
7928 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007929 *resumeChannel = pMac->lim.gResumeChannel;
7930 *resumePhyCbState = pMac->lim.gResumePhyCbState;
Jeff Johnson295189b2012-06-20 16:38:30 -07007931 }
Jeff Johnsone7245742012-09-05 17:12:55 -07007932 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007933}
7934
Jeff Johnsone7245742012-09-05 17:12:55 -07007935
Jeff Johnson295189b2012-06-20 16:38:30 -07007936#endif
7937
7938tANI_BOOLEAN limIsconnectedOnDFSChannel(tANI_U8 currentChannel)
7939{
7940 if(NV_CHANNEL_DFS == vos_nv_getChannelEnabledState(currentChannel))
7941 {
7942 return eANI_BOOLEAN_TRUE;
7943 }
7944 else
7945 {
7946 return eANI_BOOLEAN_FALSE;
7947 }
7948}
Mohit Khanna4a70d262012-09-11 16:30:12 -07007949
7950#ifdef WLAN_FEATURE_11AC
7951tANI_BOOLEAN limCheckVHTOpModeChange( tpAniSirGlobal pMac, tpPESession psessionEntry, tANI_U8 chanWidth, tANI_U8 staId)
7952{
7953 tUpdateVHTOpMode tempParam;
7954
7955 tempParam.opMode = chanWidth;
7956 tempParam.staId = staId;
7957
7958 limSendModeUpdate( pMac, &tempParam, psessionEntry );
7959
7960 return eANI_BOOLEAN_TRUE;
7961}
7962#endif