blob: 5b40fa99cea79d1a88b2c3366ab69b8c5ad62584 [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
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -070042
Jeff Johnson295189b2012-06-20 16:38:30 -070043/*
Jeff Johnson295189b2012-06-20 16:38:30 -070044 * 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
Jeff Johnson295189b2012-06-20 16:38:30 -070060#include "wniCfgSta.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070061#include "pmmApi.h"
62#include "cfgApi.h"
63
64#include "schApi.h"
65#include "utilsApi.h"
66#include "limUtils.h"
67#include "limAssocUtils.h"
68#include "limSecurityUtils.h"
69#include "limSerDesUtils.h"
70#include "limStaHashApi.h"
71#include "limAdmitControl.h"
72#include "limSendMessages.h"
73#include "limIbssPeerMgmt.h"
74#include "limSession.h"
75
76#include "vos_types.h"
77#include "wlan_qct_wda.h"
78
79/*
80 * fill up the rate info properly based on what is actually supported by the peer
81 * TBD TBD TBD
82 */
83void
84limFillSupportedRatesInfo(
85 tpAniSirGlobal pMac,
86 tpDphHashNode pSta,
87 tpSirSupportedRates pRates,
88 tpPESession psessionEntry)
89{
90 //pSta will be NULL for self entry, so get the opRateMode based on the self mode.
91 //For the peer entry get it from the peer Capabilities present in hash table
92 if(pSta == NULL)
93 pRates->opRateMode = limGetStaRateMode((tANI_U8)psessionEntry->dot11mode);
94 else
95 pRates->opRateMode = limGetStaPeerType(pMac, pSta, psessionEntry);
96
97}
98
99
100/**
101 * limCmpSSid()
102 *
103 *FUNCTION:
104 * This function is called in various places within LIM code
105 * to determine whether received SSid is same as SSID in use.
106 *
107 *LOGIC:
108 *
109 *ASSUMPTIONS:
110 * NA
111 *
112 *NOTE:
113 * NA
114 *
115 * @param *prxSSid - pointer to SSID structure
116 *
117 * @return status - true for SSID match else false.
118 */
119
120tANI_U8
121limCmpSSid(tpAniSirGlobal pMac, tSirMacSSid *prxSSid,tpPESession psessionEntry)
122{
123
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530124 if (vos_mem_compare((tANI_U8* ) prxSSid, (tANI_U8 *) &psessionEntry->ssId,
125 (tANI_U8) (psessionEntry->ssId.length + 1)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700126 return true;
127 else
128 return false;
129
130} /****** end limCmpSSid() ******/
131
132
133
134/**
135 * limCompareCapabilities()
136 *
137 *FUNCTION:
138 * This function is called during Association/Reassociation
139 * frame handling to determine whether received capabilities
140 * match with local capabilities or not.
141 *
142 *LOGIC:
143 *
144 *ASSUMPTIONS:
145 * NA
146 *
147 *NOTE:
148 * NA
149 *
150 * @param pMac - Pointer to Global MAC structure
151 * @param pAssocReq - Pointer to received Assoc Req frame
152 * @param pLocalCapabs - Pointer to local capabilities
153 *
154 * @return status - true for Capabilitity match else false.
155 */
156
157tANI_U8
158limCompareCapabilities(tpAniSirGlobal pMac,
159 tSirAssocReq *pAssocReq,
160 tSirMacCapabilityInfo *pLocalCapabs,tpPESession psessionEntry)
161{
162 tANI_U32 val;
163
164
165 if ( ((psessionEntry->limSystemRole == eLIM_AP_ROLE)||
166 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) &&
167 (pAssocReq->capabilityInfo.ibss) )
168 {
169 // Requesting STA asserting IBSS capability.
170 return false;
171 }
172
173 // Compare CF capabilities
174 if (pAssocReq->capabilityInfo.cfPollable ||
175 pAssocReq->capabilityInfo.cfPollReq)
176 {
177 // AP does not support PCF functionality
178 return false;
179 }
180
181#if 0 //See CR24696 for analysis
182 // Compare privacy capability
183 if (pAssocReq->capabilityInfo.privacy != pLocalCapabs->privacy)
184 {
185 // AP does not support privacy
186 return false;
187 }
188#endif
189
190 // Compare short preamble capability
191 if (pAssocReq->capabilityInfo.shortPreamble &&
192 (pAssocReq->capabilityInfo.shortPreamble !=
193 pLocalCapabs->shortPreamble))
194 {
195 PELOG1(limLog(pMac, LOG1,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700196 FL("Allowing a STA requesting short preamble while AP does not support it"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700197#if 0
198 // AP does not support short preamable
199 return false;
200#endif
201 }
202
203
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700204 limLog(pMac, LOGW, "QoS in AssocReq: %d, local ShortP: %d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700205 pAssocReq->capabilityInfo.qos,
206 pLocalCapabs->qos);
207
208 // Compare QoS capability
209 if (pAssocReq->capabilityInfo.qos &&
210 (pAssocReq->capabilityInfo.qos != pLocalCapabs->qos))
211 {
212 /*Temporary hack for UPF to skip 11e capability check in order to interop with
213 CSR - proper fix needs to be put in place*/
214 if ( 0 != vos_get_skip_11e_check())
215 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700216 limLog(pMac, LOG1, FL("Received unmatched QOS but cfg to suppress - continuing"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700217 }
218 else
219 {
220 // AP does not support QoS capability
221 return false;
222 }
223 }
224
225
226 /*
227 * If AP supports shortSlot and if apple user has
228 * enforced association only from shortSlot station,
229 * then AP must reject any station that does not support
230 * shortSlot
231 */
232 if ( ((psessionEntry->limSystemRole == eLIM_AP_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE)) && (pLocalCapabs->shortSlotTime == 1) )
233
234 {
235 if (wlan_cfgGetInt(pMac, WNI_CFG_ACCEPT_SHORT_SLOT_ASSOC_ONLY, &val) != eSIR_SUCCESS)
236 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700237 limLog(pMac, LOGP, FL("error getting WNI_CFG_FORCE_SHORT_SLOT_ASSOC_ONLY "));
Jeff Johnson295189b2012-06-20 16:38:30 -0700238 return false;
239 }
240 if(val)
241 {
242 if (pAssocReq->capabilityInfo.shortSlotTime != pLocalCapabs->shortSlotTime)
243 return false;
244 }
245 }
246
247 return true;
248} /****** end limCompareCapabilities() ******/
249
250
251/**
252 * limCheckRxBasicRates()
253 *
254 *FUNCTION:
255 * This function is called during Association/Reassociation
256 * frame handling to determine whether received rates in
257 * Assoc/Reassoc request frames include all BSS basic rates
258 * or not.
259 *
260 *LOGIC:
261 *
262 *ASSUMPTIONS:
263 * NA
264 *
265 *NOTE:
266 * NA
267 *
268 * @param rxRateSet - pointer to SSID structure
269 *
270 * @return status - true if ALL BSS basic rates are present in the
271 * received rateset else false.
272 */
273
274tANI_U8
275limCheckRxBasicRates(tpAniSirGlobal pMac, tSirMacRateSet rxRateSet,tpPESession psessionEntry)
276{
277 tSirMacRateSet *pRateSet, basicRate;
278 tANI_U8 i, j, k, match;
279
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530280 pRateSet = vos_mem_malloc(sizeof(tSirMacRateSet));
281 if (NULL == pRateSet)
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 {
283 // Log error
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530284 limLog(pMac, LOGP, FL("call to AllocateMemory failed for RATESET"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700285
286 return false;
287 }
288
289
290 #if 0
291 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
292 (tANI_U8 *) &pRateSet->rate,
293 (tANI_U32 *) &cfgLen) != eSIR_SUCCESS)
294 {
295 /// Could not get Operational rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700296 limLog(pMac, LOGP, FL("could not retrieve Operational rateset"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700297
298 // Free up memory allocated for rateset
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530299 vos_mem_free((tANI_U8 *) pRateSet);
Jeff Johnson295189b2012-06-20 16:38:30 -0700300
301 return false;
302 }
303 #endif //TO SUPPORT BT-AMP
304
305 /* Copy operational rate set from session Entry */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530306 vos_mem_copy(pRateSet->rate, (psessionEntry->rateSet.rate),
307 psessionEntry->rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -0700308
309 pRateSet->numRates = psessionEntry->rateSet.numRates;
310
311 // Extract BSS basic rateset from operational rateset
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -0700312 for (i = 0, j = 0; ((i < pRateSet->numRates) && (i < SIR_MAC_RATESET_EID_MAX)) ; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700313 {
314 if ((pRateSet->rate[i] & 0x80) == 0x80)
315 {
316 // msb is set, so this is a basic rate
317 basicRate.rate[j++] = pRateSet->rate[i];
318 }
319 }
320
321 /*
322 * For each BSS basic rate, find if it is present in the
323 * received rateset.
324 */
325 for (k = 0; k < j; k++)
326 {
327 match = 0;
Krunal Sonia75019a2013-05-01 01:08:22 -0700328 for (i = 0; ((i < rxRateSet.numRates) && (i < SIR_MAC_RATESET_EID_MAX)); i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 {
330 if ((rxRateSet.rate[i] | 0x80) == basicRate.rate[k])
331 match = 1;
332 }
333
334 if (!match)
335 {
336 // Free up memory allocated for rateset
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530337 vos_mem_free((tANI_U8 *)pRateSet);
Jeff Johnson295189b2012-06-20 16:38:30 -0700338
339 return false;
340 }
341 }
342
343 // Free up memory allocated for rateset
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530344 vos_mem_free((tANI_U8 *)pRateSet);
Jeff Johnson295189b2012-06-20 16:38:30 -0700345
346 return true;
347} /****** end limCheckRxBasicRates() ******/
348
349
350
351/**
352 * limCheckMCSSet()
353 *
354 *FUNCTION:
355 * This function is called during Association/Reassociation
356 * frame handling to determine whether received MCS rates in
357 * Assoc/Reassoc request frames includes all Basic MCS Rate Set or not.
358 *
359 *LOGIC:
360 *
361 *ASSUMPTIONS:
362 * NA
363 *
364 *NOTE:
365 * NA
366 *
367 * @param supportedMCSSet - pointer to Supported MCS Rate Set
368 *
369 * @return status - true if ALL MCS Basic Rate Set rates are present in the
370 * received rateset else false.
371 */
372
373tANI_U8
374limCheckMCSSet(tpAniSirGlobal pMac, tANI_U8* supportedMCSSet)
375{
376 tANI_U8 basicMCSSet[SIZE_OF_BASIC_MCS_SET] = {0};
377 tANI_U32 cfgLen = 0;
378 tANI_U8 i;
379 tANI_U8 validBytes;
380 tANI_U8 lastByteMCSMask = 0x1f;
381
382
383 cfgLen = WNI_CFG_BASIC_MCS_SET_LEN;
384 if (wlan_cfgGetStr(pMac, WNI_CFG_BASIC_MCS_SET,
385 (tANI_U8 *) basicMCSSet,
386 (tANI_U32 *) &cfgLen) != eSIR_SUCCESS)
387 {
388 /// Could not get Basic MCS rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700389 limLog(pMac, LOGP, FL("could not retrieve Basic MCS rateset"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700390 return false;
391 }
392
393 validBytes = VALID_MCS_SIZE/8;
394
395 //check if all the Basic MCS Bits are set in supported MCS bitmap
396 for(i=0; i<validBytes; i++)
397 {
398 if( (basicMCSSet[i] & supportedMCSSet[i]) != basicMCSSet[i])
399 {
400 PELOGW(limLog(pMac, LOGW, FL("One of Basic MCS Set Rates is not supported by the Station."));)
401 return false;
402 }
403 }
404
405 //check the last 5 bits of the valid MCS bitmap
406 if( ((basicMCSSet[i] & lastByteMCSMask) & (supportedMCSSet[i] & lastByteMCSMask)) !=
407 (basicMCSSet[i] & lastByteMCSMask))
408 {
409 PELOGW(limLog(pMac, LOGW, FL("One of Basic MCS Set Rates is not supported by the Station."));)
410 return false;
411 }
412
413 return true;
414}
415
Jeff Johnson295189b2012-06-20 16:38:30 -0700416
417#define SECURITY_SUITE_TYPE_MASK 0xFF
418#define SECURITY_SUITE_TYPE_WEP40 0x1
419#define SECURITY_SUITE_TYPE_TKIP 0x2
420#define SECURITY_SUITE_TYPE_CCMP 0x4
421#define SECURITY_SUITE_TYPE_WEP104 0x4
422
423/**
424 * limCheckRxRSNIeMatch()
425 *
426 *FUNCTION:
427 * This function is called during Association/Reassociation
428 * frame handling to determine whether received RSN in
429 * Assoc/Reassoc request frames include supported cipher suites or not.
430 *
431 *LOGIC:
432 *
433 *ASSUMPTIONS:
434 * NA
435 *
436 *NOTE:
437 * NA
438 *
439 * @param rxRSNIe - received RSN IE in (Re)Assco req
440 *
441 * @return status - true if ALL BSS basic rates are present in the
442 * received rateset else false.
443 */
444
445tANI_U8
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700446limCheckRxRSNIeMatch(tpAniSirGlobal pMac, tDot11fIERSN rxRSNIe,tpPESession pSessionEntry,
447 tANI_U8 staIsHT, tANI_BOOLEAN *pmfConnection)
Jeff Johnson295189b2012-06-20 16:38:30 -0700448{
449 tDot11fIERSN *pRSNIe;
450 tANI_U8 i, j, match, onlyNonHtCipher = 1;
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700451#ifdef WLAN_FEATURE_11W
452 tANI_BOOLEAN weRequirePMF;
453 tANI_BOOLEAN weArePMFCapable;
454 tANI_BOOLEAN theyRequirePMF;
455 tANI_BOOLEAN theyArePMFCapable;
456#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700457
458
459 //RSN IE should be received from PE
460 pRSNIe = &pSessionEntry->gStartBssRSNIe;
461
462 // Check groupwise cipher suite
463 for (i = 0; i < sizeof(rxRSNIe.gp_cipher_suite); i++)
464 {
465 if (pRSNIe->gp_cipher_suite[i] != rxRSNIe.gp_cipher_suite[i])
466 {
467 return eSIR_MAC_INVALID_GROUP_CIPHER_STATUS;
468 }
469 }
470
471 /*
472 * For each Pairwise cipher suite check whether we support
473 * received pairwise
474 */
475 match = 0;
476 for (i = 0; i < rxRSNIe.pwise_cipher_suite_count; i++)
477 {
478 for(j = 0; j < pRSNIe->pwise_cipher_suite_count; j++)
479 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530480 if (vos_mem_compare(&rxRSNIe.pwise_cipher_suites[i],
481 &pRSNIe->pwise_cipher_suites[j],
482 sizeof(pRSNIe->pwise_cipher_suites[j])))
Jeff Johnson295189b2012-06-20 16:38:30 -0700483 {
484 match = 1;
485 break;
486 }
487 }
488
489 if ((staIsHT)
490#ifdef ANI_LITTLE_BYTE_ENDIAN
491 &&( (rxRSNIe.pwise_cipher_suites[i][3] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
492#else
493 &&( (rxRSNIe.pwise_cipher_suites[i][0] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
494#endif
495 {
496 onlyNonHtCipher=0;
497 }
498
499 }
500
501 if ((!match) || ((staIsHT) && onlyNonHtCipher))
502 {
503 return eSIR_MAC_INVALID_PAIRWISE_CIPHER_STATUS;
504 }
Venkata Prathyusha Kuntupalliea7098e2013-01-31 16:08:13 -0800505 /* Check RSN capabilities
506 * Bit 0 of First Byte - PreAuthentication Capability
507 */
508 if(((rxRSNIe.RSN_Cap[0] >> 0) & 0x1) == true) //this is supported by AP only
Jeff Johnson295189b2012-06-20 16:38:30 -0700509 {
510 return eSIR_MAC_INVALID_RSN_IE_CAPABILITIES_STATUS;
511 }
512
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700513 *pmfConnection = eANI_BOOLEAN_FALSE;
514#ifdef WLAN_FEATURE_11W
515 weRequirePMF = (pRSNIe->RSN_Cap[0] >> 6) & 0x1;
516 weArePMFCapable = (pRSNIe->RSN_Cap[0] >> 7) & 0x1;
517 theyRequirePMF = (rxRSNIe.RSN_Cap[0] >> 6) & 0x1;
518 theyArePMFCapable = (rxRSNIe.RSN_Cap[0] >> 7) & 0x1;
519
Chet Lanctotec4de332013-10-11 15:42:22 -0700520 if ((theyRequirePMF && theyArePMFCapable && !weArePMFCapable) ||
521 (weRequirePMF && !theyArePMFCapable))
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700522 {
523 limLog(pMac, LOG1, FL("Association fail, robust management frames policy violation"));
524 return eSIR_MAC_ROBUST_MGMT_FRAMES_POLICY_VIOLATION;
525 }
526
527 if(theyArePMFCapable && weArePMFCapable)
528 *pmfConnection = eANI_BOOLEAN_TRUE;
529#endif
530
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 return eSIR_SUCCESS;
532} /****** end limCheckRxRSNIeMatch() ******/
533
534/**
535 * limCheckRxWPAIeMatch()
536 *
537 *FUNCTION:
538 * This function is called during Association/Reassociation
539 * frame handling to determine whether received RSN in
540 * Assoc/Reassoc request frames include supported cipher suites or not.
541 *
542 *LOGIC:
543 *
544 *ASSUMPTIONS:
545 * NA
546 *
547 *NOTE:
548 * NA
549 *
550 * @param rxWPAIe - Received WPA IE in (Re)Assco req
551 *
552 * @return status - true if ALL BSS basic rates are present in the
553 * received rateset else false.
554 */
555
556tANI_U8
557limCheckRxWPAIeMatch(tpAniSirGlobal pMac, tDot11fIEWPA rxWPAIe,tpPESession pSessionEntry, tANI_U8 staIsHT)
558{
559 tDot11fIEWPA *pWPAIe;
560 tANI_U8 i, j, match, onlyNonHtCipher = 1;
561
562 // WPA IE should be received from PE
563 pWPAIe = &pSessionEntry->gStartBssWPAIe;
564
565 // Check groupwise cipher suite
566 for (i = 0; i < 4; i++)
567 {
568 if (pWPAIe->multicast_cipher[i] != rxWPAIe.multicast_cipher[i])
569 {
570 return eSIR_MAC_INVALID_GROUP_CIPHER_STATUS;
571 }
572 }
573
574 /*
575 * For each Pairwise cipher suite check whether we support
576 * received pairwise
577 */
578 match = 0;
579 for (i = 0; i < rxWPAIe.unicast_cipher_count; i++)
580 {
581 for(j = 0; j < pWPAIe->unicast_cipher_count; j++)
582 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530583 if (vos_mem_compare(rxWPAIe.unicast_ciphers[i],
584 pWPAIe->unicast_ciphers[j],
585 4))
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 {
587 match = 1;
588 break;
589 }
590 }
591
592 if ((staIsHT)
593#ifdef ANI_LITTLE_BYTE_ENDIAN
594 &&( (rxWPAIe.unicast_ciphers[i][3] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
595#else
596 &&( (rxWPAIe.unicast_ciphers[i][0] & SECURITY_SUITE_TYPE_MASK) == SECURITY_SUITE_TYPE_CCMP))
597#endif
598 {
599 onlyNonHtCipher=0;
600 }
601
602 }
603
604 if ((!match) || ((staIsHT) && onlyNonHtCipher))
605 {
606 return eSIR_MAC_CIPHER_SUITE_REJECTED_STATUS;
607 }
608
609 return eSIR_SUCCESS;
610} /****** end limCheckRxWPAIeMatch() ******/
611
Jeff Johnson295189b2012-06-20 16:38:30 -0700612
613/**
614 * limCleanupRxPath()
615 *
616 *FUNCTION:
617 * This function is called to cleanup STA state at SP & RFP.
618 *
619 *LOGIC:
620 * To circumvent RFP's handling of dummy packet when it does not
621 * have an incomplete packet for the STA to be deleted, a packet
622 * with 'more framgents' bit set will be queued to RFP's WQ before
623 * queuing 'dummy packet'.
624 * A 'dummy' BD is pushed into RFP's WQ with type=00, subtype=1010
625 * (Disassociation frame) and routing flags in BD set to eCPU's
626 * Low Priority WQ.
627 * RFP cleans up its local context for the STA id mentioned in the
628 * BD and then pushes BD to eCPU's low priority WQ.
629 *
630 *ASSUMPTIONS:
631 * NA
632 *
633 *NOTE:
634 * NA
635 *
636 * @param pMac Pointer to Global MAC structure
637 * @param pStaDs Pointer to the per STA data structure
638 * initialized by LIM and maintained at DPH
639 *
640 * @return None
641 */
642
643tSirRetStatus
644limCleanupRxPath(tpAniSirGlobal pMac, tpDphHashNode pStaDs,tpPESession psessionEntry)
645{
646 tSirRetStatus retCode = eSIR_SUCCESS;
647
648
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -0700649 PELOG2(limLog( pMac, LOG2, FL("**Initiate cleanup"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700650
651 limAbortBackgroundScan( pMac );
652
653 if (pMac->lim.gLimAddtsSent)
654 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700655 MTRACE(macTrace(pMac, TRACE_CODE_TIMER_DEACTIVATE, psessionEntry->peSessionId, eLIM_ADDTS_RSP_TIMER));
Jeff Johnson295189b2012-06-20 16:38:30 -0700656 tx_timer_deactivate(&pMac->lim.limTimers.gLimAddtsRspTimer);
657 }
658
659 if (pStaDs->mlmStaContext.mlmState == eLIM_MLM_WT_ASSOC_CNF_STATE)
660 {
661 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER,
662 pStaDs->assocId);
663
664 if (!pStaDs->mlmStaContext.updateContext)
665 {
666 /**
667 * There is no context at Polaris to delete.
668 * Release our assigned AID back to the free pool
669 */
670 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
671 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
672 {
Gopichand Nakkala777e6032012-12-31 16:39:21 -0800673 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 }
675 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId,psessionEntry);
676
677 return retCode;
678 }
679 }
680
681 //delete all tspecs associated with this sta.
682 limAdmitControlDeleteSta(pMac, pStaDs->assocId);
683
Jeff Johnson295189b2012-06-20 16:38:30 -0700684
685 /**
686 * Make STA hash entry invalid at eCPU so that DPH
687 * does not process any more data packets and
688 * releases those BDs
689 */
690 pStaDs->valid = 0;
691 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
692
693 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
694 {
Jeff Johnsone7245742012-09-05 17:12:55 -0700695 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 /* Deactivating probe after heart beat timer */
698 limDeactivateAndChangeTimer(pMac, eLIM_PROBE_AFTER_HB_TIMER);
Leela Venkata Kiran Kumar Reddy Chiralade5d0592013-09-20 17:09:35 -0700699 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 limHeartBeatDeactivateAndChangeTimer(pMac, psessionEntry);
701 limDeactivateAndChangeTimer(pMac, eLIM_KEEPALIVE_TIMER);
702 pMac->lim.gLastBeaconDtimCount = 0;
703 pMac->lim.gLastBeaconDtimPeriod = 0;
704
705#ifdef FEATURE_WLAN_CCX
706 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
707#endif
708
709 /**
710 * Update the status for PMM module
711 */
712 pmmResetPmmState(pMac);
713 }
714#ifdef WLAN_DEBUG
715 // increment a debug count
716 pMac->lim.gLimNumRxCleanup++;
717#endif
718
719 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE) {
720 retCode = limDelBss( pMac, pStaDs, psessionEntry->bssIdx, psessionEntry);
721 }
722 else
723 retCode = limDelSta( pMac, pStaDs, true, psessionEntry);
724
725 return retCode;
726
727} /*** end limCleanupRxPath() ***/
728
729
730/**
731 * limSendDelStaCnf()
732 *
733 *FUNCTION:
734 * This function is called to send appropriate CNF message to SME
735 *
736 *LOGIC:
737 *
738 *
739 *ASSUMPTIONS:
740 * NA
741 *
742 *NOTE:
743 * NA
744 *
745 * @param pMac Pointer to Global MAC structure
746 * @param tpAniSirGlobal pMac,
747 * @param tSirMacAddr staDsAddr,
748 * @param tANI_U16 staDsAssocId,
749 * @param tLimMlmStaContext mlmStaContext,
750 * @param tSirResultCodes statusCode
751 *
752 * @return None
753 */
754
755void
756limSendDelStaCnf(tpAniSirGlobal pMac, tSirMacAddr staDsAddr,
757 tANI_U16 staDsAssocId, tLimMlmStaContext mlmStaContext, tSirResultCodes statusCode,tpPESession psessionEntry)
758{
759
760 tLimMlmDisassocCnf mlmDisassocCnf;
761 tLimMlmDeauthCnf mlmDeauthCnf;
762 tLimMlmPurgeStaInd mlmPurgeStaInd;
763
764 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
765 {
766 // Set BSSID at CFG to null
767 tSirMacAddr nullAddr = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
768 #if 0
769 if (cfgSetStr(pMac, WNI_CFG_BSSID, (tANI_U8 *) &nullAddr,
770 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
771 {
772 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700773 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700774
775 return;
776 }
777 #endif//TO SUPPORT BT-AMP
778
779 sirCopyMacAddr(nullAddr,psessionEntry->bssId);
780
781 // Free up buffer allocated for JoinReq held by
782 // MLM state machine
783 if (psessionEntry->pLimMlmJoinReq)
784 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530785 vos_mem_free(psessionEntry->pLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 psessionEntry->pLimMlmJoinReq = NULL;
787 }
788
789 psessionEntry->limAID = 0;
790
791
792 }
793
794 if ((mlmStaContext.cleanupTrigger ==
795 eLIM_HOST_DISASSOC) ||
796 (mlmStaContext.cleanupTrigger ==
797 eLIM_LINK_MONITORING_DISASSOC) ||
798 (mlmStaContext.cleanupTrigger ==
799 eLIM_PROMISCUOUS_MODE_DISASSOC))
800 {
801 /**
802 * Host or LMM driven Disassociation.
803 * Issue Disassoc Confirm to SME.
804 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700805 limLog( pMac, LOGW, FL("Lim Posting DISASSOC_CNF to Sme. Trigger: %X"), mlmStaContext.cleanupTrigger);
Jeff Johnson295189b2012-06-20 16:38:30 -0700806
807
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530808 vos_mem_copy((tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
809 (tANI_U8 *) staDsAddr,
810 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700811 mlmDisassocCnf.resultCode = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700812 mlmDisassocCnf.disassocTrigger =
813 mlmStaContext.cleanupTrigger;
814 /* Update PE session Id*/
815 mlmDisassocCnf.sessionId = psessionEntry->peSessionId;
816
817 limPostSmeMessage(pMac,
818 LIM_MLM_DISASSOC_CNF,
819 (tANI_U32 *) &mlmDisassocCnf);
820 }
821 else if ((mlmStaContext.cleanupTrigger ==
822 eLIM_HOST_DEAUTH) ||
823 (mlmStaContext.cleanupTrigger ==
824 eLIM_LINK_MONITORING_DEAUTH))
825 {
826 /**
827 * Host or LMM driven Deauthentication.
828 * Issue Deauth Confirm to SME.
829 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700830 limLog( pMac, LOGW, FL("Lim Posting DEAUTH_CNF to Sme. Trigger: %X"), mlmStaContext.cleanupTrigger);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530831 vos_mem_copy((tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
832 (tANI_U8 *) staDsAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 sizeof(tSirMacAddr));
834 mlmDeauthCnf.resultCode = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 mlmDeauthCnf.deauthTrigger =
836 mlmStaContext.cleanupTrigger;
837 /* PE session Id */
838 mlmDeauthCnf.sessionId = psessionEntry->peSessionId;
839
840 limPostSmeMessage(pMac,
841 LIM_MLM_DEAUTH_CNF,
842 (tANI_U32 *) &mlmDeauthCnf);
843 }
844 else if ((mlmStaContext.cleanupTrigger ==
845 eLIM_PEER_ENTITY_DISASSOC) ||
846 (mlmStaContext.cleanupTrigger ==
847 eLIM_PEER_ENTITY_DEAUTH))
848 {
849 /**
850 * Received Disassociation/Deauthentication from peer.
851 * Issue Purge Ind to SME.
852 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700853 limLog( pMac, LOGW, FL("Lim Posting PURGE_STA_IND to Sme. Trigger: %X"), mlmStaContext.cleanupTrigger) ;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530854 vos_mem_copy((tANI_U8 *) &mlmPurgeStaInd.peerMacAddr,
855 (tANI_U8 *) staDsAddr,
856 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 mlmPurgeStaInd.reasonCode = (tANI_U8) mlmStaContext.disassocReason;
858 mlmPurgeStaInd.aid = staDsAssocId;
859 mlmPurgeStaInd.purgeTrigger = mlmStaContext.cleanupTrigger;
860 mlmPurgeStaInd.sessionId = psessionEntry->peSessionId;
861
862 limPostSmeMessage(pMac,
863 LIM_MLM_PURGE_STA_IND,
864 (tANI_U32 *) &mlmPurgeStaInd);
865 }
866 else if(mlmStaContext.cleanupTrigger == eLIM_JOIN_FAILURE)
867 {
868 //PE setup the peer entry in HW upfront, right after join is completed.
869 //If there is a failure during rest of the assoc sequence, this context needs to be cleaned up.
870 tANI_U8 smesessionId;
871 tANI_U16 smetransactionId;
872
873 smesessionId = psessionEntry->smeSessionId;
874 smetransactionId = psessionEntry->transactionId;
875
876 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700877 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700878
Jeff Johnsone7245742012-09-05 17:12:55 -0700879 //if it is a reassoc failure to join new AP
Madan Mohan Koyyalamudif33324b2012-11-06 19:16:17 -0800880 if((mlmStaContext.resultCode == eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE) ||
881 (mlmStaContext.resultCode == eSIR_SME_FT_REASSOC_FAILURE))
Jeff Johnsone7245742012-09-05 17:12:55 -0700882 {
883 if(mlmStaContext.resultCode != eSIR_SME_SUCCESS )
884 {
885 peDeleteSession(pMac, psessionEntry);
886 psessionEntry = NULL;
887 }
888
889 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
890 mlmStaContext.resultCode, mlmStaContext.protStatusCode, psessionEntry,
891 smesessionId, smetransactionId);
892 }
893 else
894 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530895 vos_mem_free(psessionEntry->pLimJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 psessionEntry->pLimJoinReq = NULL;
897
898 if(mlmStaContext.resultCode != eSIR_SME_SUCCESS)
899 {
900 peDeleteSession(pMac,psessionEntry);
901 psessionEntry = NULL;
902 }
903
904 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, mlmStaContext.resultCode, mlmStaContext.protStatusCode,
905 psessionEntry, smesessionId, smetransactionId);
Jeff Johnsone7245742012-09-05 17:12:55 -0700906 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700907
908 }
909
910 if((NULL != psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 && (eLIM_AP_ROLE != psessionEntry->limSystemRole )
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 )
913 {
914 peDeleteSession(pMac,psessionEntry);
915 psessionEntry = NULL;
916 }
917}
918
919/**
920 * limRejectAssociation()
921 *
922 *FUNCTION:
923 * This function is called whenever Re/Association Request need
924 * to be rejected due to failure in assigning an AID or failure
925 * in adding STA context at Polaris or reject by applications.
926 *
927 *LOGIC:
928 * Resources allocated if any are freedup and (Re) Association
929 * Response frame is sent to requesting STA. Pre-Auth context
930 * will be added for this STA if it does not exist already
931 *
932 *ASSUMPTIONS:
933 *
934 *NOTE:
935 *
936 * @param *pBd - A pointer to Buffer descriptor + associated PDUs
937 * @param subType - Indicates whether it is Association Request (=0) or
938 * Reassociation Request (=1) frame
939 * @param addPreAuthContext - Indicates whether pre-auth context
940 * to be added for this STA
941 * @param authType - Indicates auth type to be added
942 * @param staId - Indicates staId of the STA being rejected
943 * association
944 * @param deleteSta - Indicates whether to delete STA context
945 * at Polaris
946 * @param rCode - Indicates what reasonCode to be sent in
947 * Re/Assoc response to STA
948 *
949 * @return None
950 */
951
952void
953limRejectAssociation(tpAniSirGlobal pMac, tSirMacAddr peerAddr, tANI_U8 subType,
954 tANI_U8 addPreAuthContext, tAniAuthType authType,
955 tANI_U16 staId, tANI_U8 deleteSta, tSirResultCodes rCode, tpPESession psessionEntry )
956{
957 tpDphHashNode pStaDs;
958
959 if (addPreAuthContext)
960 {
961 // Create entry for this STA in pre-auth list
962 struct tLimPreAuthNode *pAuthNode;
963
964 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
965
966 if (pAuthNode)
967 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530968 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 peerAddr,
970 sizeof(tSirMacAddr));
971 pAuthNode->fTimerStarted = 0;
972 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
973 pAuthNode->authType = (tAniAuthType) authType;
974 limAddPreAuthNode(pMac, pAuthNode);
975 }
976 }
977
978 if (deleteSta == true)
979 {
980 pStaDs = dphGetHashEntry(pMac, staId, &psessionEntry->dph.dphHashTable);
981
982 if (pStaDs == NULL)
983 {
984 limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700985 FL("No STA context, yet rejecting Association"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700986
987 return;
988 }
989
990 /**
991 * Polaris has state for this STA.
992 * Trigger cleanup.
993 */
994 pStaDs->mlmStaContext.cleanupTrigger = eLIM_REASSOC_REJECT;
995
996 // Receive path cleanup
997 limCleanupRxPath(pMac, pStaDs, psessionEntry);
998
999 // Send Re/Association Response with
1000 // status code to requesting STA.
1001 limSendAssocRspMgmtFrame(pMac,
1002 rCode,
1003 0,
1004 peerAddr,
1005 subType, 0,psessionEntry);
1006
1007 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL)
1008 {
1009 // Assoction confirmation is complete, free the copy of association request frame
1010 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
1011 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301012 vos_mem_free(((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
1014 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301015 vos_mem_free(psessionEntry->parsedAssocReq[pStaDs->assocId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001016 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
1017 }
1018 }
1019 else
1020 {
1021 limSendAssocRspMgmtFrame(pMac,
1022 eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS,
1023 1,
1024 peerAddr,
1025 subType, 0,psessionEntry);
1026 // Log error
1027 limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001028 FL("received Re/Assoc req when max associated STAs reached from "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001029 limPrintMacAddr(pMac, peerAddr, LOGW);
1030 limSendSmeMaxAssocExceededNtf(pMac, peerAddr, psessionEntry->smeSessionId);
1031 }
1032} /*** end limRejectAssociation() ***/
1033
Jeff Johnson295189b2012-06-20 16:38:30 -07001034
1035/** -------------------------------------------------------------
1036\fn limDecideApProtectionOnHt20Delete
1037\brief protection related function while HT20 station is getting deleted.
1038\param tpAniSirGlobal pMac
1039\param tpDphHashNode pStaDs
1040\param tpUpdateBeaconParams pBeaconParams
1041\return None
1042 -------------------------------------------------------------*/
1043static void
1044limDecideApProtectionOnHt20Delete(tpAniSirGlobal pMac,
1045 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1046{
1047 tANI_U32 i = 0;
1048 PELOG1( limLog(pMac, LOG1, FL("(%d) A HT 20 STA is disassociated. Addr is "),
1049 psessionEntry->gLimHt20Params.numSta);
1050 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1051 if (psessionEntry->gLimHt20Params.numSta > 0)
1052 {
1053 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1054 {
1055 if (psessionEntry->protStaCache[i].active)
1056 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301057 if (vos_mem_compare(psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 pStaDs->staAddr, sizeof(tSirMacAddr)))
1059 {
1060 psessionEntry->gLimHt20Params.numSta--;
1061 psessionEntry->protStaCache[i].active = false;
1062 break;
1063 }
1064 }
1065 }
1066 }
1067
1068 if (psessionEntry->gLimHt20Params.numSta == 0)
1069 {
1070 // disable protection
1071 limEnableHT20Protection(pMac, false, false, pBeaconParams,psessionEntry);
1072 }
1073}
1074/** -------------------------------------------------------------
1075\fn limDecideApProtectionOnDelete
1076\brief Decides about protection related settings when a station is getting deleted.
1077\param tpAniSirGlobal pMac
1078\param tpDphHashNode pStaDs
1079\param tpUpdateBeaconParams pBeaconParams
1080\return None
1081 -------------------------------------------------------------*/
1082void
1083limDecideApProtectionOnDelete(tpAniSirGlobal pMac,
1084 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1085{
1086 tANI_U32 phyMode;
1087 tHalBitVal erpEnabled = eHAL_CLEAR;
1088 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1089 tANI_U32 i;
1090
1091 if(NULL == pStaDs)
1092 return;
1093
1094 limGetRfBand(pMac, &rfBand, psessionEntry);
1095 if(SIR_BAND_5_GHZ == rfBand)
1096 {
1097 //we are HT. if we are 11A, then protection is not required.
Jeff Johnsone7245742012-09-05 17:12:55 -07001098 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001099 {
1100 //we are HT and 11A station is leaving.
1101 //protection consideration required.
1102 //HT station leaving ==> this case is commonly handled between both the bands below.
1103 if((psessionEntry->beaconParams.llaCoexist) &&
1104 (false == pStaDs->mlmStaContext.htCapability))
1105 {
1106 PELOG1(limLog(pMac, LOG1, FL("(%d) A 11A STA is disassociated. Addr is "),
1107 psessionEntry->gLim11aParams.numSta);
1108 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1109 if (psessionEntry->gLim11aParams.numSta > 0)
1110 {
1111 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1112 {
1113 if (psessionEntry->protStaCache[i].active)
1114 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301115 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 pStaDs->staAddr, sizeof(tSirMacAddr)))
1117 {
1118 psessionEntry->gLim11aParams.numSta--;
1119 psessionEntry->protStaCache[i].active = false;
1120 break;
1121 }
1122 }
1123 }
1124 }
1125
1126 if(psessionEntry->gLim11aParams.numSta == 0)
1127 {
1128 // disable protection
1129 limEnable11aProtection(pMac, false, false, pBeaconParams,psessionEntry);
1130 }
1131 }
1132 }
1133 }
1134 else if(SIR_BAND_2_4_GHZ == rfBand)
1135 {
1136 limGetPhyMode(pMac, &phyMode, psessionEntry);
1137
1138 erpEnabled = pStaDs->erpEnabled;
1139 //we are HT or 11G and 11B station is getting deleted.
1140 if (((phyMode == WNI_CFG_PHY_MODE_11G) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07001141 psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001142 (erpEnabled == eHAL_CLEAR))
1143 {
1144 PELOG1(limLog(pMac, LOG1, FL("(%d) A legacy STA is disassociated. Addr is "),
1145 psessionEntry->gLim11bParams.numSta);
1146 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1147 if (psessionEntry->gLim11bParams.numSta > 0)
1148 {
1149 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1150 {
1151 if (psessionEntry->protStaCache[i].active)
1152 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301153 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001154 pStaDs->staAddr, sizeof(tSirMacAddr)))
1155 {
1156 psessionEntry->gLim11bParams.numSta--;
1157 psessionEntry->protStaCache[i].active = false;
1158 break;
1159 }
1160 }
1161 }
1162 }
1163
1164 if (psessionEntry->gLim11bParams.numSta == 0)
1165 {
1166 // disable protection
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001167 PELOG1(limLog(pMac, LOG1, FL("No 11B STA exists"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 limEnable11gProtection(pMac, false, false, pBeaconParams,psessionEntry);
1169 }
1170 }
1171 //(non-11B station is leaving) or (we are not 11G or HT AP)
Jeff Johnsone7245742012-09-05 17:12:55 -07001172 else if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 { //we are HT AP and non-11B station is leaving.
1174
1175 //11g station is leaving
1176 if(!pStaDs->mlmStaContext.htCapability)
1177 {
1178 PELOG1(limLog(pMac, LOG1, FL("(%d) A 11g STA is disassociated. Addr is "),
1179 psessionEntry->gLim11bParams.numSta);
1180 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1181 if (psessionEntry->gLim11gParams.numSta > 0)
1182 {
1183 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1184 {
1185 if (psessionEntry->protStaCache[i].active)
1186 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301187 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001188 pStaDs->staAddr, sizeof(tSirMacAddr)))
1189 {
1190 psessionEntry->gLim11gParams.numSta--;
1191 psessionEntry->protStaCache[i].active = false;
1192 break;
1193 }
1194 }
1195 }
1196 }
1197
1198 if (psessionEntry->gLim11gParams.numSta == 0)
1199 {
1200 // disable protection
1201 limEnableHtProtectionFrom11g(pMac, false, false, pBeaconParams,psessionEntry);
1202 }
1203 }
1204 }
1205 }
1206
1207 //LSIG TXOP not supporting staiton leaving. applies to 2.4 as well as 5 GHZ.
Jeff Johnsone7245742012-09-05 17:12:55 -07001208 if((true == psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001209 (true == pStaDs->mlmStaContext.htCapability))
1210 {
1211 //HT non-GF leaving
1212 if(!pStaDs->htGreenfield)
1213 {
1214 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-GF STA is disassociated. Addr is "),
1215 psessionEntry->gLimNonGfParams.numSta);
1216 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1217 if (psessionEntry->gLimNonGfParams.numSta > 0)
1218 {
1219 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1220 {
1221 if (psessionEntry->protStaCache[i].active)
1222 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301223 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 pStaDs->staAddr, sizeof(tSirMacAddr)))
1225 {
1226 psessionEntry->gLimNonGfParams.numSta--;
1227 psessionEntry->protStaCache[i].active = false;
1228 break;
1229 }
1230 }
1231 }
1232 }
1233
1234 if (psessionEntry->gLimNonGfParams.numSta == 0)
1235 {
1236 // disable protection
1237 limEnableHTNonGfProtection(pMac, false, false, pBeaconParams,psessionEntry);
1238 }
1239 }
1240 //HT 20Mhz station leaving.
1241 if(psessionEntry->beaconParams.ht20Coexist &&
1242 (eHT_CHANNEL_WIDTH_20MHZ == pStaDs->htSupportedChannelWidthSet))
1243 {
1244 limDecideApProtectionOnHt20Delete(pMac, pStaDs, pBeaconParams,psessionEntry);
1245 }
1246
1247 if(false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport &&
1248 (false == pStaDs->htLsigTXOPProtection))
1249 {
1250 PELOG1( limLog(pMac, LOG1, FL("(%d) A HT LSIG not supporting STA is disassociated. Addr is "),
1251 psessionEntry->gLimLsigTxopParams.numSta);
1252 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1253 if (psessionEntry->gLimLsigTxopParams.numSta > 0)
1254 {
1255 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1256 {
1257 if (psessionEntry->protStaCache[i].active)
1258 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301259 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001260 pStaDs->staAddr, sizeof(tSirMacAddr)))
1261 {
1262 psessionEntry->gLimLsigTxopParams.numSta--;
1263 psessionEntry->protStaCache[i].active = false;
1264 break;
1265 }
1266 }
1267 }
1268 }
1269
1270 if (psessionEntry->gLimLsigTxopParams.numSta == 0)
1271 {
1272 // disable protection
1273 limEnableHTLsigTxopProtection(pMac, true, false, pBeaconParams,psessionEntry);
1274 }
1275 }
1276 }
1277}
1278
Jeff Johnson295189b2012-06-20 16:38:30 -07001279
1280
1281/** -------------------------------------------------------------
1282\fn limDecideShortPreamble
1283\brief Decides about any short preamble reated change because of new station joining.
1284\param tpAniSirGlobal pMac
1285\param tpDphHashNode pStaDs
1286\param tpUpdateBeaconParams pBeaconParams
1287\return None
1288 -------------------------------------------------------------*/
1289void limDecideShortPreamble(tpAniSirGlobal pMac,
1290 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry )
1291{
1292 tANI_U32 i;
1293
1294 if (pStaDs->shortPreambleEnabled == eHAL_CLEAR)
1295 {
1296 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-short preamble STA is disassociated. Addr is "),
1297 psessionEntry->gLimNoShortParams.numNonShortPreambleSta);
1298 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1299 if (psessionEntry->gLimNoShortParams.numNonShortPreambleSta > 0)
1300 {
1301 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1302 {
1303 if (psessionEntry->gLimNoShortParams.staNoShortCache[i].active)
1304 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301305 if (vos_mem_compare( psessionEntry->gLimNoShortParams.staNoShortCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001306 pStaDs->staAddr, sizeof(tSirMacAddr)))
1307 {
1308 psessionEntry->gLimNoShortParams.numNonShortPreambleSta--;
1309 psessionEntry->gLimNoShortParams.staNoShortCache[i].active = false;
1310 break;
1311 }
1312 }
1313 }
1314 }
1315
1316 if (psessionEntry->gLimNoShortParams.numNonShortPreambleSta == 0)
1317 {
1318 // enable short preamble
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001319 PELOG1(limLog(pMac, LOG1, FL("All associated STAs have short preamble support now."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301321 vos_mem_set((tANI_U8 *)&psessionEntry->gLimNoShortParams,
1322 sizeof(tLimNoShortParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001323 if (limEnableShortPreamble(pMac, true, pBeaconParams, psessionEntry) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001324 PELOGE(limLog(pMac, LOGE, FL("Cannot enable short preamble"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 }
1326 }
1327}
1328
1329/** -------------------------------------------------------------
1330\fn limDecideShortSlot
1331\brief Decides about any short slot time related change because of station leaving the BSS.
1332\param tpAniSirGlobal pMac
1333\param tpDphHashNode pStaDs
1334\return None
1335 -------------------------------------------------------------*/
1336
1337void
1338limDecideShortSlot(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1339 tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
1340{
1341 tANI_U32 i, val;
1342 if (pStaDs->shortSlotTimeEnabled == eHAL_CLEAR)
1343 {
1344 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-short slottime STA is disassociated. Addr is "),
1345 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta);
1346 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1347
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
1349 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta> 0)
1350 {
1351 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1352 {
1353 if (psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active)
1354 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301355 if (vos_mem_compare(psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001356 pStaDs->staAddr, sizeof(tSirMacAddr)))
1357 {
1358 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta--;
1359 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active = false;
1360 break;
1361 }
1362 }
1363 }
1364 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001365 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001366 {
1367 if (pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta> 0)
1368 {
1369 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1370 {
1371 if (pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active)
1372 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301373 if (vos_mem_compare(pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001374 pStaDs->staAddr, sizeof(tSirMacAddr)))
1375 {
1376 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta--;
1377 pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active = false;
1378 break;
1379 }
1380 }
1381 }
1382 }
1383 }
1384
1385 wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val);
1386
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
1388 (val && psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta == 0))
1389 {
1390 // enable short slot time
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001391 PELOG1(limLog(pMac, LOG1, FL("All associated STAs have short slot time support now."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301393 vos_mem_set((tANI_U8 *)&psessionEntry->gLimNoShortSlotParams,
1394 sizeof(tLimNoShortSlotParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 // in case of AP set SHORT_SLOT_TIME to enable
1396 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1397 {
1398 pBeaconParams->fShortSlotTime = true;
1399 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001400 psessionEntry->shortSlotTimeSupported = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07001401 }
1402 }
1403 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 {
1405 if (val && pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta == 0)
1406 {
1407 // enable short slot time
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001408 PELOG1(limLog(pMac, LOG1, FL("All associated STAs have short slot time support now."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001409 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301410 vos_mem_set((tANI_U8 *)&pMac->lim.gLimNoShortSlotParams,
1411 sizeof(tLimNoShortSlotParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001412 // in case of AP set SHORT_SLOT_TIME to enable
1413 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1414 {
1415 pBeaconParams->fShortSlotTime = true;
1416 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001417 psessionEntry->shortSlotTimeSupported = true;
1418 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 }
1420 }
1421 }
1422}
1423
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07001424void
1425limPostReassocFailure(tpAniSirGlobal pMac,
1426 tSirResultCodes resultCode,
1427 tANI_U16 protStatusCode,tpPESession psessionEntry)
1428{
1429 tLimMlmReassocCnf mlmReassocCnf;
1430
1431 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1432 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
1433
1434 // 'Change' timer for future activations
1435 limDeactivateAndChangeTimer(pMac, eLIM_REASSOC_FAIL_TIMER);
1436
1437 mlmReassocCnf.resultCode = resultCode;
1438 mlmReassocCnf.protStatusCode = protStatusCode;
1439 /* Update PE session Id */
1440 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1441 limPostSmeMessage(pMac,
1442 LIM_MLM_REASSOC_CNF,
1443 (tANI_U32 *) &mlmReassocCnf);
1444} /*** end limPostReassocFailure() ***/
1445
Jeff Johnson295189b2012-06-20 16:38:30 -07001446/**
1447 * limRestorePreReassocState()
1448 *
1449 *FUNCTION:
1450 * This function is called on STA role whenever Reasociation
1451 * Response with a reject code is received from AP.
1452 *
1453 *LOGIC:
1454 * Reassociation failure timer is stopped, Old (or current) AP's
1455 * context is restored both at Polaris & software
1456 *
1457 *ASSUMPTIONS:
1458 *
1459 *NOTE:
1460 *
1461 * @param pMac - Pointer to Global MAC structure
1462 * @param resultCode - Result code that specifies why Reassociation
1463 * attemp failed
1464 *
1465 * @return None
1466 */
1467
1468void
1469limRestorePreReassocState(tpAniSirGlobal pMac,
1470 tSirResultCodes resultCode,
1471 tANI_U16 protStatusCode,tpPESession psessionEntry)
1472{
Jeff Johnsone7245742012-09-05 17:12:55 -07001473 tANI_U8 chanNum, secChanOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001474 tLimMlmReassocCnf mlmReassocCnf;
1475
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001477 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07001478
1479 // 'Change' timer for future activations
1480 limDeactivateAndChangeTimer(pMac, eLIM_REASSOC_FAIL_TIMER);
1481
1482 // Update BSSID at CFG database
1483 #if 0
1484 if (cfgSetStr(pMac, WNI_CFG_BSSID,
1485 pMac->lim.gLimCurrentBssId,
1486 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
1487 {
1488 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001489 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001490 return;
1491 }
Madan Mohan Koyyalamudi70322d52012-10-18 20:07:33 -07001492 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001493
1494 // chanNum = pMac->lim.gLimCurrentChannelId;
1495
1496 /* To support BT-AMP */
1497 chanNum = psessionEntry->currentOperChannel;
Jeff Johnsone7245742012-09-05 17:12:55 -07001498 secChanOffset = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001499
Jeff Johnsone7245742012-09-05 17:12:55 -07001500 limSetChannel(pMac, chanNum, secChanOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001501
1502 /** @ToDo : Need to Integrate the STOP the DataTransfer to the AP from 11H code */
1503
1504 mlmReassocCnf.resultCode = resultCode;
1505 mlmReassocCnf.protStatusCode = protStatusCode;
1506 /* Update PE session Id */
1507 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1508 limPostSmeMessage(pMac,
1509 LIM_MLM_REASSOC_CNF,
1510 (tANI_U32 *) &mlmReassocCnf);
1511} /*** end limRestorePreReassocState() ***/
1512
1513
1514
1515/**
1516 * limIsReassocInProgress()
1517 *
1518 *FUNCTION:
1519 * This function is called to see if STA is in wt-reassoc-rsp state.
1520 *
1521 *LOGIC:
1522 *
1523 *ASSUMPTIONS:
1524 *
1525 *NOTE:
1526 *
1527 * @param pMac - Pointer to Global MAC structure
1528 *
1529 * @return eANI_BOOLEAN_TRUE When STA is waiting for Reassoc response from AP \n
1530 * else eANI_BOOLEAN_FALSE
1531 */
1532
1533eAniBoolean
1534limIsReassocInProgress(tpAniSirGlobal pMac,tpPESession psessionEntry)
1535{
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001536 if (psessionEntry == NULL)
1537 {
1538 return eANI_BOOLEAN_FALSE;
1539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001540 if(((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
1541 ((psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE) ||
1542 (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_LINK_FAIL_STATE)))
1543 return eANI_BOOLEAN_TRUE;
1544
1545 return eANI_BOOLEAN_FALSE;
1546} /*** end limIsReassocInProgress() ***/
1547
Jeff Johnsone7245742012-09-05 17:12:55 -07001548#ifdef WLAN_FEATURE_11AC
1549tSirRetStatus limPopulateVhtMcsSet(tpAniSirGlobal pMac,
1550 tpSirSupportedRates pRates,
1551 tDot11fIEVHTCaps *pPeerVHTCaps,
1552 tpPESession psessionEntry)
1553{
1554 tANI_U32 val;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001555 tANI_U32 selfStaDot11Mode=0;
1556 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001557
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001558// if(IS_DOT11_MODE_VHT(psessionEntry->dot11mode))
1559 if (IS_DOT11_MODE_VHT(selfStaDot11Mode))
Jeff Johnsone7245742012-09-05 17:12:55 -07001560 {
1561 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_RX_MCS_MAP,&val) !=
1562 eSIR_SUCCESS )
1563 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001564 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX MCS MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001565 goto error;
1566 }
1567 pRates->vhtRxMCSMap = (tANI_U16)val;
1568
1569 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_TX_MCS_MAP,&val ) !=
1570 eSIR_SUCCESS )
1571 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001572 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT TX MCS MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001573 goto error;
1574 }
1575 pRates->vhtTxMCSMap = (tANI_U16)val;
1576
1577 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE,&val ) !=
1578 eSIR_SUCCESS )
1579 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001580 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX Supported data rate MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001581 goto error;
1582 }
1583 pRates->vhtRxHighestDataRate = (tANI_U16)val;
1584
1585 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE,&val ) !=
1586 eSIR_SUCCESS )
1587 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001588 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX Supported data rate MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001589 goto error;
1590 }
1591 pRates->vhtTxHighestDataRate = (tANI_U16)val;
1592
1593 if( pPeerVHTCaps != NULL)
1594 {
1595 pRates->vhtTxHighestDataRate = SIR_MIN(pRates->vhtTxHighestDataRate, pPeerVHTCaps->txSupDataRate);
1596 pRates->vhtRxHighestDataRate = SIR_MIN(pRates->vhtRxHighestDataRate, pPeerVHTCaps->rxHighSupDataRate);
1597
Jeff Johnson1250df42012-12-10 14:31:52 -08001598 // Acquire PEER MCS map if we exceed.
Jeff Johnsone7245742012-09-05 17:12:55 -07001599 // We compare/update only the last 2 bits of the map as we support only single BSS.
1600 // Firmware takes care of this comparison
1601 pRates->vhtRxMCSMap &= ~(0x3); // Clearing the last 2 bits in the bitmap
1602 pRates->vhtRxMCSMap |= (pPeerVHTCaps->rxMCSMap & 0x3); // Updating the last 2 bits in the bitmap
1603
1604 // Firmware takes care of this comparison
1605 pRates->vhtTxMCSMap &= ~(0x3); // Clearing the last 2 bits in the bitmap
1606 pRates->vhtTxMCSMap |= (pPeerVHTCaps->txMCSMap & 0x3); // Updating the last 2 bits in the bitmap
1607 }
1608 }
1609 return eSIR_SUCCESS;
1610error:
1611
1612 return eSIR_FAILURE;
1613
1614}
1615#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001616
1617/**
1618 * limPopulateOwnRateSet
1619 *
1620 * FUNCTION:
1621 * This function is called by limProcessAssocRsp() or
1622 * limAddStaInIBSS()
1623 * - It creates a combined rate set of 12 rates max which
1624 * comprises the basic and extended rates read from CFG
1625 * - It sorts the combined rate Set and copy it in the
1626 * rate array of the pSTA descriptor
1627 * - It sets the erpEnabled bit of the STA descriptor
1628 *
1629 * NOTE:
1630 * ERP bit is set iff the dph PHY mode is 11G and there is at least
1631 * an A rate in the supported or extended rate sets
1632 *
1633 * @param pMac - Pointer to Global MAC structure
1634 * @param basicOnly - When passed value is true, only basic
1635 * rates are copied to DPH node else
1636 * all supported rates are copied
1637 * @return eSIR_SUCCESS or eSIR_FAILURE
1638 *
1639 */
Jeff Johnsone7245742012-09-05 17:12:55 -07001640#ifdef WLAN_FEATURE_11AC
1641tSirRetStatus
1642limPopulateOwnRateSet(tpAniSirGlobal pMac,
1643 tpSirSupportedRates pRates,
1644 tANI_U8* pSupportedMCSSet,
1645 tANI_U8 basicOnly,
1646 tpPESession psessionEntry,
1647 tDot11fIEVHTCaps *pVHTCaps)
1648#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001649tSirRetStatus
1650limPopulateOwnRateSet(tpAniSirGlobal pMac,
1651 tpSirSupportedRates pRates,
1652 tANI_U8* pSupportedMCSSet,
1653 tANI_U8 basicOnly,
1654 tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07001655#endif
1656
Jeff Johnson295189b2012-06-20 16:38:30 -07001657{
1658 tSirMacRateSet tempRateSet;
1659 tSirMacRateSet tempRateSet2;
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301660 tANI_U32 i,j,val,min,isArate;
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 tANI_U32 phyMode = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001662 tANI_U32 selfStaDot11Mode=0;
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301663
Jeff Johnson295189b2012-06-20 16:38:30 -07001664 isArate = 0;
1665
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001666 wlan_cfgGetInt(pMac, WNI_CFG_DOT11_MODE, &selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001667 limGetPhyMode(pMac, &phyMode, psessionEntry);
1668
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301669 /* Include 11b rates only when the device configured in
1670 auto, 11a/b/g or 11b_only */
1671 if ( (selfStaDot11Mode == WNI_CFG_DOT11_MODE_ALL) ||
1672 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11A) ||
1673 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11AC) ||
Leela Venkata Kiran Kumar Reddy Chiralac9a10e52013-08-29 16:37:15 -07001674 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11N) ||
1675 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11G) ||
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301676 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11B) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001677 {
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301678 val = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1679 wlan_cfgGetStr( pMac, WNI_CFG_SUPPORTED_RATES_11B,
1680 (tANI_U8 *)&tempRateSet.rate, &val );
1681 tempRateSet.numRates = (tANI_U8) val;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001682 }
1683 else
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301684 tempRateSet.numRates = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001685
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301686 /* Include 11a rates when the device configured in non-11b mode */
1687 if (!IS_DOT11_MODE_11B(selfStaDot11Mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 {
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301689 val = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1690 wlan_cfgGetStr( pMac, WNI_CFG_SUPPORTED_RATES_11A,
1691 (tANI_U8 *)&tempRateSet2.rate, &val );
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 tempRateSet2.numRates = (tANI_U8) val;
Jeff Johnson295189b2012-06-20 16:38:30 -07001693 }
1694 else
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301695 tempRateSet2.numRates = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001696
1697 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
1698 {
1699 //we are in big trouble
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001700 limLog(pMac, LOGP, FL("more than 12 rates in CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 //panic
1702 goto error;
1703 }
1704
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 //copy all rates in tempRateSet, there are 12 rates max
1706 for (i = 0;i < tempRateSet2.numRates; i++)
1707 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
1708 tempRateSet.numRates += tempRateSet2.numRates;
1709
1710 /**
1711 * Sort rates in tempRateSet (they are likely to be already sorted)
1712 * put the result in pSupportedRates
1713 */
1714 {
1715 tANI_U8 aRateIndex = 0;
1716 tANI_U8 bRateIndex = 0;
1717
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301718 vos_mem_set((tANI_U8 *) pRates, sizeof(tSirSupportedRates), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 for(i = 0;i < tempRateSet.numRates; i++)
1720 {
1721 min = 0;
1722 val = 0xff;
1723 isArate = 0;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001724 for(j = 0; (j < tempRateSet.numRates) && (j < SIR_MAC_RATESET_EID_MAX); j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 {
1726 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
1727 {
1728 val = tempRateSet.rate[j] & 0x7f;
1729 min = j;
1730 }
1731 }
1732
1733 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1734 isArate = 1;
1735
1736 /*
1737 * HAL needs to know whether the rate is basic rate or not, as it needs to
1738 * update the response rate table accordingly. e.g. if one of the 11a rates is
1739 * basic rate, then that rate can be used for sending control frames.
1740 * HAL updates the response rate table whenever basic rate set is changed.
1741 */
1742 if (basicOnly)
1743 {
1744 if (tempRateSet.rate[min] & 0x80)
1745 {
1746 if (isArate)
1747 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1748 else
1749 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1750 }
1751 }
1752 else
1753 {
1754 if (isArate)
1755 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1756 else
1757 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1758 }
1759 tempRateSet.rate[min] = 0xff;
1760 }
1761
1762 }
1763
1764
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001765 //if(IS_DOT11_MODE_HT(psessionEntry->dot11mode))
1766 if (IS_DOT11_MODE_HT(selfStaDot11Mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 {
1768 val = SIZE_OF_SUPPORTED_MCS_SET;
1769 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
1770 pRates->supportedMCSSet,
1771 &val) != eSIR_SUCCESS)
1772 {
1773 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001774 PELOGE(limLog(pMac, LOGE, FL("could not retrieve supportedMCSSet"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001775 goto error;
1776 }
1777
1778
1779 //if supported MCS Set of the peer is passed in, then do the intersection
1780 //else use the MCS set from local CFG.
1781
1782 if(pSupportedMCSSet != NULL)
1783 {
1784 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1785 pRates->supportedMCSSet[i] &= pSupportedMCSSet[i];
1786
1787 }
1788
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001789 PELOG2(limLog(pMac, LOG2, FL("MCS Rate Set Bitmap: "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1791 PELOGW(limLog(pMac, LOG2,FL("%x ") , pRates->supportedMCSSet[i]);)
1792 }
1793
Jeff Johnsone7245742012-09-05 17:12:55 -07001794#ifdef WLAN_FEATURE_11AC
1795 limPopulateVhtMcsSet(pMac, pRates , pVHTCaps,psessionEntry);
1796#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001797
1798 return eSIR_SUCCESS;
1799
1800 error:
1801
1802 return eSIR_FAILURE;
1803} /*** limPopulateOwnRateSet() ***/
1804
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001805#ifdef WLAN_FEATURE_11AC
1806tSirRetStatus
1807limPopulatePeerRateSet(tpAniSirGlobal pMac,
1808
1809 tpSirSupportedRates pRates,
1810 tANI_U8* pSupportedMCSSet,
1811 tANI_U8 basicOnly,
1812 tpPESession psessionEntry,
1813 tDot11fIEVHTCaps *pVHTCaps)
1814#else
1815tSirRetStatus
1816limPopulatePeerRateSet(tpAniSirGlobal pMac,
1817 tpSirSupportedRates pRates,
1818 tANI_U8* pSupportedMCSSet,
1819 tANI_U8 basicOnly,
1820 tpPESession psessionEntry)
1821#endif
1822{
1823 tSirMacRateSet tempRateSet;
1824 tSirMacRateSet tempRateSet2;
1825 tANI_U32 i,j,val,min,isArate;
1826 isArate = 0;
1827
1828 /* copy operational rate set from psessionEntry */
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001829 if ( psessionEntry->rateSet.numRates <= SIR_MAC_RATESET_EID_MAX )
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001830 {
1831 palCopyMemory(pMac->hHdd,(tANI_U8 *)tempRateSet.rate,(tANI_U8*)(psessionEntry->rateSet.rate), psessionEntry->rateSet.numRates);
1832 tempRateSet.numRates = psessionEntry->rateSet.numRates;
1833 }
1834 else
1835 {
1836 limLog(pMac, LOGE, FL("more than SIR_MAC_RATESET_EID_MAX rates\n"));
1837 goto error;
1838 }
Madan Mohan Koyyalamudi28321f82013-09-25 18:45:26 -07001839 if (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11G)
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001840 {
1841
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001842 if (psessionEntry->extRateSet.numRates <= SIR_MAC_RATESET_EID_MAX)
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001843 {
1844 palCopyMemory(pMac->hHdd,(tANI_U8 *)tempRateSet2.rate, (tANI_U8*)(psessionEntry->extRateSet.rate), psessionEntry->extRateSet.numRates);
1845 tempRateSet2.numRates = psessionEntry->extRateSet.numRates;
1846 }
1847 else {
1848 limLog(pMac, LOGE, FL("psessionEntry->extRateSet.numRates more than SIR_MAC_RATESET_EID_MAX rates\n"));
1849 goto error;
1850 }
1851 }
1852 else
1853 tempRateSet2.numRates = 0;
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001854 if ((tempRateSet.numRates + tempRateSet2.numRates) > SIR_MAC_RATESET_EID_MAX)
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001855 {
1856 //we are in big trouble
1857 limLog(pMac, LOGP, FL("more than 12 rates in CFG"));
1858 goto error;
1859 }
1860
1861
1862 //copy all rates in tempRateSet, there are 12 rates max
1863 for (i = 0;i < tempRateSet2.numRates; i++)
1864 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
1865 tempRateSet.numRates += tempRateSet2.numRates;
1866 /**
1867 * Sort rates in tempRateSet (they are likely to be already sorted)
1868 * put the result in pSupportedRates
1869 */
1870 {
1871 tANI_U8 aRateIndex = 0;
1872 tANI_U8 bRateIndex = 0;
1873 palZeroMemory( pMac->hHdd, (tANI_U8 *) pRates, sizeof(tSirSupportedRates));
1874 for(i = 0;i < tempRateSet.numRates; i++)
1875 {
1876 min = 0;
1877 val = 0xff;
1878 isArate = 0;
1879 for(j = 0; (j < tempRateSet.numRates) && (j < SIR_MAC_RATESET_EID_MAX); j++)
1880 {
1881 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
1882 {
1883 val = tempRateSet.rate[j] & 0x7f;
1884 min = j;
1885 }
1886 }
1887 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1888 isArate = 1;
1889 /*
1890 * HAL needs to know whether the rate is basic rate or not, as it needs to
1891 * update the response rate table accordingly. e.g. if one of the 11a rates is
1892 * basic rate, then that rate can be used for sending control frames.
1893 * HAL updates the response rate table whenever basic rate set is changed.
1894 */
1895 if (basicOnly)
1896 {
1897 if (tempRateSet.rate[min] & 0x80)
1898 {
1899 if (isArate)
1900 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1901 else
1902 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1903 }
1904 }
1905 else
1906 {
1907 if (isArate)
1908 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1909 else
1910 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1911 }
1912 tempRateSet.rate[min] = 0xff;
1913 }
1914 }
1915
1916
1917 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode))
1918 {
1919 val = SIZE_OF_SUPPORTED_MCS_SET;
1920 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
1921 pRates->supportedMCSSet,
1922 &val) != eSIR_SUCCESS)
1923 {
1924 /// Could not get rateset from CFG. Log error.
1925 PELOGE(limLog(pMac, LOGE, FL("could not retrieve supportedMCSSet"));)
1926 goto error;
1927 }
1928 //if supported MCS Set of the peer is passed in, then do the intersection
1929 //else use the MCS set from local CFG.
1930 if(pSupportedMCSSet != NULL)
1931 {
1932 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1933 pRates->supportedMCSSet[i] &= pSupportedMCSSet[i];
1934 }
1935 PELOG2(limLog(pMac, LOG2, FL("MCS Rate Set Bitmap: "));)
1936 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1937 PELOGW(limLog(pMac, LOG2,FL("%x ") , pRates->supportedMCSSet[i]);)
1938 }
1939#ifdef WLAN_FEATURE_11AC
1940 limPopulateVhtMcsSet(pMac, pRates , pVHTCaps,psessionEntry);
1941#endif
1942 return eSIR_SUCCESS;
1943 error:
1944 return eSIR_FAILURE;
1945} /*** limPopulatePeerRateSet() ***/
1946
Jeff Johnson295189b2012-06-20 16:38:30 -07001947/**
1948 * limPopulateMatchingRateSet
1949 * FUNCTION:
1950 * This is called at the time of Association Request
1951 * processing on AP and while adding peer's context
1952 * in IBSS role to process the CFG rate sets and
1953 * the rate sets received in the Assoc request on AP
1954 * or Beacon/Probe Response from peer in IBSS.
1955 *
1956 * LOGIC:
1957 * 1. It makes the intersection between our own rate Sat
1958 * and extemcded rate set and the ones received in the
1959 * association request.
1960 * 2. It creates a combined rate set of 12 rates max which
1961 * comprised the basic and extended rates
1962 * 3. It sorts the combined rate Set and copy it in the
1963 * rate array of the pSTA descriptor
1964 *
1965 * ASSUMPTION:
1966 * The parser has already ensured unicity of the rates in the
1967 * association request structure
1968 *
1969 * @param: pMac - Pointer to Global MAC structure
1970 * pStaDs - Pointer to DPH node
1971 * pOperRateSet - Pointer to peer's supported rateset
1972 * pExtRateSet - Pointer to peer's extended rateset
1973 *
1974 * @return: eSIR_SUCCESS or eSIR_FAILURE
1975 */
Jeff Johnsone7245742012-09-05 17:12:55 -07001976#ifdef WLAN_FEATURE_11AC
1977tSirRetStatus
1978limPopulateMatchingRateSet(tpAniSirGlobal pMac,
1979 tpDphHashNode pStaDs,
1980 tSirMacRateSet *pOperRateSet,
1981 tSirMacRateSet *pExtRateSet,
1982 tANI_U8* pSupportedMCSSet,
1983 tSirMacPropRateSet *pAniLegRateSet,
1984 tpPESession psessionEntry,
1985 tDot11fIEVHTCaps *pVHTCaps)
Jeff Johnson295189b2012-06-20 16:38:30 -07001986
Jeff Johnsone7245742012-09-05 17:12:55 -07001987#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001988tSirRetStatus
1989limPopulateMatchingRateSet(tpAniSirGlobal pMac,
1990 tpDphHashNode pStaDs,
1991 tSirMacRateSet *pOperRateSet,
1992 tSirMacRateSet *pExtRateSet,
1993 tANI_U8* pSupportedMCSSet,
1994 tSirMacPropRateSet *pAniLegRateSet,
1995 tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07001996#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001997{
1998 tSirMacRateSet tempRateSet;
1999 tSirMacRateSet tempRateSet2;
2000 tANI_U32 i,j,val,min,isArate;
2001 tANI_U32 phyMode;
2002 tANI_U8 mcsSet[SIZE_OF_SUPPORTED_MCS_SET];
2003
2004 isArate=0;
2005
2006 // limGetPhyMode(pMac, &phyMode);
2007 limGetPhyMode(pMac, &phyMode, psessionEntry);
2008
2009 // get own rate set
2010 // val = WNI_CFG_OPERATIONAL_RATE_SET_LEN;
2011 #if 0
2012 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
2013 (tANI_U8 *) &tempRateSet.rate,
2014 &val) != eSIR_SUCCESS)
2015 {
2016 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002017 limLog(pMac, LOGP, FL("could not retrieve rateset"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002018 }
2019
2020 #endif // TO SUPPORT BT-AMP
2021
2022 /* copy operational rate set from psessionEntry */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302023 vos_mem_copy((tempRateSet.rate), (psessionEntry->rateSet.rate),
2024 psessionEntry->rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07002025 tempRateSet.numRates = (tANI_U8) psessionEntry->rateSet.numRates;
2026
2027 if (phyMode == WNI_CFG_PHY_MODE_11G)
2028 {
2029
2030 #if 0
2031 // get own extended rate set
2032 val = WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN;
2033 if (wlan_cfgGetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
2034 (tANI_U8 *) &tempRateSet2.rate,
2035 &val) != eSIR_SUCCESS)
2036 #endif
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302037 vos_mem_copy((tempRateSet2.rate), (psessionEntry->extRateSet.rate),
2038 psessionEntry->extRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07002039 tempRateSet2.numRates = (tANI_U8) psessionEntry->extRateSet.numRates;
2040 }
2041 else
2042 tempRateSet2.numRates = 0;
2043
2044 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
2045 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002046 PELOGE(limLog(pMac, LOGE, FL("more than 12 rates in CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002047 goto error;
2048 }
2049
2050 /**
2051 * Handling of the rate set IEs is the following:
2052 * - keep only rates that we support and that the station supports
2053 * - sort and the rates into the pSta->rate array
2054 */
2055
2056 // Copy all rates in tempRateSet, there are 12 rates max
2057 for(i = 0; i < tempRateSet2.numRates; i++)
2058 tempRateSet.rate[i + tempRateSet.numRates] =
2059 tempRateSet2.rate[i];
2060
2061 tempRateSet.numRates += tempRateSet2.numRates;
2062
2063 /**
2064 * Sort rates in tempRateSet (they are likely to be already sorted)
2065 * put the result in tempRateSet2
2066 */
2067 tempRateSet2.numRates = 0;
2068
2069 for(i = 0;i < tempRateSet.numRates; i++)
2070 {
2071 min = 0;
2072 val = 0xff;
2073
2074 for(j = 0;j < tempRateSet.numRates; j++)
2075 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
2076 {
2077 val = tempRateSet.rate[j] & 0x7f;
2078 min = j;
2079 }
2080
2081 tempRateSet2.rate[tempRateSet2.numRates++] =
2082 tempRateSet.rate[min];
2083 tempRateSet.rate[min] = 0xff;
2084 }
2085
2086
2087 /**
2088 * Copy received rates in tempRateSet, the parser has ensured
2089 * unicity of the rates so there cannot be more than 12
2090 */
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002091 for(i = 0; (i < pOperRateSet->numRates && i < SIR_MAC_RATESET_EID_MAX) ; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 {
2093 tempRateSet.rate[i] = pOperRateSet->rate[i];
2094 }
2095
2096 tempRateSet.numRates = pOperRateSet->numRates;
2097
2098 if (pExtRateSet->numRates)
2099 {
2100 if((tempRateSet.numRates + pExtRateSet->numRates) > 12 )
2101 {
2102 limLog( pMac, LOG2,
2103 "Sum of SUPPORTED and EXTENDED Rate Set (%1d) exceeds 12!",
2104 tempRateSet.numRates + pExtRateSet->numRates );
2105
2106 if( tempRateSet.numRates < 12 )
2107 {
2108 int found = 0;
2109 int tail = tempRateSet.numRates;
2110
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002111 for( i = 0; (i < pExtRateSet->numRates && i < SIR_MAC_RATESET_EID_MAX); i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 {
2113 found = 0;
2114 for( j = 0; j < (tANI_U32) tail; j++ )
2115 {
2116 if((tempRateSet.rate[j] & 0x7F) ==
2117 (pExtRateSet->rate[i] & 0x7F))
2118 {
2119 found = 1;
2120 break;
2121 }
2122 }
2123
2124 if( !found )
2125 {
2126 tempRateSet.rate[tempRateSet.numRates++] =
2127 pExtRateSet->rate[i];
2128
2129 if( tempRateSet.numRates >= 12 )
2130 break;
2131 }
2132 }
2133 }
2134 else
2135 limLog( pMac, LOG2,
2136 "Relying only on the SUPPORTED Rate Set IE..." );
2137 }
2138 else
2139 {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002140 for(j = 0; ((j < pExtRateSet->numRates) && (j < SIR_MAC_RATESET_EID_MAX) && ((i+j) < SIR_MAC_RATESET_EID_MAX)); j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 tempRateSet.rate[i+j] = pExtRateSet->rate[j];
2142
2143 tempRateSet.numRates += pExtRateSet->numRates;
2144 }
2145 }
2146
2147 {
2148 tpSirSupportedRates rates = &pStaDs->supportedRates;
2149 tANI_U8 aRateIndex = 0;
2150 tANI_U8 bRateIndex = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302151 vos_mem_set((tANI_U8 *) rates, sizeof(tSirSupportedRates), 0);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002152 for(i = 0;(i < tempRateSet2.numRates && i < SIR_MAC_RATESET_EID_MAX ); i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002153 {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002154 for(j = 0;(j < tempRateSet.numRates && j < SIR_MAC_RATESET_EID_MAX); j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002155 {
2156 if ((tempRateSet2.rate[i] & 0x7F) ==
2157 (tempRateSet.rate[j] & 0x7F))
2158 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 if (sirIsArate(tempRateSet2.rate[i] & 0x7f))
2160 {
2161 isArate=1;
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -07002162 if (aRateIndex < SIR_NUM_11A_RATES)
2163 rates->llaRates[aRateIndex++] = tempRateSet2.rate[i];
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 }
2165 else
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -07002166 {
2167 if (bRateIndex < SIR_NUM_11B_RATES)
2168 rates->llbRates[bRateIndex++] = tempRateSet2.rate[i];
2169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 break;
2171 }
2172 }
2173 }
2174
2175
2176 //Now add the Polaris rates only when Proprietary rates are enabled.
2177 val = 0;
2178 if(wlan_cfgGetInt(pMac, WNI_CFG_PROPRIETARY_RATES_ENABLED, &val) != eSIR_SUCCESS)
2179 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002180 limLog(pMac, LOGP, FL("could not retrieve prop rate enabled flag from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002181 }
2182 else if(val)
2183 {
2184 for(i=0; i<pAniLegRateSet->numPropRates; i++)
2185 rates->aniLegacyRates[i] = pAniLegRateSet->propRate[i];
2186 }
2187
2188 }
2189
2190
2191 //compute the matching MCS rate set, if peer is 11n capable and self mode is 11n
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002192#ifdef FEATURE_WLAN_TDLS
2193 if(pStaDs->mlmStaContext.htCapability)
2194#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode) &&
2196 (pStaDs->mlmStaContext.htCapability))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002197#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 {
2199 val = SIZE_OF_SUPPORTED_MCS_SET;
2200 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2201 mcsSet,
2202 &val) != eSIR_SUCCESS)
2203 {
2204 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002205 limLog(pMac, LOGP, FL("could not retrieve supportedMCSSet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 goto error;
2207 }
2208
2209 for(i=0; i<val; i++)
2210 pStaDs->supportedRates.supportedMCSSet[i] = mcsSet[i] & pSupportedMCSSet[i];
2211
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002212 PELOG2(limLog(pMac, LOG2, FL("limPopulateMatchingRateSet: MCS Rate Set Bitmap from CFG and DPH : "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2214 {
2215 PELOG2(limLog(pMac, LOG2,FL("%x %x "), mcsSet[i], pStaDs->supportedRates.supportedMCSSet[i]);)
2216 }
2217 }
2218
Jeff Johnsone7245742012-09-05 17:12:55 -07002219#ifdef WLAN_FEATURE_11AC
2220 limPopulateVhtMcsSet(pMac, &pStaDs->supportedRates, pVHTCaps, psessionEntry);
2221#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002222 /**
2223 * Set the erpEnabled bit iff the phy is in G mode and at least
2224 * one A rate is supported
2225 */
2226 if ((phyMode == WNI_CFG_PHY_MODE_11G) && isArate)
2227 pStaDs->erpEnabled = eHAL_SET;
2228
2229
2230
2231 return eSIR_SUCCESS;
2232
2233 error:
2234
2235 return eSIR_FAILURE;
2236} /*** limPopulateMatchingRateSet() ***/
2237
2238
2239
2240/**
2241 * limAddSta()
2242 *
2243 *FUNCTION:
2244 * This function is called to add an STA context at hardware
2245 * whenever a STA is (Re) Associated.
2246 *
2247 *LOGIC:
2248 *
2249 *ASSUMPTIONS:
2250 * NA
2251 *
2252 *NOTE:
2253 * NA
2254 *
2255 * @param pMac - Pointer to Global MAC structure
2256 * @param pStaDs - Pointer to the STA datastructure created by
2257 * LIM and maintained by DPH
2258 * @return retCode - Indicates success or failure return code
2259 */
2260
2261tSirRetStatus
2262limAddSta(
2263 tpAniSirGlobal pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002264 tpDphHashNode pStaDs, tANI_U8 updateEntry, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07002265{
2266 tpAddStaParams pAddStaParams = NULL;
2267 tSirMsgQ msgQ;
2268 tSirRetStatus retCode = eSIR_SUCCESS;
2269 tSirMacAddr staMac, *pStaAddr;
2270 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07002271 tpSirAssocReq pAssocReq;
2272 tANI_U8 *p2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 #if 0
2274 retCode = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, staMac, &cfg);
2275 if (retCode != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002276 limLog(pMac, LOGP, FL("could not retrieve STA MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002277 #endif //To SUPPORT BT-AMP
2278
2279
2280 sirCopyMacAddr(staMac,psessionEntry->selfMacAddr);
2281
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302282 pAddStaParams = vos_mem_malloc(sizeof(tAddStaParams));
2283 if (NULL == pAddStaParams)
2284 {
2285 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
2286 return eSIR_MEM_ALLOC_FAILED;
2287 }
2288 vos_mem_set((tANI_U8 *) pAddStaParams, sizeof(tAddStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002289
2290 if ((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) ||
2291 (limGetSystemRole(psessionEntry) == eLIM_STA_IN_IBSS_ROLE) ||
2292 (limGetSystemRole(psessionEntry) == eLIM_BT_AMP_AP_ROLE) )
2293 pStaAddr = &pStaDs->staAddr;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002294#ifdef FEATURE_WLAN_TDLS
2295 /* SystemRole shouldn't be matter if staType is TDLS peer */
2296 else if(STA_ENTRY_TDLS_PEER == pStaDs->staType)
2297 {
2298 pStaAddr = &pStaDs->staAddr ;
2299 }
2300#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002301 else
2302 pStaAddr = &staMac;
2303
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302304 vos_mem_copy((tANI_U8 *) pAddStaParams->staMac,
2305 (tANI_U8 *) *pStaAddr, sizeof(tSirMacAddr));
2306 vos_mem_copy((tANI_U8 *) pAddStaParams->bssId,
2307 psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002308
2309 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
2310
2311 //Copy legacy rates
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302312 vos_mem_copy ((tANI_U8*)&pAddStaParams->supportedRates,
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 (tANI_U8*)&pStaDs->supportedRates, sizeof(tSirSupportedRates));
2314
2315 pAddStaParams->assocId = pStaDs->assocId;
2316
2317 pAddStaParams->wmmEnabled = pStaDs->qosMode;
2318 pAddStaParams->listenInterval = pStaDs->mlmStaContext.listenInterval;
2319 pAddStaParams->shortPreambleSupported = pStaDs->shortPreambleEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 if((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) && (pStaDs->mlmStaContext.subType == LIM_REASSOC))
2321 {
2322 /* TBD - need to remove this REASSOC check after fixinf rmmod issue */
2323 pAddStaParams->updateSta = pStaDs->mlmStaContext.updateContext;
2324 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 pStaDs->valid = 0;
2326 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2327
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002328 // This will indicate HAL to "allocate" a new STA index
2329#ifdef FEATURE_WLAN_TDLS
2330 /* As there is corner case in-between add_sta and change_sta,if del_sta for other staIdx happened,
2331 * firmware return wrong staIdx (recently removed staIdx). Until we get a confirmation from the
2332 * firmware team it is now return correct staIdx for same sta_mac_addr for update case, we want
2333 * to get around it by passing valid staIdx given by add_sta time.
2334 */
2335 if((STA_ENTRY_TDLS_PEER == pStaDs->staType) &&
2336 (true == updateEntry))
2337 pAddStaParams->staIdx = pStaDs->staIndex;
2338 else
2339#endif
2340 pAddStaParams->staIdx = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 pAddStaParams->staType = pStaDs->staType;
2342
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002343 pAddStaParams->updateSta = updateEntry;
2344
Jeff Johnson295189b2012-06-20 16:38:30 -07002345 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2346 pAddStaParams->respReqd = 1;
2347 //Update HT Capability
2348
2349 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 -07002350 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 pAddStaParams->htCapable = pStaDs->mlmStaContext.htCapability;
Jeff Johnsone7245742012-09-05 17:12:55 -07002352#ifdef WLAN_FEATURE_11AC
2353 pAddStaParams->vhtCapable = pStaDs->mlmStaContext.vhtCapability;
2354#endif
2355 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002356#ifdef FEATURE_WLAN_TDLS
2357 /* SystemRole shouldn't be matter if staType is TDLS peer */
2358 else if(STA_ENTRY_TDLS_PEER == pStaDs->staType)
Hoonki Lee99e53782013-02-12 18:07:03 -08002359 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002360 pAddStaParams->htCapable = pStaDs->mlmStaContext.htCapability;
Hoonki Lee99e53782013-02-12 18:07:03 -08002361#ifdef WLAN_FEATURE_11AC
2362 pAddStaParams->vhtCapable = pStaDs->mlmStaContext.vhtCapability;
2363#endif
2364 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002365#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002366 else
Jeff Johnsone7245742012-09-05 17:12:55 -07002367 {
2368 pAddStaParams->htCapable = psessionEntry->htCapability;
2369#ifdef WLAN_FEATURE_11AC
2370 pAddStaParams->vhtCapable = psessionEntry->vhtCapability;
2371#endif
2372
2373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002374
2375 pAddStaParams->greenFieldCapable = pStaDs->htGreenfield;
2376 pAddStaParams->maxAmpduDensity= pStaDs->htAMpduDensity;
2377 pAddStaParams->maxAmpduSize = pStaDs->htMaxRxAMpduFactor;
2378 pAddStaParams->fDsssCckMode40Mhz = pStaDs->htDsssCckRate40MHzSupport;
2379 pAddStaParams->fShortGI20Mhz = pStaDs->htShortGI20Mhz;
2380 pAddStaParams->fShortGI40Mhz = pStaDs->htShortGI40Mhz;
2381 pAddStaParams->lsigTxopProtection = pStaDs->htLsigTXOPProtection;
2382 pAddStaParams->maxAmsduSize = pStaDs->htMaxAmsduLength;
2383 pAddStaParams->txChannelWidthSet = pStaDs->htSupportedChannelWidthSet;
2384 pAddStaParams->mimoPS = pStaDs->htMIMOPSState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002385
2386#ifdef WLAN_FEATURE_11AC
2387 if(pAddStaParams->vhtCapable)
2388 {
Mohit Khanna7d5aeb22012-09-11 16:21:57 -07002389 pAddStaParams->vhtTxChannelWidthSet = pStaDs->vhtSupportedChannelWidthSet;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002390 pAddStaParams->vhtTxBFCapable =
Hoonki Lee99e53782013-02-12 18:07:03 -08002391#ifdef FEATURE_WLAN_TDLS
2392 (( STA_ENTRY_PEER == pStaDs->staType ) || (STA_ENTRY_TDLS_PEER == pStaDs->staType)) ?
2393 pStaDs->vhtBeamFormerCapable : psessionEntry->txBFIniFeatureEnabled ;
2394#else
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002395 ( STA_ENTRY_PEER == pStaDs->staType ) ? pStaDs->vhtBeamFormerCapable :
2396 psessionEntry->txBFIniFeatureEnabled ;
Hoonki Lee99e53782013-02-12 18:07:03 -08002397#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002398 }
2399#endif
2400
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002401#ifdef FEATURE_WLAN_TDLS
2402 if((STA_ENTRY_PEER == pStaDs->staType) ||
2403 (STA_ENTRY_TDLS_PEER == pStaDs->staType))
2404#else
2405 if (STA_ENTRY_PEER == pStaDs->staType)
2406#endif
2407 {
2408 /* peer STA get the LDPC capability from pStaDs, which populated from
2409 * HT/VHT capability*/
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08002410 if(pAddStaParams->vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP)
2411 {
2412 pAddStaParams->htLdpcCapable = 0;
2413 pAddStaParams->vhtLdpcCapable = 0;
2414 }
2415 else
2416 {
2417 pAddStaParams->htLdpcCapable = pStaDs->htLdpcCapable;
2418 pAddStaParams->vhtLdpcCapable = pStaDs->vhtLdpcCapable;
2419 }
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002420 }
2421 else if( STA_ENTRY_SELF == pStaDs->staType)
2422 {
2423 /* For Self STA get the LDPC capability from config.ini*/
2424 pAddStaParams->htLdpcCapable =
2425 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
2426 pAddStaParams->vhtLdpcCapable =
2427 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
2428 }
2429
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 /* Update PE session ID*/
2431 pAddStaParams->sessionId = psessionEntry->peSessionId;
2432
2433 if (psessionEntry->parsedAssocReq != NULL)
2434 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 // Get a copy of the already parsed Assoc Request
2436 pAssocReq = (tpSirAssocReq) psessionEntry->parsedAssocReq[pStaDs->assocId];
2437 if ( pAssocReq && pAssocReq->addIEPresent && pAssocReq->addIE.length ) {
2438 p2pIe = limGetP2pIEPtr(pMac, pAssocReq->addIE.addIEdata, pAssocReq->addIE.length);
2439 }
2440 pAddStaParams->p2pCapableSta = (p2pIe != NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 }
2442
2443 //Disable BA. It will be set as part of ADDBA negotiation.
2444 for( i = 0; i < STACFG_MAX_TC; i++ )
2445 {
2446 pAddStaParams->staTCParams[i].txUseBA = eBA_DISABLE;
2447 pAddStaParams->staTCParams[i].rxUseBA = eBA_DISABLE;
2448 }
2449
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002450#ifdef FEATURE_WLAN_TDLS
2451 if(pStaDs->wmeEnabled && \
2452 ((eLIM_AP_ROLE == psessionEntry->limSystemRole) || (STA_ENTRY_TDLS_PEER == pStaDs->staType)) )
2453#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 if(pStaDs->wmeEnabled && (eLIM_AP_ROLE == psessionEntry->limSystemRole))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002455#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 {
2457 pAddStaParams->uAPSD = 0;
2458 /* update UAPSD and send it to LIM to add STA */
2459 // bitmap MSB <- LSB MSB 4 bits are for
2460 // trigger enabled AC setting and LSB 4 bits
2461 // are for delivery enabled AC setting
2462 // 7 6 5 4 3 2 1 0
2463 // BE BK VI VO BE BK VI VO
2464 pAddStaParams->uAPSD |= pStaDs->qos.capability.qosInfo.acvo_uapsd;
2465 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acvi_uapsd << 1);
2466 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acbk_uapsd << 2);
2467 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acbe_uapsd << 3);
2468 //making delivery enabled and trigger enabled setting the same.
2469 pAddStaParams->uAPSD |= pAddStaParams->uAPSD << 4;
2470
2471 pAddStaParams->maxSPLen = pStaDs->qos.capability.qosInfo.maxSpLen;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002472 limLog( pMac, LOG1, FL( "uAPSD = 0x%x, maxSpLen = %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002473 pAddStaParams->uAPSD, pAddStaParams->maxSPLen);
2474 }
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002475
2476#ifdef WLAN_FEATURE_11W
2477 pAddStaParams->rmfEnabled = pStaDs->rmfEnabled;
2478 limLog( pMac, LOG1, FL( "Adding station, station index %d, PMF enabled %d"),
2479 pAddStaParams->staIdx, pAddStaParams->rmfEnabled);
2480#endif
2481
2482 //we need to defer the message until we get the response back from HAL.
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 if (pAddStaParams->respReqd)
2484 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07002485
2486 msgQ.type = WDA_ADD_STA_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002487
2488 msgQ.reserved = 0;
2489 msgQ.bodyptr = pAddStaParams;
2490 msgQ.bodyval = 0;
2491
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002492 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_STA_REQ for assocId %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002493 pStaDs->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002494 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002495
2496 retCode = wdaPostCtrlMsg( pMac, &msgQ );
2497 if( eSIR_SUCCESS != retCode)
2498 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002499 if (pAddStaParams->respReqd)
2500 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002501 limLog( pMac, LOGE, FL("ADD_STA_REQ for aId %d failed (reason %X)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 pStaDs->assocId, retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302503 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002504 }
2505
2506 return retCode;
2507}
2508
2509
2510/**
2511 * limDelSta()
2512 *
2513 *FUNCTION:
2514 * This function is called to delete an STA context at hardware
2515 * whenever a STA is disassociated
2516 *
2517 *LOGIC:
2518 *
2519 *ASSUMPTIONS:
2520 * NA
2521 *
2522 *NOTE:
2523 * NA
2524 *
2525 * @param pMac - Pointer to Global MAC structure
2526 * @param pStaDs - Pointer to the STA datastructure created by
2527 * LIM and maintained by DPH
2528 * @param fRespReqd - flag to indicate whether the delete is synchronous (true)
2529 * or not (false)
2530 * @return retCode - Indicates success or failure return code
2531 */
2532
2533tSirRetStatus
2534limDelSta(
2535 tpAniSirGlobal pMac,
2536 tpDphHashNode pStaDs,
2537 tANI_BOOLEAN fRespReqd,
2538 tpPESession psessionEntry)
2539{
2540 tpDeleteStaParams pDelStaParams = NULL;
2541 tSirMsgQ msgQ;
2542 tSirRetStatus retCode = eSIR_SUCCESS;
2543
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302544 pDelStaParams = vos_mem_malloc(sizeof( tDeleteStaParams ));
2545 if (NULL == pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002546 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302547 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 return eSIR_MEM_ALLOC_FAILED;
2549 }
2550
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302551 vos_mem_set((tANI_U8 *) pDelStaParams, sizeof(tDeleteStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002552
2553 //
2554 // DPH contains the STA index only for "peer" STA entries.
2555 // LIM global contains "self" STA index
2556 // Thus,
2557 // if( STA role )
2558 // get STA index from LIM global
2559 // else
2560 // get STA index from DPH
2561 //
2562
2563#if 0
2564 /* Since we have not created any STA, no need to send msg to delete
2565 * STA to HAL */
2566 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE) {
2567 pDelStaParams->staIdx = 1; /* TODO : This is workaround. Need to find right STA Index before sending to HAL */
2568 //return retCode;
2569 }
2570#endif
2571
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002572#ifdef FEATURE_WLAN_TDLS
2573 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)) )
2574#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 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 -08002576#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 pDelStaParams->staIdx= psessionEntry->staId;
2578
2579 else
2580 pDelStaParams->staIdx= pStaDs->staIndex;
2581
2582 pDelStaParams->assocId = pStaDs->assocId;
2583 pStaDs->valid = 0;
2584
2585 if (! fRespReqd)
2586 pDelStaParams->respReqd = 0;
2587 else
2588 {
2589 //when limDelSta is called from processSmeAssocCnf then mlmState is already set properly.
2590 if(eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE != GET_LIM_STA_CONTEXT_MLM_STATE(pStaDs))
2591 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002592 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002593 SET_LIM_STA_CONTEXT_MLM_STATE(pStaDs, eLIM_MLM_WT_DEL_STA_RSP_STATE);
2594 }
2595 if ( (eLIM_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) ||
2596 (eLIM_BT_AMP_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) )
2597 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002598 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002599
2600 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
2601
2602 }
2603 pDelStaParams->respReqd = 1;
2604 //we need to defer the message until we get the response back from HAL.
2605 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
2606 }
2607
2608 /* Update PE session ID*/
2609 pDelStaParams->sessionId = psessionEntry->peSessionId;
2610
2611 pDelStaParams->status = eHAL_STATUS_SUCCESS;
2612 msgQ.type = WDA_DELETE_STA_REQ;
2613 msgQ.reserved = 0;
2614 msgQ.bodyptr = pDelStaParams;
2615 msgQ.bodyval = 0;
2616
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002617 limLog( pMac, LOG1, FL( "Sending SIR_HAL_DELETE_STA_REQ for STAID: %X and AssocID: %d" ),
Gopichand Nakkalad786fa32013-03-20 23:48:19 +05302618 pDelStaParams->staIdx, pDelStaParams->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002619 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 retCode = wdaPostCtrlMsg( pMac, &msgQ );
2621 if( eSIR_SUCCESS != retCode)
2622 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002623 if(fRespReqd)
2624 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002625 limLog( pMac, LOGE, FL("Posting DELETE_STA_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302627 vos_mem_free(pDelStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002628 }
2629
2630 return retCode;
2631}
2632
2633#if defined WLAN_FEATURE_VOWIFI_11R
2634/*------------------------------------------------------------------------
2635 * limAddFTStaSelf()
2636 *
2637 * FUNCTION:
2638 *
2639 * This function is called to add a STA once we have connected with a new
2640 * AP, that we have performed an FT to.
2641 *
2642 * The Add STA Response is created and now after the ADD Bss Is Successful
2643 * we add the self sta. We update with the association id from the reassoc
2644 * response from the AP.
2645 *------------------------------------------------------------------------
2646 */
2647tSirRetStatus limAddFTStaSelf(tpAniSirGlobal pMac, tANI_U16 assocId, tpPESession psessionEntry)
2648{
2649 tpAddStaParams pAddStaParams = NULL;
2650 tSirMsgQ msgQ;
2651 tSirRetStatus retCode = eSIR_SUCCESS;
2652
2653 pAddStaParams = pMac->ft.ftPEContext.pAddStaReq;
2654 pAddStaParams->assocId = assocId;
2655
2656 msgQ.type = SIR_HAL_ADD_STA_REQ;
2657 msgQ.reserved = 0;
2658 msgQ.bodyptr = pAddStaParams;
2659 msgQ.bodyval = 0;
2660
2661
2662#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
2663 limLog( pMac, LOGE, FL( "Sending SIR_HAL_ADD_STA_REQ... (aid %d)" ), pAddStaParams->assocId);
2664#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002665 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002666
2667 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002668 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_ADD_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2670 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
2671 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002672 limLog( pMac, LOGE, FL("Posting ADD_STA_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302673 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 }
2675 //
2676 // Dont need it any more
2677 pMac->ft.ftPEContext.pAddStaReq = NULL;
2678 return retCode;
2679}
2680
2681#endif /* WLAN_FEATURE_VOWIFI_11R */
2682
2683/**
2684 * limAddStaSelf()
2685 *
2686 *FUNCTION:
2687 * This function is called to add an STA context at hardware
2688 * whenever a STA is (Re) Associated.
2689 *
2690 *LOGIC:
2691 *
2692 *ASSUMPTIONS:
2693 * NA
2694 *
2695 *NOTE:
2696 * NA
2697 *
2698 * @param pMac - Pointer to Global MAC structure
2699 * @param pStaDs - Pointer to the STA datastructure created by
2700 * LIM and maintained by DPH
2701 * @return retCode - Indicates success or failure return code
2702 */
2703
2704tSirRetStatus
2705limAddStaSelf(tpAniSirGlobal pMac,tANI_U16 staIdx, tANI_U8 updateSta, tpPESession psessionEntry)
2706{
2707 tpAddStaParams pAddStaParams = NULL;
2708 tSirMsgQ msgQ;
2709 tSirRetStatus retCode = eSIR_SUCCESS;
2710 tSirMacAddr staMac;
2711 tANI_U32 listenInterval = WNI_CFG_LISTEN_INTERVAL_STADEF;
krunal soni71343fb2013-09-16 16:16:26 -07002712 tANI_U32 shortGi20MhzSupport;
2713 tANI_U32 shortGi40MhzSupport;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002714 /*This self Sta dot 11 mode comes from the cfg and the expectation here is
2715 * that cfg carries the systemwide capability that device under
2716 * consideration can support. This capability gets plumbed into the cfg
2717 * cache at system initialization time via the .dat and .ini file override
2718 * mechanisms and will not change. If it does change, it is the
2719 * responsibility of SME to evict the selfSta and reissue a new AddStaSelf
2720 * command.*/
2721 tANI_U32 selfStaDot11Mode=0, selfTxWidth=0;
2722 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfStaDot11Mode);
2723 limLog( pMac, LOG1, FL("cfgDot11Mode %d"),(int)selfStaDot11Mode);
2724 wlan_cfgGetInt(pMac,WNI_CFG_HT_CAP_INFO_SUPPORTED_CHAN_WIDTH_SET,&selfTxWidth);
2725 limLog( pMac, LOG1, FL("SGI 20 %d"),(int)selfTxWidth);
2726 limLog( pMac, LOG1, FL("Roam Channel Bonding Mode %d"),(int)pMac->roam.configParam.uCfgDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002727
2728 #if 0
2729 retCode =wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, staMac, &cfg);
2730 if (retCode != eSIR_SUCCESS)
2731 {
2732 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002733 limLog(pMac, LOGP, FL("could not retrieve STA MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002734 return retCode;
2735 }
2736 #endif //TO SUPPORT BT-AMP
2737 sirCopyMacAddr(staMac,psessionEntry->selfMacAddr);
2738
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302739 pAddStaParams = vos_mem_malloc(sizeof(tAddStaParams));
2740 if (NULL == pAddStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302742 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002743 return eSIR_MEM_ALLOC_FAILED;
2744 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302745 vos_mem_set((tANI_U8 *) pAddStaParams, sizeof(tAddStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002746
2747 /// Add STA context at MAC HW (BMU, RHP & TFP)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302748 vos_mem_copy((tANI_U8 *) pAddStaParams->staMac,
2749 (tANI_U8 *) staMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002750
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302751 vos_mem_copy((tANI_U8 *) pAddStaParams->bssId,
2752 psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002753
2754 pAddStaParams->assocId = psessionEntry->limAID;
2755 pAddStaParams->staType = STA_ENTRY_SELF;
2756 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2757 pAddStaParams->respReqd = 1;
2758
2759 /* Update PE session ID */
2760 pAddStaParams->sessionId = psessionEntry->peSessionId;
2761
2762 // This will indicate HAL to "allocate" a new STA index
2763 pAddStaParams->staIdx = staIdx;
2764 pAddStaParams->updateSta = updateSta;
2765
2766 pAddStaParams->shortPreambleSupported = psessionEntry->beaconParams.fShortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -07002767
Jeff Johnsone7245742012-09-05 17:12:55 -07002768#ifdef WLAN_FEATURE_11AC
2769 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry,NULL);
2770#else
2771 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry);
2772#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002773// if( psessionEntry->htCapability)---> old check
2774 /*We used to check if the session is htCapable before setting the htCapable
2775 * flag. The check limited us from operating */
2776 if ( IS_DOT11_MODE_HT(selfStaDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002778 pAddStaParams->htCapable = TRUE ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002779#ifdef DISABLE_GF_FOR_INTEROP
2780 /*
2781 * To resolve the interop problem with Broadcom AP,
2782 * where TQ STA could not pass traffic with GF enabled,
2783 * TQ STA will do Greenfield only with TQ AP, for
2784 * everybody else it will be turned off.
2785 */
2786 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2787 {
2788 limLog( pMac, LOGE, FL(" Turning off Greenfield, when adding self entry"));
2789 pAddStaParams->greenFieldCapable = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
2790 }
2791 else
2792#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002793 {
2794 pAddStaParams->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD, psessionEntry);
2795 pAddStaParams->txChannelWidthSet =
2796 pMac->roam.configParam.channelBondingMode5GHz;
2797 // pAddStaParams->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
2798 pAddStaParams->mimoPS = limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE, psessionEntry );
2799 pAddStaParams->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE, psessionEntry );
2800 pAddStaParams->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION, psessionEntry );
2801 pAddStaParams->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA, psessionEntry );
2802 pAddStaParams->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY, psessionEntry );
2803 pAddStaParams->maxAmpduSize = limGetHTCapability(pMac, eHT_MAX_RX_AMPDU_FACTOR, psessionEntry);
2804 pAddStaParams->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH, psessionEntry );
2805 pAddStaParams->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ, psessionEntry);
krunal soni71343fb2013-09-16 16:16:26 -07002806 /*
2807 * We will read the gShortGI20Mhz from ini file, and if it is set
2808 * to 1 then we will tell Peer that we support 40Mhz short GI
2809 */
2810 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
2811 (pMac, WNI_CFG_SHORT_GI_20MHZ,
2812 &shortGi20MhzSupport)))
2813 {
2814 if (VOS_TRUE == shortGi20MhzSupport)
2815 {
2816 pAddStaParams->fShortGI20Mhz =
2817 WNI_CFG_SHORT_GI_20MHZ_STAMAX;
2818 //pAddStaParams->fShortGI20Mhz =
2819 //limGetHTCapability(pMac, eHT_SHORT_GI_20MHZ,
2820 // psessionEntry);
2821 }
2822 else
2823 {
2824 pAddStaParams->fShortGI20Mhz = VOS_FALSE;
2825 }
2826 }
2827 else
2828 {
2829 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
2830 "CFG,setting value to default"));)
2831 pAddStaParams->fShortGI20Mhz = WNI_CFG_SHORT_GI_20MHZ_STADEF;
2832 }
2833
2834 /*
2835 * We will read the gShortGI40Mhz from ini file, and if it is set
2836 * to 1 then we will tell Peer that we support 40Mhz short GI
2837 */
2838 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
2839 (pMac, WNI_CFG_SHORT_GI_40MHZ,
2840 &shortGi40MhzSupport)))
2841 {
2842 if (VOS_TRUE == shortGi40MhzSupport)
2843 {
2844 pAddStaParams->fShortGI40Mhz =
2845 WNI_CFG_SHORT_GI_40MHZ_STAMAX;
2846 //pAddStaParams->fShortGI40Mhz =
2847 //limGetHTCapability(pMac, eHT_SHORT_GI_40MHZ,
2848 // psessionEntry);
2849 }
2850 else
2851 {
2852 pAddStaParams->fShortGI40Mhz = VOS_FALSE;
2853 }
2854 }
2855 else
2856 {
2857 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
2858 "CFG,setting value to default"));)
2859 pAddStaParams->fShortGI40Mhz = WNI_CFG_SHORT_GI_40MHZ_STADEF;
2860 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002863#ifdef WLAN_FEATURE_11AC
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002864 pAddStaParams->vhtCapable = IS_DOT11_MODE_VHT(selfStaDot11Mode);
2865 if (pAddStaParams->vhtCapable){
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002866 pAddStaParams->vhtTxChannelWidthSet = psessionEntry->vhtTxChannelWidthSet;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002867 limLog( pMac, LOG1, FL("VHT WIDTH SET %d"),pAddStaParams->vhtTxChannelWidthSet);
2868 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002869 pAddStaParams->vhtTxBFCapable = psessionEntry->txBFIniFeatureEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07002870#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002871
2872 /* For Self STA get the LDPC capability from session i.e config.ini*/
2873 pAddStaParams->htLdpcCapable =
2874 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
2875 pAddStaParams->vhtLdpcCapable =
2876 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
2877
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 if(wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &listenInterval) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002879 limLog(pMac, LOGP, FL("Couldn't get LISTEN_INTERVAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002880 pAddStaParams->listenInterval = (tANI_U16)listenInterval;
2881
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona)
2883 {
2884 pAddStaParams->p2pCapableSta = 1;
2885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002886
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002887 //limFillSupportedRatesInfo(pMac, NULL, &pAddStaParams->supportedRates,psessionEntry);
2888 pAddStaParams->supportedRates.opRateMode = limGetStaRateMode((tANI_U8)selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002889
2890 msgQ.type = WDA_ADD_STA_REQ;
2891 //
2892 // FIXME_GEN4
2893 // A global counter (dialog token) is required to keep track of
2894 // all PE <-> HAL communication(s)
2895 //
2896 msgQ.reserved = 0;
2897 msgQ.bodyptr = pAddStaParams;
2898 msgQ.bodyval = 0;
2899
2900 limLog( pMac, LOGW, FL( "Sending SIR_HAL_ADD_STA_REQ... (aid %d)" ),
2901 pAddStaParams->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002902 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002903
2904 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
2905 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002906 limLog( pMac, LOGE, FL("Posting ADD_STA_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302907 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 }
2909 return retCode;
2910}
2911
2912
2913/**
2914 * limTeardownInfraBSS()
2915 *
2916 *FUNCTION:
2917 * This function is called by various LIM functions to teardown
2918 * an established Infrastructure BSS
2919 *
2920 *LOGIC:
2921 *
2922 *ASSUMPTIONS:
2923 *
2924 *NOTE:
2925 *
2926 * @param pMac - Pointer to Global MAC structure
2927 * @return None
2928 */
2929
2930void
2931limTeardownInfraBss(tpAniSirGlobal pMac,tpPESession psessionEntry)
2932{
2933 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
2934
2935 /**
2936 * Send Broadcast Disassociate frame with
2937 * 'leaving BSS' reason.
2938 */
2939 limSendDisassocMgmtFrame(pMac,
2940 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08002941 bcAddr,psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002942} /*** end limTeardownInfraBss() ***/
2943
2944
2945/**
2946 * limHandleCnfWaitTimeout()
2947 *
2948 *FUNCTION:
2949 * This function is called by limProcessMessageQueue to handle
2950 * various confirmation failure cases.
2951 *
2952 *LOGIC:
2953 *
2954 *ASSUMPTIONS:
2955 *
2956 *NOTE:
2957 *
2958 * @param pMac - Pointer to Global MAC structure
2959 * @param pStaDs - Pointer to a sta descriptor
2960 * @return None
2961 */
2962
2963void limHandleCnfWaitTimeout(tpAniSirGlobal pMac, tANI_U16 staId)
2964{
2965 tpDphHashNode pStaDs;
2966 tLimSystemRole systemRole;
2967 tpPESession psessionEntry = NULL;
2968
2969 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gpLimCnfWaitTimer[staId].sessionId))== NULL)
2970 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002971 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 return;
2973 }
2974 systemRole = limGetSystemRole(psessionEntry);
2975 pStaDs = dphGetHashEntry(pMac, staId, &psessionEntry->dph.dphHashTable);
2976
2977 if (pStaDs == NULL)
2978 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002979 PELOGW(limLog(pMac, LOGW, FL("No STA context in SIR_LIM_CNF_WAIT_TIMEOUT."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002980 return;
2981 }
2982
2983 switch (pStaDs->mlmStaContext.mlmState) {
2984 case eLIM_MLM_WT_ASSOC_CNF_STATE:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002985 PELOGW(limLog(pMac, LOGW, FL("Did not receive Assoc Cnf in eLIM_MLM_WT_ASSOC_CNF_STATE sta Assoc id %d"), pStaDs->assocId);)
Jeff Johnson295189b2012-06-20 16:38:30 -07002986 limPrintMacAddr(pMac, pStaDs->staAddr, LOGW);
2987
2988 if ( (systemRole == eLIM_AP_ROLE)|| (systemRole == eLIM_BT_AMP_AP_ROLE) )
2989 {
2990 limRejectAssociation(
2991 pMac,
2992 pStaDs->staAddr,
2993 pStaDs->mlmStaContext.subType,
2994 true,
2995 pStaDs->mlmStaContext.authType,
2996 pStaDs->assocId,
2997 true,
2998 (tSirResultCodes) eSIR_MAC_UNSPEC_FAILURE_STATUS,
2999 psessionEntry);
3000 }
3001 break;
3002
3003 default:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003004 limLog(pMac, LOGW, FL("Received CNF_WAIT_TIMEOUT in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003005 pStaDs->mlmStaContext.mlmState);
3006 }
3007}
3008
3009
3010/**
3011 * limDeleteDphHashEntry()
3012 *
3013 *FUNCTION:
3014 * This function is called whenever we need to delete
3015 * the dph hash entry
3016 *
3017 *LOGIC:
3018 *
3019 *ASSUMPTIONS:
3020 *
3021 *NOTE:
3022 *
3023 * @param pMac Pointer to Global MAC structure
3024 * @param tANI_U16 staId
3025 * @return None
3026 */
3027
3028void
3029limDeleteDphHashEntry(tpAniSirGlobal pMac, tSirMacAddr staAddr, tANI_U16 staId,tpPESession psessionEntry)
3030{
3031 tANI_U16 aid;
3032 tpDphHashNode pStaDs;
3033 tUpdateBeaconParams beaconParams;
3034 tLimSystemRole systemRole;
3035
3036 beaconParams.paramChangeBitmap = 0;
3037 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, staId);
3038 if (NULL == psessionEntry)
3039 {
3040 PELOGE(limLog(pMac, LOGE, FL("NULL psessionEntry"));)
3041 return;
3042 }
3043 systemRole = limGetSystemRole(psessionEntry);
3044 beaconParams.bssIdx = psessionEntry->bssIdx;
3045 pStaDs = dphLookupHashEntry(pMac, staAddr, &aid, &psessionEntry->dph.dphHashTable);
3046 if (pStaDs != NULL)
3047 {
3048 PELOGW(limLog(pMac, LOGW, FL("Deleting DPH Hash entry for STAID: %X\n "), staId);)
3049 // update the station count and perform associated actions
3050 // do this before deleting the dph hash entry
3051 limUtilCountStaDel(pMac, pStaDs, psessionEntry);
3052
3053 if((eLIM_AP_ROLE == psessionEntry->limSystemRole) ||
3054 (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole))
3055 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 if(psessionEntry->limSystemRole == eLIM_AP_ROLE ){
3057 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE){
3058 limDecideApProtectionOnDelete(pMac, pStaDs, &beaconParams,psessionEntry);
3059 }
3060 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003061
3062 if(eLIM_STA_IN_IBSS_ROLE == systemRole)
3063 limIbssDecideProtectionOnDelete(pMac, pStaDs, &beaconParams, psessionEntry);
3064
3065 limDecideShortPreamble(pMac, pStaDs, &beaconParams, psessionEntry);
3066 limDecideShortSlot(pMac, pStaDs, &beaconParams, psessionEntry);
3067
3068 //Send message to HAL about beacon parameter change.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003069 PELOGW(limLog(pMac, LOGW, FL("param bitmap = %d "), beaconParams.paramChangeBitmap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003070 if(beaconParams.paramChangeBitmap)
3071 {
3072 schSetFixedBeaconFields(pMac,psessionEntry);
3073 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
3074 }
3075 }
3076 if (dphDeleteHashEntry(pMac, staAddr, staId, &psessionEntry->dph.dphHashTable) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003077 limLog(pMac, LOGP, FL("error deleting hash entry"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 }
3079}
3080
3081
3082
3083/**
3084 * limCheckAndAnnounceJoinSuccess()
3085 *
3086 *FUNCTION:
3087 * This function is called upon receiving Beacon/Probe Response
3088 * frame in WT_JOIN_BEACON_STATE to check if the received
3089 * Beacon/Probe Response is from the BSS that we're attempting
3090 * to join.
3091 *
3092 *LOGIC:
3093 * If the Beacon/Probe Response is indeed from the BSS we're
3094 * attempting to join, join success is sent to SME.
3095 *
3096 *ASSUMPTIONS:
3097 *
3098 *NOTE:
3099 *
3100 * @param pMac Pointer to Global MAC structure
3101 * @param pBPR Pointer to received Beacon/Probe Response
3102 * @param pHdr Pointer to received Beacon/Probe Response
3103 * MAC header
3104 * @return None
3105 */
3106
3107void
3108limCheckAndAnnounceJoinSuccess(tpAniSirGlobal pMac,
3109 tSirProbeRespBeacon *pBPR,
3110 tpSirMacMgmtHdr pHdr,tpPESession psessionEntry)
3111{
3112 tSirMacSSid currentSSID;
3113 tLimMlmJoinCnf mlmJoinCnf;
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003114 tANI_U32 val = 0;
3115 tANI_U32 *noa1DurationFromBcn = NULL;
3116 tANI_U32 *noa2DurationFromBcn = NULL;
3117 tANI_U32 noa;
3118 tANI_U32 TotalNum_NoADesc = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003119
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303120 vos_mem_copy(currentSSID.ssId,
3121 psessionEntry->ssId.ssId,
3122 psessionEntry->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003123
3124 currentSSID.length = (tANI_U8)psessionEntry->ssId.length ;
3125
3126 if (
3127 /* Check for SSID only in probe response. Beacons may not carry
3128 SSID information in hidden SSID case */
3129 ( (SIR_MAC_MGMT_FRAME == pHdr->fc.type) &&
3130 (SIR_MAC_MGMT_PROBE_RSP == pHdr->fc.subType) ) &&
3131 currentSSID.length &&
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303132 (!vos_mem_compare((tANI_U8 *) &pBPR->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 (tANI_U8 *) &currentSSID,
3134 (tANI_U8) (1 + currentSSID.length)) ))
3135 {
3136 /**
3137 * Received SSID does not match with the one we've.
3138 * Ignore received Beacon frame
3139 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003140 PELOG1(limLog(pMac, LOG1, FL("SSID received in Beacon does not match"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003141#ifdef WLAN_DEBUG
3142 pMac->lim.gLimBcnSSIDMismatchCnt++;
3143#endif
3144 return;
3145 }
3146
3147 if( (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_STA_ROLE))
3148 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003149 PELOG1(limLog(pMac, LOG1, FL("Received Beacon/PR with matching BSSID"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003150
3151 // Deactivate Join Failure timer
3152 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08003153 // Deactivate Periodic Join timer
3154 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -07003155
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003156 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona &&
3157 pBPR->P2PProbeRes.NoticeOfAbsence.present)
3158 {
3159
3160 noa1DurationFromBcn = (tANI_U32*)(pBPR->P2PProbeRes.NoticeOfAbsence.NoADesc + 1);
3161
3162 if(pBPR->P2PProbeRes.NoticeOfAbsence.num_NoADesc)
3163 TotalNum_NoADesc = pBPR->P2PProbeRes.NoticeOfAbsence.num_NoADesc/SIZE_OF_NOA_DESCRIPTOR;
3164
3165 noa = *noa1DurationFromBcn;
3166
3167 if(TotalNum_NoADesc > 1)
3168 {
3169 noa2DurationFromBcn = (tANI_U32*)(pBPR->P2PProbeRes.NoticeOfAbsence.NoADesc + SIZE_OF_NOA_DESCRIPTOR + 1);
3170 noa += *noa2DurationFromBcn;
3171 }
3172
3173 /*If MAX Noa exceeds 3 secs we will consider only 3 secs to
3174 * avoid arbitary values in noa duration field
3175 */
3176 noa = noa > MAX_NOA_PERIOD_IN_MICROSECS ? MAX_NOA_PERIOD_IN_MICROSECS : noa;
3177 noa = noa/1000; //Convert to ms
3178
3179 if( wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,&val) == eSIR_SUCCESS )
3180 {
3181 psessionEntry->defaultAuthFailureTimeout = val;
3182 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,val + noa, NULL, eANI_BOOLEAN_FALSE);
3183 }
3184 }
3185 else
3186 {
3187 psessionEntry->defaultAuthFailureTimeout = 0;
3188 }
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003189
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 // Update Beacon Interval at CFG database
3191
3192 if ( pBPR->HTCaps.present )
3193 limUpdateStaRunTimeHTCapability( pMac, &pBPR->HTCaps );
3194 if ( pBPR->HTInfo.present )
3195 limUpdateStaRunTimeHTInfo( pMac, &pBPR->HTInfo, psessionEntry);
3196 psessionEntry->limMlmState = eLIM_MLM_JOINED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003197 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_JOINED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003198
Jeff Johnson295189b2012-06-20 16:38:30 -07003199
3200 /**
3201 * Announce join success by sending
3202 * Join confirm to SME.
3203 */
3204 mlmJoinCnf.resultCode = eSIR_SME_SUCCESS;
3205 mlmJoinCnf.protStatusCode = eSIR_MAC_SUCCESS_STATUS;
3206 /* Update PE sessionId*/
3207 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
3208 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
3209 } // if ((pMac->lim.gLimSystemRole == IBSS....
3210}
3211
3212/**
3213 * limExtractApCapabilities()
3214 *
3215 *FUNCTION:
3216 * This function is called to extract all of the AP's capabilities
3217 * from the IEs received from it in Beacon/Probe Response frames
3218 *
3219 *LOGIC:
3220 * This routine mimics the limExtractApCapability() API. The difference here
3221 * is that this API returns the entire tSirProbeRespBeacon info as is. It is
3222 * left to the caller of this API to use this info as required
3223 *
3224 *ASSUMPTIONS:
3225 * NA
3226 *
3227 *NOTE:
3228 *
3229 * @param pMac Pointer to Global MAC structure
3230 * @param pIE Pointer to starting IE in Beacon/Probe Response
3231 * @param ieLen Length of all IEs combined
3232 * @param beaconStruct A pointer to tSirProbeRespBeacon that needs to be
3233 * populated
3234 * @return status A status reporting eSIR_SUCCESS or eSIR_FAILURE
3235 */
3236tSirRetStatus limExtractApCapabilities( tpAniSirGlobal pMac,
3237 tANI_U8 *pIE,
3238 tANI_U16 ieLen,
3239 tpSirProbeRespBeacon beaconStruct )
3240{
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303241 vos_mem_set((tANI_U8 *) beaconStruct, sizeof( tSirProbeRespBeacon ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003242
3243 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003244 FL( "In limExtractApCapabilities: The IE's being received are:" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003245 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG3, pIE, ieLen );)
3246
3247 // Parse the Beacon IE's, Don't try to parse if we dont have anything in IE
3248 if (ieLen > 0) {
3249 if( eSIR_SUCCESS != sirParseBeaconIE( pMac, beaconStruct, pIE, (tANI_U32)ieLen ))
3250 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003251 limLog( pMac, LOGE, FL("APCapExtract: Beacon parsing error!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 return eSIR_FAILURE;
3253 }
3254 }
3255
3256 return eSIR_SUCCESS;
3257}
3258
3259
3260/**
3261 * limDelBss()
3262 *
3263 *FUNCTION:
3264 * This function is called to delete BSS context at hardware
3265 * whenever a STA is disassociated
3266 *
3267 *LOGIC:
3268 *
3269 *ASSUMPTIONS:
3270 * NA
3271 *
3272 *NOTE:
3273 * NA
3274 *
3275 * @param pMac - Pointer to Global MAC structure
3276 * @param pStaDs - Pointer to the STA datastructure created by
3277 * LIM and maintained by DPH
3278 * @return retCode - Indicates success or failure return code
3279 */
3280
3281tSirRetStatus
3282limDelBss(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tANI_U16 bssIdx,tpPESession psessionEntry)
3283{
3284 tpDeleteBssParams pDelBssParams = NULL;
3285 tSirMsgQ msgQ;
3286 tSirRetStatus retCode = eSIR_SUCCESS;
3287
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303288 pDelBssParams = vos_mem_malloc(sizeof(tDeleteBssParams));
3289 if (NULL == pDelBssParams)
3290 {
3291 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 return eSIR_MEM_ALLOC_FAILED;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303293 }
3294 vos_mem_set((tANI_U8 *) pDelBssParams, sizeof(tDeleteBssParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003295
3296
3297 pDelBssParams->sessionId = psessionEntry->peSessionId; //update PE session Id
3298
3299 //DPH was storing the AssocID in staID field,
3300 //staID is actually assigned by HAL when AddSTA message is sent.
3301 if (pStaDs != NULL)
3302 {
3303 pDelBssParams->bssIdx= pStaDs->bssId;
3304 pStaDs->valid = 0;
3305 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
3306 }
3307 else
3308 pDelBssParams->bssIdx = bssIdx;
3309 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003310 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_BSS_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003311
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07003312 if((psessionEntry->peSessionId == pMac->lim.limTimers.gLimJoinFailureTimer.sessionId) &&
3313 (VOS_TRUE == tx_timer_running(&pMac->lim.limTimers.gLimJoinFailureTimer)))
3314 {
3315 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
3316 }
3317
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 pDelBssParams->status= eHAL_STATUS_SUCCESS;
3319 pDelBssParams->respReqd = 1;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003320 PELOGW(limLog( pMac, LOGW, FL("Sending HAL_DELETE_BSS_REQ for BSSID: %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 pDelBssParams->bssIdx);)
3322
3323 //we need to defer the message until we get the response back from HAL.
3324 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3325
3326 msgQ.type = WDA_DELETE_BSS_REQ;
3327 msgQ.reserved = 0;
3328 msgQ.bodyptr = pDelBssParams;
3329 msgQ.bodyval = 0;
3330
Jeff Johnsone7245742012-09-05 17:12:55 -07003331 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003332
3333 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
3334 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003335 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003336 limLog( pMac, LOGE, FL("Posting DELETE_BSS_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303337 vos_mem_free(pDelBssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 }
3339
3340 return retCode;
3341}
3342
3343
Jeff Johnson295189b2012-06-20 16:38:30 -07003344
3345/**
3346 * limSendAddBss()
3347 *
3348 *FUNCTION:
3349 *
3350 *LOGIC:
3351 * 1) LIM receives eWNI_SME_JOIN_REQ
3352 * 2) For a valid eWNI_SME_JOIN_REQ, LIM sends
3353 * SIR_HAL_ADD_BSS_REQ to HAL
3354 *
3355 *ASSUMPTIONS:
3356 * JOIN REQ parameters are saved in pMac->lim.gLimMlmJoinReq
3357 * ADD BSS parameters can be obtained from two sources:
3358 * 1) pMac->lim.gLimMlmJoinReq
3359 * 2) beaconStruct, passed as paramter
3360 * So, if a reqd parameter is found in bssDescriptions
3361 * then it is given preference over beaconStruct
3362 *
3363 *NOTE:
3364 *
3365 * @param pMac Pointer to Global MAC structure
3366 * pAssocRsp contains the structured assoc/reassoc Response got from AP
3367 * beaconstruct Has the ProbeRsp/Beacon structured details
3368 * bssDescription bssDescription passed to PE from the SME
3369 * @return None
3370 */
3371
3372tSirRetStatus limStaSendAddBss( tpAniSirGlobal pMac, tpSirAssocRsp pAssocRsp,
3373 tpSchBeaconStruct pBeaconStruct, tpSirBssDescription bssDescription, tANI_U8 updateEntry,
3374 tpPESession psessionEntry)
3375
3376{
3377 tSirMsgQ msgQ;
3378 tpAddBssParams pAddBssParams = NULL;
3379 tANI_U32 retCode;
3380 tANI_U8 i;
3381 tpDphHashNode pStaDs = NULL;
3382 tANI_U8 chanWidthSupp = 0;
krunal soni71343fb2013-09-16 16:16:26 -07003383 tANI_U32 shortGi20MhzSupport;
3384 tANI_U32 shortGi40MhzSupport;
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 // Package SIR_HAL_ADD_BSS_REQ message parameters
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303386 pAddBssParams = vos_mem_malloc(sizeof( tAddBssParams ));
3387 if (NULL == pAddBssParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 {
3389 limLog( pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303390 FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 retCode = eSIR_MEM_ALLOC_FAILED;
3392 goto returnFailure;
3393 }
3394 else
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303395 vos_mem_set((tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003396
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303397 vos_mem_copy(pAddBssParams->bssId,bssDescription->bssId,
3398 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003399 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303400 vos_mem_copy(pAddBssParams->selfMacAddr,
3401 psessionEntry->selfMacAddr,
3402 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003403
3404 if(psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
3405 {
3406 pAddBssParams->bssType = eSIR_BTAMP_AP_MODE;
3407 }
3408 else
3409 {
3410 pAddBssParams->bssType = eSIR_INFRASTRUCTURE_MODE;
3411 }
3412
3413 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
3414
3415 /* Update PE session ID */
3416 pAddBssParams->sessionId = psessionEntry->peSessionId;
3417
3418 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
3419
3420 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
3421 pAddBssParams->updateBss = updateEntry;
3422
3423
3424 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
3425 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
3426 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
3427 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
3428
3429 pAddBssParams->rateSet.numRates = pAssocRsp->supportedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303430 vos_mem_copy(pAddBssParams->rateSet.rate,
3431 pAssocRsp->supportedRates.rate, pAssocRsp->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07003432
3433 pAddBssParams->nwType = bssDescription->nwType;
3434
Jeff Johnsone7245742012-09-05 17:12:55 -07003435 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pAssocRsp->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
3437 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
3438 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
3439 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
3440
3441
3442 // Use the advertised capabilities from the received beacon/PR
3443
3444
3445 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pAssocRsp->HTCaps.present ))
3446 {
3447 pAddBssParams->htCapable = pAssocRsp->HTCaps.present;
3448
3449 if ( pBeaconStruct->HTInfo.present )
3450 {
3451 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pAssocRsp->HTInfo.opMode;
3452 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pAssocRsp->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 if( (pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3455 (chanWidthSupp) )
3456 {
3457 pAddBssParams->txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
3458 pAddBssParams->currentExtChannel = pAssocRsp->HTInfo.secondaryChannelOffset;
3459 }
3460 else
3461 {
3462 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003463 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 }
3465 pAddBssParams->llnNonGFCoexist = (tANI_U8)pAssocRsp->HTInfo.nonGFDevicesPresent;
3466 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pAssocRsp->HTInfo.lsigTXOPProtectionFullSupport;
3467 pAddBssParams->fRIFSMode = pAssocRsp->HTInfo.rifsMode;
3468 }
3469 }
3470
3471 pAddBssParams->currentOperChannel = bssDescription->channelId;
3472
Jeff Johnsone7245742012-09-05 17:12:55 -07003473#ifdef WLAN_FEATURE_11AC
3474 if (psessionEntry->vhtCapability && ( pAssocRsp->VHTCaps.present ))
3475 {
3476 pAddBssParams->vhtCapable = pAssocRsp->VHTCaps.present;
3477 pAddBssParams->vhtTxChannelWidthSet = pAssocRsp->VHTOperation.chanWidth;
3478 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003479 pAddBssParams->currentOperChannel,
3480 pAddBssParams->currentExtChannel,
3481 psessionEntry->apCenterChan,
3482 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003483 }
3484 else
3485 {
3486 pAddBssParams->vhtCapable = 0;
3487 }
3488#endif
3489
3490
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 // Populate the STA-related parameters here
3492 // Note that the STA here refers to the AP
3493 {
3494 /* staType = PEER*/
3495 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
3496
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303497 vos_mem_copy(pAddBssParams->staContext.bssId,
3498 bssDescription->bssId,
3499 sizeof( tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003500 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
3501
3502 /* Fill Assoc id from the dph table */
3503 pStaDs = dphLookupHashEntry(pMac, pAddBssParams->staContext.bssId,
3504 &pAddBssParams->staContext.assocId, &psessionEntry->dph.dphHashTable);
3505 if (pStaDs == NULL)
3506 {
3507 PELOGE(limLog(pMac, LOGE, FL("Couldn't get assoc id for"
3508 "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x"),
3509 pAddBssParams->staContext.staMac[0],
3510 pAddBssParams->staContext.staMac[1],
3511 pAddBssParams->staContext.staMac[2],
3512 pAddBssParams->staContext.staMac[3],
3513 pAddBssParams->staContext.staMac[4],
3514 pAddBssParams->staContext.staMac[5]
3515 );)
3516 }
3517 pAddBssParams->staContext.uAPSD = 0;
3518 pAddBssParams->staContext.maxSPLen = 0;
3519 pAddBssParams->staContext.shortPreambleSupported = (tANI_U8)pAssocRsp->capabilityInfo.shortPreamble;
3520 pAddBssParams->staContext.updateSta = updateEntry;
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003521 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && pBeaconStruct->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003522 {
3523 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
3524 pAddBssParams->staContext.htCapable = 1;
3525 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 )pAssocRsp->HTCaps.greenField;
3526 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 )pAssocRsp->HTCaps.lsigTXOPProtection;
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003527#ifdef WLAN_FEATURE_11AC
3528 if (psessionEntry->vhtCapability && pBeaconStruct->VHTCaps.present)
3529 {
3530 pAddBssParams->staContext.vhtCapable = 1;
3531 if ((pAssocRsp->VHTCaps.suBeamFormerCap ||
3532 pAssocRsp->VHTCaps.muBeamformerCap) &&
3533 psessionEntry->txBFIniFeatureEnabled)
3534 {
3535 pAddBssParams->staContext.vhtTxBFCapable = 1;
3536 }
3537 }
3538#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 if( (pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3540 (chanWidthSupp) )
3541 {
3542 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
Jeff Johnsone7245742012-09-05 17:12:55 -07003543#ifdef WLAN_FEATURE_11AC
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003544 if (pAddBssParams->staContext.vhtCapable)
Jeff Johnsone7245742012-09-05 17:12:55 -07003545 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003546 pAddBssParams->staContext.vhtTxChannelWidthSet = pAssocRsp->VHTOperation.chanWidth; //pMac->lim.apChanWidth;
3547 }
3548#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003549 }
3550 else
3551 {
3552 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3553 }
3554 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pAssocRsp->HTCaps.mimoPowerSave;
3555 pAddBssParams->staContext.delBASupport = ( tANI_U8 )pAssocRsp->HTCaps.delayedBA;
3556 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 )pAssocRsp->HTCaps.maximalAMSDUsize;
3557 pAddBssParams->staContext.maxAmpduDensity = pAssocRsp->HTCaps.mpduDensity;
3558 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pAssocRsp->HTCaps.dsssCckMode40MHz;
krunal soni71343fb2013-09-16 16:16:26 -07003559 /*
3560 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
3561 * if they are set then we will use what ever Assoc response coming
3562 * from AP supports. If these values are set as 0 in ini file then
3563 * we will hardcode this values to 0.
3564 */
3565 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3566 (pMac, WNI_CFG_SHORT_GI_20MHZ,
3567 &shortGi20MhzSupport)))
3568 {
3569 if (VOS_TRUE == shortGi20MhzSupport)
3570 {
3571 pAddBssParams->staContext.fShortGI20Mhz =
3572 (tANI_U8)pAssocRsp->HTCaps.shortGI20MHz;
3573 }
3574 else
3575 {
3576 pAddBssParams->staContext.fShortGI20Mhz = VOS_FALSE;
3577 }
3578 }
3579 else
3580 {
3581 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
3582 "CFG,setting value to default"));)
3583 pAddBssParams->staContext.fShortGI20Mhz =
3584 WNI_CFG_SHORT_GI_20MHZ_STADEF;
3585 }
3586
3587 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3588 (pMac, WNI_CFG_SHORT_GI_40MHZ,
3589 &shortGi40MhzSupport)))
3590 {
3591 if (VOS_TRUE == shortGi40MhzSupport)
3592 {
3593 pAddBssParams->staContext.fShortGI40Mhz =
3594 (tANI_U8)pAssocRsp->HTCaps.shortGI40MHz;
3595 }
3596 else
3597 {
3598 pAddBssParams->staContext.fShortGI40Mhz = VOS_FALSE;
3599 }
3600 }
3601 else
3602 {
3603 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
3604 "CFG,setting value to default"));)
3605 pAddBssParams->staContext.fShortGI40Mhz =
3606 WNI_CFG_SHORT_GI_40MHZ_STADEF;
3607 }
3608
Jeff Johnson295189b2012-06-20 16:38:30 -07003609 pAddBssParams->staContext.maxAmpduSize= pAssocRsp->HTCaps.maxRxAMPDUFactor;
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08003610 if( pAddBssParams->staContext.vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP )
3611 {
3612 pAddBssParams->staContext.htLdpcCapable = 0;
3613 pAddBssParams->staContext.vhtLdpcCapable = 0;
3614 }
3615 else
3616 {
3617 pAddBssParams->staContext.htLdpcCapable = (tANI_U8)pAssocRsp->HTCaps.advCodingCap;
3618 pAddBssParams->staContext.vhtLdpcCapable = (tANI_U8)pAssocRsp->VHTCaps.ldpcCodingCap;
3619 }
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08003620
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 if( pBeaconStruct->HTInfo.present )
3622 pAddBssParams->staContext.rifsMode = pAssocRsp->HTInfo.rifsMode;
3623 }
3624
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303625 //If WMM IE or 802.11E IE is not present and AP is HT AP then enable WMM
3626 if ((psessionEntry->limWmeEnabled && (pAssocRsp->wmeEdcaPresent || pAddBssParams->htCapable)) ||
3627 (psessionEntry->limQosEnabled && (pAssocRsp->edcaPresent || pAddBssParams->htCapable)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 pAddBssParams->staContext.wmmEnabled = 1;
3629 else
3630 pAddBssParams->staContext.wmmEnabled = 0;
3631
3632 //Update the rates
3633
3634 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3635 if (pStaDs != NULL)
3636 {
3637 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303638 vos_mem_copy((tANI_U8*)&pAddBssParams->staContext.supportedRates,
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 (tANI_U8*)&pStaDs->supportedRates,
3640 sizeof(tSirSupportedRates));
3641 }
3642 else
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003643 PELOGE(limLog(pMac, LOGE, FL("could not Update the supported rates."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003644
3645 }
3646
3647 //Disable BA. It will be set as part of ADDBA negotiation.
3648 for( i = 0; i < STACFG_MAX_TC; i++ )
3649 {
3650 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
3651 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
3652 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
3653 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
3654 }
3655
3656 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
3657
3658#if defined WLAN_FEATURE_VOWIFI
3659 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
3660#endif
3661 // FIXME_GEN4 - Any other value that can be used for initialization?
3662 pAddBssParams->status = eHAL_STATUS_SUCCESS;
3663 pAddBssParams->respReqd = true;
3664
3665 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
3666
Jeff Johnson295189b2012-06-20 16:38:30 -07003667 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona)
3668 {
3669 pAddBssParams->staContext.p2pCapableSta = 1;
3670 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003671
Bansidhar Gopalacharib099ac62013-06-12 19:02:39 -07003672 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003673
3674#if defined WLAN_FEATURE_VOWIFI_11R
3675 pAddBssParams->extSetStaKeyParamValid = 0;
3676#endif
3677
Chet Lanctot186b5732013-03-18 10:26:30 -07003678#ifdef WLAN_FEATURE_11W
3679 if (psessionEntry->limRmfEnabled)
3680 {
3681 pAddBssParams->rmfEnabled = 1;
3682 pAddBssParams->staContext.rmfEnabled = 1;
3683 }
3684#endif
3685
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 // Set a new state for MLME
3687 if( eLIM_MLM_WT_ASSOC_RSP_STATE == psessionEntry->limMlmState )
3688 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE;
3689 else
3690 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003691 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003692
3693 //we need to defer the message until we get the response back from HAL.
3694 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3695
3696 msgQ.type = WDA_ADD_BSS_REQ;
3697 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
3698 msgQ.reserved = 0;
3699 msgQ.bodyptr = pAddBssParams;
3700 msgQ.bodyval = 0;
3701
3702 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_BSS_REQ..." ));
Jeff Johnsone7245742012-09-05 17:12:55 -07003703 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003704
3705 retCode = wdaPostCtrlMsg( pMac, &msgQ );
3706 if( eSIR_SUCCESS != retCode)
3707 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003708 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303709 vos_mem_free(pAddBssParams);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003710 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003711 retCode );
3712 goto returnFailure;
3713
3714 }
3715 else
3716 return retCode;
3717
3718 returnFailure:
3719 // Clean-up will be done by the caller...
3720 return retCode;
3721}
3722
3723
3724
3725
3726tSirRetStatus limStaSendAddBssPreAssoc( tpAniSirGlobal pMac, tANI_U8 updateEntry, tpPESession psessionEntry)
3727{
3728 tSirMsgQ msgQ;
3729 tpAddBssParams pAddBssParams = NULL;
3730 tANI_U32 retCode;
3731 tANI_U8 i;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003732 tSchBeaconStruct *pBeaconStruct;
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 tANI_U8 chanWidthSupp = 0;
krunal soni71343fb2013-09-16 16:16:26 -07003734 tANI_U32 shortGi20MhzSupport;
3735 tANI_U32 shortGi40MhzSupport;
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 tpSirBssDescription bssDescription = &psessionEntry->pLimJoinReq->bssDescription;
3737
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303738 pBeaconStruct = vos_mem_malloc(sizeof(tSchBeaconStruct));
3739 if (NULL == pBeaconStruct)
Jeff Johnson32d95a32012-09-10 13:15:23 -07003740 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303741 limLog(pMac, LOGE, FL("Unable to allocate memory during ADD_BSS") );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003742 return eSIR_MEM_ALLOC_FAILED;
3743 }
3744
Jeff Johnson295189b2012-06-20 16:38:30 -07003745
3746 // Package SIR_HAL_ADD_BSS_REQ message parameters
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303747 pAddBssParams = vos_mem_malloc(sizeof(tAddBssParams));
3748 if (NULL == pAddBssParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 {
3750 limLog( pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303751 FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 retCode = eSIR_MEM_ALLOC_FAILED;
3753 goto returnFailure;
3754 }
3755
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303756 vos_mem_set((tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003757
3758
3759 limExtractApCapabilities( pMac,
3760 (tANI_U8 *) bssDescription->ieFields,
3761 limGetIElenFromBssDescription( bssDescription ),
Jeff Johnson32d95a32012-09-10 13:15:23 -07003762 pBeaconStruct );
Jeff Johnson295189b2012-06-20 16:38:30 -07003763
3764 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
Jeff Johnson32d95a32012-09-10 13:15:23 -07003765 limDecideStaProtectionOnAssoc(pMac, pBeaconStruct, psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303766 vos_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
3767 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003768
3769 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303770 vos_mem_copy(pAddBssParams->selfMacAddr,
3771 psessionEntry->selfMacAddr,
3772 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003773
3774 /* Incorrect BSS Type which caused UMA Descriptor to be overwritten on
3775 * top of an already established Infra link. This lead to issues in
3776 * concurrent data transfer.
3777 */
3778
3779 pAddBssParams->bssType = psessionEntry->bssType;//eSIR_INFRASTRUCTURE_MODE;
3780 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
3781
3782 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
3783
Jeff Johnson32d95a32012-09-10 13:15:23 -07003784 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 pAddBssParams->updateBss = updateEntry;
3786
3787
Jeff Johnson32d95a32012-09-10 13:15:23 -07003788 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
3789 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
3790 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
3791 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
Jeff Johnson295189b2012-06-20 16:38:30 -07003792
3793
Jeff Johnson32d95a32012-09-10 13:15:23 -07003794 pAddBssParams->rateSet.numRates = pBeaconStruct->supportedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303795 vos_mem_copy(pAddBssParams->rateSet.rate,
3796 pBeaconStruct->supportedRates.rate, pBeaconStruct->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07003797
3798 pAddBssParams->nwType = bssDescription->nwType;
3799
Jeff Johnson32d95a32012-09-10 13:15:23 -07003800 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07003801 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
3802 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
3803 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
3804 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
3805
3806 // Use the advertised capabilities from the received beacon/PR
Jeff Johnson32d95a32012-09-10 13:15:23 -07003807 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003808 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003809 pAddBssParams->htCapable = pBeaconStruct->HTCaps.present;
Jeff Johnson295189b2012-06-20 16:38:30 -07003810
Jeff Johnson32d95a32012-09-10 13:15:23 -07003811 if ( pBeaconStruct->HTInfo.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003813 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pBeaconStruct->HTInfo.opMode;
3814 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pBeaconStruct->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -07003815
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
Jeff Johnson32d95a32012-09-10 13:15:23 -07003817 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 (chanWidthSupp) )
3819 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003820 pAddBssParams->txChannelWidthSet = ( tANI_U8 ) pBeaconStruct->HTInfo.recommendedTxWidthSet;
3821 pAddBssParams->currentExtChannel = pBeaconStruct->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 }
3823 else
3824 {
3825 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003826 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07003828 pAddBssParams->llnNonGFCoexist = (tANI_U8)pBeaconStruct->HTInfo.nonGFDevicesPresent;
3829 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pBeaconStruct->HTInfo.lsigTXOPProtectionFullSupport;
3830 pAddBssParams->fRIFSMode = pBeaconStruct->HTInfo.rifsMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 }
3832 }
3833
3834 pAddBssParams->currentOperChannel = bssDescription->channelId;
3835
Jeff Johnsone7245742012-09-05 17:12:55 -07003836#ifdef WLAN_FEATURE_11AC
Jeff Johnson32d95a32012-09-10 13:15:23 -07003837 if (psessionEntry->vhtCapability && ( pBeaconStruct->VHTCaps.present ))
Jeff Johnsone7245742012-09-05 17:12:55 -07003838 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003839 pAddBssParams->vhtCapable = pBeaconStruct->VHTCaps.present;
3840 pAddBssParams->vhtTxChannelWidthSet = pBeaconStruct->VHTOperation.chanWidth;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003841 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
3842 pAddBssParams->currentOperChannel,
3843 pAddBssParams->currentExtChannel,
3844 psessionEntry->apCenterChan,
3845 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003846 }
3847 else
3848 {
3849 pAddBssParams->vhtCapable = 0;
3850 }
3851#endif
3852
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 // Populate the STA-related parameters here
3854 // Note that the STA here refers to the AP
3855 {
3856 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
3857
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303858 vos_mem_copy(pAddBssParams->staContext.bssId,
3859 bssDescription->bssId,
3860 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
3862
3863 pAddBssParams->staContext.assocId = 0; // Is SMAC OK with this?
3864 pAddBssParams->staContext.uAPSD = 0;
3865 pAddBssParams->staContext.maxSPLen = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003866 pAddBssParams->staContext.shortPreambleSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -07003867 pAddBssParams->staContext.updateSta = updateEntry;
3868
Jeff Johnson32d95a32012-09-10 13:15:23 -07003869 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 {
3871 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
3872 pAddBssParams->staContext.htCapable = 1;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003873 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 ) pBeaconStruct->HTCaps.greenField;
3874 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 ) pBeaconStruct->HTCaps.lsigTXOPProtection;
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003875#ifdef WLAN_FEATURE_11AC
3876 if (psessionEntry->vhtCapability && pBeaconStruct->VHTCaps.present)
3877 {
3878 pAddBssParams->staContext.vhtCapable = 1;
3879 if ((pBeaconStruct->VHTCaps.suBeamFormerCap ||
3880 pBeaconStruct->VHTCaps.muBeamformerCap) &&
3881 psessionEntry->txBFIniFeatureEnabled )
3882 {
3883 pAddBssParams->staContext.vhtTxBFCapable = 1;
3884 }
3885 }
3886#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07003887 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 (chanWidthSupp) )
3889 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003890 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pBeaconStruct->HTInfo.recommendedTxWidthSet;
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003891#ifdef WLAN_FEATURE_11AC
3892 if (pAddBssParams->staContext.vhtCapable)
Jeff Johnsone7245742012-09-05 17:12:55 -07003893 {
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003894 pAddBssParams->staContext.vhtTxChannelWidthSet =
3895 pBeaconStruct->VHTOperation.chanWidth;
Jeff Johnsone7245742012-09-05 17:12:55 -07003896 }
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003897#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 }
3899 else
3900 {
3901 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3902 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07003903 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pBeaconStruct->HTCaps.mimoPowerSave;
3904 pAddBssParams->staContext.delBASupport = ( tANI_U8 ) pBeaconStruct->HTCaps.delayedBA;
3905 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 ) pBeaconStruct->HTCaps.maximalAMSDUsize;
3906 pAddBssParams->staContext.maxAmpduDensity = pBeaconStruct->HTCaps.mpduDensity;
3907 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pBeaconStruct->HTCaps.dsssCckMode40MHz;
krunal soni71343fb2013-09-16 16:16:26 -07003908 /*
3909 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
3910 * if they are set then we will use what ever Beacon coming from AP
3911 * supports. If these values are set as 0 in ini file then
3912 * we will hardcode this values to 0.
3913 */
3914 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3915 (pMac, WNI_CFG_SHORT_GI_20MHZ,
3916 &shortGi20MhzSupport)))
3917 {
3918 if (VOS_TRUE == shortGi20MhzSupport)
3919 {
3920 pAddBssParams->staContext.fShortGI20Mhz =
3921 (tANI_U8)pBeaconStruct->HTCaps.shortGI20MHz;
3922 }
3923 else
3924 {
3925 pAddBssParams->staContext.fShortGI20Mhz = VOS_FALSE;
3926 }
3927 }
3928 else
3929 {
3930 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
3931 "CFG,setting value to default"));)
3932 pAddBssParams->staContext.fShortGI20Mhz =
3933 WNI_CFG_SHORT_GI_20MHZ_STADEF;
3934 }
3935
3936 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3937 (pMac, WNI_CFG_SHORT_GI_40MHZ,
3938 &shortGi40MhzSupport)))
3939 {
3940 if (VOS_TRUE == shortGi40MhzSupport)
3941 {
3942 pAddBssParams->staContext.fShortGI40Mhz =
3943 (tANI_U8)pBeaconStruct->HTCaps.shortGI40MHz;
3944 }
3945 else
3946 {
3947 pAddBssParams->staContext.fShortGI40Mhz = VOS_FALSE;
3948 }
3949 }
3950 else
3951 {
3952 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
3953 "CFG,setting value to default"));)
3954 pAddBssParams->staContext.fShortGI40Mhz =
3955 WNI_CFG_SHORT_GI_40MHZ_STADEF;
3956 }
3957
Jeff Johnson32d95a32012-09-10 13:15:23 -07003958 pAddBssParams->staContext.maxAmpduSize= pBeaconStruct->HTCaps.maxRxAMPDUFactor;
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08003959 if( pAddBssParams->staContext.vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP )
3960 {
3961 pAddBssParams->staContext.htLdpcCapable = 0;
3962 pAddBssParams->staContext.vhtLdpcCapable = 0;
3963 }
3964 else
3965 {
3966 pAddBssParams->staContext.htLdpcCapable = (tANI_U8)pBeaconStruct->HTCaps.advCodingCap;
3967 pAddBssParams->staContext.vhtLdpcCapable = (tANI_U8)pBeaconStruct->VHTCaps.ldpcCodingCap;
3968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003969
Jeff Johnson32d95a32012-09-10 13:15:23 -07003970 if( pBeaconStruct->HTInfo.present )
3971 pAddBssParams->staContext.rifsMode = pBeaconStruct->HTInfo.rifsMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 }
3973
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303974 //If WMM IE or 802.11E IE is not present and AP is HT AP then enable WMM
3975 if ((psessionEntry->limWmeEnabled && (pBeaconStruct->wmeEdcaPresent || pAddBssParams->staContext.htCapable)) ||
3976 (psessionEntry->limQosEnabled && (pBeaconStruct->edcaPresent || pAddBssParams->staContext.htCapable)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003977 pAddBssParams->staContext.wmmEnabled = 1;
3978 else
3979 pAddBssParams->staContext.wmmEnabled = 0;
3980
3981 //Update the rates
Jeff Johnsone7245742012-09-05 17:12:55 -07003982#ifdef WLAN_FEATURE_11AC
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07003983 limPopulatePeerRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Jeff Johnson32d95a32012-09-10 13:15:23 -07003984 pBeaconStruct->HTCaps.supportedMCSSet, false,psessionEntry,
3985 &pBeaconStruct->VHTCaps);
Jeff Johnsone7245742012-09-05 17:12:55 -07003986#else
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07003987 limPopulatePeerRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Jeff Johnson32d95a32012-09-10 13:15:23 -07003988 pBeaconStruct->HTCaps.supportedMCSSet, false,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003989#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 limFillSupportedRatesInfo(pMac, NULL, &pAddBssParams->staContext.supportedRates,psessionEntry);
3991
3992 }
3993
3994
3995 //Disable BA. It will be set as part of ADDBA negotiation.
3996 for( i = 0; i < STACFG_MAX_TC; i++ )
3997 {
3998 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
3999 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
4000 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
4001 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
4002 }
4003
4004 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
4005
4006#if defined WLAN_FEATURE_VOWIFI
4007 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
4008#endif
4009
4010 pAddBssParams->status = eHAL_STATUS_SUCCESS;
4011 pAddBssParams->respReqd = true;
4012
4013 pAddBssParams->staContext.sessionId = psessionEntry->peSessionId;
4014 pAddBssParams->sessionId = psessionEntry->peSessionId;
4015
4016 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
4017
Bansidhar Gopalacharib099ac62013-06-12 19:02:39 -07004018 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07004019
4020#if defined WLAN_FEATURE_VOWIFI_11R
4021 pAddBssParams->extSetStaKeyParamValid = 0;
4022#endif
4023
Chet Lanctot186b5732013-03-18 10:26:30 -07004024#ifdef WLAN_FEATURE_11W
4025 if (psessionEntry->limRmfEnabled)
4026 {
4027 pAddBssParams->rmfEnabled = 1;
4028 pAddBssParams->staContext.rmfEnabled = 1;
4029 }
4030#endif
4031
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 // Set a new state for MLME
4033
4034 //pMac->lim.gLimMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
4035 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
4036
Jeff Johnsone7245742012-09-05 17:12:55 -07004037 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004038
4039 //we need to defer the message until we get the response back from HAL.
4040 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
4041
4042 msgQ.type = WDA_ADD_BSS_REQ;
4043 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
4044 msgQ.reserved = 0;
4045 msgQ.bodyptr = pAddBssParams;
4046 msgQ.bodyval = 0;
4047
4048 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_BSS_REQ..." ));
Jeff Johnsone7245742012-09-05 17:12:55 -07004049 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004050
4051 retCode = wdaPostCtrlMsg( pMac, &msgQ );
4052 if( eSIR_SUCCESS != retCode)
4053 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004054 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304055 vos_mem_free(pAddBssParams);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004056 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 retCode );
4058 goto returnFailure;
4059
4060 }
4061 else
Jeff Johnson32d95a32012-09-10 13:15:23 -07004062 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304063 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 return retCode;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004065 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004066
4067 returnFailure:
4068 // Clean-up will be done by the caller...
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304069 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 return retCode;
4071}
4072
4073
4074
4075
4076
Jeff Johnson295189b2012-06-20 16:38:30 -07004077
4078/** -------------------------------------------------------------
4079\fn limPrepareAndSendDelStaCnf
4080\brief deletes DPH entry
4081 changes the MLM mode for station.
4082 calls limSendDelStaCnf
4083\param tpAniSirGlobal pMac
4084\param tpDphHashNode pStaDs
4085\return none
4086 -------------------------------------------------------------*/
4087
4088
4089void
4090limPrepareAndSendDelStaCnf(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tSirResultCodes statusCode,tpPESession psessionEntry)
4091{
4092 tANI_U16 staDsAssocId = 0;
4093 tSirMacAddr staDsAddr;
4094 tLimMlmStaContext mlmStaContext;
4095
4096 if(pStaDs == NULL)
4097 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004098 PELOGW(limLog(pMac, LOGW, FL("pStaDs is NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 return;
4100 }
4101 staDsAssocId = pStaDs->assocId;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304102 vos_mem_copy((tANI_U8 *)staDsAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 pStaDs->staAddr,
4104 sizeof(tSirMacAddr));
4105
4106 mlmStaContext = pStaDs->mlmStaContext;
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304107 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
4108 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 {
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304110 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 }
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304112 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry);
4113
4114 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE)||
4115 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 {
4117 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304118 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE,
4119 psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 limSendDelStaCnf(pMac, staDsAddr, staDsAssocId, mlmStaContext, statusCode,psessionEntry);
4122}
4123
4124/** -------------------------------------------------------------
4125\fn limGetStaRateMode
4126\brief Gets the Station Rate Mode.
4127\param tANI_U8 dot11Mode
4128\return none
4129 -------------------------------------------------------------*/
4130tStaRateMode limGetStaRateMode(tANI_U8 dot11Mode)
4131{
4132 switch(dot11Mode)
4133 {
4134 case WNI_CFG_DOT11_MODE_11A:
4135 return eSTA_11a;
4136 case WNI_CFG_DOT11_MODE_11B:
4137 return eSTA_11b;
4138 case WNI_CFG_DOT11_MODE_11G:
4139 return eSTA_11bg;
4140 case WNI_CFG_DOT11_MODE_11N:
4141 return eSTA_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07004142#ifdef WLAN_FEATURE_11AC
4143 case WNI_CFG_DOT11_MODE_11AC:
4144 return eSTA_11ac;
4145#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 case WNI_CFG_DOT11_MODE_ALL:
4147 default:
4148 return eSTA_11n;
4149
4150 }
4151}
4152
4153/** -------------------------------------------------------------
4154\fn limInitPreAuthTimerTable
4155\brief Initialize the Pre Auth Tanle and creates the timer for
4156 each node for the timeout value got from cfg.
4157\param tpAniSirGlobal pMac
4158\param tpLimPreAuthTable pPreAuthTimerTable
4159\return none
4160 -------------------------------------------------------------*/
4161void limInitPreAuthTimerTable(tpAniSirGlobal pMac, tpLimPreAuthTable pPreAuthTimerTable)
4162{
4163 tANI_U32 cfgValue;
4164 tANI_U32 authNodeIdx;
4165 tpLimPreAuthNode pAuthNode = pPreAuthTimerTable->pTable;
4166
4167 // Get AUTH_RSP Timers value
4168
4169 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_RSP_TIMEOUT,
4170 &cfgValue) != eSIR_SUCCESS)
4171 {
4172 /*
4173 ** Could not get AUTH_RSP timeout value
4174 ** from CFG. Log error.
4175 **/
4176 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004177 FL("could not retrieve AUTH_RSP timeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 return;
4179 }
4180
4181 cfgValue = SYS_MS_TO_TICKS(cfgValue);
4182 for(authNodeIdx=0; authNodeIdx<pPreAuthTimerTable->numEntry; authNodeIdx++, pAuthNode++)
4183 {
4184 if (tx_timer_create(&pAuthNode->timer,
4185 "AUTH RESPONSE TIMEOUT",
4186 limAuthResponseTimerHandler,
4187 authNodeIdx,
4188 cfgValue,
4189 0,
4190 TX_NO_ACTIVATE) != TX_SUCCESS)
4191 {
4192 // Cannot create timer. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004193 limLog(pMac, LOGP, FL("Cannot create Auth Rsp timer of Index :%d."), authNodeIdx);
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 return;
4195 }
4196 pAuthNode->authNodeIdx = (tANI_U8)authNodeIdx;
4197 pAuthNode->fFree = 1;
4198 }
4199
4200}
4201
4202/** -------------------------------------------------------------
4203\fn limAcquireFreePreAuthNode
4204\brief Retrives a free Pre Auth node from Pre Auth Table.
4205\param tpAniSirGlobal pMac
4206\param tpLimPreAuthTable pPreAuthTimerTable
4207\return none
4208 -------------------------------------------------------------*/
4209tLimPreAuthNode * limAcquireFreePreAuthNode(tpAniSirGlobal pMac, tpLimPreAuthTable pPreAuthTimerTable)
4210{
4211 tANI_U32 i;
4212 tLimPreAuthNode *pTempNode = pPreAuthTimerTable->pTable;
4213 for (i=0; i<pPreAuthTimerTable->numEntry; i++,pTempNode++)
4214 {
4215 if (pTempNode->fFree == 1)
4216 {
4217 pTempNode->fFree = 0;
4218 return pTempNode;
4219 }
4220 }
4221
4222 return NULL;
4223}
4224
4225/** -------------------------------------------------------------
4226\fn limGetPreAuthNodeFromIndex
4227\brief Depending on the Index this retrives the pre auth node.
4228\param tpAniSirGlobal pMac
4229\param tpLimPreAuthTable pAuthTable
4230\param tANI_U32 authNodeIdx
4231\return none
4232 -------------------------------------------------------------*/
4233tLimPreAuthNode * limGetPreAuthNodeFromIndex(tpAniSirGlobal pMac,
4234 tpLimPreAuthTable pAuthTable, tANI_U32 authNodeIdx)
4235{
4236 if ((authNodeIdx >= pAuthTable->numEntry) || (pAuthTable->pTable == NULL))
4237 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004238 limLog(pMac, LOGE, FL("Invalid Auth Timer Index : %d NumEntry : %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004239 authNodeIdx, pAuthTable->numEntry);
4240 return NULL;
4241 }
4242
4243 return pAuthTable->pTable + authNodeIdx;
4244}
4245
4246/* Util API to check if the channels supported by STA is within range */
4247tSirRetStatus limIsDot11hSupportedChannelsValid(tpAniSirGlobal pMac, tSirAssocReq *assoc)
4248{
4249 /*
4250 * Allow all the stations to join with us.
4251 * 802.11h-2003 11.6.1 => An AP may use the supported channels list for associated STAs
4252 * as an input into an algorithm used to select a new channel for the BSS.
4253 * The specification of the algorithm is beyond the scope of this amendment.
4254 */
4255
4256 return (eSIR_SUCCESS);
4257}
4258
4259/* Util API to check if the txpower supported by STA is within range */
4260tSirRetStatus limIsDot11hPowerCapabilitiesInRange(tpAniSirGlobal pMac, tSirAssocReq *assoc,tpPESession psessionEntry)
4261{
4262 tPowerdBm localMaxTxPower;
4263 tANI_U32 localPwrConstraint;
4264
4265 localMaxTxPower = cfgGetRegulatoryMaxTransmitPower(pMac, psessionEntry->currentOperChannel);
4266
4267 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004268 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004269 return eSIR_FAILURE;
4270 }
4271 localMaxTxPower -= (tPowerdBm)localPwrConstraint;
4272
4273 /**
4274 * The min Tx Power of the associating station should not be greater than (regulatory
4275 * max tx power - local power constraint configured on AP).
4276 */
4277 if(assoc->powerCapability.minTxPower > localMaxTxPower)
4278 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004279 limLog(pMac, LOGW, FL("minTxPower (STA) = %d, localMaxTxPower (AP) = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004280 assoc->powerCapability.minTxPower, localMaxTxPower);
4281 return (eSIR_FAILURE);
4282 }
4283
4284 return (eSIR_SUCCESS);
4285}
4286
4287/** -------------------------------------------------------------
4288\fn limFillRxHighestSupportedRate
4289\brief Fills in the Rx Highest Supported Data Rate field from
4290\ the 'supported MCS set' field in HT capability element.
4291\param tpAniSirGlobal pMac
4292\param tpSirSupportedRates pRates
4293\param tANI_U8* pSupportedMCSSet
4294\return none
4295 -------------------------------------------------------------*/
4296void limFillRxHighestSupportedRate(tpAniSirGlobal pMac, tANI_U16 *rxHighestRate, tANI_U8* pSupportedMCSSet)
4297{
4298 tSirMacRxHighestSupportRate *pRxHighestRate;
4299 tANI_U8 *pBuf;
4300 tANI_U16 rate=0;
4301
4302 pBuf = pSupportedMCSSet + MCS_RX_HIGHEST_SUPPORTED_RATE_BYTE_OFFSET;
4303 rate = limGetU16(pBuf);
4304
4305 pRxHighestRate = (tSirMacRxHighestSupportRate *) &rate;
4306 *rxHighestRate = pRxHighestRate->rate;
4307
4308 return;
4309}
Chet Lanctot186b5732013-03-18 10:26:30 -07004310
4311#ifdef WLAN_FEATURE_11W
4312/** -------------------------------------------------------------
4313\fn limSendSmeUnprotectedMgmtFrameInd
4314\brief Forwards the unprotected management frame to SME.
4315\param tpAniSirGlobal pMac
4316\param frameType - 802.11 frame type
4317\param frame - frame buffer
4318\param sessionId - id for the current session
4319\param psessionEntry - PE session context
4320\return none
4321 -------------------------------------------------------------*/
4322void limSendSmeUnprotectedMgmtFrameInd(
4323 tpAniSirGlobal pMac, tANI_U8 frameType,
4324 tANI_U8 *frame, tANI_U32 frameLen, tANI_U16 sessionId,
4325 tpPESession psessionEntry)
4326{
4327 tSirMsgQ mmhMsg;
4328 tSirSmeUnprotMgmtFrameInd * pSirSmeMgmtFrame = NULL;
4329 tANI_U16 length;
4330
4331 length = sizeof(tSirSmeUnprotMgmtFrameInd) + frameLen;
4332
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304333 pSirSmeMgmtFrame = vos_mem_malloc(length);
4334 if (NULL == pSirSmeMgmtFrame)
Chet Lanctot186b5732013-03-18 10:26:30 -07004335 {
4336 limLog(pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304337 FL("AllocateMemory failed for tSirSmeUnprotectedMgmtFrameInd"));
Chet Lanctot186b5732013-03-18 10:26:30 -07004338 return;
4339 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304340 vos_mem_set((void*)pSirSmeMgmtFrame, length, 0);
Chet Lanctot186b5732013-03-18 10:26:30 -07004341
4342 pSirSmeMgmtFrame->sessionId = sessionId;
4343 pSirSmeMgmtFrame->frameType = frameType;
4344
4345 vos_mem_copy(pSirSmeMgmtFrame->frameBuf, frame, frameLen);
4346 pSirSmeMgmtFrame->frameLen = frameLen;
4347
4348 mmhMsg.type = eWNI_SME_UNPROT_MGMT_FRM_IND;
4349 mmhMsg.bodyptr = pSirSmeMgmtFrame;
4350 mmhMsg.bodyval = 0;
4351
4352 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4353 return;
4354}
4355#endif