blob: c74f363c2815944d9570add26ca279454f43b3b5 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
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/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/*
43 * Airgo Networks, Inc proprietary. All rights reserved.
44 * This file limAssocUtils.cc contains the utility functions
45 * LIM uses while processing (Re) Association messages.
46 * Author: Chandra Modumudi
47 * Date: 02/13/02
48 * History:-
49 * Date Modified by Modification Information
50 * --------------------------------------------------------------------
51 * 05/26/10 js WPA handling in (Re)Assoc frames
52 *
53 */
54
55#include "palTypes.h"
56#include "aniGlobal.h"
57#include "wniApi.h"
58#include "sirCommon.h"
59
60#if (WNI_POLARIS_FW_PRODUCT == AP)
61#include "wniCfgAp.h"
62#else
63#include "wniCfgSta.h"
64#endif
65#include "pmmApi.h"
66#include "cfgApi.h"
67
68#include "schApi.h"
69#include "utilsApi.h"
70#include "limUtils.h"
71#include "limAssocUtils.h"
72#include "limSecurityUtils.h"
73#include "limSerDesUtils.h"
74#include "limStaHashApi.h"
75#include "limAdmitControl.h"
76#include "limSendMessages.h"
77#include "limIbssPeerMgmt.h"
78#include "limSession.h"
79
80#include "vos_types.h"
81#include "wlan_qct_wda.h"
82
83/*
84 * fill up the rate info properly based on what is actually supported by the peer
85 * TBD TBD TBD
86 */
87void
88limFillSupportedRatesInfo(
89 tpAniSirGlobal pMac,
90 tpDphHashNode pSta,
91 tpSirSupportedRates pRates,
92 tpPESession psessionEntry)
93{
94 //pSta will be NULL for self entry, so get the opRateMode based on the self mode.
95 //For the peer entry get it from the peer Capabilities present in hash table
96 if(pSta == NULL)
97 pRates->opRateMode = limGetStaRateMode((tANI_U8)psessionEntry->dot11mode);
98 else
99 pRates->opRateMode = limGetStaPeerType(pMac, pSta, psessionEntry);
100
101}
102
103
104/**
105 * limCmpSSid()
106 *
107 *FUNCTION:
108 * This function is called in various places within LIM code
109 * to determine whether received SSid is same as SSID in use.
110 *
111 *LOGIC:
112 *
113 *ASSUMPTIONS:
114 * NA
115 *
116 *NOTE:
117 * NA
118 *
119 * @param *prxSSid - pointer to SSID structure
120 *
121 * @return status - true for SSID match else false.
122 */
123
124tANI_U8
125limCmpSSid(tpAniSirGlobal pMac, tSirMacSSid *prxSSid,tpPESession psessionEntry)
126{
127
128 if( palEqualMemory( pMac->hHdd, (tANI_U8* ) prxSSid, (tANI_U8 *) &psessionEntry->ssId,
129 (tANI_U8) (psessionEntry->ssId.length + 1)))
130 return true;
131 else
132 return false;
133
134} /****** end limCmpSSid() ******/
135
136
137
138/**
139 * limCompareCapabilities()
140 *
141 *FUNCTION:
142 * This function is called during Association/Reassociation
143 * frame handling to determine whether received capabilities
144 * match with local capabilities or not.
145 *
146 *LOGIC:
147 *
148 *ASSUMPTIONS:
149 * NA
150 *
151 *NOTE:
152 * NA
153 *
154 * @param pMac - Pointer to Global MAC structure
155 * @param pAssocReq - Pointer to received Assoc Req frame
156 * @param pLocalCapabs - Pointer to local capabilities
157 *
158 * @return status - true for Capabilitity match else false.
159 */
160
161tANI_U8
162limCompareCapabilities(tpAniSirGlobal pMac,
163 tSirAssocReq *pAssocReq,
164 tSirMacCapabilityInfo *pLocalCapabs,tpPESession psessionEntry)
165{
166 tANI_U32 val;
167
168
169 if ( ((psessionEntry->limSystemRole == eLIM_AP_ROLE)||
170 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
171 (pAssocReq->capabilityInfo.ibss) )
172 {
173 // Requesting STA asserting IBSS capability.
174 return false;
175 }
176
177 // Compare CF capabilities
178 if (pAssocReq->capabilityInfo.cfPollable ||
179 pAssocReq->capabilityInfo.cfPollReq)
180 {
181 // AP does not support PCF functionality
182 return false;
183 }
184
185#if 0 //See CR24696 for analysis
186 // Compare privacy capability
187 if (pAssocReq->capabilityInfo.privacy != pLocalCapabs->privacy)
188 {
189 // AP does not support privacy
190 return false;
191 }
192#endif
193
194 // Compare short preamble capability
195 if (pAssocReq->capabilityInfo.shortPreamble &&
196 (pAssocReq->capabilityInfo.shortPreamble !=
197 pLocalCapabs->shortPreamble))
198 {
199 PELOG1(limLog(pMac, LOG1,
200 FL("Allowing a STA requesting short preamble while AP does not support it\n"));)
201#if 0
202 // AP does not support short preamable
203 return false;
204#endif
205 }
206
207
208 limLog(pMac, LOGW, "QoS in AssocReq: %d, local ShortP: %d\n",
209 pAssocReq->capabilityInfo.qos,
210 pLocalCapabs->qos);
211
212 // Compare QoS capability
213 if (pAssocReq->capabilityInfo.qos &&
214 (pAssocReq->capabilityInfo.qos != pLocalCapabs->qos))
215 {
216 /*Temporary hack for UPF to skip 11e capability check in order to interop with
217 CSR - proper fix needs to be put in place*/
218 if ( 0 != vos_get_skip_11e_check())
219 {
220 limLog(pMac, LOG1, FL("Received unmatched QOS but cfg to suppress - continuing\n"));
221 }
222 else
223 {
224 // AP does not support QoS capability
225 return false;
226 }
227 }
228
229
230 /*
231 * If AP supports shortSlot and if apple user has
232 * enforced association only from shortSlot station,
233 * then AP must reject any station that does not support
234 * shortSlot
235 */
236 if ( ((psessionEntry->limSystemRole == eLIM_AP_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) && (pLocalCapabs->shortSlotTime == 1) )
237
238 {
239 if (wlan_cfgGetInt(pMac, WNI_CFG_ACCEPT_SHORT_SLOT_ASSOC_ONLY, &val) != eSIR_SUCCESS)
240 {
241 limLog(pMac, LOGP, FL("error getting WNI_CFG_FORCE_SHORT_SLOT_ASSOC_ONLY \n"));
242 return false;
243 }
244 if(val)
245 {
246 if (pAssocReq->capabilityInfo.shortSlotTime != pLocalCapabs->shortSlotTime)
247 return false;
248 }
249 }
250
251 return true;
252} /****** end limCompareCapabilities() ******/
253
254
255/**
256 * limCheckRxBasicRates()
257 *
258 *FUNCTION:
259 * This function is called during Association/Reassociation
260 * frame handling to determine whether received rates in
261 * Assoc/Reassoc request frames include all BSS basic rates
262 * or not.
263 *
264 *LOGIC:
265 *
266 *ASSUMPTIONS:
267 * NA
268 *
269 *NOTE:
270 * NA
271 *
272 * @param rxRateSet - pointer to SSID structure
273 *
274 * @return status - true if ALL BSS basic rates are present in the
275 * received rateset else false.
276 */
277
278tANI_U8
279limCheckRxBasicRates(tpAniSirGlobal pMac, tSirMacRateSet rxRateSet,tpPESession psessionEntry)
280{
281 tSirMacRateSet *pRateSet, basicRate;
282 tANI_U8 i, j, k, match;
283
284 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **)&pRateSet, sizeof(tSirMacRateSet)))
285 {
286 // Log error
287 limLog(pMac, LOGP, FL("call to palAllocateMemory failed for RATESET\n"));
288
289 return false;
290 }
291
292
293 #if 0
294 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
295 (tANI_U8 *) &pRateSet->rate,
296 (tANI_U32 *) &cfgLen) != eSIR_SUCCESS)
297 {
298 /// Could not get Operational rateset from CFG. Log error.
299 limLog(pMac, LOGP, FL("could not retrieve Operational rateset\n"));
300
301 // Free up memory allocated for rateset
302 palFreeMemory( pMac->hHdd, (tANI_U8 *) pRateSet);
303
304 return false;
305 }
306 #endif //TO SUPPORT BT-AMP
307
308 /* Copy operational rate set from session Entry */
309 palCopyMemory(pMac->hHdd, pRateSet->rate, (psessionEntry->rateSet.rate), psessionEntry->rateSet.numRates);
310
311 pRateSet->numRates = psessionEntry->rateSet.numRates;
312
313 // Extract BSS basic rateset from operational rateset
314 for (i = 0, j = 0; i < pRateSet->numRates; i++)
315 {
316 if ((pRateSet->rate[i] & 0x80) == 0x80)
317 {
318 // msb is set, so this is a basic rate
319 basicRate.rate[j++] = pRateSet->rate[i];
320 }
321 }
322
323 /*
324 * For each BSS basic rate, find if it is present in the
325 * received rateset.
326 */
327 for (k = 0; k < j; k++)
328 {
329 match = 0;
330 for (i = 0; i < rxRateSet.numRates; i++)
331 {
332 if ((rxRateSet.rate[i] | 0x80) == basicRate.rate[k])
333 match = 1;
334 }
335
336 if (!match)
337 {
338 // Free up memory allocated for rateset
339 palFreeMemory( pMac->hHdd, (tANI_U8 *) pRateSet);
340
341 return false;
342 }
343 }
344
345 // Free up memory allocated for rateset
346 palFreeMemory( pMac->hHdd, (tANI_U8 *) pRateSet);
347
348 return true;
349} /****** end limCheckRxBasicRates() ******/
350
351
352
353/**
354 * limCheckMCSSet()
355 *
356 *FUNCTION:
357 * This function is called during Association/Reassociation
358 * frame handling to determine whether received MCS rates in
359 * Assoc/Reassoc request frames includes all Basic MCS Rate Set or not.
360 *
361 *LOGIC:
362 *
363 *ASSUMPTIONS:
364 * NA
365 *
366 *NOTE:
367 * NA
368 *
369 * @param supportedMCSSet - pointer to Supported MCS Rate Set
370 *
371 * @return status - true if ALL MCS Basic Rate Set rates are present in the
372 * received rateset else false.
373 */
374
375tANI_U8
376limCheckMCSSet(tpAniSirGlobal pMac, tANI_U8* supportedMCSSet)
377{
378 tANI_U8 basicMCSSet[SIZE_OF_BASIC_MCS_SET] = {0};
379 tANI_U32 cfgLen = 0;
380 tANI_U8 i;
381 tANI_U8 validBytes;
382 tANI_U8 lastByteMCSMask = 0x1f;
383
384
385 cfgLen = WNI_CFG_BASIC_MCS_SET_LEN;
386 if (wlan_cfgGetStr(pMac, WNI_CFG_BASIC_MCS_SET,
387 (tANI_U8 *) basicMCSSet,
388 (tANI_U32 *) &cfgLen) != eSIR_SUCCESS)
389 {
390 /// Could not get Basic MCS rateset from CFG. Log error.
391 limLog(pMac, LOGP, FL("could not retrieve Basic MCS rateset\n"));
392 return false;
393 }
394
395 validBytes = VALID_MCS_SIZE/8;
396
397 //check if all the Basic MCS Bits are set in supported MCS bitmap
398 for(i=0; i<validBytes; i++)
399 {
400 if( (basicMCSSet[i] & supportedMCSSet[i]) != basicMCSSet[i])
401 {
402 PELOGW(limLog(pMac, LOGW, FL("One of Basic MCS Set Rates is not supported by the Station."));)
403 return false;
404 }
405 }
406
407 //check the last 5 bits of the valid MCS bitmap
408 if( ((basicMCSSet[i] & lastByteMCSMask) & (supportedMCSSet[i] & lastByteMCSMask)) !=
409 (basicMCSSet[i] & lastByteMCSMask))
410 {
411 PELOGW(limLog(pMac, LOGW, FL("One of Basic MCS Set Rates is not supported by the Station."));)
412 return false;
413 }
414
415 return true;
416}
417
418#ifdef WLAN_SOFTAP_FEATURE
419
420#define SECURITY_SUITE_TYPE_MASK 0xFF
421#define SECURITY_SUITE_TYPE_WEP40 0x1
422#define SECURITY_SUITE_TYPE_TKIP 0x2
423#define SECURITY_SUITE_TYPE_CCMP 0x4
424#define SECURITY_SUITE_TYPE_WEP104 0x4
425
426/**
427 * limCheckRxRSNIeMatch()
428 *
429 *FUNCTION:
430 * This function is called during Association/Reassociation
431 * frame handling to determine whether received RSN in
432 * Assoc/Reassoc request frames include supported cipher suites or not.
433 *
434 *LOGIC:
435 *
436 *ASSUMPTIONS:
437 * NA
438 *
439 *NOTE:
440 * NA
441 *
442 * @param rxRSNIe - received RSN IE in (Re)Assco req
443 *
444 * @return status - true if ALL BSS basic rates are present in the
445 * received rateset else false.
446 */
447
448tANI_U8
449limCheckRxRSNIeMatch(tpAniSirGlobal pMac, tDot11fIERSN rxRSNIe,tpPESession pSessionEntry, tANI_U8 staIsHT)
450{
451 tDot11fIERSN *pRSNIe;
452 tANI_U8 i, j, match, onlyNonHtCipher = 1;
453
454
455 //RSN IE should be received from PE
456 pRSNIe = &pSessionEntry->gStartBssRSNIe;
457
458 // Check groupwise cipher suite
459 for (i = 0; i < sizeof(rxRSNIe.gp_cipher_suite); i++)
460 {
461 if (pRSNIe->gp_cipher_suite[i] != rxRSNIe.gp_cipher_suite[i])
462 {
463 return eSIR_MAC_INVALID_GROUP_CIPHER_STATUS;
464 }
465 }
466
467 /*
468 * For each Pairwise cipher suite check whether we support
469 * received pairwise
470 */
471 match = 0;
472 for (i = 0; i < rxRSNIe.pwise_cipher_suite_count; i++)
473 {
474 for(j = 0; j < pRSNIe->pwise_cipher_suite_count; j++)
475 {
476 if(palEqualMemory(pMac,&rxRSNIe.pwise_cipher_suites[i],
477 &pRSNIe->pwise_cipher_suites[j],
478 sizeof(pRSNIe->pwise_cipher_suites[j])))
479 {
480 match = 1;
481 break;
482 }
483 }
484
485 if ((staIsHT)
486#ifdef ANI_LITTLE_BYTE_ENDIAN
487 &&( (rxRSNIe.pwise_cipher_suites[i][3] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
488#else
489 &&( (rxRSNIe.pwise_cipher_suites[i][0] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
490#endif
491 {
492 onlyNonHtCipher=0;
493 }
494
495 }
496
497 if ((!match) || ((staIsHT) && onlyNonHtCipher))
498 {
499 return eSIR_MAC_INVALID_PAIRWISE_CIPHER_STATUS;
500 }
501 /* Check RSN capabilities */
502 if(rxRSNIe.preauth == true) //this is supported by AP only
503 {
504 return eSIR_MAC_INVALID_RSN_IE_CAPABILITIES_STATUS;
505 }
506
507 return eSIR_SUCCESS;
508} /****** end limCheckRxRSNIeMatch() ******/
509
510/**
511 * limCheckRxWPAIeMatch()
512 *
513 *FUNCTION:
514 * This function is called during Association/Reassociation
515 * frame handling to determine whether received RSN in
516 * Assoc/Reassoc request frames include supported cipher suites or not.
517 *
518 *LOGIC:
519 *
520 *ASSUMPTIONS:
521 * NA
522 *
523 *NOTE:
524 * NA
525 *
526 * @param rxWPAIe - Received WPA IE in (Re)Assco req
527 *
528 * @return status - true if ALL BSS basic rates are present in the
529 * received rateset else false.
530 */
531
532tANI_U8
533limCheckRxWPAIeMatch(tpAniSirGlobal pMac, tDot11fIEWPA rxWPAIe,tpPESession pSessionEntry, tANI_U8 staIsHT)
534{
535 tDot11fIEWPA *pWPAIe;
536 tANI_U8 i, j, match, onlyNonHtCipher = 1;
537
538 // WPA IE should be received from PE
539 pWPAIe = &pSessionEntry->gStartBssWPAIe;
540
541 // Check groupwise cipher suite
542 for (i = 0; i < 4; i++)
543 {
544 if (pWPAIe->multicast_cipher[i] != rxWPAIe.multicast_cipher[i])
545 {
546 return eSIR_MAC_INVALID_GROUP_CIPHER_STATUS;
547 }
548 }
549
550 /*
551 * For each Pairwise cipher suite check whether we support
552 * received pairwise
553 */
554 match = 0;
555 for (i = 0; i < rxWPAIe.unicast_cipher_count; i++)
556 {
557 for(j = 0; j < pWPAIe->unicast_cipher_count; j++)
558 {
559 if(palEqualMemory(pMac,rxWPAIe.unicast_ciphers[i],
560 pWPAIe->unicast_ciphers[j],
561 4))
562 {
563 match = 1;
564 break;
565 }
566 }
567
568 if ((staIsHT)
569#ifdef ANI_LITTLE_BYTE_ENDIAN
570 &&( (rxWPAIe.unicast_ciphers[i][3] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
571#else
572 &&( (rxWPAIe.unicast_ciphers[i][0] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
573#endif
574 {
575 onlyNonHtCipher=0;
576 }
577
578 }
579
580 if ((!match) || ((staIsHT) && onlyNonHtCipher))
581 {
582 return eSIR_MAC_CIPHER_SUITE_REJECTED_STATUS;
583 }
584
585 return eSIR_SUCCESS;
586} /****** end limCheckRxWPAIeMatch() ******/
587
588#endif /* WLAN_SOFTAP_FEATURE */
589
590/**
591 * limCleanupRxPath()
592 *
593 *FUNCTION:
594 * This function is called to cleanup STA state at SP & RFP.
595 *
596 *LOGIC:
597 * To circumvent RFP's handling of dummy packet when it does not
598 * have an incomplete packet for the STA to be deleted, a packet
599 * with 'more framgents' bit set will be queued to RFP's WQ before
600 * queuing 'dummy packet'.
601 * A 'dummy' BD is pushed into RFP's WQ with type=00, subtype=1010
602 * (Disassociation frame) and routing flags in BD set to eCPU's
603 * Low Priority WQ.
604 * RFP cleans up its local context for the STA id mentioned in the
605 * BD and then pushes BD to eCPU's low priority WQ.
606 *
607 *ASSUMPTIONS:
608 * NA
609 *
610 *NOTE:
611 * NA
612 *
613 * @param pMac Pointer to Global MAC structure
614 * @param pStaDs Pointer to the per STA data structure
615 * initialized by LIM and maintained at DPH
616 *
617 * @return None
618 */
619
620tSirRetStatus
621limCleanupRxPath(tpAniSirGlobal pMac, tpDphHashNode pStaDs,tpPESession psessionEntry)
622{
623 tSirRetStatus retCode = eSIR_SUCCESS;
624
625
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700626 PELOG2(limLog( pMac, LOG2, FL("**Initiate cleanup"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700627
628 limAbortBackgroundScan( pMac );
629
630 if (pMac->lim.gLimAddtsSent)
631 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700632 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 tx_timer_deactivate(&pMac->lim.limTimers.gLimAddtsRspTimer);
634 }
635
636 if (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_ASSOC_CNF_STATE)
637 {
638 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER,
639 pStaDs->assocId);
640
641 if (!pStaDs->mlmStaContext.updateContext)
642 {
643 /**
644 * There is no context at Polaris to delete.
645 * Release our assigned AID back to the free pool
646 */
647 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
648 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
649 {
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800650 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 }
652 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId,psessionEntry);
653
654 return retCode;
655 }
656 }
657
658 //delete all tspecs associated with this sta.
659 limAdmitControlDeleteSta(pMac, pStaDs->assocId);
660
661#if (WNI_POLARIS_FW_PRODUCT==AP)
662 // Reset PMM state for this STA if it exists
663 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)
664 pmmUpdatePMMode(pMac, pStaDs->assocId, 0);
665#endif
666
667 /**
668 * Make STA hash entry invalid at eCPU so that DPH
669 * does not process any more data packets and
670 * releases those BDs
671 */
672 pStaDs->valid = 0;
673 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
674
675 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
676 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700677 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -0700678 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700679 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 /* Deactivating probe after heart beat timer */
681 limDeactivateAndChangeTimer(pMac, eLIM_PROBE_AFTER_HB_TIMER);
682 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
683 limDeactivateAndChangeTimer(pMac, eLIM_KEEPALIVE_TIMER);
684 pMac->lim.gLastBeaconDtimCount = 0;
685 pMac->lim.gLastBeaconDtimPeriod = 0;
686
687#ifdef FEATURE_WLAN_CCX
688 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
689#endif
690
691 /**
692 * Update the status for PMM module
693 */
694 pmmResetPmmState(pMac);
695 }
696#ifdef WLAN_DEBUG
697 // increment a debug count
698 pMac->lim.gLimNumRxCleanup++;
699#endif
700
701 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE) {
702 retCode = limDelBss( pMac, pStaDs, psessionEntry->bssIdx, psessionEntry);
703 }
704 else
705 retCode = limDelSta( pMac, pStaDs, true, psessionEntry);
706
707 return retCode;
708
709} /*** end limCleanupRxPath() ***/
710
711
712/**
713 * limSendDelStaCnf()
714 *
715 *FUNCTION:
716 * This function is called to send appropriate CNF message to SME
717 *
718 *LOGIC:
719 *
720 *
721 *ASSUMPTIONS:
722 * NA
723 *
724 *NOTE:
725 * NA
726 *
727 * @param pMac Pointer to Global MAC structure
728 * @param tpAniSirGlobal pMac,
729 * @param tSirMacAddr staDsAddr,
730 * @param tANI_U16 staDsAssocId,
731 * @param tLimMlmStaContext mlmStaContext,
732 * @param tSirResultCodes statusCode
733 *
734 * @return None
735 */
736
737void
738limSendDelStaCnf(tpAniSirGlobal pMac, tSirMacAddr staDsAddr,
739 tANI_U16 staDsAssocId, tLimMlmStaContext mlmStaContext, tSirResultCodes statusCode,tpPESession psessionEntry)
740{
741
742 tLimMlmDisassocCnf mlmDisassocCnf;
743 tLimMlmDeauthCnf mlmDeauthCnf;
744 tLimMlmPurgeStaInd mlmPurgeStaInd;
745
746 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
747 {
748 // Set BSSID at CFG to null
749 tSirMacAddr nullAddr = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
750 #if 0
751 if (cfgSetStr(pMac, WNI_CFG_BSSID, (tANI_U8 *) &nullAddr,
752 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
753 {
754 /// Could not update BSSID at CFG. Log error.
755 limLog(pMac, LOGP, FL("could not update BSSID at CFG\n"));
756
757 return;
758 }
759 #endif//TO SUPPORT BT-AMP
760
761 sirCopyMacAddr(nullAddr,psessionEntry->bssId);
762
763 // Free up buffer allocated for JoinReq held by
764 // MLM state machine
765 if (psessionEntry->pLimMlmJoinReq)
766 {
767 palFreeMemory( pMac->hHdd, (tANI_U8 *) psessionEntry->pLimMlmJoinReq);
768 psessionEntry->pLimMlmJoinReq = NULL;
769 }
770
771 psessionEntry->limAID = 0;
772
773
774 }
775
776 if ((mlmStaContext.cleanupTrigger ==
777 eLIM_HOST_DISASSOC) ||
778 (mlmStaContext.cleanupTrigger ==
779 eLIM_LINK_MONITORING_DISASSOC) ||
780 (mlmStaContext.cleanupTrigger ==
781 eLIM_PROMISCUOUS_MODE_DISASSOC))
782 {
783 /**
784 * Host or LMM driven Disassociation.
785 * Issue Disassoc Confirm to SME.
786 */
787 limLog( pMac, LOGW, FL("Lim Posting DISASSOC_CNF to Sme. Trigger: %X\n"), mlmStaContext.cleanupTrigger);
788
789
790 palCopyMemory( pMac->hHdd,
791 (tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
792 (tANI_U8 *) staDsAddr,
793 sizeof(tSirMacAddr));
794 mlmDisassocCnf.resultCode = statusCode;
795#if (WNI_POLARIS_FW_PRODUCT == AP)
796 mlmDisassocCnf.aid = staDsAssocId;
797#endif
798 mlmDisassocCnf.disassocTrigger =
799 mlmStaContext.cleanupTrigger;
800 /* Update PE session Id*/
801 mlmDisassocCnf.sessionId = psessionEntry->peSessionId;
802
803 limPostSmeMessage(pMac,
804 LIM_MLM_DISASSOC_CNF,
805 (tANI_U32 *) &mlmDisassocCnf);
806 }
807 else if ((mlmStaContext.cleanupTrigger ==
808 eLIM_HOST_DEAUTH) ||
809 (mlmStaContext.cleanupTrigger ==
810 eLIM_LINK_MONITORING_DEAUTH))
811 {
812 /**
813 * Host or LMM driven Deauthentication.
814 * Issue Deauth Confirm to SME.
815 */
816 limLog( pMac, LOGW, FL("Lim Posting DEAUTH_CNF to Sme. Trigger: %X\n"), mlmStaContext.cleanupTrigger);
817 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
818 (tANI_U8 *) staDsAddr,
819 sizeof(tSirMacAddr));
820 mlmDeauthCnf.resultCode = statusCode;
821#if (WNI_POLARIS_FW_PRODUCT == AP)
822 mlmDeauthCnf.aid = staDsAssocId;
823#endif
824 mlmDeauthCnf.deauthTrigger =
825 mlmStaContext.cleanupTrigger;
826 /* PE session Id */
827 mlmDeauthCnf.sessionId = psessionEntry->peSessionId;
828
829 limPostSmeMessage(pMac,
830 LIM_MLM_DEAUTH_CNF,
831 (tANI_U32 *) &mlmDeauthCnf);
832 }
833 else if ((mlmStaContext.cleanupTrigger ==
834 eLIM_PEER_ENTITY_DISASSOC) ||
835 (mlmStaContext.cleanupTrigger ==
836 eLIM_PEER_ENTITY_DEAUTH))
837 {
838 /**
839 * Received Disassociation/Deauthentication from peer.
840 * Issue Purge Ind to SME.
841 */
842 limLog( pMac, LOGW, FL("Lim Posting PURGE_STA_IND to Sme. Trigger: %X\n"), mlmStaContext.cleanupTrigger) ;
843 palCopyMemory( pMac->hHdd, (tANI_U8 *) &mlmPurgeStaInd.peerMacAddr,
844 (tANI_U8 *) staDsAddr,
845 sizeof(tSirMacAddr));
846 mlmPurgeStaInd.reasonCode = (tANI_U8) mlmStaContext.disassocReason;
847 mlmPurgeStaInd.aid = staDsAssocId;
848 mlmPurgeStaInd.purgeTrigger = mlmStaContext.cleanupTrigger;
849 mlmPurgeStaInd.sessionId = psessionEntry->peSessionId;
850
851 limPostSmeMessage(pMac,
852 LIM_MLM_PURGE_STA_IND,
853 (tANI_U32 *) &mlmPurgeStaInd);
854 }
855 else if(mlmStaContext.cleanupTrigger == eLIM_JOIN_FAILURE)
856 {
857 //PE setup the peer entry in HW upfront, right after join is completed.
858 //If there is a failure during rest of the assoc sequence, this context needs to be cleaned up.
859 tANI_U8 smesessionId;
860 tANI_U16 smetransactionId;
861
862 smesessionId = psessionEntry->smeSessionId;
863 smetransactionId = psessionEntry->transactionId;
864
865 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700866 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700867
Jeff Johnsone7245742012-09-05 17:12:55 -0700868 //if it is a reassoc failure to join new AP
Madan Mohan Koyyalamudif33324b2012-11-06 19:16:17 -0800869 if((mlmStaContext.resultCode == eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE) ||
870 (mlmStaContext.resultCode == eSIR_SME_FT_REASSOC_FAILURE))
Jeff Johnsone7245742012-09-05 17:12:55 -0700871 {
872 if(mlmStaContext.resultCode != eSIR_SME_SUCCESS )
873 {
874 peDeleteSession(pMac, psessionEntry);
875 psessionEntry = NULL;
876 }
877
878 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
879 mlmStaContext.resultCode, mlmStaContext.protStatusCode, psessionEntry,
880 smesessionId, smetransactionId);
881 }
882 else
883 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700884 palFreeMemory( pMac->hHdd, psessionEntry->pLimJoinReq);
885 psessionEntry->pLimJoinReq = NULL;
886
887 if(mlmStaContext.resultCode != eSIR_SME_SUCCESS)
888 {
889 peDeleteSession(pMac,psessionEntry);
890 psessionEntry = NULL;
891 }
892
893 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, mlmStaContext.resultCode, mlmStaContext.protStatusCode,
894 psessionEntry, smesessionId, smetransactionId);
Jeff Johnsone7245742012-09-05 17:12:55 -0700895 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700896
897 }
898
899 if((NULL != psessionEntry)
900#ifdef WLAN_SOFTAP_FEATURE
901 && (eLIM_AP_ROLE != psessionEntry->limSystemRole )
902#endif
903 )
904 {
905 peDeleteSession(pMac,psessionEntry);
906 psessionEntry = NULL;
907 }
908}
909
910/**
911 * limRejectAssociation()
912 *
913 *FUNCTION:
914 * This function is called whenever Re/Association Request need
915 * to be rejected due to failure in assigning an AID or failure
916 * in adding STA context at Polaris or reject by applications.
917 *
918 *LOGIC:
919 * Resources allocated if any are freedup and (Re) Association
920 * Response frame is sent to requesting STA. Pre-Auth context
921 * will be added for this STA if it does not exist already
922 *
923 *ASSUMPTIONS:
924 *
925 *NOTE:
926 *
927 * @param *pBd - A pointer to Buffer descriptor + associated PDUs
928 * @param subType - Indicates whether it is Association Request (=0) or
929 * Reassociation Request (=1) frame
930 * @param addPreAuthContext - Indicates whether pre-auth context
931 * to be added for this STA
932 * @param authType - Indicates auth type to be added
933 * @param staId - Indicates staId of the STA being rejected
934 * association
935 * @param deleteSta - Indicates whether to delete STA context
936 * at Polaris
937 * @param rCode - Indicates what reasonCode to be sent in
938 * Re/Assoc response to STA
939 *
940 * @return None
941 */
942
943void
944limRejectAssociation(tpAniSirGlobal pMac, tSirMacAddr peerAddr, tANI_U8 subType,
945 tANI_U8 addPreAuthContext, tAniAuthType authType,
946 tANI_U16 staId, tANI_U8 deleteSta, tSirResultCodes rCode, tpPESession psessionEntry )
947{
948 tpDphHashNode pStaDs;
949
950 if (addPreAuthContext)
951 {
952 // Create entry for this STA in pre-auth list
953 struct tLimPreAuthNode *pAuthNode;
954
955 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
956
957 if (pAuthNode)
958 {
959 palCopyMemory( pMac->hHdd, (tANI_U8 *) pAuthNode->peerMacAddr,
960 peerAddr,
961 sizeof(tSirMacAddr));
962 pAuthNode->fTimerStarted = 0;
963 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
964 pAuthNode->authType = (tAniAuthType) authType;
965 limAddPreAuthNode(pMac, pAuthNode);
966 }
967 }
968
969 if (deleteSta == true)
970 {
971 pStaDs = dphGetHashEntry(pMac, staId, &psessionEntry->dph.dphHashTable);
972
973 if (pStaDs == NULL)
974 {
975 limLog(pMac, LOGW,
976 FL("No STA context, yet rejecting Association\n"));
977
978 return;
979 }
980
981 /**
982 * Polaris has state for this STA.
983 * Trigger cleanup.
984 */
985 pStaDs->mlmStaContext.cleanupTrigger = eLIM_REASSOC_REJECT;
986
987 // Receive path cleanup
988 limCleanupRxPath(pMac, pStaDs, psessionEntry);
989
990 // Send Re/Association Response with
991 // status code to requesting STA.
992 limSendAssocRspMgmtFrame(pMac,
993 rCode,
994 0,
995 peerAddr,
996 subType, 0,psessionEntry);
997
998 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL)
999 {
1000 // Assoction confirmation is complete, free the copy of association request frame
1001 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
1002 {
1003 palFreeMemory(pMac->hHdd,((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
1004 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
1005 }
1006 palFreeMemory(pMac->hHdd, psessionEntry->parsedAssocReq[pStaDs->assocId]);
1007 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
1008 }
1009 }
1010 else
1011 {
1012 limSendAssocRspMgmtFrame(pMac,
1013 eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS,
1014 1,
1015 peerAddr,
1016 subType, 0,psessionEntry);
1017 // Log error
1018 limLog(pMac, LOGW,
1019 FL("received Re/Assoc req when max associated STAs reached from \n"));
1020 limPrintMacAddr(pMac, peerAddr, LOGW);
1021 limSendSmeMaxAssocExceededNtf(pMac, peerAddr, psessionEntry->smeSessionId);
1022 }
1023} /*** end limRejectAssociation() ***/
1024
1025#ifdef WLAN_SOFTAP_FEATURE
1026
1027/** -------------------------------------------------------------
1028\fn limDecideApProtectionOnHt20Delete
1029\brief protection related function while HT20 station is getting deleted.
1030\param tpAniSirGlobal pMac
1031\param tpDphHashNode pStaDs
1032\param tpUpdateBeaconParams pBeaconParams
1033\return None
1034 -------------------------------------------------------------*/
1035static void
1036limDecideApProtectionOnHt20Delete(tpAniSirGlobal pMac,
1037 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1038{
1039 tANI_U32 i = 0;
1040 PELOG1( limLog(pMac, LOG1, FL("(%d) A HT 20 STA is disassociated. Addr is "),
1041 psessionEntry->gLimHt20Params.numSta);
1042 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1043 if (psessionEntry->gLimHt20Params.numSta > 0)
1044 {
1045 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1046 {
1047 if (psessionEntry->protStaCache[i].active)
1048 {
1049 if (palEqualMemory( pMac->hHdd,psessionEntry->protStaCache[i].addr,
1050 pStaDs->staAddr, sizeof(tSirMacAddr)))
1051 {
1052 psessionEntry->gLimHt20Params.numSta--;
1053 psessionEntry->protStaCache[i].active = false;
1054 break;
1055 }
1056 }
1057 }
1058 }
1059
1060 if (psessionEntry->gLimHt20Params.numSta == 0)
1061 {
1062 // disable protection
1063 limEnableHT20Protection(pMac, false, false, pBeaconParams,psessionEntry);
1064 }
1065}
1066/** -------------------------------------------------------------
1067\fn limDecideApProtectionOnDelete
1068\brief Decides about protection related settings when a station is getting deleted.
1069\param tpAniSirGlobal pMac
1070\param tpDphHashNode pStaDs
1071\param tpUpdateBeaconParams pBeaconParams
1072\return None
1073 -------------------------------------------------------------*/
1074void
1075limDecideApProtectionOnDelete(tpAniSirGlobal pMac,
1076 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1077{
1078 tANI_U32 phyMode;
1079 tHalBitVal erpEnabled = eHAL_CLEAR;
1080 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1081 tANI_U32 i;
1082
1083 if(NULL == pStaDs)
1084 return;
1085
1086 limGetRfBand(pMac, &rfBand, psessionEntry);
1087 if(SIR_BAND_5_GHZ == rfBand)
1088 {
1089 //we are HT. if we are 11A, then protection is not required.
Jeff Johnsone7245742012-09-05 17:12:55 -07001090 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 {
1092 //we are HT and 11A station is leaving.
1093 //protection consideration required.
1094 //HT station leaving ==> this case is commonly handled between both the bands below.
1095 if((psessionEntry->beaconParams.llaCoexist) &&
1096 (false == pStaDs->mlmStaContext.htCapability))
1097 {
1098 PELOG1(limLog(pMac, LOG1, FL("(%d) A 11A STA is disassociated. Addr is "),
1099 psessionEntry->gLim11aParams.numSta);
1100 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1101 if (psessionEntry->gLim11aParams.numSta > 0)
1102 {
1103 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1104 {
1105 if (psessionEntry->protStaCache[i].active)
1106 {
1107 if (palEqualMemory( pMac->hHdd,psessionEntry->protStaCache[i].addr,
1108 pStaDs->staAddr, sizeof(tSirMacAddr)))
1109 {
1110 psessionEntry->gLim11aParams.numSta--;
1111 psessionEntry->protStaCache[i].active = false;
1112 break;
1113 }
1114 }
1115 }
1116 }
1117
1118 if(psessionEntry->gLim11aParams.numSta == 0)
1119 {
1120 // disable protection
1121 limEnable11aProtection(pMac, false, false, pBeaconParams,psessionEntry);
1122 }
1123 }
1124 }
1125 }
1126 else if(SIR_BAND_2_4_GHZ == rfBand)
1127 {
1128 limGetPhyMode(pMac, &phyMode, psessionEntry);
1129
1130 erpEnabled = pStaDs->erpEnabled;
1131 //we are HT or 11G and 11B station is getting deleted.
1132 if (((phyMode == WNI_CFG_PHY_MODE_11G) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07001133 psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001134 (erpEnabled == eHAL_CLEAR))
1135 {
1136 PELOG1(limLog(pMac, LOG1, FL("(%d) A legacy STA is disassociated. Addr is "),
1137 psessionEntry->gLim11bParams.numSta);
1138 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1139 if (psessionEntry->gLim11bParams.numSta > 0)
1140 {
1141 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1142 {
1143 if (psessionEntry->protStaCache[i].active)
1144 {
1145 if (palEqualMemory( pMac->hHdd,psessionEntry->protStaCache[i].addr,
1146 pStaDs->staAddr, sizeof(tSirMacAddr)))
1147 {
1148 psessionEntry->gLim11bParams.numSta--;
1149 psessionEntry->protStaCache[i].active = false;
1150 break;
1151 }
1152 }
1153 }
1154 }
1155
1156 if (psessionEntry->gLim11bParams.numSta == 0)
1157 {
1158 // disable protection
1159 PELOG1(limLog(pMac, LOG1, FL("No 11B STA exists\n"));)
1160 limEnable11gProtection(pMac, false, false, pBeaconParams,psessionEntry);
1161 }
1162 }
1163 //(non-11B station is leaving) or (we are not 11G or HT AP)
Jeff Johnsone7245742012-09-05 17:12:55 -07001164 else if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001165 { //we are HT AP and non-11B station is leaving.
1166
1167 //11g station is leaving
1168 if(!pStaDs->mlmStaContext.htCapability)
1169 {
1170 PELOG1(limLog(pMac, LOG1, FL("(%d) A 11g STA is disassociated. Addr is "),
1171 psessionEntry->gLim11bParams.numSta);
1172 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1173 if (psessionEntry->gLim11gParams.numSta > 0)
1174 {
1175 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1176 {
1177 if (psessionEntry->protStaCache[i].active)
1178 {
1179 if (palEqualMemory( pMac->hHdd,psessionEntry->protStaCache[i].addr,
1180 pStaDs->staAddr, sizeof(tSirMacAddr)))
1181 {
1182 psessionEntry->gLim11gParams.numSta--;
1183 psessionEntry->protStaCache[i].active = false;
1184 break;
1185 }
1186 }
1187 }
1188 }
1189
1190 if (psessionEntry->gLim11gParams.numSta == 0)
1191 {
1192 // disable protection
1193 limEnableHtProtectionFrom11g(pMac, false, false, pBeaconParams,psessionEntry);
1194 }
1195 }
1196 }
1197 }
1198
1199 //LSIG TXOP not supporting staiton leaving. applies to 2.4 as well as 5 GHZ.
Jeff Johnsone7245742012-09-05 17:12:55 -07001200 if((true == psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001201 (true == pStaDs->mlmStaContext.htCapability))
1202 {
1203 //HT non-GF leaving
1204 if(!pStaDs->htGreenfield)
1205 {
1206 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-GF STA is disassociated. Addr is "),
1207 psessionEntry->gLimNonGfParams.numSta);
1208 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1209 if (psessionEntry->gLimNonGfParams.numSta > 0)
1210 {
1211 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1212 {
1213 if (psessionEntry->protStaCache[i].active)
1214 {
1215 if (palEqualMemory( pMac->hHdd,psessionEntry->protStaCache[i].addr,
1216 pStaDs->staAddr, sizeof(tSirMacAddr)))
1217 {
1218 psessionEntry->gLimNonGfParams.numSta--;
1219 psessionEntry->protStaCache[i].active = false;
1220 break;
1221 }
1222 }
1223 }
1224 }
1225
1226 if (psessionEntry->gLimNonGfParams.numSta == 0)
1227 {
1228 // disable protection
1229 limEnableHTNonGfProtection(pMac, false, false, pBeaconParams,psessionEntry);
1230 }
1231 }
1232 //HT 20Mhz station leaving.
1233 if(psessionEntry->beaconParams.ht20Coexist &&
1234 (eHT_CHANNEL_WIDTH_20MHZ == pStaDs->htSupportedChannelWidthSet))
1235 {
1236 limDecideApProtectionOnHt20Delete(pMac, pStaDs, pBeaconParams,psessionEntry);
1237 }
1238
1239 if(false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport &&
1240 (false == pStaDs->htLsigTXOPProtection))
1241 {
1242 PELOG1( limLog(pMac, LOG1, FL("(%d) A HT LSIG not supporting STA is disassociated. Addr is "),
1243 psessionEntry->gLimLsigTxopParams.numSta);
1244 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1245 if (psessionEntry->gLimLsigTxopParams.numSta > 0)
1246 {
1247 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1248 {
1249 if (psessionEntry->protStaCache[i].active)
1250 {
1251 if (palEqualMemory( pMac->hHdd,psessionEntry->protStaCache[i].addr,
1252 pStaDs->staAddr, sizeof(tSirMacAddr)))
1253 {
1254 psessionEntry->gLimLsigTxopParams.numSta--;
1255 psessionEntry->protStaCache[i].active = false;
1256 break;
1257 }
1258 }
1259 }
1260 }
1261
1262 if (psessionEntry->gLimLsigTxopParams.numSta == 0)
1263 {
1264 // disable protection
1265 limEnableHTLsigTxopProtection(pMac, true, false, pBeaconParams,psessionEntry);
1266 }
1267 }
1268 }
1269}
1270
1271#endif
1272
1273
1274/** -------------------------------------------------------------
1275\fn limDecideShortPreamble
1276\brief Decides about any short preamble reated change because of new station joining.
1277\param tpAniSirGlobal pMac
1278\param tpDphHashNode pStaDs
1279\param tpUpdateBeaconParams pBeaconParams
1280\return None
1281 -------------------------------------------------------------*/
1282void limDecideShortPreamble(tpAniSirGlobal pMac,
1283 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry )
1284{
1285 tANI_U32 i;
1286
1287 if (pStaDs->shortPreambleEnabled == eHAL_CLEAR)
1288 {
1289 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-short preamble STA is disassociated. Addr is "),
1290 psessionEntry->gLimNoShortParams.numNonShortPreambleSta);
1291 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1292 if (psessionEntry->gLimNoShortParams.numNonShortPreambleSta > 0)
1293 {
1294 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1295 {
1296 if (psessionEntry->gLimNoShortParams.staNoShortCache[i].active)
1297 {
1298 if (palEqualMemory( pMac->hHdd, psessionEntry->gLimNoShortParams.staNoShortCache[i].addr,
1299 pStaDs->staAddr, sizeof(tSirMacAddr)))
1300 {
1301 psessionEntry->gLimNoShortParams.numNonShortPreambleSta--;
1302 psessionEntry->gLimNoShortParams.staNoShortCache[i].active = false;
1303 break;
1304 }
1305 }
1306 }
1307 }
1308
1309 if (psessionEntry->gLimNoShortParams.numNonShortPreambleSta == 0)
1310 {
1311 // enable short preamble
1312 PELOG1(limLog(pMac, LOG1, FL("All associated STAs have short preamble support now.\n"));)
1313 //reset the cache
1314 palZeroMemory( pMac->hHdd, (tANI_U8 *)&psessionEntry->gLimNoShortParams , sizeof(tLimNoShortParams));
1315 if (limEnableShortPreamble(pMac, true, pBeaconParams, psessionEntry) != eSIR_SUCCESS)
1316 PELOGE(limLog(pMac, LOGE, FL("Cannot enable short preamble\n"));)
1317 }
1318 }
1319}
1320
1321/** -------------------------------------------------------------
1322\fn limDecideShortSlot
1323\brief Decides about any short slot time related change because of station leaving the BSS.
1324\param tpAniSirGlobal pMac
1325\param tpDphHashNode pStaDs
1326\return None
1327 -------------------------------------------------------------*/
1328
1329void
1330limDecideShortSlot(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1331 tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
1332{
1333 tANI_U32 i, val;
1334 if (pStaDs->shortSlotTimeEnabled == eHAL_CLEAR)
1335 {
1336 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-short slottime STA is disassociated. Addr is "),
1337 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta);
1338 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1339
1340#ifdef WLAN_SOFTAP_FEATURE
1341 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
1342 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta> 0)
1343 {
1344 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1345 {
1346 if (psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active)
1347 {
1348 if (palEqualMemory( pMac->hHdd, psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
1349 pStaDs->staAddr, sizeof(tSirMacAddr)))
1350 {
1351 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta--;
1352 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active = false;
1353 break;
1354 }
1355 }
1356 }
1357 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001358 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001359#endif
1360 {
1361 if (pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta> 0)
1362 {
1363 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1364 {
1365 if (pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active)
1366 {
1367 if (palEqualMemory( pMac->hHdd, pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
1368 pStaDs->staAddr, sizeof(tSirMacAddr)))
1369 {
1370 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta--;
1371 pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active = false;
1372 break;
1373 }
1374 }
1375 }
1376 }
1377 }
1378
1379 wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val);
1380
1381#ifdef WLAN_SOFTAP_FEATURE
1382 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
1383 (val && psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta == 0))
1384 {
1385 // enable short slot time
1386 PELOG1(limLog(pMac, LOG1, FL("All associated STAs have short slot time support now.\n"));)
1387 //reset the cache
1388 palZeroMemory( pMac->hHdd, (tANI_U8 *)&psessionEntry->gLimNoShortSlotParams , sizeof(tLimNoShortSlotParams));
1389 // in case of AP set SHORT_SLOT_TIME to enable
1390 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1391 {
1392 pBeaconParams->fShortSlotTime = true;
1393 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001394 psessionEntry->shortSlotTimeSupported = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 }
1396 }
1397 else
1398#endif
1399 {
1400 if (val && pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta == 0)
1401 {
1402 // enable short slot time
1403 PELOG1(limLog(pMac, LOG1, FL("All associated STAs have short slot time support now.\n"));)
1404 //reset the cache
1405 palZeroMemory( pMac->hHdd, (tANI_U8 *)&pMac->lim.gLimNoShortSlotParams , sizeof(tLimNoShortSlotParams));
1406 // in case of AP set SHORT_SLOT_TIME to enable
1407 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1408 {
1409 pBeaconParams->fShortSlotTime = true;
1410 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001411 psessionEntry->shortSlotTimeSupported = true;
1412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 }
1414 }
1415 }
1416}
1417
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07001418void
1419limPostReassocFailure(tpAniSirGlobal pMac,
1420 tSirResultCodes resultCode,
1421 tANI_U16 protStatusCode,tpPESession psessionEntry)
1422{
1423 tLimMlmReassocCnf mlmReassocCnf;
1424
1425 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1426 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
1427
1428 // 'Change' timer for future activations
1429 limDeactivateAndChangeTimer(pMac, eLIM_REASSOC_FAIL_TIMER);
1430
1431 mlmReassocCnf.resultCode = resultCode;
1432 mlmReassocCnf.protStatusCode = protStatusCode;
1433 /* Update PE session Id */
1434 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1435 limPostSmeMessage(pMac,
1436 LIM_MLM_REASSOC_CNF,
1437 (tANI_U32 *) &mlmReassocCnf);
1438} /*** end limPostReassocFailure() ***/
1439
Jeff Johnson295189b2012-06-20 16:38:30 -07001440/**
1441 * limRestorePreReassocState()
1442 *
1443 *FUNCTION:
1444 * This function is called on STA role whenever Reasociation
1445 * Response with a reject code is received from AP.
1446 *
1447 *LOGIC:
1448 * Reassociation failure timer is stopped, Old (or current) AP's
1449 * context is restored both at Polaris & software
1450 *
1451 *ASSUMPTIONS:
1452 *
1453 *NOTE:
1454 *
1455 * @param pMac - Pointer to Global MAC structure
1456 * @param resultCode - Result code that specifies why Reassociation
1457 * attemp failed
1458 *
1459 * @return None
1460 */
1461
1462void
1463limRestorePreReassocState(tpAniSirGlobal pMac,
1464 tSirResultCodes resultCode,
1465 tANI_U16 protStatusCode,tpPESession psessionEntry)
1466{
Jeff Johnsone7245742012-09-05 17:12:55 -07001467 tANI_U8 chanNum, secChanOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 tLimMlmReassocCnf mlmReassocCnf;
1469
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001471 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07001472
1473 // 'Change' timer for future activations
1474 limDeactivateAndChangeTimer(pMac, eLIM_REASSOC_FAIL_TIMER);
1475
1476 // Update BSSID at CFG database
1477 #if 0
1478 if (cfgSetStr(pMac, WNI_CFG_BSSID,
1479 pMac->lim.gLimCurrentBssId,
1480 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
1481 {
1482 /// Could not update BSSID at CFG. Log error.
1483 limLog(pMac, LOGP, FL("could not update BSSID at CFG\n"));
1484 return;
1485 }
Madan Mohan Koyyalamudi70322d52012-10-18 20:07:33 -07001486 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001487
1488 // chanNum = pMac->lim.gLimCurrentChannelId;
1489
1490 /* To support BT-AMP */
1491 chanNum = psessionEntry->currentOperChannel;
Jeff Johnsone7245742012-09-05 17:12:55 -07001492 secChanOffset = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001493
Jeff Johnsone7245742012-09-05 17:12:55 -07001494 limSetChannel(pMac, chanNum, secChanOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001495
1496 /** @ToDo : Need to Integrate the STOP the DataTransfer to the AP from 11H code */
1497
1498 mlmReassocCnf.resultCode = resultCode;
1499 mlmReassocCnf.protStatusCode = protStatusCode;
1500 /* Update PE session Id */
1501 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1502 limPostSmeMessage(pMac,
1503 LIM_MLM_REASSOC_CNF,
1504 (tANI_U32 *) &mlmReassocCnf);
1505} /*** end limRestorePreReassocState() ***/
1506
1507
1508
1509/**
1510 * limIsReassocInProgress()
1511 *
1512 *FUNCTION:
1513 * This function is called to see if STA is in wt-reassoc-rsp state.
1514 *
1515 *LOGIC:
1516 *
1517 *ASSUMPTIONS:
1518 *
1519 *NOTE:
1520 *
1521 * @param pMac - Pointer to Global MAC structure
1522 *
1523 * @return eANI_BOOLEAN_TRUE When STA is waiting for Reassoc response from AP \n
1524 * else eANI_BOOLEAN_FALSE
1525 */
1526
1527eAniBoolean
1528limIsReassocInProgress(tpAniSirGlobal pMac,tpPESession psessionEntry)
1529{
1530 if(((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
1531 ((psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE) ||
1532 (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_LINK_FAIL_STATE)))
1533 return eANI_BOOLEAN_TRUE;
1534
1535 return eANI_BOOLEAN_FALSE;
1536} /*** end limIsReassocInProgress() ***/
1537
Jeff Johnsone7245742012-09-05 17:12:55 -07001538#ifdef WLAN_FEATURE_11AC
1539tSirRetStatus limPopulateVhtMcsSet(tpAniSirGlobal pMac,
1540 tpSirSupportedRates pRates,
1541 tDot11fIEVHTCaps *pPeerVHTCaps,
1542 tpPESession psessionEntry)
1543{
1544 tANI_U32 val;
Jeff Johnson295189b2012-06-20 16:38:30 -07001545
Jeff Johnsone7245742012-09-05 17:12:55 -07001546 if(IS_DOT11_MODE_VHT(psessionEntry->dot11mode))
1547 {
1548 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_RX_MCS_MAP,&val) !=
1549 eSIR_SUCCESS )
1550 {
1551 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX MCS MAP\n"));)
1552 goto error;
1553 }
1554 pRates->vhtRxMCSMap = (tANI_U16)val;
1555
1556 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_TX_MCS_MAP,&val ) !=
1557 eSIR_SUCCESS )
1558 {
1559 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT TX MCS MAP\n"));)
1560 goto error;
1561 }
1562 pRates->vhtTxMCSMap = (tANI_U16)val;
1563
1564 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE,&val ) !=
1565 eSIR_SUCCESS )
1566 {
1567 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX Supported data rate MAP\n"));)
1568 goto error;
1569 }
1570 pRates->vhtRxHighestDataRate = (tANI_U16)val;
1571
1572 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE,&val ) !=
1573 eSIR_SUCCESS )
1574 {
1575 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX Supported data rate MAP\n"));)
1576 goto error;
1577 }
1578 pRates->vhtTxHighestDataRate = (tANI_U16)val;
1579
1580 if( pPeerVHTCaps != NULL)
1581 {
1582 pRates->vhtTxHighestDataRate = SIR_MIN(pRates->vhtTxHighestDataRate, pPeerVHTCaps->txSupDataRate);
1583 pRates->vhtRxHighestDataRate = SIR_MIN(pRates->vhtRxHighestDataRate, pPeerVHTCaps->rxHighSupDataRate);
1584
Jeff Johnson1250df42012-12-10 14:31:52 -08001585 // Acquire PEER MCS map if we exceed.
Jeff Johnsone7245742012-09-05 17:12:55 -07001586 // We compare/update only the last 2 bits of the map as we support only single BSS.
1587 // Firmware takes care of this comparison
1588 pRates->vhtRxMCSMap &= ~(0x3); // Clearing the last 2 bits in the bitmap
1589 pRates->vhtRxMCSMap |= (pPeerVHTCaps->rxMCSMap & 0x3); // Updating the last 2 bits in the bitmap
1590
1591 // Firmware takes care of this comparison
1592 pRates->vhtTxMCSMap &= ~(0x3); // Clearing the last 2 bits in the bitmap
1593 pRates->vhtTxMCSMap |= (pPeerVHTCaps->txMCSMap & 0x3); // Updating the last 2 bits in the bitmap
1594 }
1595 }
1596 return eSIR_SUCCESS;
1597error:
1598
1599 return eSIR_FAILURE;
1600
1601}
1602#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001603
1604/**
1605 * limPopulateOwnRateSet
1606 *
1607 * FUNCTION:
1608 * This function is called by limProcessAssocRsp() or
1609 * limAddStaInIBSS()
1610 * - It creates a combined rate set of 12 rates max which
1611 * comprises the basic and extended rates read from CFG
1612 * - It sorts the combined rate Set and copy it in the
1613 * rate array of the pSTA descriptor
1614 * - It sets the erpEnabled bit of the STA descriptor
1615 *
1616 * NOTE:
1617 * ERP bit is set iff the dph PHY mode is 11G and there is at least
1618 * an A rate in the supported or extended rate sets
1619 *
1620 * @param pMac - Pointer to Global MAC structure
1621 * @param basicOnly - When passed value is true, only basic
1622 * rates are copied to DPH node else
1623 * all supported rates are copied
1624 * @return eSIR_SUCCESS or eSIR_FAILURE
1625 *
1626 */
Jeff Johnsone7245742012-09-05 17:12:55 -07001627#ifdef WLAN_FEATURE_11AC
1628tSirRetStatus
1629limPopulateOwnRateSet(tpAniSirGlobal pMac,
1630 tpSirSupportedRates pRates,
1631 tANI_U8* pSupportedMCSSet,
1632 tANI_U8 basicOnly,
1633 tpPESession psessionEntry,
1634 tDot11fIEVHTCaps *pVHTCaps)
1635#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001636tSirRetStatus
1637limPopulateOwnRateSet(tpAniSirGlobal pMac,
1638 tpSirSupportedRates pRates,
1639 tANI_U8* pSupportedMCSSet,
1640 tANI_U8 basicOnly,
1641 tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07001642#endif
1643
Jeff Johnson295189b2012-06-20 16:38:30 -07001644{
1645 tSirMacRateSet tempRateSet;
1646 tSirMacRateSet tempRateSet2;
1647 tANI_U32 i,j,val,min,isArate;
1648 tANI_U32 phyMode = 0;
1649
1650 isArate = 0;
1651
1652 limGetPhyMode(pMac, &phyMode, psessionEntry);
1653
1654 // Get own rate set
1655 #if 0
1656 val = WNI_CFG_OPERATIONAL_RATE_SET_LEN;
1657 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
1658 (tANI_U8 *) &tempRateSet.rate,
1659 &val) != eSIR_SUCCESS)
1660 {
1661 /// Could not get rateset from CFG. Log error.
1662 limLog(pMac, LOGP, FL("could not retrieve rateset\n"));
1663 }
1664 #endif // TO SUPPORT BT-AMP
1665
1666 /* copy operational rate set from psessionEntry */
1667 palCopyMemory(pMac->hHdd,(tANI_U8 *)tempRateSet.rate,(tANI_U8*)(psessionEntry->rateSet.rate), psessionEntry->rateSet.numRates);
1668 tempRateSet.numRates = psessionEntry->rateSet.numRates;
1669
1670 if (phyMode == WNI_CFG_PHY_MODE_11G)
1671 {
1672
1673 // get own extended rate set
1674 #if 0
1675 val = WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN;
1676 if (wlan_cfgGetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
1677 (tANI_U8 *) &tempRateSet2.rate,
1678 &val) != eSIR_SUCCESS)
1679 {
1680 /// Could not get extended rateset from CFG. Log error.
1681 limLog(pMac, LOGP, FL("could not retrieve extended rateset\n"));
1682 }
1683 tempRateSet2.numRates = (tANI_U8) val;
1684 #endif
1685
1686 palCopyMemory(pMac->hHdd,(tANI_U8 *)tempRateSet2.rate, (tANI_U8*)(psessionEntry->extRateSet.rate), psessionEntry->extRateSet.numRates);
1687 tempRateSet2.numRates = psessionEntry->extRateSet.numRates;
1688
1689 }
1690 else
1691 tempRateSet2.numRates = 0;
1692
1693
1694 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
1695 {
1696 //we are in big trouble
1697 limLog(pMac, LOGP, FL("more than 12 rates in CFG\n"));
1698 //panic
1699 goto error;
1700 }
1701
1702
1703 //copy all rates in tempRateSet, there are 12 rates max
1704 for (i = 0;i < tempRateSet2.numRates; i++)
1705 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
1706 tempRateSet.numRates += tempRateSet2.numRates;
1707
1708 /**
1709 * Sort rates in tempRateSet (they are likely to be already sorted)
1710 * put the result in pSupportedRates
1711 */
1712 {
1713 tANI_U8 aRateIndex = 0;
1714 tANI_U8 bRateIndex = 0;
1715
1716 palZeroMemory( pMac->hHdd, (tANI_U8 *) pRates, sizeof(tSirSupportedRates));
1717 for(i = 0;i < tempRateSet.numRates; i++)
1718 {
1719 min = 0;
1720 val = 0xff;
1721 isArate = 0;
1722 for(j = 0;j < tempRateSet.numRates; j++)
1723 {
1724 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
1725 {
1726 val = tempRateSet.rate[j] & 0x7f;
1727 min = j;
1728 }
1729 }
1730
1731 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1732 isArate = 1;
1733
1734 /*
1735 * HAL needs to know whether the rate is basic rate or not, as it needs to
1736 * update the response rate table accordingly. e.g. if one of the 11a rates is
1737 * basic rate, then that rate can be used for sending control frames.
1738 * HAL updates the response rate table whenever basic rate set is changed.
1739 */
1740 if (basicOnly)
1741 {
1742 if (tempRateSet.rate[min] & 0x80)
1743 {
1744 if (isArate)
1745 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1746 else
1747 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1748 }
1749 }
1750 else
1751 {
1752 if (isArate)
1753 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1754 else
1755 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1756 }
1757 tempRateSet.rate[min] = 0xff;
1758 }
1759
1760 }
1761
1762
1763 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode))
1764 {
1765 val = SIZE_OF_SUPPORTED_MCS_SET;
1766 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
1767 pRates->supportedMCSSet,
1768 &val) != eSIR_SUCCESS)
1769 {
1770 /// Could not get rateset from CFG. Log error.
1771 PELOGE(limLog(pMac, LOGE, FL("could not retrieve supportedMCSSet\n"));)
1772 goto error;
1773 }
1774
1775
1776 //if supported MCS Set of the peer is passed in, then do the intersection
1777 //else use the MCS set from local CFG.
1778
1779 if(pSupportedMCSSet != NULL)
1780 {
1781 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1782 pRates->supportedMCSSet[i] &= pSupportedMCSSet[i];
1783
1784 }
1785
1786 PELOG2(limLog(pMac, LOG2, FL("MCS Rate Set Bitmap: \n"));)
1787 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1788 PELOGW(limLog(pMac, LOG2,FL("%x ") , pRates->supportedMCSSet[i]);)
1789 }
1790
Jeff Johnsone7245742012-09-05 17:12:55 -07001791#ifdef WLAN_FEATURE_11AC
1792 limPopulateVhtMcsSet(pMac, pRates , pVHTCaps,psessionEntry);
1793#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001794
1795 return eSIR_SUCCESS;
1796
1797 error:
1798
1799 return eSIR_FAILURE;
1800} /*** limPopulateOwnRateSet() ***/
1801
Jeff Johnson295189b2012-06-20 16:38:30 -07001802/**
1803 * limPopulateMatchingRateSet
1804 * FUNCTION:
1805 * This is called at the time of Association Request
1806 * processing on AP and while adding peer's context
1807 * in IBSS role to process the CFG rate sets and
1808 * the rate sets received in the Assoc request on AP
1809 * or Beacon/Probe Response from peer in IBSS.
1810 *
1811 * LOGIC:
1812 * 1. It makes the intersection between our own rate Sat
1813 * and extemcded rate set and the ones received in the
1814 * association request.
1815 * 2. It creates a combined rate set of 12 rates max which
1816 * comprised the basic and extended rates
1817 * 3. It sorts the combined rate Set and copy it in the
1818 * rate array of the pSTA descriptor
1819 *
1820 * ASSUMPTION:
1821 * The parser has already ensured unicity of the rates in the
1822 * association request structure
1823 *
1824 * @param: pMac - Pointer to Global MAC structure
1825 * pStaDs - Pointer to DPH node
1826 * pOperRateSet - Pointer to peer's supported rateset
1827 * pExtRateSet - Pointer to peer's extended rateset
1828 *
1829 * @return: eSIR_SUCCESS or eSIR_FAILURE
1830 */
Jeff Johnsone7245742012-09-05 17:12:55 -07001831#ifdef WLAN_FEATURE_11AC
1832tSirRetStatus
1833limPopulateMatchingRateSet(tpAniSirGlobal pMac,
1834 tpDphHashNode pStaDs,
1835 tSirMacRateSet *pOperRateSet,
1836 tSirMacRateSet *pExtRateSet,
1837 tANI_U8* pSupportedMCSSet,
1838 tSirMacPropRateSet *pAniLegRateSet,
1839 tpPESession psessionEntry,
1840 tDot11fIEVHTCaps *pVHTCaps)
Jeff Johnson295189b2012-06-20 16:38:30 -07001841
Jeff Johnsone7245742012-09-05 17:12:55 -07001842#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001843tSirRetStatus
1844limPopulateMatchingRateSet(tpAniSirGlobal pMac,
1845 tpDphHashNode pStaDs,
1846 tSirMacRateSet *pOperRateSet,
1847 tSirMacRateSet *pExtRateSet,
1848 tANI_U8* pSupportedMCSSet,
1849 tSirMacPropRateSet *pAniLegRateSet,
1850 tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07001851#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001852{
1853 tSirMacRateSet tempRateSet;
1854 tSirMacRateSet tempRateSet2;
1855 tANI_U32 i,j,val,min,isArate;
1856 tANI_U32 phyMode;
1857 tANI_U8 mcsSet[SIZE_OF_SUPPORTED_MCS_SET];
1858
1859 isArate=0;
1860
1861 // limGetPhyMode(pMac, &phyMode);
1862 limGetPhyMode(pMac, &phyMode, psessionEntry);
1863
1864 // get own rate set
1865 // val = WNI_CFG_OPERATIONAL_RATE_SET_LEN;
1866 #if 0
1867 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
1868 (tANI_U8 *) &tempRateSet.rate,
1869 &val) != eSIR_SUCCESS)
1870 {
1871 /// Could not get rateset from CFG. Log error.
1872 limLog(pMac, LOGP, FL("could not retrieve rateset\n"));
1873 }
1874
1875 #endif // TO SUPPORT BT-AMP
1876
1877 /* copy operational rate set from psessionEntry */
1878 palCopyMemory(pMac->hHdd,(tempRateSet.rate),(psessionEntry->rateSet.rate),psessionEntry->rateSet.numRates);
1879 tempRateSet.numRates = (tANI_U8) psessionEntry->rateSet.numRates;
1880
1881 if (phyMode == WNI_CFG_PHY_MODE_11G)
1882 {
1883
1884 #if 0
1885 // get own extended rate set
1886 val = WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN;
1887 if (wlan_cfgGetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
1888 (tANI_U8 *) &tempRateSet2.rate,
1889 &val) != eSIR_SUCCESS)
1890 #endif
1891 palCopyMemory(pMac->hHdd,(tempRateSet2.rate),(psessionEntry->extRateSet.rate),psessionEntry->extRateSet.numRates);
1892 tempRateSet2.numRates = (tANI_U8) psessionEntry->extRateSet.numRates;
1893 }
1894 else
1895 tempRateSet2.numRates = 0;
1896
1897 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
1898 {
1899 PELOGE(limLog(pMac, LOGE, FL("more than 12 rates in CFG\n"));)
1900 goto error;
1901 }
1902
1903 /**
1904 * Handling of the rate set IEs is the following:
1905 * - keep only rates that we support and that the station supports
1906 * - sort and the rates into the pSta->rate array
1907 */
1908
1909 // Copy all rates in tempRateSet, there are 12 rates max
1910 for(i = 0; i < tempRateSet2.numRates; i++)
1911 tempRateSet.rate[i + tempRateSet.numRates] =
1912 tempRateSet2.rate[i];
1913
1914 tempRateSet.numRates += tempRateSet2.numRates;
1915
1916 /**
1917 * Sort rates in tempRateSet (they are likely to be already sorted)
1918 * put the result in tempRateSet2
1919 */
1920 tempRateSet2.numRates = 0;
1921
1922 for(i = 0;i < tempRateSet.numRates; i++)
1923 {
1924 min = 0;
1925 val = 0xff;
1926
1927 for(j = 0;j < tempRateSet.numRates; j++)
1928 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
1929 {
1930 val = tempRateSet.rate[j] & 0x7f;
1931 min = j;
1932 }
1933
1934 tempRateSet2.rate[tempRateSet2.numRates++] =
1935 tempRateSet.rate[min];
1936 tempRateSet.rate[min] = 0xff;
1937 }
1938
1939
1940 /**
1941 * Copy received rates in tempRateSet, the parser has ensured
1942 * unicity of the rates so there cannot be more than 12
1943 */
1944 for(i = 0; i < pOperRateSet->numRates; i++)
1945 {
1946 tempRateSet.rate[i] = pOperRateSet->rate[i];
1947 }
1948
1949 tempRateSet.numRates = pOperRateSet->numRates;
1950
1951 if (pExtRateSet->numRates)
1952 {
1953 if((tempRateSet.numRates + pExtRateSet->numRates) > 12 )
1954 {
1955 limLog( pMac, LOG2,
1956 "Sum of SUPPORTED and EXTENDED Rate Set (%1d) exceeds 12!",
1957 tempRateSet.numRates + pExtRateSet->numRates );
1958
1959 if( tempRateSet.numRates < 12 )
1960 {
1961 int found = 0;
1962 int tail = tempRateSet.numRates;
1963
1964 for( i = 0; i < pExtRateSet->numRates; i++ )
1965 {
1966 found = 0;
1967 for( j = 0; j < (tANI_U32) tail; j++ )
1968 {
1969 if((tempRateSet.rate[j] & 0x7F) ==
1970 (pExtRateSet->rate[i] & 0x7F))
1971 {
1972 found = 1;
1973 break;
1974 }
1975 }
1976
1977 if( !found )
1978 {
1979 tempRateSet.rate[tempRateSet.numRates++] =
1980 pExtRateSet->rate[i];
1981
1982 if( tempRateSet.numRates >= 12 )
1983 break;
1984 }
1985 }
1986 }
1987 else
1988 limLog( pMac, LOG2,
1989 "Relying only on the SUPPORTED Rate Set IE..." );
1990 }
1991 else
1992 {
1993 for(j = 0; j < pExtRateSet->numRates; j++)
1994 tempRateSet.rate[i+j] = pExtRateSet->rate[j];
1995
1996 tempRateSet.numRates += pExtRateSet->numRates;
1997 }
1998 }
1999
2000 {
2001 tpSirSupportedRates rates = &pStaDs->supportedRates;
2002 tANI_U8 aRateIndex = 0;
2003 tANI_U8 bRateIndex = 0;
2004 palZeroMemory( pMac->hHdd, (tANI_U8 *) rates, sizeof(tSirSupportedRates));
2005 for(i = 0;i < tempRateSet2.numRates; i++)
2006 {
2007 for(j = 0;j < tempRateSet.numRates; j++)
2008 {
2009 if ((tempRateSet2.rate[i] & 0x7F) ==
2010 (tempRateSet.rate[j] & 0x7F))
2011 {
2012#ifdef FEATURE_WLAN_NON_INTEGRATED_SOC
2013 if ((bRateIndex > HAL_NUM_11B_RATES) || (aRateIndex > HAL_NUM_11A_RATES))
2014 {
2015 limLog(pMac, LOGE, FL("Invalid number of rates (11b->%d, 11a->%d)\n"),
2016 bRateIndex, aRateIndex);
2017 return eSIR_FAILURE;
2018 }
2019#endif
2020 if (sirIsArate(tempRateSet2.rate[i] & 0x7f))
2021 {
2022 isArate=1;
2023 rates->llaRates[aRateIndex++] = tempRateSet2.rate[i];
2024 }
2025 else
2026 rates->llbRates[bRateIndex++] = tempRateSet2.rate[i];
2027 break;
2028 }
2029 }
2030 }
2031
2032
2033 //Now add the Polaris rates only when Proprietary rates are enabled.
2034 val = 0;
2035 if(wlan_cfgGetInt(pMac, WNI_CFG_PROPRIETARY_RATES_ENABLED, &val) != eSIR_SUCCESS)
2036 {
2037 limLog(pMac, LOGP, FL("could not retrieve prop rate enabled flag from CFG\n"));
2038 }
2039 else if(val)
2040 {
2041 for(i=0; i<pAniLegRateSet->numPropRates; i++)
2042 rates->aniLegacyRates[i] = pAniLegRateSet->propRate[i];
2043 }
2044
2045 }
2046
2047
2048 //compute the matching MCS rate set, if peer is 11n capable and self mode is 11n
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002049#ifdef FEATURE_WLAN_TDLS
2050 if(pStaDs->mlmStaContext.htCapability)
2051#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode) &&
2053 (pStaDs->mlmStaContext.htCapability))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002054#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 {
2056 val = SIZE_OF_SUPPORTED_MCS_SET;
2057 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2058 mcsSet,
2059 &val) != eSIR_SUCCESS)
2060 {
2061 /// Could not get rateset from CFG. Log error.
2062 limLog(pMac, LOGP, FL("could not retrieve supportedMCSSet\n"));
2063 goto error;
2064 }
2065
2066 for(i=0; i<val; i++)
2067 pStaDs->supportedRates.supportedMCSSet[i] = mcsSet[i] & pSupportedMCSSet[i];
2068
2069 PELOG2(limLog(pMac, LOG2, FL("limPopulateMatchingRateSet: MCS Rate Set Bitmap from CFG and DPH : \n"));)
2070 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2071 {
2072 PELOG2(limLog(pMac, LOG2,FL("%x %x "), mcsSet[i], pStaDs->supportedRates.supportedMCSSet[i]);)
2073 }
2074 }
2075
Jeff Johnsone7245742012-09-05 17:12:55 -07002076#ifdef WLAN_FEATURE_11AC
2077 limPopulateVhtMcsSet(pMac, &pStaDs->supportedRates, pVHTCaps, psessionEntry);
2078#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 /**
2080 * Set the erpEnabled bit iff the phy is in G mode and at least
2081 * one A rate is supported
2082 */
2083 if ((phyMode == WNI_CFG_PHY_MODE_11G) && isArate)
2084 pStaDs->erpEnabled = eHAL_SET;
2085
2086
2087
2088 return eSIR_SUCCESS;
2089
2090 error:
2091
2092 return eSIR_FAILURE;
2093} /*** limPopulateMatchingRateSet() ***/
2094
2095
2096
2097/**
2098 * limAddSta()
2099 *
2100 *FUNCTION:
2101 * This function is called to add an STA context at hardware
2102 * whenever a STA is (Re) Associated.
2103 *
2104 *LOGIC:
2105 *
2106 *ASSUMPTIONS:
2107 * NA
2108 *
2109 *NOTE:
2110 * NA
2111 *
2112 * @param pMac - Pointer to Global MAC structure
2113 * @param pStaDs - Pointer to the STA datastructure created by
2114 * LIM and maintained by DPH
2115 * @return retCode - Indicates success or failure return code
2116 */
2117
2118tSirRetStatus
2119limAddSta(
2120 tpAniSirGlobal pMac,
2121 tpDphHashNode pStaDs,tpPESession psessionEntry)
2122{
2123 tpAddStaParams pAddStaParams = NULL;
2124 tSirMsgQ msgQ;
2125 tSirRetStatus retCode = eSIR_SUCCESS;
2126 tSirMacAddr staMac, *pStaAddr;
2127 tANI_U8 i;
2128#ifdef WLAN_FEATURE_P2P
2129 tpSirAssocReq pAssocReq;
2130 tANI_U8 *p2pIe = NULL;
2131#endif
2132 #if 0
2133 retCode = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, staMac, &cfg);
2134 if (retCode != eSIR_SUCCESS)
2135 limLog(pMac, LOGP, FL("could not retrieve STA MAC\n"));
2136 #endif //To SUPPORT BT-AMP
2137
2138
2139 sirCopyMacAddr(staMac,psessionEntry->selfMacAddr);
2140
2141 if( eHAL_STATUS_SUCCESS !=
2142 palAllocateMemory( pMac->hHdd, (void **) &pAddStaParams, sizeof( tAddStaParams )))
2143 {
2144 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA\n" ));
2145 return eSIR_MEM_ALLOC_FAILED;
2146 }
2147 palZeroMemory( pMac->hHdd, (tANI_U8 *) pAddStaParams, sizeof(tAddStaParams));
2148
2149 if ((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) ||
2150 (limGetSystemRole(psessionEntry) == eLIM_STA_IN_IBSS_ROLE) ||
2151 (limGetSystemRole(psessionEntry) == eLIM_BT_AMP_AP_ROLE) )
2152 pStaAddr = &pStaDs->staAddr;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002153#ifdef FEATURE_WLAN_TDLS
2154 /* SystemRole shouldn't be matter if staType is TDLS peer */
2155 else if(STA_ENTRY_TDLS_PEER == pStaDs->staType)
2156 {
2157 pStaAddr = &pStaDs->staAddr ;
2158 }
2159#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002160 else
2161 pStaAddr = &staMac;
2162
2163 palCopyMemory( pMac->hHdd, (tANI_U8 *) pAddStaParams->staMac,
2164 (tANI_U8 *) *pStaAddr, sizeof(tSirMacAddr));
2165 palCopyMemory( pMac->hHdd, (tANI_U8 *) pAddStaParams->bssId,
2166 psessionEntry->bssId, sizeof(tSirMacAddr));
2167
2168 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
2169
2170 //Copy legacy rates
2171 palCopyMemory(pMac->hHdd, (tANI_U8*)&pAddStaParams->supportedRates,
2172 (tANI_U8*)&pStaDs->supportedRates, sizeof(tSirSupportedRates));
2173
2174 pAddStaParams->assocId = pStaDs->assocId;
2175
2176 pAddStaParams->wmmEnabled = pStaDs->qosMode;
2177 pAddStaParams->listenInterval = pStaDs->mlmStaContext.listenInterval;
2178 pAddStaParams->shortPreambleSupported = pStaDs->shortPreambleEnabled;
2179#ifdef WLAN_SOFTAP_FEATURE
2180 if((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) && (pStaDs->mlmStaContext.subType == LIM_REASSOC))
2181 {
2182 /* TBD - need to remove this REASSOC check after fixinf rmmod issue */
2183 pAddStaParams->updateSta = pStaDs->mlmStaContext.updateContext;
2184 }
2185#endif
2186 pStaDs->valid = 0;
2187 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2188
2189 // This will indicate HAL to "allocate" a new STA index
2190 pAddStaParams->staIdx = HAL_STA_INVALID_IDX;
2191 pAddStaParams->staType = pStaDs->staType;
2192
2193 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2194 pAddStaParams->respReqd = 1;
2195 //Update HT Capability
2196
2197 if ((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) ||(limGetSystemRole(psessionEntry) == eLIM_BT_AMP_AP_ROLE) || (limGetSystemRole(psessionEntry) == eLIM_STA_IN_IBSS_ROLE))
Jeff Johnsone7245742012-09-05 17:12:55 -07002198 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 pAddStaParams->htCapable = pStaDs->mlmStaContext.htCapability;
Jeff Johnsone7245742012-09-05 17:12:55 -07002200#ifdef WLAN_FEATURE_11AC
2201 pAddStaParams->vhtCapable = pStaDs->mlmStaContext.vhtCapability;
2202#endif
2203 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002204#ifdef FEATURE_WLAN_TDLS
2205 /* SystemRole shouldn't be matter if staType is TDLS peer */
2206 else if(STA_ENTRY_TDLS_PEER == pStaDs->staType)
2207 pAddStaParams->htCapable = pStaDs->mlmStaContext.htCapability;
2208#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 else
Jeff Johnsone7245742012-09-05 17:12:55 -07002210 {
2211 pAddStaParams->htCapable = psessionEntry->htCapability;
2212#ifdef WLAN_FEATURE_11AC
2213 pAddStaParams->vhtCapable = psessionEntry->vhtCapability;
2214#endif
2215
2216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002217
2218 pAddStaParams->greenFieldCapable = pStaDs->htGreenfield;
2219 pAddStaParams->maxAmpduDensity= pStaDs->htAMpduDensity;
2220 pAddStaParams->maxAmpduSize = pStaDs->htMaxRxAMpduFactor;
2221 pAddStaParams->fDsssCckMode40Mhz = pStaDs->htDsssCckRate40MHzSupport;
2222 pAddStaParams->fShortGI20Mhz = pStaDs->htShortGI20Mhz;
2223 pAddStaParams->fShortGI40Mhz = pStaDs->htShortGI40Mhz;
2224 pAddStaParams->lsigTxopProtection = pStaDs->htLsigTXOPProtection;
2225 pAddStaParams->maxAmsduSize = pStaDs->htMaxAmsduLength;
2226 pAddStaParams->txChannelWidthSet = pStaDs->htSupportedChannelWidthSet;
2227 pAddStaParams->mimoPS = pStaDs->htMIMOPSState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002228
2229#ifdef WLAN_FEATURE_11AC
2230 if(pAddStaParams->vhtCapable)
2231 {
Mohit Khanna7d5aeb22012-09-11 16:21:57 -07002232 pAddStaParams->vhtTxChannelWidthSet = pStaDs->vhtSupportedChannelWidthSet;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002233 pAddStaParams->vhtTxBFCapable =
2234 ( STA_ENTRY_PEER == pStaDs->staType ) ? pStaDs->vhtBeamFormerCapable :
2235 psessionEntry->txBFIniFeatureEnabled ;
Jeff Johnsone7245742012-09-05 17:12:55 -07002236 }
2237#endif
2238
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002239#ifdef FEATURE_WLAN_TDLS
2240 if((STA_ENTRY_PEER == pStaDs->staType) ||
2241 (STA_ENTRY_TDLS_PEER == pStaDs->staType))
2242#else
2243 if (STA_ENTRY_PEER == pStaDs->staType)
2244#endif
2245 {
2246 /* peer STA get the LDPC capability from pStaDs, which populated from
2247 * HT/VHT capability*/
2248 pAddStaParams->htLdpcCapable = pStaDs->htLdpcCapable;
2249 pAddStaParams->vhtLdpcCapable = pStaDs->vhtLdpcCapable;
2250 }
2251 else if( STA_ENTRY_SELF == pStaDs->staType)
2252 {
2253 /* For Self STA get the LDPC capability from config.ini*/
2254 pAddStaParams->htLdpcCapable =
2255 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
2256 pAddStaParams->vhtLdpcCapable =
2257 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
2258 }
2259
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 /* Update PE session ID*/
2261 pAddStaParams->sessionId = psessionEntry->peSessionId;
2262
2263 if (psessionEntry->parsedAssocReq != NULL)
2264 {
2265#ifdef WLAN_FEATURE_P2P
2266 // Get a copy of the already parsed Assoc Request
2267 pAssocReq = (tpSirAssocReq) psessionEntry->parsedAssocReq[pStaDs->assocId];
2268 if ( pAssocReq && pAssocReq->addIEPresent && pAssocReq->addIE.length ) {
2269 p2pIe = limGetP2pIEPtr(pMac, pAssocReq->addIE.addIEdata, pAssocReq->addIE.length);
2270 }
2271 pAddStaParams->p2pCapableSta = (p2pIe != NULL);
2272#endif
2273 }
2274
2275 //Disable BA. It will be set as part of ADDBA negotiation.
2276 for( i = 0; i < STACFG_MAX_TC; i++ )
2277 {
2278 pAddStaParams->staTCParams[i].txUseBA = eBA_DISABLE;
2279 pAddStaParams->staTCParams[i].rxUseBA = eBA_DISABLE;
2280 }
2281
2282#ifdef WLAN_SOFTAP_FEATURE
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002283#ifdef FEATURE_WLAN_TDLS
2284 if(pStaDs->wmeEnabled && \
2285 ((eLIM_AP_ROLE == psessionEntry->limSystemRole) || (STA_ENTRY_TDLS_PEER == pStaDs->staType)) )
2286#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002287 if(pStaDs->wmeEnabled && (eLIM_AP_ROLE == psessionEntry->limSystemRole))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002288#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 {
2290 pAddStaParams->uAPSD = 0;
2291 /* update UAPSD and send it to LIM to add STA */
2292 // bitmap MSB <- LSB MSB 4 bits are for
2293 // trigger enabled AC setting and LSB 4 bits
2294 // are for delivery enabled AC setting
2295 // 7 6 5 4 3 2 1 0
2296 // BE BK VI VO BE BK VI VO
2297 pAddStaParams->uAPSD |= pStaDs->qos.capability.qosInfo.acvo_uapsd;
2298 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acvi_uapsd << 1);
2299 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acbk_uapsd << 2);
2300 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acbe_uapsd << 3);
2301 //making delivery enabled and trigger enabled setting the same.
2302 pAddStaParams->uAPSD |= pAddStaParams->uAPSD << 4;
2303
2304 pAddStaParams->maxSPLen = pStaDs->qos.capability.qosInfo.maxSpLen;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002305 limLog( pMac, LOG1, FL( "uAPSD = 0x%x, maxSpLen = %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 pAddStaParams->uAPSD, pAddStaParams->maxSPLen);
2307 }
2308#endif
2309 //we need to defer the message until we get the response back from HAL.
2310 if (pAddStaParams->respReqd)
2311 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07002312
2313 msgQ.type = WDA_ADD_STA_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002314
2315 msgQ.reserved = 0;
2316 msgQ.bodyptr = pAddStaParams;
2317 msgQ.bodyval = 0;
2318
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002319 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_STA_REQ for assocId %d\n" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 pStaDs->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002321 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002322
2323 retCode = wdaPostCtrlMsg( pMac, &msgQ );
2324 if( eSIR_SUCCESS != retCode)
2325 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002326 if (pAddStaParams->respReqd)
2327 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Jeff Johnson295189b2012-06-20 16:38:30 -07002328 limLog( pMac, LOGE, FL("ADD_STA_REQ for aId %d failed (reason %X)\n"),
2329 pStaDs->assocId, retCode );
2330 palFreeMemory(pMac->hHdd, (void*)pAddStaParams);
2331 }
2332
2333 return retCode;
2334}
2335
2336
2337/**
2338 * limDelSta()
2339 *
2340 *FUNCTION:
2341 * This function is called to delete an STA context at hardware
2342 * whenever a STA is disassociated
2343 *
2344 *LOGIC:
2345 *
2346 *ASSUMPTIONS:
2347 * NA
2348 *
2349 *NOTE:
2350 * NA
2351 *
2352 * @param pMac - Pointer to Global MAC structure
2353 * @param pStaDs - Pointer to the STA datastructure created by
2354 * LIM and maintained by DPH
2355 * @param fRespReqd - flag to indicate whether the delete is synchronous (true)
2356 * or not (false)
2357 * @return retCode - Indicates success or failure return code
2358 */
2359
2360tSirRetStatus
2361limDelSta(
2362 tpAniSirGlobal pMac,
2363 tpDphHashNode pStaDs,
2364 tANI_BOOLEAN fRespReqd,
2365 tpPESession psessionEntry)
2366{
2367 tpDeleteStaParams pDelStaParams = NULL;
2368 tSirMsgQ msgQ;
2369 tSirRetStatus retCode = eSIR_SUCCESS;
2370
2371 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd, (void **) &pDelStaParams, sizeof( tDeleteStaParams )))
2372 {
2373 limLog( pMac, LOGP, FL( "Unable to PAL allocate memory during ADD_STA\n" ));
2374 return eSIR_MEM_ALLOC_FAILED;
2375 }
2376
2377 palZeroMemory( pMac->hHdd, (tANI_U8 *) pDelStaParams, sizeof(tDeleteStaParams));
2378
2379 //
2380 // DPH contains the STA index only for "peer" STA entries.
2381 // LIM global contains "self" STA index
2382 // Thus,
2383 // if( STA role )
2384 // get STA index from LIM global
2385 // else
2386 // get STA index from DPH
2387 //
2388
2389#if 0
2390 /* Since we have not created any STA, no need to send msg to delete
2391 * STA to HAL */
2392 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE) {
2393 pDelStaParams->staIdx = 1; /* TODO : This is workaround. Need to find right STA Index before sending to HAL */
2394 //return retCode;
2395 }
2396#endif
2397
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002398#ifdef FEATURE_WLAN_TDLS
2399 if( ((eLIM_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) && (pStaDs->staType != STA_ENTRY_TDLS_PEER)) ||(eLIM_BT_AMP_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) )
2400#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002401 if( (eLIM_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) ||(eLIM_BT_AMP_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002402#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002403 pDelStaParams->staIdx= psessionEntry->staId;
2404
2405 else
2406 pDelStaParams->staIdx= pStaDs->staIndex;
2407
2408 pDelStaParams->assocId = pStaDs->assocId;
2409 pStaDs->valid = 0;
2410
2411 if (! fRespReqd)
2412 pDelStaParams->respReqd = 0;
2413 else
2414 {
2415 //when limDelSta is called from processSmeAssocCnf then mlmState is already set properly.
2416 if(eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE != GET_LIM_STA_CONTEXT_MLM_STATE(pStaDs))
2417 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002418 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 SET_LIM_STA_CONTEXT_MLM_STATE(pStaDs, eLIM_MLM_WT_DEL_STA_RSP_STATE);
2420 }
2421 if ( (eLIM_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) ||
2422 (eLIM_BT_AMP_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) )
2423 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002424 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002425
2426 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
2427
2428 }
2429 pDelStaParams->respReqd = 1;
2430 //we need to defer the message until we get the response back from HAL.
2431 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
2432 }
2433
2434 /* Update PE session ID*/
2435 pDelStaParams->sessionId = psessionEntry->peSessionId;
2436
2437 pDelStaParams->status = eHAL_STATUS_SUCCESS;
2438 msgQ.type = WDA_DELETE_STA_REQ;
2439 msgQ.reserved = 0;
2440 msgQ.bodyptr = pDelStaParams;
2441 msgQ.bodyval = 0;
2442
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002443 limLog( pMac, LOG1, FL( "Sending SIR_HAL_DELETE_STA_REQ for STAID: %X and AssocID: %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 pDelStaParams->staIdx, pDelStaParams->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002445 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 retCode = wdaPostCtrlMsg( pMac, &msgQ );
2447 if( eSIR_SUCCESS != retCode)
2448 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002449 if(fRespReqd)
2450 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 limLog( pMac, LOGE, FL("Posting DELETE_STA_REQ to HAL failed, reason=%X\n"),
2452 retCode );
2453 palFreeMemory(pMac->hHdd, (void*)pDelStaParams);
2454 }
2455
2456 return retCode;
2457}
2458
2459#if defined WLAN_FEATURE_VOWIFI_11R
2460/*------------------------------------------------------------------------
2461 * limAddFTStaSelf()
2462 *
2463 * FUNCTION:
2464 *
2465 * This function is called to add a STA once we have connected with a new
2466 * AP, that we have performed an FT to.
2467 *
2468 * The Add STA Response is created and now after the ADD Bss Is Successful
2469 * we add the self sta. We update with the association id from the reassoc
2470 * response from the AP.
2471 *------------------------------------------------------------------------
2472 */
2473tSirRetStatus limAddFTStaSelf(tpAniSirGlobal pMac, tANI_U16 assocId, tpPESession psessionEntry)
2474{
2475 tpAddStaParams pAddStaParams = NULL;
2476 tSirMsgQ msgQ;
2477 tSirRetStatus retCode = eSIR_SUCCESS;
2478
2479 pAddStaParams = pMac->ft.ftPEContext.pAddStaReq;
2480 pAddStaParams->assocId = assocId;
2481
2482 msgQ.type = SIR_HAL_ADD_STA_REQ;
2483 msgQ.reserved = 0;
2484 msgQ.bodyptr = pAddStaParams;
2485 msgQ.bodyval = 0;
2486
2487
2488#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
2489 limLog( pMac, LOGE, FL( "Sending SIR_HAL_ADD_STA_REQ... (aid %d)" ), pAddStaParams->assocId);
2490#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002491 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002492
2493 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
2494 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2495 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
2496 {
2497 limLog( pMac, LOGE, FL("Posting ADD_STA_REQ to HAL failed, reason=%X\n"), retCode );
2498 palFreeMemory(pMac->hHdd, (void*)pAddStaParams);
2499 }
2500 //
2501 // Dont need it any more
2502 pMac->ft.ftPEContext.pAddStaReq = NULL;
2503 return retCode;
2504}
2505
2506#endif /* WLAN_FEATURE_VOWIFI_11R */
2507
2508/**
2509 * limAddStaSelf()
2510 *
2511 *FUNCTION:
2512 * This function is called to add an STA context at hardware
2513 * whenever a STA is (Re) Associated.
2514 *
2515 *LOGIC:
2516 *
2517 *ASSUMPTIONS:
2518 * NA
2519 *
2520 *NOTE:
2521 * NA
2522 *
2523 * @param pMac - Pointer to Global MAC structure
2524 * @param pStaDs - Pointer to the STA datastructure created by
2525 * LIM and maintained by DPH
2526 * @return retCode - Indicates success or failure return code
2527 */
2528
2529tSirRetStatus
2530limAddStaSelf(tpAniSirGlobal pMac,tANI_U16 staIdx, tANI_U8 updateSta, tpPESession psessionEntry)
2531{
2532 tpAddStaParams pAddStaParams = NULL;
2533 tSirMsgQ msgQ;
2534 tSirRetStatus retCode = eSIR_SUCCESS;
2535 tSirMacAddr staMac;
2536 tANI_U32 listenInterval = WNI_CFG_LISTEN_INTERVAL_STADEF;
2537
2538 #if 0
2539 retCode =wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, staMac, &cfg);
2540 if (retCode != eSIR_SUCCESS)
2541 {
2542 /// Could not get BSSID from CFG. Log error.
2543 limLog(pMac, LOGP, FL("could not retrieve STA MAC\n"));
2544 return retCode;
2545 }
2546 #endif //TO SUPPORT BT-AMP
2547 sirCopyMacAddr(staMac,psessionEntry->selfMacAddr);
2548
2549 if( eHAL_STATUS_SUCCESS !=
2550 palAllocateMemory( pMac->hHdd, (void **) &pAddStaParams, sizeof( tAddStaParams )))
2551 {
2552 limLog( pMac, LOGP, FL( "Unable to PAL allocate memory during ADD_STA\n" ));
2553 return eSIR_MEM_ALLOC_FAILED;
2554 }
2555 palZeroMemory( pMac->hHdd, (tANI_U8 *) pAddStaParams, sizeof(tAddStaParams));
2556
2557 /// Add STA context at MAC HW (BMU, RHP & TFP)
2558 palCopyMemory( pMac->hHdd, (tANI_U8 *) pAddStaParams->staMac,
2559 (tANI_U8 *) staMac, sizeof(tSirMacAddr));
2560
2561 palCopyMemory( pMac->hHdd, (tANI_U8 *) pAddStaParams->bssId,
2562 psessionEntry->bssId, sizeof(tSirMacAddr));
2563
2564 pAddStaParams->assocId = psessionEntry->limAID;
2565 pAddStaParams->staType = STA_ENTRY_SELF;
2566 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2567 pAddStaParams->respReqd = 1;
2568
2569 /* Update PE session ID */
2570 pAddStaParams->sessionId = psessionEntry->peSessionId;
2571
2572 // This will indicate HAL to "allocate" a new STA index
2573 pAddStaParams->staIdx = staIdx;
2574 pAddStaParams->updateSta = updateSta;
2575
2576 pAddStaParams->shortPreambleSupported = psessionEntry->beaconParams.fShortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -07002577
Jeff Johnsone7245742012-09-05 17:12:55 -07002578#ifdef WLAN_FEATURE_11AC
2579 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry,NULL);
2580#else
2581 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry);
2582#endif
2583 if( psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002585 pAddStaParams->htCapable = psessionEntry->htCapability;
Jeff Johnson295189b2012-06-20 16:38:30 -07002586#ifdef DISABLE_GF_FOR_INTEROP
2587 /*
2588 * To resolve the interop problem with Broadcom AP,
2589 * where TQ STA could not pass traffic with GF enabled,
2590 * TQ STA will do Greenfield only with TQ AP, for
2591 * everybody else it will be turned off.
2592 */
2593 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2594 {
2595 limLog( pMac, LOGE, FL(" Turning off Greenfield, when adding self entry"));
2596 pAddStaParams->greenFieldCapable = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
2597 }
2598 else
2599#endif
2600
2601#ifdef WLAN_SOFTAP_FEATURE
2602 pAddStaParams->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD, psessionEntry);
2603 pAddStaParams->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
2604 pAddStaParams->mimoPS = limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE, psessionEntry );
2605 pAddStaParams->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE, psessionEntry );
2606 pAddStaParams->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION, psessionEntry );
2607 pAddStaParams->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA, psessionEntry );
2608 pAddStaParams->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY, psessionEntry );
2609 pAddStaParams->maxAmpduSize = limGetHTCapability(pMac, eHT_MAX_RX_AMPDU_FACTOR, psessionEntry);
2610 pAddStaParams->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH, psessionEntry );
2611 pAddStaParams->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ, psessionEntry);
2612 pAddStaParams->fShortGI20Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_20MHZ, psessionEntry);
2613 pAddStaParams->fShortGI40Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_40MHZ, psessionEntry);
2614#else
2615 pAddStaParams->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD );
2616 pAddStaParams->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET );
2617 pAddStaParams->mimoPS = limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE );
2618 pAddStaParams->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE );
2619 pAddStaParams->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION );
2620 pAddStaParams->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA );
2621 pAddStaParams->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY );
2622 pAddStaParams->maxAmpduSize = limGetHTCapability(pMac, eHT_MAX_RX_AMPDU_FACTOR);
2623 pAddStaParams->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH );
2624 pAddStaParams->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ);
2625 pAddStaParams->fShortGI20Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_20MHZ);
2626 pAddStaParams->fShortGI40Mhz = limGetHTCapability( pMac, eHT_SHORT_GI_40MHZ);
2627#endif
2628 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002629#ifdef WLAN_FEATURE_11AC
2630 pAddStaParams->vhtCapable = psessionEntry->vhtCapability;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07002631 pAddStaParams->vhtTxChannelWidthSet = psessionEntry->apChanWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002632 pAddStaParams->vhtTxBFCapable = psessionEntry->txBFIniFeatureEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07002633#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002634
2635 /* For Self STA get the LDPC capability from session i.e config.ini*/
2636 pAddStaParams->htLdpcCapable =
2637 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
2638 pAddStaParams->vhtLdpcCapable =
2639 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
2640
Jeff Johnson295189b2012-06-20 16:38:30 -07002641 if(wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &listenInterval) != eSIR_SUCCESS)
2642 limLog(pMac, LOGP, FL("Couldn't get LISTEN_INTERVAL\n"));
2643 pAddStaParams->listenInterval = (tANI_U16)listenInterval;
2644
2645#ifdef WLAN_FEATURE_P2P
2646 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona)
2647 {
2648 pAddStaParams->p2pCapableSta = 1;
2649 }
2650#endif
2651
2652 limFillSupportedRatesInfo(pMac, NULL, &pAddStaParams->supportedRates,psessionEntry);
2653
2654 msgQ.type = WDA_ADD_STA_REQ;
2655 //
2656 // FIXME_GEN4
2657 // A global counter (dialog token) is required to keep track of
2658 // all PE <-> HAL communication(s)
2659 //
2660 msgQ.reserved = 0;
2661 msgQ.bodyptr = pAddStaParams;
2662 msgQ.bodyval = 0;
2663
2664 limLog( pMac, LOGW, FL( "Sending SIR_HAL_ADD_STA_REQ... (aid %d)" ),
2665 pAddStaParams->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002666 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002667
2668 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
2669 {
2670 limLog( pMac, LOGE, FL("Posting ADD_STA_REQ to HAL failed, reason=%X\n"), retCode );
2671 palFreeMemory(pMac->hHdd, (void*)pAddStaParams);
2672 }
2673 return retCode;
2674}
2675
2676
2677/**
2678 * limTeardownInfraBSS()
2679 *
2680 *FUNCTION:
2681 * This function is called by various LIM functions to teardown
2682 * an established Infrastructure BSS
2683 *
2684 *LOGIC:
2685 *
2686 *ASSUMPTIONS:
2687 *
2688 *NOTE:
2689 *
2690 * @param pMac - Pointer to Global MAC structure
2691 * @return None
2692 */
2693
2694void
2695limTeardownInfraBss(tpAniSirGlobal pMac,tpPESession psessionEntry)
2696{
2697 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
2698
2699 /**
2700 * Send Broadcast Disassociate frame with
2701 * 'leaving BSS' reason.
2702 */
2703 limSendDisassocMgmtFrame(pMac,
2704 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08002705 bcAddr,psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002706} /*** end limTeardownInfraBss() ***/
2707
2708
2709/**
2710 * limHandleCnfWaitTimeout()
2711 *
2712 *FUNCTION:
2713 * This function is called by limProcessMessageQueue to handle
2714 * various confirmation failure cases.
2715 *
2716 *LOGIC:
2717 *
2718 *ASSUMPTIONS:
2719 *
2720 *NOTE:
2721 *
2722 * @param pMac - Pointer to Global MAC structure
2723 * @param pStaDs - Pointer to a sta descriptor
2724 * @return None
2725 */
2726
2727void limHandleCnfWaitTimeout(tpAniSirGlobal pMac, tANI_U16 staId)
2728{
2729 tpDphHashNode pStaDs;
2730 tLimSystemRole systemRole;
2731 tpPESession psessionEntry = NULL;
2732
2733 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gpLimCnfWaitTimer[staId].sessionId))== NULL)
2734 {
2735 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID\n"));
2736 return;
2737 }
2738 systemRole = limGetSystemRole(psessionEntry);
2739 pStaDs = dphGetHashEntry(pMac, staId, &psessionEntry->dph.dphHashTable);
2740
2741 if (pStaDs == NULL)
2742 {
2743 PELOGW(limLog(pMac, LOGW, FL("No STA context in SIR_LIM_CNF_WAIT_TIMEOUT.\n"));)
2744 return;
2745 }
2746
2747 switch (pStaDs->mlmStaContext.mlmState) {
2748 case eLIM_MLM_WT_ASSOC_CNF_STATE:
2749 PELOGW(limLog(pMac, LOGW, FL("Did not receive Assoc Cnf in eLIM_MLM_WT_ASSOC_CNF_STATE sta Assoc id %d\n"), pStaDs->assocId);)
2750 limPrintMacAddr(pMac, pStaDs->staAddr, LOGW);
2751
2752 if ( (systemRole == eLIM_AP_ROLE)|| (systemRole == eLIM_BT_AMP_AP_ROLE) )
2753 {
2754 limRejectAssociation(
2755 pMac,
2756 pStaDs->staAddr,
2757 pStaDs->mlmStaContext.subType,
2758 true,
2759 pStaDs->mlmStaContext.authType,
2760 pStaDs->assocId,
2761 true,
2762 (tSirResultCodes) eSIR_MAC_UNSPEC_FAILURE_STATUS,
2763 psessionEntry);
2764 }
2765 break;
2766
2767 default:
2768 limLog(pMac, LOGW, FL("Received CNF_WAIT_TIMEOUT in state %d\n"),
2769 pStaDs->mlmStaContext.mlmState);
2770 }
2771}
2772
2773
2774/**
2775 * limDeleteDphHashEntry()
2776 *
2777 *FUNCTION:
2778 * This function is called whenever we need to delete
2779 * the dph hash entry
2780 *
2781 *LOGIC:
2782 *
2783 *ASSUMPTIONS:
2784 *
2785 *NOTE:
2786 *
2787 * @param pMac Pointer to Global MAC structure
2788 * @param tANI_U16 staId
2789 * @return None
2790 */
2791
2792void
2793limDeleteDphHashEntry(tpAniSirGlobal pMac, tSirMacAddr staAddr, tANI_U16 staId,tpPESession psessionEntry)
2794{
2795 tANI_U16 aid;
2796 tpDphHashNode pStaDs;
2797 tUpdateBeaconParams beaconParams;
2798 tLimSystemRole systemRole;
2799
2800 beaconParams.paramChangeBitmap = 0;
2801 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, staId);
2802 if (NULL == psessionEntry)
2803 {
2804 PELOGE(limLog(pMac, LOGE, FL("NULL psessionEntry"));)
2805 return;
2806 }
2807 systemRole = limGetSystemRole(psessionEntry);
2808 beaconParams.bssIdx = psessionEntry->bssIdx;
2809 pStaDs = dphLookupHashEntry(pMac, staAddr, &aid, &psessionEntry->dph.dphHashTable);
2810 if (pStaDs != NULL)
2811 {
2812 PELOGW(limLog(pMac, LOGW, FL("Deleting DPH Hash entry for STAID: %X\n "), staId);)
2813 // update the station count and perform associated actions
2814 // do this before deleting the dph hash entry
2815 limUtilCountStaDel(pMac, pStaDs, psessionEntry);
2816
2817 if((eLIM_AP_ROLE == psessionEntry->limSystemRole) ||
2818 (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole))
2819 {
2820#ifdef WLAN_SOFTAP_FEATURE
2821 if(psessionEntry->limSystemRole == eLIM_AP_ROLE ){
2822 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE){
2823 limDecideApProtectionOnDelete(pMac, pStaDs, &beaconParams,psessionEntry);
2824 }
2825 }
2826#endif
2827
2828 if(eLIM_STA_IN_IBSS_ROLE == systemRole)
2829 limIbssDecideProtectionOnDelete(pMac, pStaDs, &beaconParams, psessionEntry);
2830
2831 limDecideShortPreamble(pMac, pStaDs, &beaconParams, psessionEntry);
2832 limDecideShortSlot(pMac, pStaDs, &beaconParams, psessionEntry);
2833
2834 //Send message to HAL about beacon parameter change.
2835 PELOGW(limLog(pMac, LOGW, FL("param bitmap = %d \n"), beaconParams.paramChangeBitmap);)
2836 if(beaconParams.paramChangeBitmap)
2837 {
2838 schSetFixedBeaconFields(pMac,psessionEntry);
2839 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
2840 }
2841 }
2842 if (dphDeleteHashEntry(pMac, staAddr, staId, &psessionEntry->dph.dphHashTable) != eSIR_SUCCESS)
2843 limLog(pMac, LOGP, FL("error deleting hash entry\n"));
2844 }
2845}
2846
2847
2848
2849/**
2850 * limCheckAndAnnounceJoinSuccess()
2851 *
2852 *FUNCTION:
2853 * This function is called upon receiving Beacon/Probe Response
2854 * frame in WT_JOIN_BEACON_STATE to check if the received
2855 * Beacon/Probe Response is from the BSS that we're attempting
2856 * to join.
2857 *
2858 *LOGIC:
2859 * If the Beacon/Probe Response is indeed from the BSS we're
2860 * attempting to join, join success is sent to SME.
2861 *
2862 *ASSUMPTIONS:
2863 *
2864 *NOTE:
2865 *
2866 * @param pMac Pointer to Global MAC structure
2867 * @param pBPR Pointer to received Beacon/Probe Response
2868 * @param pHdr Pointer to received Beacon/Probe Response
2869 * MAC header
2870 * @return None
2871 */
2872
2873void
2874limCheckAndAnnounceJoinSuccess(tpAniSirGlobal pMac,
2875 tSirProbeRespBeacon *pBPR,
2876 tpSirMacMgmtHdr pHdr,tpPESession psessionEntry)
2877{
2878 tSirMacSSid currentSSID;
2879 tLimMlmJoinCnf mlmJoinCnf;
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08002880#ifdef WLAN_FEATURE_P2P
2881 tANI_U32 val = 0;
2882 tANI_U32 *noa1DurationFromBcn = NULL;
2883 tANI_U32 *noa2DurationFromBcn = NULL;
2884 tANI_U32 noa;
2885 tANI_U32 TotalNum_NoADesc = 0;
2886#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002887
2888 palCopyMemory( pMac->hHdd, currentSSID.ssId,
2889 psessionEntry->ssId.ssId,
2890 psessionEntry->ssId.length);
2891
2892 currentSSID.length = (tANI_U8)psessionEntry->ssId.length ;
2893
2894 if (
2895 /* Check for SSID only in probe response. Beacons may not carry
2896 SSID information in hidden SSID case */
2897 ( (SIR_MAC_MGMT_FRAME == pHdr->fc.type) &&
2898 (SIR_MAC_MGMT_PROBE_RSP == pHdr->fc.subType) ) &&
2899 currentSSID.length &&
2900 (!palEqualMemory( pMac->hHdd,(tANI_U8 *) &pBPR->ssId,
2901 (tANI_U8 *) &currentSSID,
2902 (tANI_U8) (1 + currentSSID.length)) ))
2903 {
2904 /**
2905 * Received SSID does not match with the one we've.
2906 * Ignore received Beacon frame
2907 */
2908 PELOG1(limLog(pMac, LOG1, FL("SSID received in Beacon does not match\n"));)
2909#ifdef WLAN_DEBUG
2910 pMac->lim.gLimBcnSSIDMismatchCnt++;
2911#endif
2912 return;
2913 }
2914
2915 if( (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_STA_ROLE))
2916 {
2917 PELOG1(limLog(pMac, LOG1, FL("Received Beacon/PR with matching BSSID\n"));)
2918
2919 // Deactivate Join Failure timer
2920 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08002921 // Deactivate Periodic Join timer
2922 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -07002923
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08002924#ifdef WLAN_FEATURE_P2P
2925 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona &&
2926 pBPR->P2PProbeRes.NoticeOfAbsence.present)
2927 {
2928
2929 noa1DurationFromBcn = (tANI_U32*)(pBPR->P2PProbeRes.NoticeOfAbsence.NoADesc + 1);
2930
2931 if(pBPR->P2PProbeRes.NoticeOfAbsence.num_NoADesc)
2932 TotalNum_NoADesc = pBPR->P2PProbeRes.NoticeOfAbsence.num_NoADesc/SIZE_OF_NOA_DESCRIPTOR;
2933
2934 noa = *noa1DurationFromBcn;
2935
2936 if(TotalNum_NoADesc > 1)
2937 {
2938 noa2DurationFromBcn = (tANI_U32*)(pBPR->P2PProbeRes.NoticeOfAbsence.NoADesc + SIZE_OF_NOA_DESCRIPTOR + 1);
2939 noa += *noa2DurationFromBcn;
2940 }
2941
2942 /*If MAX Noa exceeds 3 secs we will consider only 3 secs to
2943 * avoid arbitary values in noa duration field
2944 */
2945 noa = noa > MAX_NOA_PERIOD_IN_MICROSECS ? MAX_NOA_PERIOD_IN_MICROSECS : noa;
2946 noa = noa/1000; //Convert to ms
2947
2948 if( wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,&val) == eSIR_SUCCESS )
2949 {
2950 psessionEntry->defaultAuthFailureTimeout = val;
2951 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,val + noa, NULL, eANI_BOOLEAN_FALSE);
2952 }
2953 }
2954 else
2955 {
2956 psessionEntry->defaultAuthFailureTimeout = 0;
2957 }
2958#endif
2959
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 // Update Beacon Interval at CFG database
2961
2962 if ( pBPR->HTCaps.present )
2963 limUpdateStaRunTimeHTCapability( pMac, &pBPR->HTCaps );
2964 if ( pBPR->HTInfo.present )
2965 limUpdateStaRunTimeHTInfo( pMac, &pBPR->HTInfo, psessionEntry);
2966 psessionEntry->limMlmState = eLIM_MLM_JOINED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002967 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_JOINED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002968
2969#if (WNI_POLARIS_FW_PRODUCT == AP)
2970 // In case of BP, we need to adopt to all rates
2971 // advertised by AP. Update the operational rates at CFG
2972 if (cfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
2973 (tANI_U8 *) &pBPR->supportedRates.rate,
2974 pBPR->supportedRates.numRates)
2975 != eSIR_SUCCESS)
2976 limLog(pMac, LOGP, FL("could not update Oper.rates at CFG\n"));
2977
2978#endif
2979
2980 /**
2981 * Announce join success by sending
2982 * Join confirm to SME.
2983 */
2984 mlmJoinCnf.resultCode = eSIR_SME_SUCCESS;
2985 mlmJoinCnf.protStatusCode = eSIR_MAC_SUCCESS_STATUS;
2986 /* Update PE sessionId*/
2987 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
2988 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
2989 } // if ((pMac->lim.gLimSystemRole == IBSS....
2990}
2991
2992/**
2993 * limExtractApCapabilities()
2994 *
2995 *FUNCTION:
2996 * This function is called to extract all of the AP's capabilities
2997 * from the IEs received from it in Beacon/Probe Response frames
2998 *
2999 *LOGIC:
3000 * This routine mimics the limExtractApCapability() API. The difference here
3001 * is that this API returns the entire tSirProbeRespBeacon info as is. It is
3002 * left to the caller of this API to use this info as required
3003 *
3004 *ASSUMPTIONS:
3005 * NA
3006 *
3007 *NOTE:
3008 *
3009 * @param pMac Pointer to Global MAC structure
3010 * @param pIE Pointer to starting IE in Beacon/Probe Response
3011 * @param ieLen Length of all IEs combined
3012 * @param beaconStruct A pointer to tSirProbeRespBeacon that needs to be
3013 * populated
3014 * @return status A status reporting eSIR_SUCCESS or eSIR_FAILURE
3015 */
3016tSirRetStatus limExtractApCapabilities( tpAniSirGlobal pMac,
3017 tANI_U8 *pIE,
3018 tANI_U16 ieLen,
3019 tpSirProbeRespBeacon beaconStruct )
3020{
3021 palZeroMemory( pMac->hHdd, (tANI_U8 *) beaconStruct, sizeof( tSirProbeRespBeacon ));
3022
3023 PELOG3(limLog( pMac, LOG3,
3024 FL( "In limExtractApCapabilities: The IE's being received are:\n" ));
3025 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG3, pIE, ieLen );)
3026
3027 // Parse the Beacon IE's, Don't try to parse if we dont have anything in IE
3028 if (ieLen > 0) {
3029 if( eSIR_SUCCESS != sirParseBeaconIE( pMac, beaconStruct, pIE, (tANI_U32)ieLen ))
3030 {
3031 limLog( pMac, LOGE, FL("APCapExtract: Beacon parsing error!\n"));
3032 return eSIR_FAILURE;
3033 }
3034 }
3035
3036 return eSIR_SUCCESS;
3037}
3038
3039
3040/**
3041 * limDelBss()
3042 *
3043 *FUNCTION:
3044 * This function is called to delete BSS context at hardware
3045 * whenever a STA is disassociated
3046 *
3047 *LOGIC:
3048 *
3049 *ASSUMPTIONS:
3050 * NA
3051 *
3052 *NOTE:
3053 * NA
3054 *
3055 * @param pMac - Pointer to Global MAC structure
3056 * @param pStaDs - Pointer to the STA datastructure created by
3057 * LIM and maintained by DPH
3058 * @return retCode - Indicates success or failure return code
3059 */
3060
3061tSirRetStatus
3062limDelBss(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tANI_U16 bssIdx,tpPESession psessionEntry)
3063{
3064 tpDeleteBssParams pDelBssParams = NULL;
3065 tSirMsgQ msgQ;
3066 tSirRetStatus retCode = eSIR_SUCCESS;
3067
3068 if( eHAL_STATUS_SUCCESS !=
3069 palAllocateMemory( pMac->hHdd, (void **) &pDelBssParams, sizeof( tDeleteBssParams )))
3070 {
3071 limLog( pMac, LOGP, FL( "Unable to PAL allocate memory during ADD_BSS\n" ));
3072 return eSIR_MEM_ALLOC_FAILED;
3073 }
3074 palZeroMemory( pMac->hHdd, (tANI_U8 *) pDelBssParams, sizeof(tDeleteBssParams));
3075
3076
3077 pDelBssParams->sessionId = psessionEntry->peSessionId; //update PE session Id
3078
3079 //DPH was storing the AssocID in staID field,
3080 //staID is actually assigned by HAL when AddSTA message is sent.
3081 if (pStaDs != NULL)
3082 {
3083 pDelBssParams->bssIdx= pStaDs->bssId;
3084 pStaDs->valid = 0;
3085 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
3086 }
3087 else
3088 pDelBssParams->bssIdx = bssIdx;
3089 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003090 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_BSS_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003091
3092 pDelBssParams->status= eHAL_STATUS_SUCCESS;
3093 pDelBssParams->respReqd = 1;
3094 PELOGW(limLog( pMac, LOGW, FL("Sending HAL_DELETE_BSS_REQ for BSSID: %X\n"),
3095 pDelBssParams->bssIdx);)
3096
3097 //we need to defer the message until we get the response back from HAL.
3098 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3099
3100 msgQ.type = WDA_DELETE_BSS_REQ;
3101 msgQ.reserved = 0;
3102 msgQ.bodyptr = pDelBssParams;
3103 msgQ.bodyval = 0;
3104
Jeff Johnsone7245742012-09-05 17:12:55 -07003105 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003106
3107 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
3108 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003109 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 limLog( pMac, LOGE, FL("Posting DELETE_BSS_REQ to HAL failed, reason=%X\n"), retCode );
3111 palFreeMemory(pMac->hHdd, (void*)pDelBssParams);
3112 }
3113
3114 return retCode;
3115}
3116
3117
3118#ifdef ANI_PRODUCT_TYPE_CLIENT
3119
3120/**
3121 * limSendAddBss()
3122 *
3123 *FUNCTION:
3124 *
3125 *LOGIC:
3126 * 1) LIM receives eWNI_SME_JOIN_REQ
3127 * 2) For a valid eWNI_SME_JOIN_REQ, LIM sends
3128 * SIR_HAL_ADD_BSS_REQ to HAL
3129 *
3130 *ASSUMPTIONS:
3131 * JOIN REQ parameters are saved in pMac->lim.gLimMlmJoinReq
3132 * ADD BSS parameters can be obtained from two sources:
3133 * 1) pMac->lim.gLimMlmJoinReq
3134 * 2) beaconStruct, passed as paramter
3135 * So, if a reqd parameter is found in bssDescriptions
3136 * then it is given preference over beaconStruct
3137 *
3138 *NOTE:
3139 *
3140 * @param pMac Pointer to Global MAC structure
3141 * pAssocRsp contains the structured assoc/reassoc Response got from AP
3142 * beaconstruct Has the ProbeRsp/Beacon structured details
3143 * bssDescription bssDescription passed to PE from the SME
3144 * @return None
3145 */
3146
3147tSirRetStatus limStaSendAddBss( tpAniSirGlobal pMac, tpSirAssocRsp pAssocRsp,
3148 tpSchBeaconStruct pBeaconStruct, tpSirBssDescription bssDescription, tANI_U8 updateEntry,
3149 tpPESession psessionEntry)
3150
3151{
3152 tSirMsgQ msgQ;
3153 tpAddBssParams pAddBssParams = NULL;
3154 tANI_U32 retCode;
3155 tANI_U8 i;
3156 tpDphHashNode pStaDs = NULL;
3157 tANI_U8 chanWidthSupp = 0;
3158 // Package SIR_HAL_ADD_BSS_REQ message parameters
3159 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
3160 (void **) &pAddBssParams,
3161 sizeof( tAddBssParams )))
3162 {
3163 limLog( pMac, LOGP,
3164 FL( "Unable to PAL allocate memory during ADD_BSS\n" ));
3165 retCode = eSIR_MEM_ALLOC_FAILED;
3166 goto returnFailure;
3167 }
3168 else
3169 palZeroMemory( pMac->hHdd, (tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ));
3170
3171 palCopyMemory( pMac->hHdd, pAddBssParams->bssId,bssDescription->bssId,
3172 sizeof( tSirMacAddr ));
3173 // Fill in tAddBssParams selfMacAddr
3174 palCopyMemory( pMac->hHdd, pAddBssParams->selfMacAddr,
3175 psessionEntry->selfMacAddr,
3176 sizeof( tSirMacAddr ));
3177
3178 if(psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
3179 {
3180 pAddBssParams->bssType = eSIR_BTAMP_AP_MODE;
3181 }
3182 else
3183 {
3184 pAddBssParams->bssType = eSIR_INFRASTRUCTURE_MODE;
3185 }
3186
3187 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
3188
3189 /* Update PE session ID */
3190 pAddBssParams->sessionId = psessionEntry->peSessionId;
3191
3192 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
3193
3194 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
3195 pAddBssParams->updateBss = updateEntry;
3196
3197
3198 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
3199 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
3200 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
3201 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
3202
3203 pAddBssParams->rateSet.numRates = pAssocRsp->supportedRates.numRates;
3204 palCopyMemory( pMac->hHdd, pAddBssParams->rateSet.rate,
3205 pAssocRsp->supportedRates.rate, pAssocRsp->supportedRates.numRates );
3206
3207 pAddBssParams->nwType = bssDescription->nwType;
3208
Jeff Johnsone7245742012-09-05 17:12:55 -07003209 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pAssocRsp->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
3211 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
3212 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
3213 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
3214
3215
3216 // Use the advertised capabilities from the received beacon/PR
3217
3218
3219 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pAssocRsp->HTCaps.present ))
3220 {
3221 pAddBssParams->htCapable = pAssocRsp->HTCaps.present;
3222
3223 if ( pBeaconStruct->HTInfo.present )
3224 {
3225 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pAssocRsp->HTInfo.opMode;
3226 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pAssocRsp->HTInfo.dualCTSProtection;
3227#ifdef WLAN_SOFTAP_FEATURE
3228 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
3229#else
3230 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET);
3231#endif
3232 if( (pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3233 (chanWidthSupp) )
3234 {
3235 pAddBssParams->txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
3236 pAddBssParams->currentExtChannel = pAssocRsp->HTInfo.secondaryChannelOffset;
3237 }
3238 else
3239 {
3240 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003241 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 }
3243 pAddBssParams->llnNonGFCoexist = (tANI_U8)pAssocRsp->HTInfo.nonGFDevicesPresent;
3244 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pAssocRsp->HTInfo.lsigTXOPProtectionFullSupport;
3245 pAddBssParams->fRIFSMode = pAssocRsp->HTInfo.rifsMode;
3246 }
3247 }
3248
3249 pAddBssParams->currentOperChannel = bssDescription->channelId;
3250
Jeff Johnsone7245742012-09-05 17:12:55 -07003251#ifdef WLAN_FEATURE_11AC
3252 if (psessionEntry->vhtCapability && ( pAssocRsp->VHTCaps.present ))
3253 {
3254 pAddBssParams->vhtCapable = pAssocRsp->VHTCaps.present;
3255 pAddBssParams->vhtTxChannelWidthSet = pAssocRsp->VHTOperation.chanWidth;
3256 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003257 pAddBssParams->currentOperChannel,
3258 pAddBssParams->currentExtChannel,
3259 psessionEntry->apCenterChan,
3260 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003261 }
3262 else
3263 {
3264 pAddBssParams->vhtCapable = 0;
3265 }
3266#endif
3267
3268
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 // Populate the STA-related parameters here
3270 // Note that the STA here refers to the AP
3271 {
3272 /* staType = PEER*/
3273 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
3274
3275 palCopyMemory( pMac->hHdd, pAddBssParams->staContext.bssId,
3276 bssDescription->bssId,
3277 sizeof( tSirMacAddr ));
3278 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
3279
3280 /* Fill Assoc id from the dph table */
3281 pStaDs = dphLookupHashEntry(pMac, pAddBssParams->staContext.bssId,
3282 &pAddBssParams->staContext.assocId, &psessionEntry->dph.dphHashTable);
3283 if (pStaDs == NULL)
3284 {
3285 PELOGE(limLog(pMac, LOGE, FL("Couldn't get assoc id for"
3286 "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x"),
3287 pAddBssParams->staContext.staMac[0],
3288 pAddBssParams->staContext.staMac[1],
3289 pAddBssParams->staContext.staMac[2],
3290 pAddBssParams->staContext.staMac[3],
3291 pAddBssParams->staContext.staMac[4],
3292 pAddBssParams->staContext.staMac[5]
3293 );)
3294 }
3295 pAddBssParams->staContext.uAPSD = 0;
3296 pAddBssParams->staContext.maxSPLen = 0;
3297 pAddBssParams->staContext.shortPreambleSupported = (tANI_U8)pAssocRsp->capabilityInfo.shortPreamble;
3298 pAddBssParams->staContext.updateSta = updateEntry;
3299
3300 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
3301 {
3302 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
3303 pAddBssParams->staContext.htCapable = 1;
3304 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 )pAssocRsp->HTCaps.greenField;
3305 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 )pAssocRsp->HTCaps.lsigTXOPProtection;
3306 if( (pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3307 (chanWidthSupp) )
3308 {
3309 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
Jeff Johnsone7245742012-09-05 17:12:55 -07003310
3311#ifdef WLAN_FEATURE_11AC
3312 if (psessionEntry->vhtCapability && ( pBeaconStruct->VHTCaps.present ))
3313 {
3314 pAddBssParams->staContext.vhtCapable = 1;
3315 pAddBssParams->staContext.vhtTxChannelWidthSet = pAssocRsp->VHTOperation.chanWidth; //pMac->lim.apChanWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08003316 if ( (pAssocRsp->VHTCaps.suBeamFormerCap ||
3317 pAssocRsp->VHTCaps.muBeamformerCap) &&
3318 psessionEntry->txBFIniFeatureEnabled )
3319 {
3320 pAddBssParams->staContext.vhtTxBFCapable = 1;
3321 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003322 }
3323#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 }
3325 else
3326 {
3327 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3328 }
3329 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pAssocRsp->HTCaps.mimoPowerSave;
3330 pAddBssParams->staContext.delBASupport = ( tANI_U8 )pAssocRsp->HTCaps.delayedBA;
3331 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 )pAssocRsp->HTCaps.maximalAMSDUsize;
3332 pAddBssParams->staContext.maxAmpduDensity = pAssocRsp->HTCaps.mpduDensity;
3333 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pAssocRsp->HTCaps.dsssCckMode40MHz;
3334 pAddBssParams->staContext.fShortGI20Mhz = (tANI_U8)pAssocRsp->HTCaps.shortGI20MHz;
3335 pAddBssParams->staContext.fShortGI40Mhz = (tANI_U8)pAssocRsp->HTCaps.shortGI40MHz;
3336 pAddBssParams->staContext.maxAmpduSize= pAssocRsp->HTCaps.maxRxAMPDUFactor;
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08003337 pAddBssParams->staContext.htLdpcCapable = (tANI_U8)pAssocRsp->HTCaps.advCodingCap;
3338 pAddBssParams->staContext.vhtLdpcCapable = (tANI_U8)pAssocRsp->VHTCaps.ldpcCodingCap;
3339
Jeff Johnson295189b2012-06-20 16:38:30 -07003340 if( pBeaconStruct->HTInfo.present )
3341 pAddBssParams->staContext.rifsMode = pAssocRsp->HTInfo.rifsMode;
3342 }
3343
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303344 //If WMM IE or 802.11E IE is not present and AP is HT AP then enable WMM
3345 if ((psessionEntry->limWmeEnabled && (pAssocRsp->wmeEdcaPresent || pAddBssParams->htCapable)) ||
3346 (psessionEntry->limQosEnabled && (pAssocRsp->edcaPresent || pAddBssParams->htCapable)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 pAddBssParams->staContext.wmmEnabled = 1;
3348 else
3349 pAddBssParams->staContext.wmmEnabled = 0;
3350
3351 //Update the rates
3352
3353 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3354 if (pStaDs != NULL)
3355 {
3356 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
3357 palCopyMemory(pMac->hHdd, (tANI_U8*)&pAddBssParams->staContext.supportedRates,
3358 (tANI_U8*)&pStaDs->supportedRates,
3359 sizeof(tSirSupportedRates));
3360 }
3361 else
3362 PELOGE(limLog(pMac, LOGE, FL("could not Update the supported rates.\n"));)
3363
3364 }
3365
3366 //Disable BA. It will be set as part of ADDBA negotiation.
3367 for( i = 0; i < STACFG_MAX_TC; i++ )
3368 {
3369 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
3370 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
3371 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
3372 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
3373 }
3374
3375 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
3376
3377#if defined WLAN_FEATURE_VOWIFI
3378 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
3379#endif
3380 // FIXME_GEN4 - Any other value that can be used for initialization?
3381 pAddBssParams->status = eHAL_STATUS_SUCCESS;
3382 pAddBssParams->respReqd = true;
3383
3384 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
3385
3386#ifdef WLAN_FEATURE_P2P
3387 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona)
3388 {
3389 pAddBssParams->staContext.p2pCapableSta = 1;
3390 }
3391#endif
3392
Jeff Johnsone7245742012-09-05 17:12:55 -07003393 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled ||
3394 limIsconnectedOnDFSChannel(bssDescription->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003395
3396#if defined WLAN_FEATURE_VOWIFI_11R
3397 pAddBssParams->extSetStaKeyParamValid = 0;
3398#endif
3399
3400 // Set a new state for MLME
3401 if( eLIM_MLM_WT_ASSOC_RSP_STATE == psessionEntry->limMlmState )
3402 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE;
3403 else
3404 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003405 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003406
3407 //we need to defer the message until we get the response back from HAL.
3408 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3409
3410 msgQ.type = WDA_ADD_BSS_REQ;
3411 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
3412 msgQ.reserved = 0;
3413 msgQ.bodyptr = pAddBssParams;
3414 msgQ.bodyval = 0;
3415
3416 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_BSS_REQ..." ));
Jeff Johnsone7245742012-09-05 17:12:55 -07003417 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003418
3419 retCode = wdaPostCtrlMsg( pMac, &msgQ );
3420 if( eSIR_SUCCESS != retCode)
3421 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003422 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 palFreeMemory(pMac->hHdd, pAddBssParams);
3424 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X\n"),
3425 retCode );
3426 goto returnFailure;
3427
3428 }
3429 else
3430 return retCode;
3431
3432 returnFailure:
3433 // Clean-up will be done by the caller...
3434 return retCode;
3435}
3436
3437
3438
3439
3440tSirRetStatus limStaSendAddBssPreAssoc( tpAniSirGlobal pMac, tANI_U8 updateEntry, tpPESession psessionEntry)
3441{
3442 tSirMsgQ msgQ;
3443 tpAddBssParams pAddBssParams = NULL;
3444 tANI_U32 retCode;
3445 tANI_U8 i;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003446 tSchBeaconStruct *pBeaconStruct;
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 tANI_U8 chanWidthSupp = 0;
3448 tpSirBssDescription bssDescription = &psessionEntry->pLimJoinReq->bssDescription;
3449
Jeff Johnson32d95a32012-09-10 13:15:23 -07003450 if(eHAL_STATUS_SUCCESS != palAllocateMemory(pMac->hHdd,
3451 (void **)&pBeaconStruct, sizeof(tSchBeaconStruct)))
3452 {
3453 limLog(pMac, LOGE, FL("Unable to PAL allocate memory during ADD_BSS\n") );
3454 return eSIR_MEM_ALLOC_FAILED;
3455 }
3456
Jeff Johnson295189b2012-06-20 16:38:30 -07003457
3458 // Package SIR_HAL_ADD_BSS_REQ message parameters
3459 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
3460 (void **) &pAddBssParams,
3461 sizeof( tAddBssParams )))
3462 {
3463 limLog( pMac, LOGP,
3464 FL( "Unable to PAL allocate memory during ADD_BSS\n" ));
3465 retCode = eSIR_MEM_ALLOC_FAILED;
3466 goto returnFailure;
3467 }
3468
3469 palZeroMemory( pMac->hHdd, (tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ));
3470
3471
3472 limExtractApCapabilities( pMac,
3473 (tANI_U8 *) bssDescription->ieFields,
3474 limGetIElenFromBssDescription( bssDescription ),
Jeff Johnson32d95a32012-09-10 13:15:23 -07003475 pBeaconStruct );
Jeff Johnson295189b2012-06-20 16:38:30 -07003476
3477 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
Jeff Johnson32d95a32012-09-10 13:15:23 -07003478 limDecideStaProtectionOnAssoc(pMac, pBeaconStruct, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 palCopyMemory( pMac->hHdd, pAddBssParams->bssId,bssDescription->bssId,
3480 sizeof( tSirMacAddr ));
3481
3482 // Fill in tAddBssParams selfMacAddr
3483 palCopyMemory( pMac->hHdd, pAddBssParams->selfMacAddr,
3484 psessionEntry->selfMacAddr,
3485 sizeof( tSirMacAddr ));
3486
3487 /* Incorrect BSS Type which caused UMA Descriptor to be overwritten on
3488 * top of an already established Infra link. This lead to issues in
3489 * concurrent data transfer.
3490 */
3491
3492 pAddBssParams->bssType = psessionEntry->bssType;//eSIR_INFRASTRUCTURE_MODE;
3493 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
3494
3495 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
3496
Jeff Johnson32d95a32012-09-10 13:15:23 -07003497 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 pAddBssParams->updateBss = updateEntry;
3499
3500
Jeff Johnson32d95a32012-09-10 13:15:23 -07003501 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
3502 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
3503 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
3504 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
Jeff Johnson295189b2012-06-20 16:38:30 -07003505
3506
Jeff Johnson32d95a32012-09-10 13:15:23 -07003507 pAddBssParams->rateSet.numRates = pBeaconStruct->supportedRates.numRates;
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 palCopyMemory( pMac->hHdd, pAddBssParams->rateSet.rate,
Jeff Johnson32d95a32012-09-10 13:15:23 -07003509 pBeaconStruct->supportedRates.rate, pBeaconStruct->supportedRates.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -07003510
3511 pAddBssParams->nwType = bssDescription->nwType;
3512
Jeff Johnson32d95a32012-09-10 13:15:23 -07003513 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07003514 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
3515 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
3516 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
3517 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
3518
3519 // Use the advertised capabilities from the received beacon/PR
Jeff Johnson32d95a32012-09-10 13:15:23 -07003520 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003522 pAddBssParams->htCapable = pBeaconStruct->HTCaps.present;
Jeff Johnson295189b2012-06-20 16:38:30 -07003523
Jeff Johnson32d95a32012-09-10 13:15:23 -07003524 if ( pBeaconStruct->HTInfo.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07003525 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003526 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pBeaconStruct->HTInfo.opMode;
3527 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pBeaconStruct->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -07003528
3529#ifdef WLAN_SOFTAP_FEATURE
3530 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
3531#else
3532 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET);
3533#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07003534 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 (chanWidthSupp) )
3536 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003537 pAddBssParams->txChannelWidthSet = ( tANI_U8 ) pBeaconStruct->HTInfo.recommendedTxWidthSet;
3538 pAddBssParams->currentExtChannel = pBeaconStruct->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 }
3540 else
3541 {
3542 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003543 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07003545 pAddBssParams->llnNonGFCoexist = (tANI_U8)pBeaconStruct->HTInfo.nonGFDevicesPresent;
3546 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pBeaconStruct->HTInfo.lsigTXOPProtectionFullSupport;
3547 pAddBssParams->fRIFSMode = pBeaconStruct->HTInfo.rifsMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 }
3549 }
3550
3551 pAddBssParams->currentOperChannel = bssDescription->channelId;
3552
Jeff Johnsone7245742012-09-05 17:12:55 -07003553#ifdef WLAN_FEATURE_11AC
Jeff Johnson32d95a32012-09-10 13:15:23 -07003554 if (psessionEntry->vhtCapability && ( pBeaconStruct->VHTCaps.present ))
Jeff Johnsone7245742012-09-05 17:12:55 -07003555 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003556 pAddBssParams->vhtCapable = pBeaconStruct->VHTCaps.present;
3557 pAddBssParams->vhtTxChannelWidthSet = pBeaconStruct->VHTOperation.chanWidth;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003558 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
3559 pAddBssParams->currentOperChannel,
3560 pAddBssParams->currentExtChannel,
3561 psessionEntry->apCenterChan,
3562 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003563 }
3564 else
3565 {
3566 pAddBssParams->vhtCapable = 0;
3567 }
3568#endif
3569
Jeff Johnson295189b2012-06-20 16:38:30 -07003570 // Populate the STA-related parameters here
3571 // Note that the STA here refers to the AP
3572 {
3573 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
3574
3575 palCopyMemory( pMac->hHdd, pAddBssParams->staContext.bssId,
3576 bssDescription->bssId,
3577 sizeof( tSirMacAddr ));
3578 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
3579
3580 pAddBssParams->staContext.assocId = 0; // Is SMAC OK with this?
3581 pAddBssParams->staContext.uAPSD = 0;
3582 pAddBssParams->staContext.maxSPLen = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003583 pAddBssParams->staContext.shortPreambleSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -07003584 pAddBssParams->staContext.updateSta = updateEntry;
3585
Jeff Johnson32d95a32012-09-10 13:15:23 -07003586 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 {
3588 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
3589 pAddBssParams->staContext.htCapable = 1;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003590 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 ) pBeaconStruct->HTCaps.greenField;
3591 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 ) pBeaconStruct->HTCaps.lsigTXOPProtection;
3592 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003593 (chanWidthSupp) )
3594 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003595 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pBeaconStruct->HTInfo.recommendedTxWidthSet;
Jeff Johnsone7245742012-09-05 17:12:55 -07003596 #ifdef WLAN_FEATURE_11AC
Jeff Johnson32d95a32012-09-10 13:15:23 -07003597 if (psessionEntry->vhtCapability && ( pBeaconStruct->VHTCaps.present ))
Jeff Johnsone7245742012-09-05 17:12:55 -07003598 {
3599 pAddBssParams->staContext.vhtCapable = 1;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003600 pAddBssParams->staContext.vhtTxChannelWidthSet = pBeaconStruct->VHTOperation.chanWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08003601 if ((pBeaconStruct->VHTCaps.suBeamFormerCap ||
3602 pBeaconStruct->VHTCaps.muBeamformerCap) &&
3603 psessionEntry->txBFIniFeatureEnabled )
3604 {
3605 pAddBssParams->staContext.vhtTxBFCapable = 1;
3606 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003607 }
3608 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003609 }
3610 else
3611 {
3612 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3613 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07003614 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pBeaconStruct->HTCaps.mimoPowerSave;
3615 pAddBssParams->staContext.delBASupport = ( tANI_U8 ) pBeaconStruct->HTCaps.delayedBA;
3616 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 ) pBeaconStruct->HTCaps.maximalAMSDUsize;
3617 pAddBssParams->staContext.maxAmpduDensity = pBeaconStruct->HTCaps.mpduDensity;
3618 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pBeaconStruct->HTCaps.dsssCckMode40MHz;
3619 pAddBssParams->staContext.fShortGI20Mhz = (tANI_U8)pBeaconStruct->HTCaps.shortGI20MHz;
3620 pAddBssParams->staContext.fShortGI40Mhz = (tANI_U8)pBeaconStruct->HTCaps.shortGI40MHz;
3621 pAddBssParams->staContext.maxAmpduSize= pBeaconStruct->HTCaps.maxRxAMPDUFactor;
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08003622 pAddBssParams->staContext.htLdpcCapable = (tANI_U8)pBeaconStruct->HTCaps.advCodingCap;
3623 pAddBssParams->staContext.vhtLdpcCapable = (tANI_U8)pBeaconStruct->VHTCaps.ldpcCodingCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003624
Jeff Johnson32d95a32012-09-10 13:15:23 -07003625 if( pBeaconStruct->HTInfo.present )
3626 pAddBssParams->staContext.rifsMode = pBeaconStruct->HTInfo.rifsMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003627 }
3628
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303629 //If WMM IE or 802.11E IE is not present and AP is HT AP then enable WMM
3630 if ((psessionEntry->limWmeEnabled && (pBeaconStruct->wmeEdcaPresent || pAddBssParams->staContext.htCapable)) ||
3631 (psessionEntry->limQosEnabled && (pBeaconStruct->edcaPresent || pAddBssParams->staContext.htCapable)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 pAddBssParams->staContext.wmmEnabled = 1;
3633 else
3634 pAddBssParams->staContext.wmmEnabled = 0;
3635
3636 //Update the rates
Jeff Johnsone7245742012-09-05 17:12:55 -07003637#ifdef WLAN_FEATURE_11AC
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 limPopulateOwnRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Jeff Johnson32d95a32012-09-10 13:15:23 -07003639 pBeaconStruct->HTCaps.supportedMCSSet, false,psessionEntry,
3640 &pBeaconStruct->VHTCaps);
Jeff Johnsone7245742012-09-05 17:12:55 -07003641#else
3642 limPopulateOwnRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Jeff Johnson32d95a32012-09-10 13:15:23 -07003643 pBeaconStruct->HTCaps.supportedMCSSet, false,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003644#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 limFillSupportedRatesInfo(pMac, NULL, &pAddBssParams->staContext.supportedRates,psessionEntry);
3646
3647 }
3648
3649
3650 //Disable BA. It will be set as part of ADDBA negotiation.
3651 for( i = 0; i < STACFG_MAX_TC; i++ )
3652 {
3653 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
3654 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
3655 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
3656 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
3657 }
3658
3659 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
3660
3661#if defined WLAN_FEATURE_VOWIFI
3662 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
3663#endif
3664
3665 pAddBssParams->status = eHAL_STATUS_SUCCESS;
3666 pAddBssParams->respReqd = true;
3667
3668 pAddBssParams->staContext.sessionId = psessionEntry->peSessionId;
3669 pAddBssParams->sessionId = psessionEntry->peSessionId;
3670
3671 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
3672
Jeff Johnsone7245742012-09-05 17:12:55 -07003673 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled ||
3674 limIsconnectedOnDFSChannel(bssDescription->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -07003675
3676#if defined WLAN_FEATURE_VOWIFI_11R
3677 pAddBssParams->extSetStaKeyParamValid = 0;
3678#endif
3679
3680 // Set a new state for MLME
3681
3682 //pMac->lim.gLimMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
3683 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
3684
Jeff Johnsone7245742012-09-05 17:12:55 -07003685 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003686
3687 //we need to defer the message until we get the response back from HAL.
3688 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3689
3690 msgQ.type = WDA_ADD_BSS_REQ;
3691 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
3692 msgQ.reserved = 0;
3693 msgQ.bodyptr = pAddBssParams;
3694 msgQ.bodyval = 0;
3695
3696 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_BSS_REQ..." ));
Jeff Johnsone7245742012-09-05 17:12:55 -07003697 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003698
3699 retCode = wdaPostCtrlMsg( pMac, &msgQ );
3700 if( eSIR_SUCCESS != retCode)
3701 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003702 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 palFreeMemory(pMac->hHdd, pAddBssParams);
3704 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X\n"),
3705 retCode );
3706 goto returnFailure;
3707
3708 }
3709 else
Jeff Johnson32d95a32012-09-10 13:15:23 -07003710 {
3711 palFreeMemory(pMac->hHdd, pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 return retCode;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003713 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003714
3715 returnFailure:
3716 // Clean-up will be done by the caller...
Jeff Johnson32d95a32012-09-10 13:15:23 -07003717 palFreeMemory(pMac->hHdd, pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 return retCode;
3719}
3720
3721
3722
3723
3724
3725#elif defined(ANI_AP_CLIENT_SDK)
3726tSirRetStatus limStaSendAddBss( tpAniSirGlobal pMac, tpSirAssocRsp pAssocRsp,
3727 tpSirNeighborBssInfo neighborBssInfo, tANI_U8 updateEntry,
3728 tpPESession psessionEntry)
3729{
3730 tSirMsgQ msgQ;
3731 tpAddBssParams pAddBssParams = NULL;
3732 tANI_U32 retCode;
3733 tANI_U8 i;
3734 tpDphHashNode pStaDs = NULL;
3735
3736 // Package SIR_HAL_ADD_BSS_REQ message parameters
3737 if( eHAL_STATUS_SUCCESS != palAllocateMemory( pMac->hHdd,
3738 (void **) &pAddBssParams,
3739 sizeof( tAddBssParams )))
3740 {
3741 limLog( pMac, LOGP,
3742 FL( "Unable to PAL allocate memory during ADD_BSS\n" ));
3743 retCode = eSIR_MEM_ALLOC_FAILED;
3744 goto returnFailure;
3745 }
3746 else
3747 palZeroMemory( pMac->hHdd, (tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ));
3748
3749 palCopyMemory( pMac->hHdd, pAddBssParams->bssId,neighborBssInfo->bssId,
3750 sizeof( tSirMacAddr ));
3751
3752#ifdef WLAN_SOFTAP_FEATURE
3753 // Fill in tAddBssParams selfMacAddr
3754 palCopyMemory( pMac->hHdd, pAddBssParams->selfMacAddr, psessionEntry->selfMacAddr,
3755 sizeof( tSirMacAddr ));
3756#endif
3757
3758 pAddBssParams->bssType = eSIR_INFRASTRUCTURE_MODE;
3759 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
3760 pAddBssParams->beaconInterval = (tANI_U16) neighborBssInfo->beaconInterval;
3761 pAddBssParams->dtimPeriod = neighborBssInfo->dtimPeriod;
3762 pAddBssParams->updateBss = updateEntry;
3763
3764
3765 /* The following parameters are commented since the information is not available from the
3766 * neighborBssInfo. This needs to be fixed later */
3767#if 0
3768
3769 pAddBssParams->cfParamSet.cfpCount = beaconStruct.cfParamSet.cfpCount;
3770 pAddBssParams->cfParamSet.cfpPeriod = beaconStruct.cfParamSet.cfpPeriod;
3771 pAddBssParams->cfParamSet.cfpMaxDuration = beaconStruct.cfParamSet.cfpMaxDuration;
3772 pAddBssParams->cfParamSet.cfpDurRemaining = beaconStruct.cfParamSet.cfpDurRemaining;
3773#endif
3774 pAddBssParams->rateSet.numRates = pAssocRsp->supportedRates.numRates;
3775 palCopyMemory( pMac->hHdd, pAddBssParams->rateSet.rate,
3776 pAssocRsp->supportedRates.rate, pAssocRsp->supportedRates.numRates );
3777
3778 /* Update PE session ID */
3779 pAddBssParams->sessionId = psessionEntry->peSessionId;
3780
3781 pAddBssParams->nwType = neighborBssInfo->nwType;
3782
3783 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pAssocRsp->capabilityInfo.shortSlotTime;
3784 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
3785 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
3786 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
3787 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
3788
3789 // Use the advertised capabilities from the received beacon/PR
3790 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( neighborBssInfo->HTCapsPresent ))
3791 {
3792 pAddBssParams->htCapable = pAssocRsp->HTCaps.present;
3793
3794 if ( neighborBssInfo->HTInfoPresent )
3795 {
3796 pAddBssParams->htOperMode = pAssocRsp->HTInfo.opMode;
3797 pAddBssParams->dualCTSProtection = ( tANI_U8 )pAssocRsp->HTInfo.dualCTSProtection;
3798
3799 if(pAssocRsp->HTCaps.supportedChannelWidthSet)
3800 {
3801 pAddBssParams->txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
3802 pAddBssParams->currentExtChannel = pAssocRsp->HTInfo.secondaryChannelOffset;
3803 }
3804 else
3805 {
3806 pAddBssParams->txChannelWidthSet = (tANI_U8)pAssocRsp->HTCaps.supportedChannelWidthSet;
Jeff Johnsone7245742012-09-05 17:12:55 -07003807 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07003808 }
3809 pAddBssParams->llnNonGFCoexist = (tANI_U8)pAssocRsp->HTInfo.nonGFDevicesPresent;
3810 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pAssocRsp->HTInfo.lsigTXOPProtectionFullSupport;
3811 pAddBssParams->fRIFSMode = pAssocRsp->HTInfo.rifsMode;
3812 }
3813 }
3814
3815 pAddBssParams->currentOperChannel = neighborBssInfo->channelId;
3816
3817 // Populate the STA-related parameters here
3818 // Note that the STA here refers to the AP
3819 {
3820 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
3821
3822 palCopyMemory( pMac->hHdd, pAddBssParams->staContext.bssId,
3823 neighborBssInfo->bssId,
3824 sizeof( tSirMacAddr ));
3825 pAddBssParams->staContext.listenInterval = (tANI_U8) neighborBssInfo->beaconInterval;
3826
3827 pAddBssParams->staContext.assocId = 0; // Is SMAC OK with this?
3828 pAddBssParams->staContext.uAPSD = 0;
3829 pAddBssParams->staContext.maxSPLen = 0;
3830 pAddBssParams->staContext.shortPreambleSupported = (tANI_U8)pAssocRsp->capabilityInfo.shortPreamble;
3831 pAddBssParams->staContext.updateSta = updateEntry;
3832
3833
3834 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pAssocRsp->HTCaps.present ))
3835 {
3836 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
3837 pAddBssParams->staContext.htCapable = 1;
3838 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 )pAssocRsp->HTCaps.greenField;
3839 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 )pAssocRsp->HTCaps.lsigTXOPProtection;
3840 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )(pAssocRsp->HTCaps.supportedChannelWidthSet ?
3841 pAssocRsp->HTInfo.recommendedTxWidthSet :
3842 pAssocRsp->HTCaps.supportedChannelWidthSet );
3843 pAddBssParams->staContext.mimoPS = pAssocRsp->HTCaps.mimoPowerSave;
3844 pAddBssParams->staContext.delBASupport = ( tANI_U8 )pAssocRsp->HTCaps.delayedBA;
3845 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 )pAssocRsp->HTCaps.maximalAMSDUsize;
3846 pAddBssParams->staContext.maxAmpduDensity = pAssocRsp->HTCaps.mpduDensity;
3847 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pAssocRsp->HTCaps.dsssCckMode40MHz;
3848 pAddBssParams->staContext.fShortGI20Mhz = (tANI_U8)pAssocRsp->HTCaps.shortGI20MHz;
3849 pAddBssParams->staContext.fShortGI40Mhz = (tANI_U8)pAssocRsp->HTCaps.shortGI40MHz;
3850 pAddBssParams->staContext.maxAmpduSize= pAssocRsp->HTCaps.maxRxAMPDUFactor;
3851
3852 if( pAssocRsp->HTInfo.present )
3853 pAddBssParams->staContext.rifsMode = pAssocRsp->HTInfo.rifsMode;
3854 }
3855
3856 if ((psessionEntry->limWmeEnabled && pAssocRsp->wmeEdcaPresent) ||
3857 (psessionEntry->limQosEnabled && pAssocRsp->edcaPresent))
3858 pAddBssParams->staContext.wmmEnabled = 1;
3859 else
3860 pAddBssParams->staContext.wmmEnabled = 0;
3861
3862 //Update the rates
3863
3864 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3865 if (pStaDs != NULL)
3866 {
3867 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
3868 palCopyMemory(pMac->hHdd, (tANI_U8*)&pAddBssParams->staContext.supportedRates,
3869 (tANI_U8*)&pStaDs->supportedRates,
3870 sizeof(tSirSupportedRates));
3871 }
3872 else
3873 PELOGE(limLog(pMac, LOGE, FL("could not Update the supported rates.\n"));)
3874
3875 }
3876
3877 //Disable BA. It will be set as part of ADDBA negotiation.
3878 for( i = 0; i < SMAC_STACFG_MAX_TC; i++ )
3879 {
3880 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
3881 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
3882 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
3883 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
3884 }
3885
3886#if defined WLAN_FEATURE_VOWIFI
3887 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
3888#endif
3889 // FIXME_GEN4 - Any other value that can be used for initialization?
3890 pAddBssParams->status = eHAL_STATUS_SUCCESS;
3891 pAddBssParams->respReqd = true;
3892
3893 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
3894
3895#if defined WLAN_FEATURE_VOWIFI_11R
3896 pAddBssParams->extSetStaKeyParamValid = 0;
3897#endif
3898
3899 // Set a new state for MLME
3900 if( eLIM_MLM_WT_ASSOC_RSP_STATE == psessionEntry->limMlmState )
3901 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE;
3902 else
3903 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003904 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003905
3906 //we need to defer the message until we get the response back from HAL.
3907 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3908
3909 msgQ.type = SIR_HAL_ADD_BSS_REQ;
3910 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
3911 msgQ.reserved = 0;
3912 msgQ.bodyptr = pAddBssParams;
3913 msgQ.bodyval = 0;
3914
3915 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_BSS_REQ..." ));
Jeff Johnsone7245742012-09-05 17:12:55 -07003916 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003917
3918 retCode = halPostMsgApi( pMac, &msgQ );
3919 if( eSIR_SUCCESS != retCode)
3920 {
3921 palFreeMemory(pMac->hHdd, pAddBssParams);
3922 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X\n"),
3923 retCode );
3924 }
3925 else
3926 return retCode;
3927
3928 returnFailure:
3929 // Clean-up will be done by the caller...
3930 return retCode;
3931}
3932
3933#endif // ANI_PRODUCT_TYPE_CLIENT
3934
3935/** -------------------------------------------------------------
3936\fn limPrepareAndSendDelStaCnf
3937\brief deletes DPH entry
3938 changes the MLM mode for station.
3939 calls limSendDelStaCnf
3940\param tpAniSirGlobal pMac
3941\param tpDphHashNode pStaDs
3942\return none
3943 -------------------------------------------------------------*/
3944
3945
3946void
3947limPrepareAndSendDelStaCnf(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tSirResultCodes statusCode,tpPESession psessionEntry)
3948{
3949 tANI_U16 staDsAssocId = 0;
3950 tSirMacAddr staDsAddr;
3951 tLimMlmStaContext mlmStaContext;
3952
3953 if(pStaDs == NULL)
3954 {
3955 PELOGW(limLog(pMac, LOGW, FL("pStaDs is NULL\n"));)
3956 return;
3957 }
3958 staDsAssocId = pStaDs->assocId;
3959 palCopyMemory( pMac->hHdd, (tANI_U8 *)staDsAddr,
3960 pStaDs->staAddr,
3961 sizeof(tSirMacAddr));
3962
3963 mlmStaContext = pStaDs->mlmStaContext;
3964 if(eSIR_SME_SUCCESS == statusCode)
3965 {
3966 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
3967 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
3968 {
Gopichand Nakkala777e6032012-12-31 16:39:21 -08003969 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 }
3971
3972 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId,psessionEntry);
3973 }
3974 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
3975 {
3976 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003977 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 }
3979
3980 limSendDelStaCnf(pMac, staDsAddr, staDsAssocId, mlmStaContext, statusCode,psessionEntry);
3981}
3982
3983/** -------------------------------------------------------------
3984\fn limGetStaRateMode
3985\brief Gets the Station Rate Mode.
3986\param tANI_U8 dot11Mode
3987\return none
3988 -------------------------------------------------------------*/
3989tStaRateMode limGetStaRateMode(tANI_U8 dot11Mode)
3990{
3991 switch(dot11Mode)
3992 {
3993 case WNI_CFG_DOT11_MODE_11A:
3994 return eSTA_11a;
3995 case WNI_CFG_DOT11_MODE_11B:
3996 return eSTA_11b;
3997 case WNI_CFG_DOT11_MODE_11G:
3998 return eSTA_11bg;
3999 case WNI_CFG_DOT11_MODE_11N:
4000 return eSTA_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07004001#ifdef WLAN_FEATURE_11AC
4002 case WNI_CFG_DOT11_MODE_11AC:
4003 return eSTA_11ac;
4004#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 case WNI_CFG_DOT11_MODE_ALL:
4006 default:
4007 return eSTA_11n;
4008
4009 }
4010}
4011
4012/** -------------------------------------------------------------
4013\fn limInitPreAuthTimerTable
4014\brief Initialize the Pre Auth Tanle and creates the timer for
4015 each node for the timeout value got from cfg.
4016\param tpAniSirGlobal pMac
4017\param tpLimPreAuthTable pPreAuthTimerTable
4018\return none
4019 -------------------------------------------------------------*/
4020void limInitPreAuthTimerTable(tpAniSirGlobal pMac, tpLimPreAuthTable pPreAuthTimerTable)
4021{
4022 tANI_U32 cfgValue;
4023 tANI_U32 authNodeIdx;
4024 tpLimPreAuthNode pAuthNode = pPreAuthTimerTable->pTable;
4025
4026 // Get AUTH_RSP Timers value
4027
4028 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_RSP_TIMEOUT,
4029 &cfgValue) != eSIR_SUCCESS)
4030 {
4031 /*
4032 ** Could not get AUTH_RSP timeout value
4033 ** from CFG. Log error.
4034 **/
4035 limLog(pMac, LOGP,
4036 FL("could not retrieve AUTH_RSP timeout value\n"));
4037 return;
4038 }
4039
4040 cfgValue = SYS_MS_TO_TICKS(cfgValue);
4041 for(authNodeIdx=0; authNodeIdx<pPreAuthTimerTable->numEntry; authNodeIdx++, pAuthNode++)
4042 {
4043 if (tx_timer_create(&pAuthNode->timer,
4044 "AUTH RESPONSE TIMEOUT",
4045 limAuthResponseTimerHandler,
4046 authNodeIdx,
4047 cfgValue,
4048 0,
4049 TX_NO_ACTIVATE) != TX_SUCCESS)
4050 {
4051 // Cannot create timer. Log error.
4052 limLog(pMac, LOGP, FL("Cannot create Auth Rsp timer of Index :%d.\n"), authNodeIdx);
4053 return;
4054 }
4055 pAuthNode->authNodeIdx = (tANI_U8)authNodeIdx;
4056 pAuthNode->fFree = 1;
4057 }
4058
4059}
4060
4061/** -------------------------------------------------------------
4062\fn limAcquireFreePreAuthNode
4063\brief Retrives a free Pre Auth node from Pre Auth Table.
4064\param tpAniSirGlobal pMac
4065\param tpLimPreAuthTable pPreAuthTimerTable
4066\return none
4067 -------------------------------------------------------------*/
4068tLimPreAuthNode * limAcquireFreePreAuthNode(tpAniSirGlobal pMac, tpLimPreAuthTable pPreAuthTimerTable)
4069{
4070 tANI_U32 i;
4071 tLimPreAuthNode *pTempNode = pPreAuthTimerTable->pTable;
4072 for (i=0; i<pPreAuthTimerTable->numEntry; i++,pTempNode++)
4073 {
4074 if (pTempNode->fFree == 1)
4075 {
4076 pTempNode->fFree = 0;
4077 return pTempNode;
4078 }
4079 }
4080
4081 return NULL;
4082}
4083
4084/** -------------------------------------------------------------
4085\fn limGetPreAuthNodeFromIndex
4086\brief Depending on the Index this retrives the pre auth node.
4087\param tpAniSirGlobal pMac
4088\param tpLimPreAuthTable pAuthTable
4089\param tANI_U32 authNodeIdx
4090\return none
4091 -------------------------------------------------------------*/
4092tLimPreAuthNode * limGetPreAuthNodeFromIndex(tpAniSirGlobal pMac,
4093 tpLimPreAuthTable pAuthTable, tANI_U32 authNodeIdx)
4094{
4095 if ((authNodeIdx >= pAuthTable->numEntry) || (pAuthTable->pTable == NULL))
4096 {
4097 limLog(pMac, LOGE, FL("Invalid Auth Timer Index : %d NumEntry : %d\n"),
4098 authNodeIdx, pAuthTable->numEntry);
4099 return NULL;
4100 }
4101
4102 return pAuthTable->pTable + authNodeIdx;
4103}
4104
4105/* Util API to check if the channels supported by STA is within range */
4106tSirRetStatus limIsDot11hSupportedChannelsValid(tpAniSirGlobal pMac, tSirAssocReq *assoc)
4107{
4108 /*
4109 * Allow all the stations to join with us.
4110 * 802.11h-2003 11.6.1 => An AP may use the supported channels list for associated STAs
4111 * as an input into an algorithm used to select a new channel for the BSS.
4112 * The specification of the algorithm is beyond the scope of this amendment.
4113 */
4114
4115 return (eSIR_SUCCESS);
4116}
4117
4118/* Util API to check if the txpower supported by STA is within range */
4119tSirRetStatus limIsDot11hPowerCapabilitiesInRange(tpAniSirGlobal pMac, tSirAssocReq *assoc,tpPESession psessionEntry)
4120{
4121 tPowerdBm localMaxTxPower;
4122 tANI_U32 localPwrConstraint;
4123
4124 localMaxTxPower = cfgGetRegulatoryMaxTransmitPower(pMac, psessionEntry->currentOperChannel);
4125
4126 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
4127 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg\n" ));
4128 return eSIR_FAILURE;
4129 }
4130 localMaxTxPower -= (tPowerdBm)localPwrConstraint;
4131
4132 /**
4133 * The min Tx Power of the associating station should not be greater than (regulatory
4134 * max tx power - local power constraint configured on AP).
4135 */
4136 if(assoc->powerCapability.minTxPower > localMaxTxPower)
4137 {
4138 limLog(pMac, LOGW, FL("minTxPower (STA) = %d, localMaxTxPower (AP) = %d\n"),
4139 assoc->powerCapability.minTxPower, localMaxTxPower);
4140 return (eSIR_FAILURE);
4141 }
4142
4143 return (eSIR_SUCCESS);
4144}
4145
4146/** -------------------------------------------------------------
4147\fn limFillRxHighestSupportedRate
4148\brief Fills in the Rx Highest Supported Data Rate field from
4149\ the 'supported MCS set' field in HT capability element.
4150\param tpAniSirGlobal pMac
4151\param tpSirSupportedRates pRates
4152\param tANI_U8* pSupportedMCSSet
4153\return none
4154 -------------------------------------------------------------*/
4155void limFillRxHighestSupportedRate(tpAniSirGlobal pMac, tANI_U16 *rxHighestRate, tANI_U8* pSupportedMCSSet)
4156{
4157 tSirMacRxHighestSupportRate *pRxHighestRate;
4158 tANI_U8 *pBuf;
4159 tANI_U16 rate=0;
4160
4161 pBuf = pSupportedMCSSet + MCS_RX_HIGHEST_SUPPORTED_RATE_BYTE_OFFSET;
4162 rate = limGetU16(pBuf);
4163
4164 pRxHighestRate = (tSirMacRxHighestSupportRate *) &rate;
4165 *rxHighestRate = pRxHighestRate->rate;
4166
4167 return;
4168}