blob: f3c5bf65b25eadbea5ff91da7c2f95d3fe67452c [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
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700706#ifdef FEATURE_WLAN_CCX_UPLOAD
707 limSendSmeTsmIEInd(pMac, psessionEntry, 0, 0, 0);
708#else
Jeff Johnson295189b2012-06-20 16:38:30 -0700709 limDeactivateAndChangeTimer(pMac,eLIM_TSM_TIMER);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700710#endif /* FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -0700711#endif
712
713 /**
714 * Update the status for PMM module
715 */
716 pmmResetPmmState(pMac);
717 }
718#ifdef WLAN_DEBUG
719 // increment a debug count
720 pMac->lim.gLimNumRxCleanup++;
721#endif
722
723 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE) {
724 retCode = limDelBss( pMac, pStaDs, psessionEntry->bssIdx, psessionEntry);
725 }
726 else
727 retCode = limDelSta( pMac, pStaDs, true, psessionEntry);
728
729 return retCode;
730
731} /*** end limCleanupRxPath() ***/
732
733
734/**
735 * limSendDelStaCnf()
736 *
737 *FUNCTION:
738 * This function is called to send appropriate CNF message to SME
739 *
740 *LOGIC:
741 *
742 *
743 *ASSUMPTIONS:
744 * NA
745 *
746 *NOTE:
747 * NA
748 *
749 * @param pMac Pointer to Global MAC structure
750 * @param tpAniSirGlobal pMac,
751 * @param tSirMacAddr staDsAddr,
752 * @param tANI_U16 staDsAssocId,
753 * @param tLimMlmStaContext mlmStaContext,
754 * @param tSirResultCodes statusCode
755 *
756 * @return None
757 */
758
759void
760limSendDelStaCnf(tpAniSirGlobal pMac, tSirMacAddr staDsAddr,
761 tANI_U16 staDsAssocId, tLimMlmStaContext mlmStaContext, tSirResultCodes statusCode,tpPESession psessionEntry)
762{
763
764 tLimMlmDisassocCnf mlmDisassocCnf;
765 tLimMlmDeauthCnf mlmDeauthCnf;
766 tLimMlmPurgeStaInd mlmPurgeStaInd;
767
768 if ((psessionEntry->limSystemRole == eLIM_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
769 {
770 // Set BSSID at CFG to null
771 tSirMacAddr nullAddr = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
772 #if 0
773 if (cfgSetStr(pMac, WNI_CFG_BSSID, (tANI_U8 *) &nullAddr,
774 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
775 {
776 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700777 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700778
779 return;
780 }
781 #endif//TO SUPPORT BT-AMP
782
783 sirCopyMacAddr(nullAddr,psessionEntry->bssId);
784
785 // Free up buffer allocated for JoinReq held by
786 // MLM state machine
787 if (psessionEntry->pLimMlmJoinReq)
788 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530789 vos_mem_free(psessionEntry->pLimMlmJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700790 psessionEntry->pLimMlmJoinReq = NULL;
791 }
792
793 psessionEntry->limAID = 0;
794
795
796 }
797
798 if ((mlmStaContext.cleanupTrigger ==
799 eLIM_HOST_DISASSOC) ||
800 (mlmStaContext.cleanupTrigger ==
801 eLIM_LINK_MONITORING_DISASSOC) ||
802 (mlmStaContext.cleanupTrigger ==
803 eLIM_PROMISCUOUS_MODE_DISASSOC))
804 {
805 /**
806 * Host or LMM driven Disassociation.
807 * Issue Disassoc Confirm to SME.
808 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700809 limLog( pMac, LOGW, FL("Lim Posting DISASSOC_CNF to Sme. Trigger: %X"), mlmStaContext.cleanupTrigger);
Jeff Johnson295189b2012-06-20 16:38:30 -0700810
811
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530812 vos_mem_copy((tANI_U8 *) &mlmDisassocCnf.peerMacAddr,
813 (tANI_U8 *) staDsAddr,
814 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700815 mlmDisassocCnf.resultCode = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700816 mlmDisassocCnf.disassocTrigger =
817 mlmStaContext.cleanupTrigger;
818 /* Update PE session Id*/
819 mlmDisassocCnf.sessionId = psessionEntry->peSessionId;
820
821 limPostSmeMessage(pMac,
822 LIM_MLM_DISASSOC_CNF,
823 (tANI_U32 *) &mlmDisassocCnf);
824 }
825 else if ((mlmStaContext.cleanupTrigger ==
826 eLIM_HOST_DEAUTH) ||
827 (mlmStaContext.cleanupTrigger ==
828 eLIM_LINK_MONITORING_DEAUTH))
829 {
830 /**
831 * Host or LMM driven Deauthentication.
832 * Issue Deauth Confirm to SME.
833 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700834 limLog( pMac, LOGW, FL("Lim Posting DEAUTH_CNF to Sme. Trigger: %X"), mlmStaContext.cleanupTrigger);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530835 vos_mem_copy((tANI_U8 *) &mlmDeauthCnf.peerMacAddr,
836 (tANI_U8 *) staDsAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 sizeof(tSirMacAddr));
838 mlmDeauthCnf.resultCode = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 mlmDeauthCnf.deauthTrigger =
840 mlmStaContext.cleanupTrigger;
841 /* PE session Id */
842 mlmDeauthCnf.sessionId = psessionEntry->peSessionId;
843
844 limPostSmeMessage(pMac,
845 LIM_MLM_DEAUTH_CNF,
846 (tANI_U32 *) &mlmDeauthCnf);
847 }
848 else if ((mlmStaContext.cleanupTrigger ==
849 eLIM_PEER_ENTITY_DISASSOC) ||
850 (mlmStaContext.cleanupTrigger ==
851 eLIM_PEER_ENTITY_DEAUTH))
852 {
853 /**
854 * Received Disassociation/Deauthentication from peer.
855 * Issue Purge Ind to SME.
856 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700857 limLog( pMac, LOGW, FL("Lim Posting PURGE_STA_IND to Sme. Trigger: %X"), mlmStaContext.cleanupTrigger) ;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530858 vos_mem_copy((tANI_U8 *) &mlmPurgeStaInd.peerMacAddr,
859 (tANI_U8 *) staDsAddr,
860 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -0700861 mlmPurgeStaInd.reasonCode = (tANI_U8) mlmStaContext.disassocReason;
862 mlmPurgeStaInd.aid = staDsAssocId;
863 mlmPurgeStaInd.purgeTrigger = mlmStaContext.cleanupTrigger;
864 mlmPurgeStaInd.sessionId = psessionEntry->peSessionId;
865
866 limPostSmeMessage(pMac,
867 LIM_MLM_PURGE_STA_IND,
868 (tANI_U32 *) &mlmPurgeStaInd);
869 }
870 else if(mlmStaContext.cleanupTrigger == eLIM_JOIN_FAILURE)
871 {
872 //PE setup the peer entry in HW upfront, right after join is completed.
873 //If there is a failure during rest of the assoc sequence, this context needs to be cleaned up.
874 tANI_U8 smesessionId;
875 tANI_U16 smetransactionId;
876
877 smesessionId = psessionEntry->smeSessionId;
878 smetransactionId = psessionEntry->transactionId;
879
880 psessionEntry->limSmeState = eLIM_SME_JOIN_FAILURE_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -0700881 MTRACE(macTrace(pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId, psessionEntry->limSmeState));
Jeff Johnson295189b2012-06-20 16:38:30 -0700882
Jeff Johnsone7245742012-09-05 17:12:55 -0700883 //if it is a reassoc failure to join new AP
Madan Mohan Koyyalamudif33324b2012-11-06 19:16:17 -0800884 if((mlmStaContext.resultCode == eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE) ||
885 (mlmStaContext.resultCode == eSIR_SME_FT_REASSOC_FAILURE))
Jeff Johnsone7245742012-09-05 17:12:55 -0700886 {
887 if(mlmStaContext.resultCode != eSIR_SME_SUCCESS )
888 {
889 peDeleteSession(pMac, psessionEntry);
890 psessionEntry = NULL;
891 }
892
893 limSendSmeJoinReassocRsp(pMac, eWNI_SME_REASSOC_RSP,
894 mlmStaContext.resultCode, mlmStaContext.protStatusCode, psessionEntry,
895 smesessionId, smetransactionId);
896 }
897 else
898 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530899 vos_mem_free(psessionEntry->pLimJoinReq);
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 psessionEntry->pLimJoinReq = NULL;
901
902 if(mlmStaContext.resultCode != eSIR_SME_SUCCESS)
903 {
904 peDeleteSession(pMac,psessionEntry);
905 psessionEntry = NULL;
906 }
907
908 limSendSmeJoinReassocRsp(pMac, eWNI_SME_JOIN_RSP, mlmStaContext.resultCode, mlmStaContext.protStatusCode,
909 psessionEntry, smesessionId, smetransactionId);
Jeff Johnsone7245742012-09-05 17:12:55 -0700910 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700911
912 }
913
914 if((NULL != psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -0700915 && (eLIM_AP_ROLE != psessionEntry->limSystemRole )
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 )
917 {
918 peDeleteSession(pMac,psessionEntry);
919 psessionEntry = NULL;
920 }
921}
922
923/**
924 * limRejectAssociation()
925 *
926 *FUNCTION:
927 * This function is called whenever Re/Association Request need
928 * to be rejected due to failure in assigning an AID or failure
929 * in adding STA context at Polaris or reject by applications.
930 *
931 *LOGIC:
932 * Resources allocated if any are freedup and (Re) Association
933 * Response frame is sent to requesting STA. Pre-Auth context
934 * will be added for this STA if it does not exist already
935 *
936 *ASSUMPTIONS:
937 *
938 *NOTE:
939 *
940 * @param *pBd - A pointer to Buffer descriptor + associated PDUs
941 * @param subType - Indicates whether it is Association Request (=0) or
942 * Reassociation Request (=1) frame
943 * @param addPreAuthContext - Indicates whether pre-auth context
944 * to be added for this STA
945 * @param authType - Indicates auth type to be added
946 * @param staId - Indicates staId of the STA being rejected
947 * association
948 * @param deleteSta - Indicates whether to delete STA context
949 * at Polaris
950 * @param rCode - Indicates what reasonCode to be sent in
951 * Re/Assoc response to STA
952 *
953 * @return None
954 */
955
956void
957limRejectAssociation(tpAniSirGlobal pMac, tSirMacAddr peerAddr, tANI_U8 subType,
958 tANI_U8 addPreAuthContext, tAniAuthType authType,
959 tANI_U16 staId, tANI_U8 deleteSta, tSirResultCodes rCode, tpPESession psessionEntry )
960{
961 tpDphHashNode pStaDs;
962
963 if (addPreAuthContext)
964 {
965 // Create entry for this STA in pre-auth list
966 struct tLimPreAuthNode *pAuthNode;
967
968 pAuthNode = limAcquireFreePreAuthNode(pMac, &pMac->lim.gLimPreAuthTimerTable);
969
970 if (pAuthNode)
971 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +0530972 vos_mem_copy((tANI_U8 *) pAuthNode->peerMacAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700973 peerAddr,
974 sizeof(tSirMacAddr));
975 pAuthNode->fTimerStarted = 0;
976 pAuthNode->mlmState = eLIM_MLM_AUTHENTICATED_STATE;
977 pAuthNode->authType = (tAniAuthType) authType;
978 limAddPreAuthNode(pMac, pAuthNode);
979 }
980 }
981
982 if (deleteSta == true)
983 {
984 pStaDs = dphGetHashEntry(pMac, staId, &psessionEntry->dph.dphHashTable);
985
986 if (pStaDs == NULL)
987 {
988 limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -0700989 FL("No STA context, yet rejecting Association"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700990
991 return;
992 }
993
994 /**
995 * Polaris has state for this STA.
996 * Trigger cleanup.
997 */
998 pStaDs->mlmStaContext.cleanupTrigger = eLIM_REASSOC_REJECT;
999
1000 // Receive path cleanup
1001 limCleanupRxPath(pMac, pStaDs, psessionEntry);
1002
1003 // Send Re/Association Response with
1004 // status code to requesting STA.
1005 limSendAssocRspMgmtFrame(pMac,
1006 rCode,
1007 0,
1008 peerAddr,
1009 subType, 0,psessionEntry);
1010
1011 if ( psessionEntry->parsedAssocReq[pStaDs->assocId] != NULL)
1012 {
1013 // Assoction confirmation is complete, free the copy of association request frame
1014 if ( ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame)
1015 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301016 vos_mem_free(((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame);
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 ((tpSirAssocReq)(psessionEntry->parsedAssocReq[pStaDs->assocId]))->assocReqFrame = NULL;
1018 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301019 vos_mem_free(psessionEntry->parsedAssocReq[pStaDs->assocId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 psessionEntry->parsedAssocReq[pStaDs->assocId] = NULL;
1021 }
1022 }
1023 else
1024 {
1025 limSendAssocRspMgmtFrame(pMac,
1026 eSIR_MAC_MAX_ASSOC_STA_REACHED_STATUS,
1027 1,
1028 peerAddr,
1029 subType, 0,psessionEntry);
1030 // Log error
1031 limLog(pMac, LOGW,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001032 FL("received Re/Assoc req when max associated STAs reached from "));
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 limPrintMacAddr(pMac, peerAddr, LOGW);
1034 limSendSmeMaxAssocExceededNtf(pMac, peerAddr, psessionEntry->smeSessionId);
1035 }
1036} /*** end limRejectAssociation() ***/
1037
Jeff Johnson295189b2012-06-20 16:38:30 -07001038
1039/** -------------------------------------------------------------
1040\fn limDecideApProtectionOnHt20Delete
1041\brief protection related function while HT20 station is getting deleted.
1042\param tpAniSirGlobal pMac
1043\param tpDphHashNode pStaDs
1044\param tpUpdateBeaconParams pBeaconParams
1045\return None
1046 -------------------------------------------------------------*/
1047static void
1048limDecideApProtectionOnHt20Delete(tpAniSirGlobal pMac,
1049 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1050{
1051 tANI_U32 i = 0;
1052 PELOG1( limLog(pMac, LOG1, FL("(%d) A HT 20 STA is disassociated. Addr is "),
1053 psessionEntry->gLimHt20Params.numSta);
1054 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1055 if (psessionEntry->gLimHt20Params.numSta > 0)
1056 {
1057 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1058 {
1059 if (psessionEntry->protStaCache[i].active)
1060 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301061 if (vos_mem_compare(psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 pStaDs->staAddr, sizeof(tSirMacAddr)))
1063 {
1064 psessionEntry->gLimHt20Params.numSta--;
1065 psessionEntry->protStaCache[i].active = false;
1066 break;
1067 }
1068 }
1069 }
1070 }
1071
1072 if (psessionEntry->gLimHt20Params.numSta == 0)
1073 {
1074 // disable protection
1075 limEnableHT20Protection(pMac, false, false, pBeaconParams,psessionEntry);
1076 }
1077}
1078/** -------------------------------------------------------------
1079\fn limDecideApProtectionOnDelete
1080\brief Decides about protection related settings when a station is getting deleted.
1081\param tpAniSirGlobal pMac
1082\param tpDphHashNode pStaDs
1083\param tpUpdateBeaconParams pBeaconParams
1084\return None
1085 -------------------------------------------------------------*/
1086void
1087limDecideApProtectionOnDelete(tpAniSirGlobal pMac,
1088 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams,tpPESession psessionEntry)
1089{
1090 tANI_U32 phyMode;
1091 tHalBitVal erpEnabled = eHAL_CLEAR;
1092 tSirRFBand rfBand = SIR_BAND_UNKNOWN;
1093 tANI_U32 i;
1094
1095 if(NULL == pStaDs)
1096 return;
1097
1098 limGetRfBand(pMac, &rfBand, psessionEntry);
1099 if(SIR_BAND_5_GHZ == rfBand)
1100 {
1101 //we are HT. if we are 11A, then protection is not required.
Jeff Johnsone7245742012-09-05 17:12:55 -07001102 if(true == psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 {
1104 //we are HT and 11A station is leaving.
1105 //protection consideration required.
1106 //HT station leaving ==> this case is commonly handled between both the bands below.
1107 if((psessionEntry->beaconParams.llaCoexist) &&
1108 (false == pStaDs->mlmStaContext.htCapability))
1109 {
1110 PELOG1(limLog(pMac, LOG1, FL("(%d) A 11A STA is disassociated. Addr is "),
1111 psessionEntry->gLim11aParams.numSta);
1112 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1113 if (psessionEntry->gLim11aParams.numSta > 0)
1114 {
1115 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1116 {
1117 if (psessionEntry->protStaCache[i].active)
1118 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301119 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001120 pStaDs->staAddr, sizeof(tSirMacAddr)))
1121 {
1122 psessionEntry->gLim11aParams.numSta--;
1123 psessionEntry->protStaCache[i].active = false;
1124 break;
1125 }
1126 }
1127 }
1128 }
1129
1130 if(psessionEntry->gLim11aParams.numSta == 0)
1131 {
1132 // disable protection
1133 limEnable11aProtection(pMac, false, false, pBeaconParams,psessionEntry);
1134 }
1135 }
1136 }
1137 }
1138 else if(SIR_BAND_2_4_GHZ == rfBand)
1139 {
1140 limGetPhyMode(pMac, &phyMode, psessionEntry);
1141
1142 erpEnabled = pStaDs->erpEnabled;
1143 //we are HT or 11G and 11B station is getting deleted.
1144 if (((phyMode == WNI_CFG_PHY_MODE_11G) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07001145 psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001146 (erpEnabled == eHAL_CLEAR))
1147 {
1148 PELOG1(limLog(pMac, LOG1, FL("(%d) A legacy STA is disassociated. Addr is "),
1149 psessionEntry->gLim11bParams.numSta);
1150 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1151 if (psessionEntry->gLim11bParams.numSta > 0)
1152 {
1153 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1154 {
1155 if (psessionEntry->protStaCache[i].active)
1156 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301157 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001158 pStaDs->staAddr, sizeof(tSirMacAddr)))
1159 {
1160 psessionEntry->gLim11bParams.numSta--;
1161 psessionEntry->protStaCache[i].active = false;
1162 break;
1163 }
1164 }
1165 }
1166 }
1167
1168 if (psessionEntry->gLim11bParams.numSta == 0)
1169 {
1170 // disable protection
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001171 PELOG1(limLog(pMac, LOG1, FL("No 11B STA exists"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 limEnable11gProtection(pMac, false, false, pBeaconParams,psessionEntry);
1173 }
1174 }
1175 //(non-11B station is leaving) or (we are not 11G or HT AP)
Jeff Johnsone7245742012-09-05 17:12:55 -07001176 else if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 { //we are HT AP and non-11B station is leaving.
1178
1179 //11g station is leaving
1180 if(!pStaDs->mlmStaContext.htCapability)
1181 {
1182 PELOG1(limLog(pMac, LOG1, FL("(%d) A 11g STA is disassociated. Addr is "),
1183 psessionEntry->gLim11bParams.numSta);
1184 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1185 if (psessionEntry->gLim11gParams.numSta > 0)
1186 {
1187 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1188 {
1189 if (psessionEntry->protStaCache[i].active)
1190 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301191 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001192 pStaDs->staAddr, sizeof(tSirMacAddr)))
1193 {
1194 psessionEntry->gLim11gParams.numSta--;
1195 psessionEntry->protStaCache[i].active = false;
1196 break;
1197 }
1198 }
1199 }
1200 }
1201
1202 if (psessionEntry->gLim11gParams.numSta == 0)
1203 {
1204 // disable protection
1205 limEnableHtProtectionFrom11g(pMac, false, false, pBeaconParams,psessionEntry);
1206 }
1207 }
1208 }
1209 }
1210
1211 //LSIG TXOP not supporting staiton leaving. applies to 2.4 as well as 5 GHZ.
Jeff Johnsone7245742012-09-05 17:12:55 -07001212 if((true == psessionEntry->htCapability) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001213 (true == pStaDs->mlmStaContext.htCapability))
1214 {
1215 //HT non-GF leaving
1216 if(!pStaDs->htGreenfield)
1217 {
1218 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-GF STA is disassociated. Addr is "),
1219 psessionEntry->gLimNonGfParams.numSta);
1220 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1221 if (psessionEntry->gLimNonGfParams.numSta > 0)
1222 {
1223 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1224 {
1225 if (psessionEntry->protStaCache[i].active)
1226 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301227 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 pStaDs->staAddr, sizeof(tSirMacAddr)))
1229 {
1230 psessionEntry->gLimNonGfParams.numSta--;
1231 psessionEntry->protStaCache[i].active = false;
1232 break;
1233 }
1234 }
1235 }
1236 }
1237
1238 if (psessionEntry->gLimNonGfParams.numSta == 0)
1239 {
1240 // disable protection
1241 limEnableHTNonGfProtection(pMac, false, false, pBeaconParams,psessionEntry);
1242 }
1243 }
1244 //HT 20Mhz station leaving.
1245 if(psessionEntry->beaconParams.ht20Coexist &&
1246 (eHT_CHANNEL_WIDTH_20MHZ == pStaDs->htSupportedChannelWidthSet))
1247 {
1248 limDecideApProtectionOnHt20Delete(pMac, pStaDs, pBeaconParams,psessionEntry);
1249 }
1250
1251 if(false == psessionEntry->beaconParams.fLsigTXOPProtectionFullSupport &&
1252 (false == pStaDs->htLsigTXOPProtection))
1253 {
1254 PELOG1( limLog(pMac, LOG1, FL("(%d) A HT LSIG not supporting STA is disassociated. Addr is "),
1255 psessionEntry->gLimLsigTxopParams.numSta);
1256 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1257 if (psessionEntry->gLimLsigTxopParams.numSta > 0)
1258 {
1259 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1260 {
1261 if (psessionEntry->protStaCache[i].active)
1262 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301263 if (vos_mem_compare( psessionEntry->protStaCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001264 pStaDs->staAddr, sizeof(tSirMacAddr)))
1265 {
1266 psessionEntry->gLimLsigTxopParams.numSta--;
1267 psessionEntry->protStaCache[i].active = false;
1268 break;
1269 }
1270 }
1271 }
1272 }
1273
1274 if (psessionEntry->gLimLsigTxopParams.numSta == 0)
1275 {
1276 // disable protection
1277 limEnableHTLsigTxopProtection(pMac, true, false, pBeaconParams,psessionEntry);
1278 }
1279 }
1280 }
1281}
1282
Jeff Johnson295189b2012-06-20 16:38:30 -07001283
1284
1285/** -------------------------------------------------------------
1286\fn limDecideShortPreamble
1287\brief Decides about any short preamble reated change because of new station joining.
1288\param tpAniSirGlobal pMac
1289\param tpDphHashNode pStaDs
1290\param tpUpdateBeaconParams pBeaconParams
1291\return None
1292 -------------------------------------------------------------*/
1293void limDecideShortPreamble(tpAniSirGlobal pMac,
1294 tpDphHashNode pStaDs, tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry )
1295{
1296 tANI_U32 i;
1297
1298 if (pStaDs->shortPreambleEnabled == eHAL_CLEAR)
1299 {
1300 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-short preamble STA is disassociated. Addr is "),
1301 psessionEntry->gLimNoShortParams.numNonShortPreambleSta);
1302 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1303 if (psessionEntry->gLimNoShortParams.numNonShortPreambleSta > 0)
1304 {
1305 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1306 {
1307 if (psessionEntry->gLimNoShortParams.staNoShortCache[i].active)
1308 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301309 if (vos_mem_compare( psessionEntry->gLimNoShortParams.staNoShortCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001310 pStaDs->staAddr, sizeof(tSirMacAddr)))
1311 {
1312 psessionEntry->gLimNoShortParams.numNonShortPreambleSta--;
1313 psessionEntry->gLimNoShortParams.staNoShortCache[i].active = false;
1314 break;
1315 }
1316 }
1317 }
1318 }
1319
1320 if (psessionEntry->gLimNoShortParams.numNonShortPreambleSta == 0)
1321 {
1322 // enable short preamble
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001323 PELOG1(limLog(pMac, LOG1, FL("All associated STAs have short preamble support now."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301325 vos_mem_set((tANI_U8 *)&psessionEntry->gLimNoShortParams,
1326 sizeof(tLimNoShortParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001327 if (limEnableShortPreamble(pMac, true, pBeaconParams, psessionEntry) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001328 PELOGE(limLog(pMac, LOGE, FL("Cannot enable short preamble"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 }
1330 }
1331}
1332
1333/** -------------------------------------------------------------
1334\fn limDecideShortSlot
1335\brief Decides about any short slot time related change because of station leaving the BSS.
1336\param tpAniSirGlobal pMac
1337\param tpDphHashNode pStaDs
1338\return None
1339 -------------------------------------------------------------*/
1340
1341void
1342limDecideShortSlot(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1343 tpUpdateBeaconParams pBeaconParams, tpPESession psessionEntry)
1344{
1345 tANI_U32 i, val;
1346 if (pStaDs->shortSlotTimeEnabled == eHAL_CLEAR)
1347 {
1348 PELOG1(limLog(pMac, LOG1, FL("(%d) A non-short slottime STA is disassociated. Addr is "),
1349 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta);
1350 limPrintMacAddr(pMac, pStaDs->staAddr, LOG1);)
1351
Jeff Johnson295189b2012-06-20 16:38:30 -07001352 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
1353 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta> 0)
1354 {
1355 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1356 {
1357 if (psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active)
1358 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301359 if (vos_mem_compare(psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 pStaDs->staAddr, sizeof(tSirMacAddr)))
1361 {
1362 psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta--;
1363 psessionEntry->gLimNoShortSlotParams.staNoShortSlotCache[i].active = false;
1364 break;
1365 }
1366 }
1367 }
1368 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001369 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001370 {
1371 if (pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta> 0)
1372 {
1373 for (i=0; i<LIM_PROT_STA_CACHE_SIZE; i++)
1374 {
1375 if (pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active)
1376 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301377 if (vos_mem_compare(pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 pStaDs->staAddr, sizeof(tSirMacAddr)))
1379 {
1380 pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta--;
1381 pMac->lim.gLimNoShortSlotParams.staNoShortSlotCache[i].active = false;
1382 break;
1383 }
1384 }
1385 }
1386 }
1387 }
1388
1389 wlan_cfgGetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, &val);
1390
Jeff Johnson295189b2012-06-20 16:38:30 -07001391 if ( (psessionEntry->limSystemRole == eLIM_AP_ROLE ) &&
1392 (val && psessionEntry->gLimNoShortSlotParams.numNonShortSlotSta == 0))
1393 {
1394 // enable short slot time
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001395 PELOG1(limLog(pMac, LOG1, FL("All associated STAs have short slot time support now."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001396 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301397 vos_mem_set((tANI_U8 *)&psessionEntry->gLimNoShortSlotParams,
1398 sizeof(tLimNoShortSlotParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001399 // in case of AP set SHORT_SLOT_TIME to enable
1400 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1401 {
1402 pBeaconParams->fShortSlotTime = true;
1403 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001404 psessionEntry->shortSlotTimeSupported = true;
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 }
1406 }
1407 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001408 {
1409 if (val && pMac->lim.gLimNoShortSlotParams.numNonShortSlotSta == 0)
1410 {
1411 // enable short slot time
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001412 PELOG1(limLog(pMac, LOG1, FL("All associated STAs have short slot time support now."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 //reset the cache
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301414 vos_mem_set((tANI_U8 *)&pMac->lim.gLimNoShortSlotParams,
1415 sizeof(tLimNoShortSlotParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001416 // in case of AP set SHORT_SLOT_TIME to enable
1417 if (psessionEntry->limSystemRole == eLIM_AP_ROLE)
1418 {
1419 pBeaconParams->fShortSlotTime = true;
1420 pBeaconParams->paramChangeBitmap |= PARAM_SHORT_SLOT_TIME_CHANGED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001421 psessionEntry->shortSlotTimeSupported = true;
1422 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 }
1424 }
1425 }
1426}
1427
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07001428void
1429limPostReassocFailure(tpAniSirGlobal pMac,
1430 tSirResultCodes resultCode,
1431 tANI_U16 protStatusCode,tpPESession psessionEntry)
1432{
1433 tLimMlmReassocCnf mlmReassocCnf;
1434
1435 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1436 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
1437
1438 // 'Change' timer for future activations
1439 limDeactivateAndChangeTimer(pMac, eLIM_REASSOC_FAIL_TIMER);
1440
1441 mlmReassocCnf.resultCode = resultCode;
1442 mlmReassocCnf.protStatusCode = protStatusCode;
1443 /* Update PE session Id */
1444 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1445 limPostSmeMessage(pMac,
1446 LIM_MLM_REASSOC_CNF,
1447 (tANI_U32 *) &mlmReassocCnf);
1448} /*** end limPostReassocFailure() ***/
1449
Jeff Johnson295189b2012-06-20 16:38:30 -07001450/**
1451 * limRestorePreReassocState()
1452 *
1453 *FUNCTION:
1454 * This function is called on STA role whenever Reasociation
1455 * Response with a reject code is received from AP.
1456 *
1457 *LOGIC:
1458 * Reassociation failure timer is stopped, Old (or current) AP's
1459 * context is restored both at Polaris & software
1460 *
1461 *ASSUMPTIONS:
1462 *
1463 *NOTE:
1464 *
1465 * @param pMac - Pointer to Global MAC structure
1466 * @param resultCode - Result code that specifies why Reassociation
1467 * attemp failed
1468 *
1469 * @return None
1470 */
1471
1472void
1473limRestorePreReassocState(tpAniSirGlobal pMac,
1474 tSirResultCodes resultCode,
1475 tANI_U16 protStatusCode,tpPESession psessionEntry)
1476{
Jeff Johnsone7245742012-09-05 17:12:55 -07001477 tANI_U8 chanNum, secChanOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 tLimMlmReassocCnf mlmReassocCnf;
1479
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 psessionEntry->limMlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001481 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_LINK_ESTABLISHED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07001482
1483 // 'Change' timer for future activations
1484 limDeactivateAndChangeTimer(pMac, eLIM_REASSOC_FAIL_TIMER);
1485
1486 // Update BSSID at CFG database
1487 #if 0
1488 if (cfgSetStr(pMac, WNI_CFG_BSSID,
1489 pMac->lim.gLimCurrentBssId,
1490 sizeof(tSirMacAddr)) != eSIR_SUCCESS)
1491 {
1492 /// Could not update BSSID at CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001493 limLog(pMac, LOGP, FL("could not update BSSID at CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001494 return;
1495 }
Madan Mohan Koyyalamudi70322d52012-10-18 20:07:33 -07001496 #endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001497
1498 // chanNum = pMac->lim.gLimCurrentChannelId;
1499
1500 /* To support BT-AMP */
1501 chanNum = psessionEntry->currentOperChannel;
Jeff Johnsone7245742012-09-05 17:12:55 -07001502 secChanOffset = psessionEntry->htSecondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07001503
Jeff Johnsone7245742012-09-05 17:12:55 -07001504 limSetChannel(pMac, chanNum, secChanOffset, psessionEntry->maxTxPower, psessionEntry->peSessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001505
1506 /** @ToDo : Need to Integrate the STOP the DataTransfer to the AP from 11H code */
1507
1508 mlmReassocCnf.resultCode = resultCode;
1509 mlmReassocCnf.protStatusCode = protStatusCode;
1510 /* Update PE session Id */
1511 mlmReassocCnf.sessionId = psessionEntry->peSessionId;
1512 limPostSmeMessage(pMac,
1513 LIM_MLM_REASSOC_CNF,
1514 (tANI_U32 *) &mlmReassocCnf);
1515} /*** end limRestorePreReassocState() ***/
1516
1517
1518
1519/**
1520 * limIsReassocInProgress()
1521 *
1522 *FUNCTION:
1523 * This function is called to see if STA is in wt-reassoc-rsp state.
1524 *
1525 *LOGIC:
1526 *
1527 *ASSUMPTIONS:
1528 *
1529 *NOTE:
1530 *
1531 * @param pMac - Pointer to Global MAC structure
1532 *
1533 * @return eANI_BOOLEAN_TRUE When STA is waiting for Reassoc response from AP \n
1534 * else eANI_BOOLEAN_FALSE
1535 */
1536
1537eAniBoolean
1538limIsReassocInProgress(tpAniSirGlobal pMac,tpPESession psessionEntry)
1539{
Dhanashri Atreaf3e84d2013-01-18 18:03:06 -08001540 if (psessionEntry == NULL)
1541 {
1542 return eANI_BOOLEAN_FALSE;
1543 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 if(((psessionEntry->limSystemRole == eLIM_STA_ROLE) || (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))&&
1545 ((psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_STATE) ||
1546 (psessionEntry->limSmeState == eLIM_SME_WT_REASSOC_LINK_FAIL_STATE)))
1547 return eANI_BOOLEAN_TRUE;
1548
1549 return eANI_BOOLEAN_FALSE;
1550} /*** end limIsReassocInProgress() ***/
1551
Jeff Johnsone7245742012-09-05 17:12:55 -07001552#ifdef WLAN_FEATURE_11AC
1553tSirRetStatus limPopulateVhtMcsSet(tpAniSirGlobal pMac,
1554 tpSirSupportedRates pRates,
1555 tDot11fIEVHTCaps *pPeerVHTCaps,
1556 tpPESession psessionEntry)
1557{
1558 tANI_U32 val;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001559 tANI_U32 selfStaDot11Mode=0;
1560 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001561
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001562// if(IS_DOT11_MODE_VHT(psessionEntry->dot11mode))
1563 if (IS_DOT11_MODE_VHT(selfStaDot11Mode))
Jeff Johnsone7245742012-09-05 17:12:55 -07001564 {
1565 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_RX_MCS_MAP,&val) !=
1566 eSIR_SUCCESS )
1567 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001568 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX MCS MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001569 goto error;
1570 }
1571 pRates->vhtRxMCSMap = (tANI_U16)val;
1572
1573 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_TX_MCS_MAP,&val ) !=
1574 eSIR_SUCCESS )
1575 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001576 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT TX MCS MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001577 goto error;
1578 }
1579 pRates->vhtTxMCSMap = (tANI_U16)val;
1580
1581 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE,&val ) !=
1582 eSIR_SUCCESS )
1583 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001584 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX Supported data rate MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001585 goto error;
1586 }
1587 pRates->vhtRxHighestDataRate = (tANI_U16)val;
1588
1589 if ( wlan_cfgGetInt( pMac,WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE,&val ) !=
1590 eSIR_SUCCESS )
1591 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001592 PELOGE(limLog(pMac, LOGE, FL("could not retrieve VHT RX Supported data rate MAP"));)
Jeff Johnsone7245742012-09-05 17:12:55 -07001593 goto error;
1594 }
1595 pRates->vhtTxHighestDataRate = (tANI_U16)val;
1596
1597 if( pPeerVHTCaps != NULL)
1598 {
1599 pRates->vhtTxHighestDataRate = SIR_MIN(pRates->vhtTxHighestDataRate, pPeerVHTCaps->txSupDataRate);
1600 pRates->vhtRxHighestDataRate = SIR_MIN(pRates->vhtRxHighestDataRate, pPeerVHTCaps->rxHighSupDataRate);
1601
Jeff Johnson1250df42012-12-10 14:31:52 -08001602 // Acquire PEER MCS map if we exceed.
Jeff Johnsone7245742012-09-05 17:12:55 -07001603 // We compare/update only the last 2 bits of the map as we support only single BSS.
1604 // Firmware takes care of this comparison
1605 pRates->vhtRxMCSMap &= ~(0x3); // Clearing the last 2 bits in the bitmap
1606 pRates->vhtRxMCSMap |= (pPeerVHTCaps->rxMCSMap & 0x3); // Updating the last 2 bits in the bitmap
1607
1608 // Firmware takes care of this comparison
1609 pRates->vhtTxMCSMap &= ~(0x3); // Clearing the last 2 bits in the bitmap
1610 pRates->vhtTxMCSMap |= (pPeerVHTCaps->txMCSMap & 0x3); // Updating the last 2 bits in the bitmap
1611 }
1612 }
1613 return eSIR_SUCCESS;
1614error:
1615
1616 return eSIR_FAILURE;
1617
1618}
1619#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001620
1621/**
1622 * limPopulateOwnRateSet
1623 *
1624 * FUNCTION:
1625 * This function is called by limProcessAssocRsp() or
1626 * limAddStaInIBSS()
1627 * - It creates a combined rate set of 12 rates max which
1628 * comprises the basic and extended rates read from CFG
1629 * - It sorts the combined rate Set and copy it in the
1630 * rate array of the pSTA descriptor
1631 * - It sets the erpEnabled bit of the STA descriptor
1632 *
1633 * NOTE:
1634 * ERP bit is set iff the dph PHY mode is 11G and there is at least
1635 * an A rate in the supported or extended rate sets
1636 *
1637 * @param pMac - Pointer to Global MAC structure
1638 * @param basicOnly - When passed value is true, only basic
1639 * rates are copied to DPH node else
1640 * all supported rates are copied
1641 * @return eSIR_SUCCESS or eSIR_FAILURE
1642 *
1643 */
Jeff Johnsone7245742012-09-05 17:12:55 -07001644#ifdef WLAN_FEATURE_11AC
1645tSirRetStatus
1646limPopulateOwnRateSet(tpAniSirGlobal pMac,
1647 tpSirSupportedRates pRates,
1648 tANI_U8* pSupportedMCSSet,
1649 tANI_U8 basicOnly,
1650 tpPESession psessionEntry,
1651 tDot11fIEVHTCaps *pVHTCaps)
1652#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001653tSirRetStatus
1654limPopulateOwnRateSet(tpAniSirGlobal pMac,
1655 tpSirSupportedRates pRates,
1656 tANI_U8* pSupportedMCSSet,
1657 tANI_U8 basicOnly,
1658 tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07001659#endif
1660
Jeff Johnson295189b2012-06-20 16:38:30 -07001661{
1662 tSirMacRateSet tempRateSet;
1663 tSirMacRateSet tempRateSet2;
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301664 tANI_U32 i,j,val,min,isArate;
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 tANI_U32 phyMode = 0;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001666 tANI_U32 selfStaDot11Mode=0;
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301667
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 isArate = 0;
1669
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001670 wlan_cfgGetInt(pMac, WNI_CFG_DOT11_MODE, &selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 limGetPhyMode(pMac, &phyMode, psessionEntry);
1672
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301673 /* Include 11b rates only when the device configured in
1674 auto, 11a/b/g or 11b_only */
1675 if ( (selfStaDot11Mode == WNI_CFG_DOT11_MODE_ALL) ||
1676 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11A) ||
1677 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11AC) ||
Leela Venkata Kiran Kumar Reddy Chiralac9a10e52013-08-29 16:37:15 -07001678 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11N) ||
1679 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11G) ||
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301680 (selfStaDot11Mode == WNI_CFG_DOT11_MODE_11B) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 {
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301682 val = WNI_CFG_SUPPORTED_RATES_11B_LEN;
1683 wlan_cfgGetStr( pMac, WNI_CFG_SUPPORTED_RATES_11B,
1684 (tANI_U8 *)&tempRateSet.rate, &val );
1685 tempRateSet.numRates = (tANI_U8) val;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001686 }
1687 else
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301688 tempRateSet.numRates = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001689
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301690 /* Include 11a rates when the device configured in non-11b mode */
1691 if (!IS_DOT11_MODE_11B(selfStaDot11Mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 {
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301693 val = WNI_CFG_SUPPORTED_RATES_11A_LEN;
1694 wlan_cfgGetStr( pMac, WNI_CFG_SUPPORTED_RATES_11A,
1695 (tANI_U8 *)&tempRateSet2.rate, &val );
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 tempRateSet2.numRates = (tANI_U8) val;
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 }
1698 else
Madan Mohan Koyyalamudi626959e2013-07-15 20:50:43 +05301699 tempRateSet2.numRates = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001700
1701 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
1702 {
1703 //we are in big trouble
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001704 limLog(pMac, LOGP, FL("more than 12 rates in CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001705 //panic
1706 goto error;
1707 }
1708
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 //copy all rates in tempRateSet, there are 12 rates max
1710 for (i = 0;i < tempRateSet2.numRates; i++)
1711 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
1712 tempRateSet.numRates += tempRateSet2.numRates;
1713
1714 /**
1715 * Sort rates in tempRateSet (they are likely to be already sorted)
1716 * put the result in pSupportedRates
1717 */
1718 {
1719 tANI_U8 aRateIndex = 0;
1720 tANI_U8 bRateIndex = 0;
1721
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05301722 vos_mem_set((tANI_U8 *) pRates, sizeof(tSirSupportedRates), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 for(i = 0;i < tempRateSet.numRates; i++)
1724 {
1725 min = 0;
1726 val = 0xff;
1727 isArate = 0;
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07001728 for(j = 0; (j < tempRateSet.numRates) && (j < SIR_MAC_RATESET_EID_MAX); j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 {
1730 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
1731 {
1732 val = tempRateSet.rate[j] & 0x7f;
1733 min = j;
1734 }
1735 }
1736
1737 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1738 isArate = 1;
1739
1740 /*
1741 * HAL needs to know whether the rate is basic rate or not, as it needs to
1742 * update the response rate table accordingly. e.g. if one of the 11a rates is
1743 * basic rate, then that rate can be used for sending control frames.
1744 * HAL updates the response rate table whenever basic rate set is changed.
1745 */
1746 if (basicOnly)
1747 {
1748 if (tempRateSet.rate[min] & 0x80)
1749 {
1750 if (isArate)
1751 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1752 else
1753 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1754 }
1755 }
1756 else
1757 {
1758 if (isArate)
1759 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1760 else
1761 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1762 }
1763 tempRateSet.rate[min] = 0xff;
1764 }
1765
1766 }
1767
1768
Gopichand Nakkala681989c2013-03-06 22:27:48 -08001769 //if(IS_DOT11_MODE_HT(psessionEntry->dot11mode))
1770 if (IS_DOT11_MODE_HT(selfStaDot11Mode))
Jeff Johnson295189b2012-06-20 16:38:30 -07001771 {
1772 val = SIZE_OF_SUPPORTED_MCS_SET;
1773 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
1774 pRates->supportedMCSSet,
1775 &val) != eSIR_SUCCESS)
1776 {
1777 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001778 PELOGE(limLog(pMac, LOGE, FL("could not retrieve supportedMCSSet"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001779 goto error;
1780 }
1781
1782
1783 //if supported MCS Set of the peer is passed in, then do the intersection
1784 //else use the MCS set from local CFG.
1785
1786 if(pSupportedMCSSet != NULL)
1787 {
1788 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1789 pRates->supportedMCSSet[i] &= pSupportedMCSSet[i];
1790
1791 }
1792
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07001793 PELOG2(limLog(pMac, LOG2, FL("MCS Rate Set Bitmap: "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1795 PELOGW(limLog(pMac, LOG2,FL("%x ") , pRates->supportedMCSSet[i]);)
1796 }
1797
Jeff Johnsone7245742012-09-05 17:12:55 -07001798#ifdef WLAN_FEATURE_11AC
1799 limPopulateVhtMcsSet(pMac, pRates , pVHTCaps,psessionEntry);
1800#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001801
1802 return eSIR_SUCCESS;
1803
1804 error:
1805
1806 return eSIR_FAILURE;
1807} /*** limPopulateOwnRateSet() ***/
1808
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001809#ifdef WLAN_FEATURE_11AC
1810tSirRetStatus
1811limPopulatePeerRateSet(tpAniSirGlobal pMac,
1812
1813 tpSirSupportedRates pRates,
1814 tANI_U8* pSupportedMCSSet,
1815 tANI_U8 basicOnly,
1816 tpPESession psessionEntry,
1817 tDot11fIEVHTCaps *pVHTCaps)
1818#else
1819tSirRetStatus
1820limPopulatePeerRateSet(tpAniSirGlobal pMac,
1821 tpSirSupportedRates pRates,
1822 tANI_U8* pSupportedMCSSet,
1823 tANI_U8 basicOnly,
1824 tpPESession psessionEntry)
1825#endif
1826{
1827 tSirMacRateSet tempRateSet;
1828 tSirMacRateSet tempRateSet2;
1829 tANI_U32 i,j,val,min,isArate;
1830 isArate = 0;
1831
1832 /* copy operational rate set from psessionEntry */
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001833 if ( psessionEntry->rateSet.numRates <= SIR_MAC_RATESET_EID_MAX )
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001834 {
1835 palCopyMemory(pMac->hHdd,(tANI_U8 *)tempRateSet.rate,(tANI_U8*)(psessionEntry->rateSet.rate), psessionEntry->rateSet.numRates);
1836 tempRateSet.numRates = psessionEntry->rateSet.numRates;
1837 }
1838 else
1839 {
1840 limLog(pMac, LOGE, FL("more than SIR_MAC_RATESET_EID_MAX rates\n"));
1841 goto error;
1842 }
Madan Mohan Koyyalamudi28321f82013-09-25 18:45:26 -07001843 if (psessionEntry->dot11mode == WNI_CFG_DOT11_MODE_11G)
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001844 {
1845
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001846 if (psessionEntry->extRateSet.numRates <= SIR_MAC_RATESET_EID_MAX)
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001847 {
1848 palCopyMemory(pMac->hHdd,(tANI_U8 *)tempRateSet2.rate, (tANI_U8*)(psessionEntry->extRateSet.rate), psessionEntry->extRateSet.numRates);
1849 tempRateSet2.numRates = psessionEntry->extRateSet.numRates;
1850 }
1851 else {
1852 limLog(pMac, LOGE, FL("psessionEntry->extRateSet.numRates more than SIR_MAC_RATESET_EID_MAX rates\n"));
1853 goto error;
1854 }
1855 }
1856 else
1857 tempRateSet2.numRates = 0;
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -07001858 if ((tempRateSet.numRates + tempRateSet2.numRates) > SIR_MAC_RATESET_EID_MAX)
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07001859 {
1860 //we are in big trouble
1861 limLog(pMac, LOGP, FL("more than 12 rates in CFG"));
1862 goto error;
1863 }
1864
1865
1866 //copy all rates in tempRateSet, there are 12 rates max
1867 for (i = 0;i < tempRateSet2.numRates; i++)
1868 tempRateSet.rate[i + tempRateSet.numRates] = tempRateSet2.rate[i];
1869 tempRateSet.numRates += tempRateSet2.numRates;
1870 /**
1871 * Sort rates in tempRateSet (they are likely to be already sorted)
1872 * put the result in pSupportedRates
1873 */
1874 {
1875 tANI_U8 aRateIndex = 0;
1876 tANI_U8 bRateIndex = 0;
1877 palZeroMemory( pMac->hHdd, (tANI_U8 *) pRates, sizeof(tSirSupportedRates));
1878 for(i = 0;i < tempRateSet.numRates; i++)
1879 {
1880 min = 0;
1881 val = 0xff;
1882 isArate = 0;
1883 for(j = 0; (j < tempRateSet.numRates) && (j < SIR_MAC_RATESET_EID_MAX); j++)
1884 {
1885 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
1886 {
1887 val = tempRateSet.rate[j] & 0x7f;
1888 min = j;
1889 }
1890 }
1891 if (sirIsArate(tempRateSet.rate[min] & 0x7f))
1892 isArate = 1;
1893 /*
1894 * HAL needs to know whether the rate is basic rate or not, as it needs to
1895 * update the response rate table accordingly. e.g. if one of the 11a rates is
1896 * basic rate, then that rate can be used for sending control frames.
1897 * HAL updates the response rate table whenever basic rate set is changed.
1898 */
1899 if (basicOnly)
1900 {
1901 if (tempRateSet.rate[min] & 0x80)
1902 {
1903 if (isArate)
1904 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1905 else
1906 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1907 }
1908 }
1909 else
1910 {
1911 if (isArate)
1912 pRates->llaRates[aRateIndex++] = tempRateSet.rate[min];
1913 else
1914 pRates->llbRates[bRateIndex++] = tempRateSet.rate[min];
1915 }
1916 tempRateSet.rate[min] = 0xff;
1917 }
1918 }
1919
1920
1921 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode))
1922 {
1923 val = SIZE_OF_SUPPORTED_MCS_SET;
1924 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
1925 pRates->supportedMCSSet,
1926 &val) != eSIR_SUCCESS)
1927 {
1928 /// Could not get rateset from CFG. Log error.
1929 PELOGE(limLog(pMac, LOGE, FL("could not retrieve supportedMCSSet"));)
1930 goto error;
1931 }
1932 //if supported MCS Set of the peer is passed in, then do the intersection
1933 //else use the MCS set from local CFG.
1934 if(pSupportedMCSSet != NULL)
1935 {
1936 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1937 pRates->supportedMCSSet[i] &= pSupportedMCSSet[i];
1938 }
1939 PELOG2(limLog(pMac, LOG2, FL("MCS Rate Set Bitmap: "));)
1940 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
1941 PELOGW(limLog(pMac, LOG2,FL("%x ") , pRates->supportedMCSSet[i]);)
1942 }
1943#ifdef WLAN_FEATURE_11AC
1944 limPopulateVhtMcsSet(pMac, pRates , pVHTCaps,psessionEntry);
1945#endif
1946 return eSIR_SUCCESS;
1947 error:
1948 return eSIR_FAILURE;
1949} /*** limPopulatePeerRateSet() ***/
1950
Jeff Johnson295189b2012-06-20 16:38:30 -07001951/**
1952 * limPopulateMatchingRateSet
1953 * FUNCTION:
1954 * This is called at the time of Association Request
1955 * processing on AP and while adding peer's context
1956 * in IBSS role to process the CFG rate sets and
1957 * the rate sets received in the Assoc request on AP
1958 * or Beacon/Probe Response from peer in IBSS.
1959 *
1960 * LOGIC:
1961 * 1. It makes the intersection between our own rate Sat
1962 * and extemcded rate set and the ones received in the
1963 * association request.
1964 * 2. It creates a combined rate set of 12 rates max which
1965 * comprised the basic and extended rates
1966 * 3. It sorts the combined rate Set and copy it in the
1967 * rate array of the pSTA descriptor
1968 *
1969 * ASSUMPTION:
1970 * The parser has already ensured unicity of the rates in the
1971 * association request structure
1972 *
1973 * @param: pMac - Pointer to Global MAC structure
1974 * pStaDs - Pointer to DPH node
1975 * pOperRateSet - Pointer to peer's supported rateset
1976 * pExtRateSet - Pointer to peer's extended rateset
1977 *
1978 * @return: eSIR_SUCCESS or eSIR_FAILURE
1979 */
Jeff Johnsone7245742012-09-05 17:12:55 -07001980#ifdef WLAN_FEATURE_11AC
1981tSirRetStatus
1982limPopulateMatchingRateSet(tpAniSirGlobal pMac,
1983 tpDphHashNode pStaDs,
1984 tSirMacRateSet *pOperRateSet,
1985 tSirMacRateSet *pExtRateSet,
1986 tANI_U8* pSupportedMCSSet,
1987 tSirMacPropRateSet *pAniLegRateSet,
1988 tpPESession psessionEntry,
1989 tDot11fIEVHTCaps *pVHTCaps)
Jeff Johnson295189b2012-06-20 16:38:30 -07001990
Jeff Johnsone7245742012-09-05 17:12:55 -07001991#else
Jeff Johnson295189b2012-06-20 16:38:30 -07001992tSirRetStatus
1993limPopulateMatchingRateSet(tpAniSirGlobal pMac,
1994 tpDphHashNode pStaDs,
1995 tSirMacRateSet *pOperRateSet,
1996 tSirMacRateSet *pExtRateSet,
1997 tANI_U8* pSupportedMCSSet,
1998 tSirMacPropRateSet *pAniLegRateSet,
1999 tpPESession psessionEntry)
Jeff Johnsone7245742012-09-05 17:12:55 -07002000#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002001{
2002 tSirMacRateSet tempRateSet;
2003 tSirMacRateSet tempRateSet2;
2004 tANI_U32 i,j,val,min,isArate;
2005 tANI_U32 phyMode;
2006 tANI_U8 mcsSet[SIZE_OF_SUPPORTED_MCS_SET];
2007
2008 isArate=0;
2009
2010 // limGetPhyMode(pMac, &phyMode);
2011 limGetPhyMode(pMac, &phyMode, psessionEntry);
2012
2013 // get own rate set
2014 // val = WNI_CFG_OPERATIONAL_RATE_SET_LEN;
2015 #if 0
2016 if (wlan_cfgGetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET,
2017 (tANI_U8 *) &tempRateSet.rate,
2018 &val) != eSIR_SUCCESS)
2019 {
2020 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002021 limLog(pMac, LOGP, FL("could not retrieve rateset"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002022 }
2023
2024 #endif // TO SUPPORT BT-AMP
2025
2026 /* copy operational rate set from psessionEntry */
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302027 vos_mem_copy((tempRateSet.rate), (psessionEntry->rateSet.rate),
2028 psessionEntry->rateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07002029 tempRateSet.numRates = (tANI_U8) psessionEntry->rateSet.numRates;
2030
2031 if (phyMode == WNI_CFG_PHY_MODE_11G)
2032 {
2033
2034 #if 0
2035 // get own extended rate set
2036 val = WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET_LEN;
2037 if (wlan_cfgGetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
2038 (tANI_U8 *) &tempRateSet2.rate,
2039 &val) != eSIR_SUCCESS)
2040 #endif
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302041 vos_mem_copy((tempRateSet2.rate), (psessionEntry->extRateSet.rate),
2042 psessionEntry->extRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 tempRateSet2.numRates = (tANI_U8) psessionEntry->extRateSet.numRates;
2044 }
2045 else
2046 tempRateSet2.numRates = 0;
2047
2048 if ((tempRateSet.numRates + tempRateSet2.numRates) > 12)
2049 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002050 PELOGE(limLog(pMac, LOGE, FL("more than 12 rates in CFG"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002051 goto error;
2052 }
2053
2054 /**
2055 * Handling of the rate set IEs is the following:
2056 * - keep only rates that we support and that the station supports
2057 * - sort and the rates into the pSta->rate array
2058 */
2059
2060 // Copy all rates in tempRateSet, there are 12 rates max
2061 for(i = 0; i < tempRateSet2.numRates; i++)
2062 tempRateSet.rate[i + tempRateSet.numRates] =
2063 tempRateSet2.rate[i];
2064
2065 tempRateSet.numRates += tempRateSet2.numRates;
2066
2067 /**
2068 * Sort rates in tempRateSet (they are likely to be already sorted)
2069 * put the result in tempRateSet2
2070 */
2071 tempRateSet2.numRates = 0;
2072
2073 for(i = 0;i < tempRateSet.numRates; i++)
2074 {
2075 min = 0;
2076 val = 0xff;
2077
2078 for(j = 0;j < tempRateSet.numRates; j++)
2079 if ((tANI_U32) (tempRateSet.rate[j] & 0x7f) < val)
2080 {
2081 val = tempRateSet.rate[j] & 0x7f;
2082 min = j;
2083 }
2084
2085 tempRateSet2.rate[tempRateSet2.numRates++] =
2086 tempRateSet.rate[min];
2087 tempRateSet.rate[min] = 0xff;
2088 }
2089
2090
2091 /**
2092 * Copy received rates in tempRateSet, the parser has ensured
2093 * unicity of the rates so there cannot be more than 12
2094 */
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002095 for(i = 0; (i < pOperRateSet->numRates && i < SIR_MAC_RATESET_EID_MAX) ; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002096 {
2097 tempRateSet.rate[i] = pOperRateSet->rate[i];
2098 }
2099
2100 tempRateSet.numRates = pOperRateSet->numRates;
2101
2102 if (pExtRateSet->numRates)
2103 {
2104 if((tempRateSet.numRates + pExtRateSet->numRates) > 12 )
2105 {
2106 limLog( pMac, LOG2,
2107 "Sum of SUPPORTED and EXTENDED Rate Set (%1d) exceeds 12!",
2108 tempRateSet.numRates + pExtRateSet->numRates );
2109
2110 if( tempRateSet.numRates < 12 )
2111 {
2112 int found = 0;
2113 int tail = tempRateSet.numRates;
2114
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002115 for( i = 0; (i < pExtRateSet->numRates && i < SIR_MAC_RATESET_EID_MAX); i++ )
Jeff Johnson295189b2012-06-20 16:38:30 -07002116 {
2117 found = 0;
2118 for( j = 0; j < (tANI_U32) tail; j++ )
2119 {
2120 if((tempRateSet.rate[j] & 0x7F) ==
2121 (pExtRateSet->rate[i] & 0x7F))
2122 {
2123 found = 1;
2124 break;
2125 }
2126 }
2127
2128 if( !found )
2129 {
2130 tempRateSet.rate[tempRateSet.numRates++] =
2131 pExtRateSet->rate[i];
2132
2133 if( tempRateSet.numRates >= 12 )
2134 break;
2135 }
2136 }
2137 }
2138 else
2139 limLog( pMac, LOG2,
2140 "Relying only on the SUPPORTED Rate Set IE..." );
2141 }
2142 else
2143 {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002144 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 -07002145 tempRateSet.rate[i+j] = pExtRateSet->rate[j];
2146
2147 tempRateSet.numRates += pExtRateSet->numRates;
2148 }
2149 }
2150
2151 {
2152 tpSirSupportedRates rates = &pStaDs->supportedRates;
2153 tANI_U8 aRateIndex = 0;
2154 tANI_U8 bRateIndex = 0;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302155 vos_mem_set((tANI_U8 *) rates, sizeof(tSirSupportedRates), 0);
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002156 for(i = 0;(i < tempRateSet2.numRates && i < SIR_MAC_RATESET_EID_MAX ); i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002157 {
Kiran Kumar Lokerea4db3dc2013-03-25 18:05:24 -07002158 for(j = 0;(j < tempRateSet.numRates && j < SIR_MAC_RATESET_EID_MAX); j++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 {
2160 if ((tempRateSet2.rate[i] & 0x7F) ==
2161 (tempRateSet.rate[j] & 0x7F))
2162 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 if (sirIsArate(tempRateSet2.rate[i] & 0x7f))
2164 {
2165 isArate=1;
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -07002166 if (aRateIndex < SIR_NUM_11A_RATES)
2167 rates->llaRates[aRateIndex++] = tempRateSet2.rate[i];
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 }
2169 else
Kiran Kumar Lokerea328bcd2013-04-22 22:02:05 -07002170 {
2171 if (bRateIndex < SIR_NUM_11B_RATES)
2172 rates->llbRates[bRateIndex++] = tempRateSet2.rate[i];
2173 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 break;
2175 }
2176 }
2177 }
2178
2179
2180 //Now add the Polaris rates only when Proprietary rates are enabled.
2181 val = 0;
2182 if(wlan_cfgGetInt(pMac, WNI_CFG_PROPRIETARY_RATES_ENABLED, &val) != eSIR_SUCCESS)
2183 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002184 limLog(pMac, LOGP, FL("could not retrieve prop rate enabled flag from CFG"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 }
2186 else if(val)
2187 {
2188 for(i=0; i<pAniLegRateSet->numPropRates; i++)
2189 rates->aniLegacyRates[i] = pAniLegRateSet->propRate[i];
2190 }
2191
2192 }
2193
2194
2195 //compute the matching MCS rate set, if peer is 11n capable and self mode is 11n
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002196#ifdef FEATURE_WLAN_TDLS
2197 if(pStaDs->mlmStaContext.htCapability)
2198#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 if(IS_DOT11_MODE_HT(psessionEntry->dot11mode) &&
2200 (pStaDs->mlmStaContext.htCapability))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002201#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 {
2203 val = SIZE_OF_SUPPORTED_MCS_SET;
2204 if (wlan_cfgGetStr(pMac, WNI_CFG_SUPPORTED_MCS_SET,
2205 mcsSet,
2206 &val) != eSIR_SUCCESS)
2207 {
2208 /// Could not get rateset from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002209 limLog(pMac, LOGP, FL("could not retrieve supportedMCSSet"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 goto error;
2211 }
2212
2213 for(i=0; i<val; i++)
2214 pStaDs->supportedRates.supportedMCSSet[i] = mcsSet[i] & pSupportedMCSSet[i];
2215
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002216 PELOG2(limLog(pMac, LOG2, FL("limPopulateMatchingRateSet: MCS Rate Set Bitmap from CFG and DPH : "));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 for(i=0; i<SIR_MAC_MAX_SUPPORTED_MCS_SET; i++)
2218 {
2219 PELOG2(limLog(pMac, LOG2,FL("%x %x "), mcsSet[i], pStaDs->supportedRates.supportedMCSSet[i]);)
2220 }
2221 }
2222
Jeff Johnsone7245742012-09-05 17:12:55 -07002223#ifdef WLAN_FEATURE_11AC
2224 limPopulateVhtMcsSet(pMac, &pStaDs->supportedRates, pVHTCaps, psessionEntry);
2225#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 /**
2227 * Set the erpEnabled bit iff the phy is in G mode and at least
2228 * one A rate is supported
2229 */
2230 if ((phyMode == WNI_CFG_PHY_MODE_11G) && isArate)
2231 pStaDs->erpEnabled = eHAL_SET;
2232
2233
2234
2235 return eSIR_SUCCESS;
2236
2237 error:
2238
2239 return eSIR_FAILURE;
2240} /*** limPopulateMatchingRateSet() ***/
2241
2242
2243
2244/**
2245 * limAddSta()
2246 *
2247 *FUNCTION:
2248 * This function is called to add an STA context at hardware
2249 * whenever a STA is (Re) Associated.
2250 *
2251 *LOGIC:
2252 *
2253 *ASSUMPTIONS:
2254 * NA
2255 *
2256 *NOTE:
2257 * NA
2258 *
2259 * @param pMac - Pointer to Global MAC structure
2260 * @param pStaDs - Pointer to the STA datastructure created by
2261 * LIM and maintained by DPH
2262 * @return retCode - Indicates success or failure return code
2263 */
2264
2265tSirRetStatus
2266limAddSta(
2267 tpAniSirGlobal pMac,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002268 tpDphHashNode pStaDs, tANI_U8 updateEntry, tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07002269{
2270 tpAddStaParams pAddStaParams = NULL;
2271 tSirMsgQ msgQ;
2272 tSirRetStatus retCode = eSIR_SUCCESS;
2273 tSirMacAddr staMac, *pStaAddr;
2274 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07002275 tpSirAssocReq pAssocReq;
2276 tANI_U8 *p2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002277 #if 0
2278 retCode = wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, staMac, &cfg);
2279 if (retCode != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002280 limLog(pMac, LOGP, FL("could not retrieve STA MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 #endif //To SUPPORT BT-AMP
2282
2283
2284 sirCopyMacAddr(staMac,psessionEntry->selfMacAddr);
2285
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302286 pAddStaParams = vos_mem_malloc(sizeof(tAddStaParams));
2287 if (NULL == pAddStaParams)
2288 {
2289 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
2290 return eSIR_MEM_ALLOC_FAILED;
2291 }
2292 vos_mem_set((tANI_U8 *) pAddStaParams, sizeof(tAddStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002293
2294 if ((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) ||
2295 (limGetSystemRole(psessionEntry) == eLIM_STA_IN_IBSS_ROLE) ||
2296 (limGetSystemRole(psessionEntry) == eLIM_BT_AMP_AP_ROLE) )
2297 pStaAddr = &pStaDs->staAddr;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002298#ifdef FEATURE_WLAN_TDLS
2299 /* SystemRole shouldn't be matter if staType is TDLS peer */
2300 else if(STA_ENTRY_TDLS_PEER == pStaDs->staType)
2301 {
2302 pStaAddr = &pStaDs->staAddr ;
2303 }
2304#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 else
2306 pStaAddr = &staMac;
2307
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302308 vos_mem_copy((tANI_U8 *) pAddStaParams->staMac,
2309 (tANI_U8 *) *pStaAddr, sizeof(tSirMacAddr));
2310 vos_mem_copy((tANI_U8 *) pAddStaParams->bssId,
2311 psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002312
2313 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
2314
2315 //Copy legacy rates
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302316 vos_mem_copy ((tANI_U8*)&pAddStaParams->supportedRates,
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 (tANI_U8*)&pStaDs->supportedRates, sizeof(tSirSupportedRates));
2318
2319 pAddStaParams->assocId = pStaDs->assocId;
2320
2321 pAddStaParams->wmmEnabled = pStaDs->qosMode;
2322 pAddStaParams->listenInterval = pStaDs->mlmStaContext.listenInterval;
2323 pAddStaParams->shortPreambleSupported = pStaDs->shortPreambleEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002324 if((limGetSystemRole(psessionEntry) == eLIM_AP_ROLE) && (pStaDs->mlmStaContext.subType == LIM_REASSOC))
2325 {
2326 /* TBD - need to remove this REASSOC check after fixinf rmmod issue */
2327 pAddStaParams->updateSta = pStaDs->mlmStaContext.updateContext;
2328 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 pStaDs->valid = 0;
2330 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2331
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002332 // This will indicate HAL to "allocate" a new STA index
2333#ifdef FEATURE_WLAN_TDLS
2334 /* As there is corner case in-between add_sta and change_sta,if del_sta for other staIdx happened,
2335 * firmware return wrong staIdx (recently removed staIdx). Until we get a confirmation from the
2336 * firmware team it is now return correct staIdx for same sta_mac_addr for update case, we want
2337 * to get around it by passing valid staIdx given by add_sta time.
2338 */
2339 if((STA_ENTRY_TDLS_PEER == pStaDs->staType) &&
2340 (true == updateEntry))
2341 pAddStaParams->staIdx = pStaDs->staIndex;
2342 else
2343#endif
2344 pAddStaParams->staIdx = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07002345 pAddStaParams->staType = pStaDs->staType;
2346
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002347 pAddStaParams->updateSta = updateEntry;
2348
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2350 pAddStaParams->respReqd = 1;
2351 //Update HT Capability
2352
2353 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 -07002354 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 pAddStaParams->htCapable = pStaDs->mlmStaContext.htCapability;
Jeff Johnsone7245742012-09-05 17:12:55 -07002356#ifdef WLAN_FEATURE_11AC
2357 pAddStaParams->vhtCapable = pStaDs->mlmStaContext.vhtCapability;
2358#endif
2359 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002360#ifdef FEATURE_WLAN_TDLS
2361 /* SystemRole shouldn't be matter if staType is TDLS peer */
2362 else if(STA_ENTRY_TDLS_PEER == pStaDs->staType)
Hoonki Lee99e53782013-02-12 18:07:03 -08002363 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002364 pAddStaParams->htCapable = pStaDs->mlmStaContext.htCapability;
Hoonki Lee99e53782013-02-12 18:07:03 -08002365#ifdef WLAN_FEATURE_11AC
2366 pAddStaParams->vhtCapable = pStaDs->mlmStaContext.vhtCapability;
2367#endif
2368 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002369#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002370 else
Jeff Johnsone7245742012-09-05 17:12:55 -07002371 {
2372 pAddStaParams->htCapable = psessionEntry->htCapability;
2373#ifdef WLAN_FEATURE_11AC
2374 pAddStaParams->vhtCapable = psessionEntry->vhtCapability;
2375#endif
2376
2377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002378
2379 pAddStaParams->greenFieldCapable = pStaDs->htGreenfield;
2380 pAddStaParams->maxAmpduDensity= pStaDs->htAMpduDensity;
2381 pAddStaParams->maxAmpduSize = pStaDs->htMaxRxAMpduFactor;
2382 pAddStaParams->fDsssCckMode40Mhz = pStaDs->htDsssCckRate40MHzSupport;
2383 pAddStaParams->fShortGI20Mhz = pStaDs->htShortGI20Mhz;
2384 pAddStaParams->fShortGI40Mhz = pStaDs->htShortGI40Mhz;
2385 pAddStaParams->lsigTxopProtection = pStaDs->htLsigTXOPProtection;
2386 pAddStaParams->maxAmsduSize = pStaDs->htMaxAmsduLength;
2387 pAddStaParams->txChannelWidthSet = pStaDs->htSupportedChannelWidthSet;
2388 pAddStaParams->mimoPS = pStaDs->htMIMOPSState;
Jeff Johnsone7245742012-09-05 17:12:55 -07002389
2390#ifdef WLAN_FEATURE_11AC
2391 if(pAddStaParams->vhtCapable)
2392 {
Mohit Khanna7d5aeb22012-09-11 16:21:57 -07002393 pAddStaParams->vhtTxChannelWidthSet = pStaDs->vhtSupportedChannelWidthSet;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002394 pAddStaParams->vhtTxBFCapable =
Hoonki Lee99e53782013-02-12 18:07:03 -08002395#ifdef FEATURE_WLAN_TDLS
2396 (( STA_ENTRY_PEER == pStaDs->staType ) || (STA_ENTRY_TDLS_PEER == pStaDs->staType)) ?
2397 pStaDs->vhtBeamFormerCapable : psessionEntry->txBFIniFeatureEnabled ;
2398#else
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002399 ( STA_ENTRY_PEER == pStaDs->staType ) ? pStaDs->vhtBeamFormerCapable :
2400 psessionEntry->txBFIniFeatureEnabled ;
Hoonki Lee99e53782013-02-12 18:07:03 -08002401#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002402 }
2403#endif
2404
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002405#ifdef FEATURE_WLAN_TDLS
2406 if((STA_ENTRY_PEER == pStaDs->staType) ||
2407 (STA_ENTRY_TDLS_PEER == pStaDs->staType))
2408#else
2409 if (STA_ENTRY_PEER == pStaDs->staType)
2410#endif
2411 {
2412 /* peer STA get the LDPC capability from pStaDs, which populated from
2413 * HT/VHT capability*/
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08002414 if(pAddStaParams->vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP)
2415 {
2416 pAddStaParams->htLdpcCapable = 0;
2417 pAddStaParams->vhtLdpcCapable = 0;
2418 }
2419 else
2420 {
2421 pAddStaParams->htLdpcCapable = pStaDs->htLdpcCapable;
2422 pAddStaParams->vhtLdpcCapable = pStaDs->vhtLdpcCapable;
2423 }
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002424 }
2425 else if( STA_ENTRY_SELF == pStaDs->staType)
2426 {
2427 /* For Self STA get the LDPC capability from config.ini*/
2428 pAddStaParams->htLdpcCapable =
2429 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
2430 pAddStaParams->vhtLdpcCapable =
2431 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
2432 }
2433
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 /* Update PE session ID*/
2435 pAddStaParams->sessionId = psessionEntry->peSessionId;
2436
2437 if (psessionEntry->parsedAssocReq != NULL)
2438 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 // Get a copy of the already parsed Assoc Request
2440 pAssocReq = (tpSirAssocReq) psessionEntry->parsedAssocReq[pStaDs->assocId];
2441 if ( pAssocReq && pAssocReq->addIEPresent && pAssocReq->addIE.length ) {
2442 p2pIe = limGetP2pIEPtr(pMac, pAssocReq->addIE.addIEdata, pAssocReq->addIE.length);
2443 }
2444 pAddStaParams->p2pCapableSta = (p2pIe != NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002445 }
2446
2447 //Disable BA. It will be set as part of ADDBA negotiation.
2448 for( i = 0; i < STACFG_MAX_TC; i++ )
2449 {
2450 pAddStaParams->staTCParams[i].txUseBA = eBA_DISABLE;
2451 pAddStaParams->staTCParams[i].rxUseBA = eBA_DISABLE;
2452 }
2453
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002454#ifdef FEATURE_WLAN_TDLS
2455 if(pStaDs->wmeEnabled && \
2456 ((eLIM_AP_ROLE == psessionEntry->limSystemRole) || (STA_ENTRY_TDLS_PEER == pStaDs->staType)) )
2457#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 if(pStaDs->wmeEnabled && (eLIM_AP_ROLE == psessionEntry->limSystemRole))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002459#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 {
2461 pAddStaParams->uAPSD = 0;
2462 /* update UAPSD and send it to LIM to add STA */
2463 // bitmap MSB <- LSB MSB 4 bits are for
2464 // trigger enabled AC setting and LSB 4 bits
2465 // are for delivery enabled AC setting
2466 // 7 6 5 4 3 2 1 0
2467 // BE BK VI VO BE BK VI VO
2468 pAddStaParams->uAPSD |= pStaDs->qos.capability.qosInfo.acvo_uapsd;
2469 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acvi_uapsd << 1);
2470 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acbk_uapsd << 2);
2471 pAddStaParams->uAPSD |= (pStaDs->qos.capability.qosInfo.acbe_uapsd << 3);
2472 //making delivery enabled and trigger enabled setting the same.
2473 pAddStaParams->uAPSD |= pAddStaParams->uAPSD << 4;
2474
2475 pAddStaParams->maxSPLen = pStaDs->qos.capability.qosInfo.maxSpLen;
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002476 limLog( pMac, LOG1, FL( "uAPSD = 0x%x, maxSpLen = %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 pAddStaParams->uAPSD, pAddStaParams->maxSPLen);
2478 }
Chet Lanctot4b9abd72013-06-27 11:14:56 -07002479
2480#ifdef WLAN_FEATURE_11W
2481 pAddStaParams->rmfEnabled = pStaDs->rmfEnabled;
2482 limLog( pMac, LOG1, FL( "Adding station, station index %d, PMF enabled %d"),
2483 pAddStaParams->staIdx, pAddStaParams->rmfEnabled);
2484#endif
2485
2486 //we need to defer the message until we get the response back from HAL.
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 if (pAddStaParams->respReqd)
2488 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
Jeff Johnsone7245742012-09-05 17:12:55 -07002489
2490 msgQ.type = WDA_ADD_STA_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002491
2492 msgQ.reserved = 0;
2493 msgQ.bodyptr = pAddStaParams;
2494 msgQ.bodyval = 0;
2495
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002496 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_STA_REQ for assocId %d" ),
Jeff Johnson295189b2012-06-20 16:38:30 -07002497 pStaDs->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002498 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002499
2500 retCode = wdaPostCtrlMsg( pMac, &msgQ );
2501 if( eSIR_SUCCESS != retCode)
2502 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002503 if (pAddStaParams->respReqd)
2504 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002505 limLog( pMac, LOGE, FL("ADD_STA_REQ for aId %d failed (reason %X)"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002506 pStaDs->assocId, retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302507 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002508 }
2509
2510 return retCode;
2511}
2512
2513
2514/**
2515 * limDelSta()
2516 *
2517 *FUNCTION:
2518 * This function is called to delete an STA context at hardware
2519 * whenever a STA is disassociated
2520 *
2521 *LOGIC:
2522 *
2523 *ASSUMPTIONS:
2524 * NA
2525 *
2526 *NOTE:
2527 * NA
2528 *
2529 * @param pMac - Pointer to Global MAC structure
2530 * @param pStaDs - Pointer to the STA datastructure created by
2531 * LIM and maintained by DPH
2532 * @param fRespReqd - flag to indicate whether the delete is synchronous (true)
2533 * or not (false)
2534 * @return retCode - Indicates success or failure return code
2535 */
2536
2537tSirRetStatus
2538limDelSta(
2539 tpAniSirGlobal pMac,
2540 tpDphHashNode pStaDs,
2541 tANI_BOOLEAN fRespReqd,
2542 tpPESession psessionEntry)
2543{
2544 tpDeleteStaParams pDelStaParams = NULL;
2545 tSirMsgQ msgQ;
2546 tSirRetStatus retCode = eSIR_SUCCESS;
2547
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302548 pDelStaParams = vos_mem_malloc(sizeof( tDeleteStaParams ));
2549 if (NULL == pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302551 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 return eSIR_MEM_ALLOC_FAILED;
2553 }
2554
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302555 vos_mem_set((tANI_U8 *) pDelStaParams, sizeof(tDeleteStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002556
2557 //
2558 // DPH contains the STA index only for "peer" STA entries.
2559 // LIM global contains "self" STA index
2560 // Thus,
2561 // if( STA role )
2562 // get STA index from LIM global
2563 // else
2564 // get STA index from DPH
2565 //
2566
2567#if 0
2568 /* Since we have not created any STA, no need to send msg to delete
2569 * STA to HAL */
2570 if (psessionEntry->limSmeState == eLIM_SME_JOIN_FAILURE_STATE) {
2571 pDelStaParams->staIdx = 1; /* TODO : This is workaround. Need to find right STA Index before sending to HAL */
2572 //return retCode;
2573 }
2574#endif
2575
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002576#ifdef FEATURE_WLAN_TDLS
2577 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)) )
2578#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002579 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 -08002580#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002581 pDelStaParams->staIdx= psessionEntry->staId;
2582
2583 else
2584 pDelStaParams->staIdx= pStaDs->staIndex;
2585
2586 pDelStaParams->assocId = pStaDs->assocId;
2587 pStaDs->valid = 0;
2588
2589 if (! fRespReqd)
2590 pDelStaParams->respReqd = 0;
2591 else
2592 {
2593 //when limDelSta is called from processSmeAssocCnf then mlmState is already set properly.
2594 if(eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE != GET_LIM_STA_CONTEXT_MLM_STATE(pStaDs))
2595 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002596 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 SET_LIM_STA_CONTEXT_MLM_STATE(pStaDs, eLIM_MLM_WT_DEL_STA_RSP_STATE);
2598 }
2599 if ( (eLIM_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) ||
2600 (eLIM_BT_AMP_STA_ROLE == GET_LIM_SYSTEM_ROLE(psessionEntry)) )
2601 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002602 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002603
2604 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_STA_RSP_STATE;
2605
2606 }
2607 pDelStaParams->respReqd = 1;
2608 //we need to defer the message until we get the response back from HAL.
2609 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
2610 }
2611
2612 /* Update PE session ID*/
2613 pDelStaParams->sessionId = psessionEntry->peSessionId;
2614
2615 pDelStaParams->status = eHAL_STATUS_SUCCESS;
2616 msgQ.type = WDA_DELETE_STA_REQ;
2617 msgQ.reserved = 0;
2618 msgQ.bodyptr = pDelStaParams;
2619 msgQ.bodyval = 0;
2620
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07002621 limLog( pMac, LOG1, FL( "Sending SIR_HAL_DELETE_STA_REQ for STAID: %X and AssocID: %d" ),
Gopichand Nakkalad786fa32013-03-20 23:48:19 +05302622 pDelStaParams->staIdx, pDelStaParams->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002623 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 retCode = wdaPostCtrlMsg( pMac, &msgQ );
2625 if( eSIR_SUCCESS != retCode)
2626 {
Jeff Johnsone7245742012-09-05 17:12:55 -07002627 if(fRespReqd)
2628 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002629 limLog( pMac, LOGE, FL("Posting DELETE_STA_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302631 vos_mem_free(pDelStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 }
2633
2634 return retCode;
2635}
2636
2637#if defined WLAN_FEATURE_VOWIFI_11R
2638/*------------------------------------------------------------------------
2639 * limAddFTStaSelf()
2640 *
2641 * FUNCTION:
2642 *
2643 * This function is called to add a STA once we have connected with a new
2644 * AP, that we have performed an FT to.
2645 *
2646 * The Add STA Response is created and now after the ADD Bss Is Successful
2647 * we add the self sta. We update with the association id from the reassoc
2648 * response from the AP.
2649 *------------------------------------------------------------------------
2650 */
2651tSirRetStatus limAddFTStaSelf(tpAniSirGlobal pMac, tANI_U16 assocId, tpPESession psessionEntry)
2652{
2653 tpAddStaParams pAddStaParams = NULL;
2654 tSirMsgQ msgQ;
2655 tSirRetStatus retCode = eSIR_SUCCESS;
2656
2657 pAddStaParams = pMac->ft.ftPEContext.pAddStaReq;
2658 pAddStaParams->assocId = assocId;
2659
2660 msgQ.type = SIR_HAL_ADD_STA_REQ;
2661 msgQ.reserved = 0;
2662 msgQ.bodyptr = pAddStaParams;
2663 msgQ.bodyval = 0;
2664
2665
2666#if defined WLAN_FEATURE_VOWIFI_11R_DEBUG
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002667 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_STA_REQ... (aid %d)" ), pAddStaParams->assocId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002668#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002669 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002670
2671 psessionEntry->limPrevMlmState = psessionEntry->limMlmState;
Varun Reddy Yeturue3bbf6e2013-02-08 18:50:55 -08002672 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_ADD_STA_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_STA_RSP_STATE;
2674 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
2675 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002676 limLog( pMac, LOGE, FL("Posting ADD_STA_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302677 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 }
2679 //
2680 // Dont need it any more
2681 pMac->ft.ftPEContext.pAddStaReq = NULL;
2682 return retCode;
2683}
2684
2685#endif /* WLAN_FEATURE_VOWIFI_11R */
2686
2687/**
2688 * limAddStaSelf()
2689 *
2690 *FUNCTION:
2691 * This function is called to add an STA context at hardware
2692 * whenever a STA is (Re) Associated.
2693 *
2694 *LOGIC:
2695 *
2696 *ASSUMPTIONS:
2697 * NA
2698 *
2699 *NOTE:
2700 * NA
2701 *
2702 * @param pMac - Pointer to Global MAC structure
2703 * @param pStaDs - Pointer to the STA datastructure created by
2704 * LIM and maintained by DPH
2705 * @return retCode - Indicates success or failure return code
2706 */
2707
2708tSirRetStatus
2709limAddStaSelf(tpAniSirGlobal pMac,tANI_U16 staIdx, tANI_U8 updateSta, tpPESession psessionEntry)
2710{
2711 tpAddStaParams pAddStaParams = NULL;
2712 tSirMsgQ msgQ;
2713 tSirRetStatus retCode = eSIR_SUCCESS;
2714 tSirMacAddr staMac;
2715 tANI_U32 listenInterval = WNI_CFG_LISTEN_INTERVAL_STADEF;
krunal soni71343fb2013-09-16 16:16:26 -07002716 tANI_U32 shortGi20MhzSupport;
2717 tANI_U32 shortGi40MhzSupport;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002718 /*This self Sta dot 11 mode comes from the cfg and the expectation here is
2719 * that cfg carries the systemwide capability that device under
2720 * consideration can support. This capability gets plumbed into the cfg
2721 * cache at system initialization time via the .dat and .ini file override
2722 * mechanisms and will not change. If it does change, it is the
2723 * responsibility of SME to evict the selfSta and reissue a new AddStaSelf
2724 * command.*/
2725 tANI_U32 selfStaDot11Mode=0, selfTxWidth=0;
2726 wlan_cfgGetInt(pMac,WNI_CFG_DOT11_MODE,&selfStaDot11Mode);
2727 limLog( pMac, LOG1, FL("cfgDot11Mode %d"),(int)selfStaDot11Mode);
2728 wlan_cfgGetInt(pMac,WNI_CFG_HT_CAP_INFO_SUPPORTED_CHAN_WIDTH_SET,&selfTxWidth);
2729 limLog( pMac, LOG1, FL("SGI 20 %d"),(int)selfTxWidth);
2730 limLog( pMac, LOG1, FL("Roam Channel Bonding Mode %d"),(int)pMac->roam.configParam.uCfgDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002731
2732 #if 0
2733 retCode =wlan_cfgGetStr(pMac, WNI_CFG_STA_ID, staMac, &cfg);
2734 if (retCode != eSIR_SUCCESS)
2735 {
2736 /// Could not get BSSID from CFG. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002737 limLog(pMac, LOGP, FL("could not retrieve STA MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002738 return retCode;
2739 }
2740 #endif //TO SUPPORT BT-AMP
2741 sirCopyMacAddr(staMac,psessionEntry->selfMacAddr);
2742
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302743 pAddStaParams = vos_mem_malloc(sizeof(tAddStaParams));
2744 if (NULL == pAddStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302746 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_STA" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07002747 return eSIR_MEM_ALLOC_FAILED;
2748 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302749 vos_mem_set((tANI_U8 *) pAddStaParams, sizeof(tAddStaParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002750
2751 /// Add STA context at MAC HW (BMU, RHP & TFP)
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302752 vos_mem_copy((tANI_U8 *) pAddStaParams->staMac,
2753 (tANI_U8 *) staMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002754
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302755 vos_mem_copy((tANI_U8 *) pAddStaParams->bssId,
2756 psessionEntry->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07002757
2758 pAddStaParams->assocId = psessionEntry->limAID;
2759 pAddStaParams->staType = STA_ENTRY_SELF;
2760 pAddStaParams->status = eHAL_STATUS_SUCCESS;
2761 pAddStaParams->respReqd = 1;
2762
2763 /* Update PE session ID */
2764 pAddStaParams->sessionId = psessionEntry->peSessionId;
2765
2766 // This will indicate HAL to "allocate" a new STA index
2767 pAddStaParams->staIdx = staIdx;
2768 pAddStaParams->updateSta = updateSta;
2769
2770 pAddStaParams->shortPreambleSupported = psessionEntry->beaconParams.fShortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -07002771
Jeff Johnsone7245742012-09-05 17:12:55 -07002772#ifdef WLAN_FEATURE_11AC
2773 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry,NULL);
2774#else
2775 limPopulateOwnRateSet(pMac, &pAddStaParams->supportedRates, NULL, false,psessionEntry);
2776#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002777// if( psessionEntry->htCapability)---> old check
2778 /*We used to check if the session is htCapable before setting the htCapable
2779 * flag. The check limited us from operating */
2780 if ( IS_DOT11_MODE_HT(selfStaDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002782 pAddStaParams->htCapable = TRUE ;
Jeff Johnson295189b2012-06-20 16:38:30 -07002783#ifdef DISABLE_GF_FOR_INTEROP
2784 /*
2785 * To resolve the interop problem with Broadcom AP,
2786 * where TQ STA could not pass traffic with GF enabled,
2787 * TQ STA will do Greenfield only with TQ AP, for
2788 * everybody else it will be turned off.
2789 */
2790 if( (psessionEntry->pLimJoinReq != NULL) && (!psessionEntry->pLimJoinReq->bssDescription.aniIndicator))
2791 {
2792 limLog( pMac, LOGE, FL(" Turning off Greenfield, when adding self entry"));
2793 pAddStaParams->greenFieldCapable = WNI_CFG_GREENFIELD_CAPABILITY_DISABLE;
2794 }
2795 else
2796#endif
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002797 {
2798 pAddStaParams->greenFieldCapable = limGetHTCapability( pMac, eHT_GREENFIELD, psessionEntry);
2799 pAddStaParams->txChannelWidthSet =
2800 pMac->roam.configParam.channelBondingMode5GHz;
2801 // pAddStaParams->txChannelWidthSet = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
2802 pAddStaParams->mimoPS = limGetHTCapability( pMac, eHT_MIMO_POWER_SAVE, psessionEntry );
2803 pAddStaParams->rifsMode = limGetHTCapability( pMac, eHT_RIFS_MODE, psessionEntry );
2804 pAddStaParams->lsigTxopProtection = limGetHTCapability( pMac, eHT_LSIG_TXOP_PROTECTION, psessionEntry );
2805 pAddStaParams->delBASupport = limGetHTCapability( pMac, eHT_DELAYED_BA, psessionEntry );
2806 pAddStaParams->maxAmpduDensity = limGetHTCapability( pMac, eHT_MPDU_DENSITY, psessionEntry );
2807 pAddStaParams->maxAmpduSize = limGetHTCapability(pMac, eHT_MAX_RX_AMPDU_FACTOR, psessionEntry);
2808 pAddStaParams->maxAmsduSize = limGetHTCapability( pMac, eHT_MAX_AMSDU_LENGTH, psessionEntry );
2809 pAddStaParams->fDsssCckMode40Mhz = limGetHTCapability( pMac, eHT_DSSS_CCK_MODE_40MHZ, psessionEntry);
krunal soni71343fb2013-09-16 16:16:26 -07002810 /*
2811 * We will read the gShortGI20Mhz from ini file, and if it is set
2812 * to 1 then we will tell Peer that we support 40Mhz short GI
2813 */
2814 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
2815 (pMac, WNI_CFG_SHORT_GI_20MHZ,
2816 &shortGi20MhzSupport)))
2817 {
2818 if (VOS_TRUE == shortGi20MhzSupport)
2819 {
2820 pAddStaParams->fShortGI20Mhz =
2821 WNI_CFG_SHORT_GI_20MHZ_STAMAX;
2822 //pAddStaParams->fShortGI20Mhz =
2823 //limGetHTCapability(pMac, eHT_SHORT_GI_20MHZ,
2824 // psessionEntry);
2825 }
2826 else
2827 {
2828 pAddStaParams->fShortGI20Mhz = VOS_FALSE;
2829 }
2830 }
2831 else
2832 {
2833 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
2834 "CFG,setting value to default"));)
2835 pAddStaParams->fShortGI20Mhz = WNI_CFG_SHORT_GI_20MHZ_STADEF;
2836 }
2837
2838 /*
2839 * We will read the gShortGI40Mhz from ini file, and if it is set
2840 * to 1 then we will tell Peer that we support 40Mhz short GI
2841 */
2842 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
2843 (pMac, WNI_CFG_SHORT_GI_40MHZ,
2844 &shortGi40MhzSupport)))
2845 {
2846 if (VOS_TRUE == shortGi40MhzSupport)
2847 {
2848 pAddStaParams->fShortGI40Mhz =
2849 WNI_CFG_SHORT_GI_40MHZ_STAMAX;
2850 //pAddStaParams->fShortGI40Mhz =
2851 //limGetHTCapability(pMac, eHT_SHORT_GI_40MHZ,
2852 // psessionEntry);
2853 }
2854 else
2855 {
2856 pAddStaParams->fShortGI40Mhz = VOS_FALSE;
2857 }
2858 }
2859 else
2860 {
2861 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
2862 "CFG,setting value to default"));)
2863 pAddStaParams->fShortGI40Mhz = WNI_CFG_SHORT_GI_40MHZ_STADEF;
2864 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002865 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002867#ifdef WLAN_FEATURE_11AC
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002868 pAddStaParams->vhtCapable = IS_DOT11_MODE_VHT(selfStaDot11Mode);
2869 if (pAddStaParams->vhtCapable){
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002870 pAddStaParams->vhtTxChannelWidthSet = psessionEntry->vhtTxChannelWidthSet;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002871 limLog( pMac, LOG1, FL("VHT WIDTH SET %d"),pAddStaParams->vhtTxChannelWidthSet);
2872 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002873 pAddStaParams->vhtTxBFCapable = psessionEntry->txBFIniFeatureEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07002874#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002875
2876 /* For Self STA get the LDPC capability from session i.e config.ini*/
2877 pAddStaParams->htLdpcCapable =
2878 (psessionEntry->txLdpcIniFeatureEnabled & 0x01);
2879 pAddStaParams->vhtLdpcCapable =
2880 ((psessionEntry->txLdpcIniFeatureEnabled >> 1)& 0x01);
2881
Jeff Johnson295189b2012-06-20 16:38:30 -07002882 if(wlan_cfgGetInt(pMac, WNI_CFG_LISTEN_INTERVAL, &listenInterval) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002883 limLog(pMac, LOGP, FL("Couldn't get LISTEN_INTERVAL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 pAddStaParams->listenInterval = (tANI_U16)listenInterval;
2885
Jeff Johnson295189b2012-06-20 16:38:30 -07002886 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona)
2887 {
2888 pAddStaParams->p2pCapableSta = 1;
2889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002890
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002891 //limFillSupportedRatesInfo(pMac, NULL, &pAddStaParams->supportedRates,psessionEntry);
2892 pAddStaParams->supportedRates.opRateMode = limGetStaRateMode((tANI_U8)selfStaDot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002893
2894 msgQ.type = WDA_ADD_STA_REQ;
2895 //
2896 // FIXME_GEN4
2897 // A global counter (dialog token) is required to keep track of
2898 // all PE <-> HAL communication(s)
2899 //
2900 msgQ.reserved = 0;
2901 msgQ.bodyptr = pAddStaParams;
2902 msgQ.bodyval = 0;
2903
2904 limLog( pMac, LOGW, FL( "Sending SIR_HAL_ADD_STA_REQ... (aid %d)" ),
2905 pAddStaParams->assocId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002906 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07002907
2908 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
2909 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002910 limLog( pMac, LOGE, FL("Posting ADD_STA_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05302911 vos_mem_free(pAddStaParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 }
2913 return retCode;
2914}
2915
2916
2917/**
2918 * limTeardownInfraBSS()
2919 *
2920 *FUNCTION:
2921 * This function is called by various LIM functions to teardown
2922 * an established Infrastructure BSS
2923 *
2924 *LOGIC:
2925 *
2926 *ASSUMPTIONS:
2927 *
2928 *NOTE:
2929 *
2930 * @param pMac - Pointer to Global MAC structure
2931 * @return None
2932 */
2933
2934void
2935limTeardownInfraBss(tpAniSirGlobal pMac,tpPESession psessionEntry)
2936{
2937 tSirMacAddr bcAddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
2938
2939 /**
2940 * Send Broadcast Disassociate frame with
2941 * 'leaving BSS' reason.
2942 */
2943 limSendDisassocMgmtFrame(pMac,
2944 eSIR_MAC_DISASSOC_LEAVING_BSS_REASON,
Madan Mohan Koyyalamudi521ff192012-11-15 17:13:08 -08002945 bcAddr,psessionEntry, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002946} /*** end limTeardownInfraBss() ***/
2947
2948
2949/**
2950 * limHandleCnfWaitTimeout()
2951 *
2952 *FUNCTION:
2953 * This function is called by limProcessMessageQueue to handle
2954 * various confirmation failure cases.
2955 *
2956 *LOGIC:
2957 *
2958 *ASSUMPTIONS:
2959 *
2960 *NOTE:
2961 *
2962 * @param pMac - Pointer to Global MAC structure
2963 * @param pStaDs - Pointer to a sta descriptor
2964 * @return None
2965 */
2966
2967void limHandleCnfWaitTimeout(tpAniSirGlobal pMac, tANI_U16 staId)
2968{
2969 tpDphHashNode pStaDs;
2970 tLimSystemRole systemRole;
2971 tpPESession psessionEntry = NULL;
2972
2973 if((psessionEntry = peFindSessionBySessionId(pMac, pMac->lim.limTimers.gpLimCnfWaitTimer[staId].sessionId))== NULL)
2974 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002975 limLog(pMac, LOGP,FL("Session Does not exist for given sessionID"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002976 return;
2977 }
2978 systemRole = limGetSystemRole(psessionEntry);
2979 pStaDs = dphGetHashEntry(pMac, staId, &psessionEntry->dph.dphHashTable);
2980
2981 if (pStaDs == NULL)
2982 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002983 PELOGW(limLog(pMac, LOGW, FL("No STA context in SIR_LIM_CNF_WAIT_TIMEOUT."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 return;
2985 }
2986
2987 switch (pStaDs->mlmStaContext.mlmState) {
2988 case eLIM_MLM_WT_ASSOC_CNF_STATE:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07002989 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 -07002990 limPrintMacAddr(pMac, pStaDs->staAddr, LOGW);
2991
2992 if ( (systemRole == eLIM_AP_ROLE)|| (systemRole == eLIM_BT_AMP_AP_ROLE) )
2993 {
2994 limRejectAssociation(
2995 pMac,
2996 pStaDs->staAddr,
2997 pStaDs->mlmStaContext.subType,
2998 true,
2999 pStaDs->mlmStaContext.authType,
3000 pStaDs->assocId,
3001 true,
3002 (tSirResultCodes) eSIR_MAC_UNSPEC_FAILURE_STATUS,
3003 psessionEntry);
3004 }
3005 break;
3006
3007 default:
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003008 limLog(pMac, LOGW, FL("Received CNF_WAIT_TIMEOUT in state %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 pStaDs->mlmStaContext.mlmState);
3010 }
3011}
3012
3013
3014/**
3015 * limDeleteDphHashEntry()
3016 *
3017 *FUNCTION:
3018 * This function is called whenever we need to delete
3019 * the dph hash entry
3020 *
3021 *LOGIC:
3022 *
3023 *ASSUMPTIONS:
3024 *
3025 *NOTE:
3026 *
3027 * @param pMac Pointer to Global MAC structure
3028 * @param tANI_U16 staId
3029 * @return None
3030 */
3031
3032void
3033limDeleteDphHashEntry(tpAniSirGlobal pMac, tSirMacAddr staAddr, tANI_U16 staId,tpPESession psessionEntry)
3034{
3035 tANI_U16 aid;
3036 tpDphHashNode pStaDs;
3037 tUpdateBeaconParams beaconParams;
3038 tLimSystemRole systemRole;
3039
3040 beaconParams.paramChangeBitmap = 0;
3041 limDeactivateAndChangePerStaIdTimer(pMac, eLIM_CNF_WAIT_TIMER, staId);
3042 if (NULL == psessionEntry)
3043 {
3044 PELOGE(limLog(pMac, LOGE, FL("NULL psessionEntry"));)
3045 return;
3046 }
3047 systemRole = limGetSystemRole(psessionEntry);
3048 beaconParams.bssIdx = psessionEntry->bssIdx;
3049 pStaDs = dphLookupHashEntry(pMac, staAddr, &aid, &psessionEntry->dph.dphHashTable);
3050 if (pStaDs != NULL)
3051 {
3052 PELOGW(limLog(pMac, LOGW, FL("Deleting DPH Hash entry for STAID: %X\n "), staId);)
3053 // update the station count and perform associated actions
3054 // do this before deleting the dph hash entry
3055 limUtilCountStaDel(pMac, pStaDs, psessionEntry);
3056
3057 if((eLIM_AP_ROLE == psessionEntry->limSystemRole) ||
3058 (eLIM_STA_IN_IBSS_ROLE == psessionEntry->limSystemRole))
3059 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 if(psessionEntry->limSystemRole == eLIM_AP_ROLE ){
3061 if(psessionEntry->gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE){
3062 limDecideApProtectionOnDelete(pMac, pStaDs, &beaconParams,psessionEntry);
3063 }
3064 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003065
3066 if(eLIM_STA_IN_IBSS_ROLE == systemRole)
3067 limIbssDecideProtectionOnDelete(pMac, pStaDs, &beaconParams, psessionEntry);
3068
3069 limDecideShortPreamble(pMac, pStaDs, &beaconParams, psessionEntry);
3070 limDecideShortSlot(pMac, pStaDs, &beaconParams, psessionEntry);
3071
3072 //Send message to HAL about beacon parameter change.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003073 PELOGW(limLog(pMac, LOGW, FL("param bitmap = %d "), beaconParams.paramChangeBitmap);)
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 if(beaconParams.paramChangeBitmap)
3075 {
3076 schSetFixedBeaconFields(pMac,psessionEntry);
3077 limSendBeaconParams(pMac, &beaconParams, psessionEntry );
3078 }
3079 }
3080 if (dphDeleteHashEntry(pMac, staAddr, staId, &psessionEntry->dph.dphHashTable) != eSIR_SUCCESS)
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003081 limLog(pMac, LOGP, FL("error deleting hash entry"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 }
3083}
3084
3085
3086
3087/**
3088 * limCheckAndAnnounceJoinSuccess()
3089 *
3090 *FUNCTION:
3091 * This function is called upon receiving Beacon/Probe Response
3092 * frame in WT_JOIN_BEACON_STATE to check if the received
3093 * Beacon/Probe Response is from the BSS that we're attempting
3094 * to join.
3095 *
3096 *LOGIC:
3097 * If the Beacon/Probe Response is indeed from the BSS we're
3098 * attempting to join, join success is sent to SME.
3099 *
3100 *ASSUMPTIONS:
3101 *
3102 *NOTE:
3103 *
3104 * @param pMac Pointer to Global MAC structure
3105 * @param pBPR Pointer to received Beacon/Probe Response
3106 * @param pHdr Pointer to received Beacon/Probe Response
3107 * MAC header
3108 * @return None
3109 */
3110
3111void
3112limCheckAndAnnounceJoinSuccess(tpAniSirGlobal pMac,
3113 tSirProbeRespBeacon *pBPR,
3114 tpSirMacMgmtHdr pHdr,tpPESession psessionEntry)
3115{
3116 tSirMacSSid currentSSID;
3117 tLimMlmJoinCnf mlmJoinCnf;
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003118 tANI_U32 val = 0;
3119 tANI_U32 *noa1DurationFromBcn = NULL;
3120 tANI_U32 *noa2DurationFromBcn = NULL;
3121 tANI_U32 noa;
3122 tANI_U32 TotalNum_NoADesc = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003123
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303124 vos_mem_copy(currentSSID.ssId,
3125 psessionEntry->ssId.ssId,
3126 psessionEntry->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07003127
3128 currentSSID.length = (tANI_U8)psessionEntry->ssId.length ;
3129
3130 if (
3131 /* Check for SSID only in probe response. Beacons may not carry
3132 SSID information in hidden SSID case */
3133 ( (SIR_MAC_MGMT_FRAME == pHdr->fc.type) &&
3134 (SIR_MAC_MGMT_PROBE_RSP == pHdr->fc.subType) ) &&
3135 currentSSID.length &&
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303136 (!vos_mem_compare((tANI_U8 *) &pBPR->ssId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 (tANI_U8 *) &currentSSID,
3138 (tANI_U8) (1 + currentSSID.length)) ))
3139 {
3140 /**
3141 * Received SSID does not match with the one we've.
3142 * Ignore received Beacon frame
3143 */
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003144 PELOG1(limLog(pMac, LOG1, FL("SSID received in Beacon does not match"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003145#ifdef WLAN_DEBUG
3146 pMac->lim.gLimBcnSSIDMismatchCnt++;
3147#endif
3148 return;
3149 }
3150
3151 if( (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE)||(psessionEntry->limSystemRole == eLIM_STA_ROLE))
3152 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003153 PELOG1(limLog(pMac, LOG1, FL("Received Beacon/PR with matching BSSID"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003154
3155 // Deactivate Join Failure timer
3156 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
Madan Mohan Koyyalamudi9aff9ff2012-11-29 11:27:25 -08003157 // Deactivate Periodic Join timer
3158 limDeactivateAndChangeTimer(pMac, eLIM_PERIODIC_JOIN_PROBE_REQ_TIMER);
Jeff Johnson295189b2012-06-20 16:38:30 -07003159
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003160 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona &&
3161 pBPR->P2PProbeRes.NoticeOfAbsence.present)
3162 {
3163
3164 noa1DurationFromBcn = (tANI_U32*)(pBPR->P2PProbeRes.NoticeOfAbsence.NoADesc + 1);
3165
3166 if(pBPR->P2PProbeRes.NoticeOfAbsence.num_NoADesc)
3167 TotalNum_NoADesc = pBPR->P2PProbeRes.NoticeOfAbsence.num_NoADesc/SIZE_OF_NOA_DESCRIPTOR;
3168
3169 noa = *noa1DurationFromBcn;
3170
3171 if(TotalNum_NoADesc > 1)
3172 {
3173 noa2DurationFromBcn = (tANI_U32*)(pBPR->P2PProbeRes.NoticeOfAbsence.NoADesc + SIZE_OF_NOA_DESCRIPTOR + 1);
3174 noa += *noa2DurationFromBcn;
3175 }
3176
3177 /*If MAX Noa exceeds 3 secs we will consider only 3 secs to
3178 * avoid arbitary values in noa duration field
3179 */
3180 noa = noa > MAX_NOA_PERIOD_IN_MICROSECS ? MAX_NOA_PERIOD_IN_MICROSECS : noa;
3181 noa = noa/1000; //Convert to ms
3182
3183 if( wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT,&val) == eSIR_SUCCESS )
3184 {
3185 psessionEntry->defaultAuthFailureTimeout = val;
3186 ccmCfgSetInt(pMac,WNI_CFG_AUTHENTICATE_FAILURE_TIMEOUT ,val + noa, NULL, eANI_BOOLEAN_FALSE);
3187 }
3188 }
3189 else
3190 {
3191 psessionEntry->defaultAuthFailureTimeout = 0;
3192 }
Madan Mohan Koyyalamudi666d33a2012-11-29 11:32:59 -08003193
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 // Update Beacon Interval at CFG database
3195
3196 if ( pBPR->HTCaps.present )
3197 limUpdateStaRunTimeHTCapability( pMac, &pBPR->HTCaps );
3198 if ( pBPR->HTInfo.present )
3199 limUpdateStaRunTimeHTInfo( pMac, &pBPR->HTInfo, psessionEntry);
3200 psessionEntry->limMlmState = eLIM_MLM_JOINED_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003201 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_JOINED_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003202
Jeff Johnson295189b2012-06-20 16:38:30 -07003203
3204 /**
3205 * Announce join success by sending
3206 * Join confirm to SME.
3207 */
3208 mlmJoinCnf.resultCode = eSIR_SME_SUCCESS;
3209 mlmJoinCnf.protStatusCode = eSIR_MAC_SUCCESS_STATUS;
3210 /* Update PE sessionId*/
3211 mlmJoinCnf.sessionId = psessionEntry->peSessionId;
3212 limPostSmeMessage(pMac, LIM_MLM_JOIN_CNF, (tANI_U32 *) &mlmJoinCnf);
3213 } // if ((pMac->lim.gLimSystemRole == IBSS....
3214}
3215
3216/**
3217 * limExtractApCapabilities()
3218 *
3219 *FUNCTION:
3220 * This function is called to extract all of the AP's capabilities
3221 * from the IEs received from it in Beacon/Probe Response frames
3222 *
3223 *LOGIC:
3224 * This routine mimics the limExtractApCapability() API. The difference here
3225 * is that this API returns the entire tSirProbeRespBeacon info as is. It is
3226 * left to the caller of this API to use this info as required
3227 *
3228 *ASSUMPTIONS:
3229 * NA
3230 *
3231 *NOTE:
3232 *
3233 * @param pMac Pointer to Global MAC structure
3234 * @param pIE Pointer to starting IE in Beacon/Probe Response
3235 * @param ieLen Length of all IEs combined
3236 * @param beaconStruct A pointer to tSirProbeRespBeacon that needs to be
3237 * populated
3238 * @return status A status reporting eSIR_SUCCESS or eSIR_FAILURE
3239 */
3240tSirRetStatus limExtractApCapabilities( tpAniSirGlobal pMac,
3241 tANI_U8 *pIE,
3242 tANI_U16 ieLen,
3243 tpSirProbeRespBeacon beaconStruct )
3244{
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303245 vos_mem_set((tANI_U8 *) beaconStruct, sizeof( tSirProbeRespBeacon ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003246
3247 PELOG3(limLog( pMac, LOG3,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003248 FL( "In limExtractApCapabilities: The IE's being received are:" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 sirDumpBuf( pMac, SIR_LIM_MODULE_ID, LOG3, pIE, ieLen );)
3250
3251 // Parse the Beacon IE's, Don't try to parse if we dont have anything in IE
3252 if (ieLen > 0) {
3253 if( eSIR_SUCCESS != sirParseBeaconIE( pMac, beaconStruct, pIE, (tANI_U32)ieLen ))
3254 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003255 limLog( pMac, LOGE, FL("APCapExtract: Beacon parsing error!"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 return eSIR_FAILURE;
3257 }
3258 }
3259
3260 return eSIR_SUCCESS;
3261}
3262
3263
3264/**
3265 * limDelBss()
3266 *
3267 *FUNCTION:
3268 * This function is called to delete BSS context at hardware
3269 * whenever a STA is disassociated
3270 *
3271 *LOGIC:
3272 *
3273 *ASSUMPTIONS:
3274 * NA
3275 *
3276 *NOTE:
3277 * NA
3278 *
3279 * @param pMac - Pointer to Global MAC structure
3280 * @param pStaDs - Pointer to the STA datastructure created by
3281 * LIM and maintained by DPH
3282 * @return retCode - Indicates success or failure return code
3283 */
3284
3285tSirRetStatus
3286limDelBss(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tANI_U16 bssIdx,tpPESession psessionEntry)
3287{
3288 tpDeleteBssParams pDelBssParams = NULL;
3289 tSirMsgQ msgQ;
3290 tSirRetStatus retCode = eSIR_SUCCESS;
3291
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303292 pDelBssParams = vos_mem_malloc(sizeof(tDeleteBssParams));
3293 if (NULL == pDelBssParams)
3294 {
3295 limLog( pMac, LOGP, FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003296 return eSIR_MEM_ALLOC_FAILED;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303297 }
3298 vos_mem_set((tANI_U8 *) pDelBssParams, sizeof(tDeleteBssParams), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003299
3300
3301 pDelBssParams->sessionId = psessionEntry->peSessionId; //update PE session Id
3302
3303 //DPH was storing the AssocID in staID field,
3304 //staID is actually assigned by HAL when AddSTA message is sent.
3305 if (pStaDs != NULL)
3306 {
3307 pDelBssParams->bssIdx= pStaDs->bssId;
3308 pStaDs->valid = 0;
3309 pStaDs->mlmStaContext.mlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
3310 }
3311 else
3312 pDelBssParams->bssIdx = bssIdx;
3313 psessionEntry->limMlmState = eLIM_MLM_WT_DEL_BSS_RSP_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003314 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, eLIM_MLM_WT_DEL_BSS_RSP_STATE));
Jeff Johnson295189b2012-06-20 16:38:30 -07003315
Srinivas Girigowda2a69dcf2013-09-13 14:48:34 -07003316 if((psessionEntry->peSessionId == pMac->lim.limTimers.gLimJoinFailureTimer.sessionId) &&
3317 (VOS_TRUE == tx_timer_running(&pMac->lim.limTimers.gLimJoinFailureTimer)))
3318 {
3319 limDeactivateAndChangeTimer(pMac, eLIM_JOIN_FAIL_TIMER);
3320 }
3321
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 pDelBssParams->status= eHAL_STATUS_SUCCESS;
3323 pDelBssParams->respReqd = 1;
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003324 PELOGW(limLog( pMac, LOGW, FL("Sending HAL_DELETE_BSS_REQ for BSSID: %X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 pDelBssParams->bssIdx);)
3326
3327 //we need to defer the message until we get the response back from HAL.
3328 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3329
3330 msgQ.type = WDA_DELETE_BSS_REQ;
3331 msgQ.reserved = 0;
3332 msgQ.bodyptr = pDelBssParams;
3333 msgQ.bodyval = 0;
3334
Jeff Johnsone7245742012-09-05 17:12:55 -07003335 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003336
3337 if( eSIR_SUCCESS != (retCode = wdaPostCtrlMsg( pMac, &msgQ )))
3338 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003339 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003340 limLog( pMac, LOGE, FL("Posting DELETE_BSS_REQ to HAL failed, reason=%X"), retCode );
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303341 vos_mem_free(pDelBssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -07003342 }
3343
3344 return retCode;
3345}
3346
3347
Jeff Johnson295189b2012-06-20 16:38:30 -07003348
3349/**
3350 * limSendAddBss()
3351 *
3352 *FUNCTION:
3353 *
3354 *LOGIC:
3355 * 1) LIM receives eWNI_SME_JOIN_REQ
3356 * 2) For a valid eWNI_SME_JOIN_REQ, LIM sends
3357 * SIR_HAL_ADD_BSS_REQ to HAL
3358 *
3359 *ASSUMPTIONS:
3360 * JOIN REQ parameters are saved in pMac->lim.gLimMlmJoinReq
3361 * ADD BSS parameters can be obtained from two sources:
3362 * 1) pMac->lim.gLimMlmJoinReq
3363 * 2) beaconStruct, passed as paramter
3364 * So, if a reqd parameter is found in bssDescriptions
3365 * then it is given preference over beaconStruct
3366 *
3367 *NOTE:
3368 *
3369 * @param pMac Pointer to Global MAC structure
3370 * pAssocRsp contains the structured assoc/reassoc Response got from AP
3371 * beaconstruct Has the ProbeRsp/Beacon structured details
3372 * bssDescription bssDescription passed to PE from the SME
3373 * @return None
3374 */
3375
3376tSirRetStatus limStaSendAddBss( tpAniSirGlobal pMac, tpSirAssocRsp pAssocRsp,
3377 tpSchBeaconStruct pBeaconStruct, tpSirBssDescription bssDescription, tANI_U8 updateEntry,
3378 tpPESession psessionEntry)
3379
3380{
3381 tSirMsgQ msgQ;
3382 tpAddBssParams pAddBssParams = NULL;
3383 tANI_U32 retCode;
3384 tANI_U8 i;
3385 tpDphHashNode pStaDs = NULL;
3386 tANI_U8 chanWidthSupp = 0;
krunal soni71343fb2013-09-16 16:16:26 -07003387 tANI_U32 shortGi20MhzSupport;
3388 tANI_U32 shortGi40MhzSupport;
Jeff Johnson295189b2012-06-20 16:38:30 -07003389 // Package SIR_HAL_ADD_BSS_REQ message parameters
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303390 pAddBssParams = vos_mem_malloc(sizeof( tAddBssParams ));
3391 if (NULL == pAddBssParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 {
3393 limLog( pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303394 FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 retCode = eSIR_MEM_ALLOC_FAILED;
3396 goto returnFailure;
3397 }
3398 else
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303399 vos_mem_set((tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003400
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303401 vos_mem_copy(pAddBssParams->bssId,bssDescription->bssId,
3402 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303404 vos_mem_copy(pAddBssParams->selfMacAddr,
3405 psessionEntry->selfMacAddr,
3406 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003407
3408 if(psessionEntry->bssType == eSIR_BTAMP_AP_MODE)
3409 {
3410 pAddBssParams->bssType = eSIR_BTAMP_AP_MODE;
3411 }
3412 else
3413 {
3414 pAddBssParams->bssType = eSIR_INFRASTRUCTURE_MODE;
3415 }
3416
3417 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
3418
3419 /* Update PE session ID */
3420 pAddBssParams->sessionId = psessionEntry->peSessionId;
3421
3422 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
3423
3424 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
3425 pAddBssParams->updateBss = updateEntry;
3426
3427
3428 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
3429 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
3430 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
3431 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
3432
3433 pAddBssParams->rateSet.numRates = pAssocRsp->supportedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303434 vos_mem_copy(pAddBssParams->rateSet.rate,
3435 pAssocRsp->supportedRates.rate, pAssocRsp->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07003436
3437 pAddBssParams->nwType = bssDescription->nwType;
3438
Jeff Johnsone7245742012-09-05 17:12:55 -07003439 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pAssocRsp->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
3441 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
3442 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
3443 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
3444
3445
3446 // Use the advertised capabilities from the received beacon/PR
3447
3448
3449 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pAssocRsp->HTCaps.present ))
3450 {
3451 pAddBssParams->htCapable = pAssocRsp->HTCaps.present;
3452
3453 if ( pBeaconStruct->HTInfo.present )
3454 {
3455 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pAssocRsp->HTInfo.opMode;
3456 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pAssocRsp->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 if( (pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3459 (chanWidthSupp) )
3460 {
3461 pAddBssParams->txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
3462 pAddBssParams->currentExtChannel = pAssocRsp->HTInfo.secondaryChannelOffset;
3463 }
3464 else
3465 {
3466 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003467 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 }
3469 pAddBssParams->llnNonGFCoexist = (tANI_U8)pAssocRsp->HTInfo.nonGFDevicesPresent;
3470 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pAssocRsp->HTInfo.lsigTXOPProtectionFullSupport;
3471 pAddBssParams->fRIFSMode = pAssocRsp->HTInfo.rifsMode;
3472 }
3473 }
3474
3475 pAddBssParams->currentOperChannel = bssDescription->channelId;
3476
Jeff Johnsone7245742012-09-05 17:12:55 -07003477#ifdef WLAN_FEATURE_11AC
3478 if (psessionEntry->vhtCapability && ( pAssocRsp->VHTCaps.present ))
3479 {
3480 pAddBssParams->vhtCapable = pAssocRsp->VHTCaps.present;
3481 pAddBssParams->vhtTxChannelWidthSet = pAssocRsp->VHTOperation.chanWidth;
3482 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003483 pAddBssParams->currentOperChannel,
3484 pAddBssParams->currentExtChannel,
3485 psessionEntry->apCenterChan,
3486 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003487 }
3488 else
3489 {
3490 pAddBssParams->vhtCapable = 0;
3491 }
3492#endif
3493
3494
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 // Populate the STA-related parameters here
3496 // Note that the STA here refers to the AP
3497 {
3498 /* staType = PEER*/
3499 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
3500
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303501 vos_mem_copy(pAddBssParams->staContext.bssId,
3502 bssDescription->bssId,
3503 sizeof( tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
3505
3506 /* Fill Assoc id from the dph table */
3507 pStaDs = dphLookupHashEntry(pMac, pAddBssParams->staContext.bssId,
3508 &pAddBssParams->staContext.assocId, &psessionEntry->dph.dphHashTable);
3509 if (pStaDs == NULL)
3510 {
3511 PELOGE(limLog(pMac, LOGE, FL("Couldn't get assoc id for"
3512 "MAC ADDR: %02x:%02x:%02x:%02x:%02x:%02x"),
3513 pAddBssParams->staContext.staMac[0],
3514 pAddBssParams->staContext.staMac[1],
3515 pAddBssParams->staContext.staMac[2],
3516 pAddBssParams->staContext.staMac[3],
3517 pAddBssParams->staContext.staMac[4],
3518 pAddBssParams->staContext.staMac[5]
3519 );)
3520 }
3521 pAddBssParams->staContext.uAPSD = 0;
3522 pAddBssParams->staContext.maxSPLen = 0;
3523 pAddBssParams->staContext.shortPreambleSupported = (tANI_U8)pAssocRsp->capabilityInfo.shortPreamble;
3524 pAddBssParams->staContext.updateSta = updateEntry;
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003525 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && pBeaconStruct->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 {
3527 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
3528 pAddBssParams->staContext.htCapable = 1;
3529 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 )pAssocRsp->HTCaps.greenField;
3530 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 )pAssocRsp->HTCaps.lsigTXOPProtection;
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003531#ifdef WLAN_FEATURE_11AC
3532 if (psessionEntry->vhtCapability && pBeaconStruct->VHTCaps.present)
3533 {
3534 pAddBssParams->staContext.vhtCapable = 1;
3535 if ((pAssocRsp->VHTCaps.suBeamFormerCap ||
3536 pAssocRsp->VHTCaps.muBeamformerCap) &&
3537 psessionEntry->txBFIniFeatureEnabled)
3538 {
3539 pAddBssParams->staContext.vhtTxBFCapable = 1;
3540 }
3541 }
3542#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 if( (pAssocRsp->HTCaps.supportedChannelWidthSet) &&
3544 (chanWidthSupp) )
3545 {
3546 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pAssocRsp->HTInfo.recommendedTxWidthSet;
Jeff Johnsone7245742012-09-05 17:12:55 -07003547#ifdef WLAN_FEATURE_11AC
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003548 if (pAddBssParams->staContext.vhtCapable)
Jeff Johnsone7245742012-09-05 17:12:55 -07003549 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003550 pAddBssParams->staContext.vhtTxChannelWidthSet = pAssocRsp->VHTOperation.chanWidth; //pMac->lim.apChanWidth;
3551 }
3552#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 }
3554 else
3555 {
3556 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3557 }
3558 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pAssocRsp->HTCaps.mimoPowerSave;
3559 pAddBssParams->staContext.delBASupport = ( tANI_U8 )pAssocRsp->HTCaps.delayedBA;
3560 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 )pAssocRsp->HTCaps.maximalAMSDUsize;
3561 pAddBssParams->staContext.maxAmpduDensity = pAssocRsp->HTCaps.mpduDensity;
3562 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pAssocRsp->HTCaps.dsssCckMode40MHz;
krunal soni71343fb2013-09-16 16:16:26 -07003563 /*
3564 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
3565 * if they are set then we will use what ever Assoc response coming
3566 * from AP supports. If these values are set as 0 in ini file then
3567 * we will hardcode this values to 0.
3568 */
3569 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3570 (pMac, WNI_CFG_SHORT_GI_20MHZ,
3571 &shortGi20MhzSupport)))
3572 {
3573 if (VOS_TRUE == shortGi20MhzSupport)
3574 {
3575 pAddBssParams->staContext.fShortGI20Mhz =
3576 (tANI_U8)pAssocRsp->HTCaps.shortGI20MHz;
3577 }
3578 else
3579 {
3580 pAddBssParams->staContext.fShortGI20Mhz = VOS_FALSE;
3581 }
3582 }
3583 else
3584 {
3585 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
3586 "CFG,setting value to default"));)
3587 pAddBssParams->staContext.fShortGI20Mhz =
3588 WNI_CFG_SHORT_GI_20MHZ_STADEF;
3589 }
3590
3591 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3592 (pMac, WNI_CFG_SHORT_GI_40MHZ,
3593 &shortGi40MhzSupport)))
3594 {
3595 if (VOS_TRUE == shortGi40MhzSupport)
3596 {
3597 pAddBssParams->staContext.fShortGI40Mhz =
3598 (tANI_U8)pAssocRsp->HTCaps.shortGI40MHz;
3599 }
3600 else
3601 {
3602 pAddBssParams->staContext.fShortGI40Mhz = VOS_FALSE;
3603 }
3604 }
3605 else
3606 {
3607 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
3608 "CFG,setting value to default"));)
3609 pAddBssParams->staContext.fShortGI40Mhz =
3610 WNI_CFG_SHORT_GI_40MHZ_STADEF;
3611 }
3612
Jeff Johnson295189b2012-06-20 16:38:30 -07003613 pAddBssParams->staContext.maxAmpduSize= pAssocRsp->HTCaps.maxRxAMPDUFactor;
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08003614 if( pAddBssParams->staContext.vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP )
3615 {
3616 pAddBssParams->staContext.htLdpcCapable = 0;
3617 pAddBssParams->staContext.vhtLdpcCapable = 0;
3618 }
3619 else
3620 {
3621 pAddBssParams->staContext.htLdpcCapable = (tANI_U8)pAssocRsp->HTCaps.advCodingCap;
3622 pAddBssParams->staContext.vhtLdpcCapable = (tANI_U8)pAssocRsp->VHTCaps.ldpcCodingCap;
3623 }
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08003624
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 if( pBeaconStruct->HTInfo.present )
3626 pAddBssParams->staContext.rifsMode = pAssocRsp->HTInfo.rifsMode;
3627 }
3628
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303629 //If WMM IE or 802.11E IE is not present and AP is HT AP then enable WMM
3630 if ((psessionEntry->limWmeEnabled && (pAssocRsp->wmeEdcaPresent || pAddBssParams->htCapable)) ||
3631 (psessionEntry->limQosEnabled && (pAssocRsp->edcaPresent || pAddBssParams->htCapable)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 pAddBssParams->staContext.wmmEnabled = 1;
3633 else
3634 pAddBssParams->staContext.wmmEnabled = 0;
3635
3636 //Update the rates
3637
3638 pStaDs = dphGetHashEntry(pMac, DPH_STA_HASH_INDEX_PEER, &psessionEntry->dph.dphHashTable);
3639 if (pStaDs != NULL)
3640 {
3641 limFillSupportedRatesInfo(pMac, pStaDs, &pStaDs->supportedRates,psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303642 vos_mem_copy((tANI_U8*)&pAddBssParams->staContext.supportedRates,
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 (tANI_U8*)&pStaDs->supportedRates,
3644 sizeof(tSirSupportedRates));
3645 }
3646 else
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003647 PELOGE(limLog(pMac, LOGE, FL("could not Update the supported rates."));)
Jeff Johnson295189b2012-06-20 16:38:30 -07003648
3649 }
3650
3651 //Disable BA. It will be set as part of ADDBA negotiation.
3652 for( i = 0; i < STACFG_MAX_TC; i++ )
3653 {
3654 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
3655 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
3656 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
3657 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
3658 }
3659
3660 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
3661
3662#if defined WLAN_FEATURE_VOWIFI
3663 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
3664#endif
3665 // FIXME_GEN4 - Any other value that can be used for initialization?
3666 pAddBssParams->status = eHAL_STATUS_SUCCESS;
3667 pAddBssParams->respReqd = true;
3668
3669 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
3670
Jeff Johnson295189b2012-06-20 16:38:30 -07003671 if (VOS_P2P_CLIENT_MODE == psessionEntry->pePersona)
3672 {
3673 pAddBssParams->staContext.p2pCapableSta = 1;
3674 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003675
Bansidhar Gopalacharib099ac62013-06-12 19:02:39 -07003676 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003677
3678#if defined WLAN_FEATURE_VOWIFI_11R
3679 pAddBssParams->extSetStaKeyParamValid = 0;
3680#endif
3681
Chet Lanctot186b5732013-03-18 10:26:30 -07003682#ifdef WLAN_FEATURE_11W
3683 if (psessionEntry->limRmfEnabled)
3684 {
3685 pAddBssParams->rmfEnabled = 1;
3686 pAddBssParams->staContext.rmfEnabled = 1;
3687 }
3688#endif
3689
Jeff Johnson295189b2012-06-20 16:38:30 -07003690 // Set a new state for MLME
3691 if( eLIM_MLM_WT_ASSOC_RSP_STATE == psessionEntry->limMlmState )
3692 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE;
3693 else
3694 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003695 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07003696
3697 //we need to defer the message until we get the response back from HAL.
3698 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
3699
3700 msgQ.type = WDA_ADD_BSS_REQ;
3701 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
3702 msgQ.reserved = 0;
3703 msgQ.bodyptr = pAddBssParams;
3704 msgQ.bodyval = 0;
3705
3706 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_BSS_REQ..." ));
Jeff Johnsone7245742012-09-05 17:12:55 -07003707 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07003708
3709 retCode = wdaPostCtrlMsg( pMac, &msgQ );
3710 if( eSIR_SUCCESS != retCode)
3711 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003712 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303713 vos_mem_free(pAddBssParams);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07003714 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07003715 retCode );
3716 goto returnFailure;
3717
3718 }
3719 else
3720 return retCode;
3721
3722 returnFailure:
3723 // Clean-up will be done by the caller...
3724 return retCode;
3725}
3726
3727
3728
3729
3730tSirRetStatus limStaSendAddBssPreAssoc( tpAniSirGlobal pMac, tANI_U8 updateEntry, tpPESession psessionEntry)
3731{
3732 tSirMsgQ msgQ;
3733 tpAddBssParams pAddBssParams = NULL;
3734 tANI_U32 retCode;
3735 tANI_U8 i;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003736 tSchBeaconStruct *pBeaconStruct;
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 tANI_U8 chanWidthSupp = 0;
krunal soni71343fb2013-09-16 16:16:26 -07003738 tANI_U32 shortGi20MhzSupport;
3739 tANI_U32 shortGi40MhzSupport;
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 tpSirBssDescription bssDescription = &psessionEntry->pLimJoinReq->bssDescription;
3741
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303742 pBeaconStruct = vos_mem_malloc(sizeof(tSchBeaconStruct));
3743 if (NULL == pBeaconStruct)
Jeff Johnson32d95a32012-09-10 13:15:23 -07003744 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303745 limLog(pMac, LOGE, FL("Unable to allocate memory during ADD_BSS") );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003746 return eSIR_MEM_ALLOC_FAILED;
3747 }
3748
Jeff Johnson295189b2012-06-20 16:38:30 -07003749
3750 // Package SIR_HAL_ADD_BSS_REQ message parameters
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303751 pAddBssParams = vos_mem_malloc(sizeof(tAddBssParams));
3752 if (NULL == pAddBssParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 {
3754 limLog( pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303755 FL( "Unable to allocate memory during ADD_BSS" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 retCode = eSIR_MEM_ALLOC_FAILED;
3757 goto returnFailure;
3758 }
3759
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303760 vos_mem_set((tANI_U8 *) pAddBssParams, sizeof( tAddBssParams ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003761
3762
3763 limExtractApCapabilities( pMac,
3764 (tANI_U8 *) bssDescription->ieFields,
3765 limGetIElenFromBssDescription( bssDescription ),
Jeff Johnson32d95a32012-09-10 13:15:23 -07003766 pBeaconStruct );
Jeff Johnson295189b2012-06-20 16:38:30 -07003767
3768 if(pMac->lim.gLimProtectionControl != WNI_CFG_FORCE_POLICY_PROTECTION_DISABLE)
Jeff Johnson32d95a32012-09-10 13:15:23 -07003769 limDecideStaProtectionOnAssoc(pMac, pBeaconStruct, psessionEntry);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303770 vos_mem_copy(pAddBssParams->bssId, bssDescription->bssId,
3771 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003772
3773 // Fill in tAddBssParams selfMacAddr
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303774 vos_mem_copy(pAddBssParams->selfMacAddr,
3775 psessionEntry->selfMacAddr,
3776 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003777
3778 /* Incorrect BSS Type which caused UMA Descriptor to be overwritten on
3779 * top of an already established Infra link. This lead to issues in
3780 * concurrent data transfer.
3781 */
3782
3783 pAddBssParams->bssType = psessionEntry->bssType;//eSIR_INFRASTRUCTURE_MODE;
3784 pAddBssParams->operMode = BSS_OPERATIONAL_MODE_STA;
3785
3786 pAddBssParams->beaconInterval = bssDescription->beaconInterval;
3787
Jeff Johnson32d95a32012-09-10 13:15:23 -07003788 pAddBssParams->dtimPeriod = pBeaconStruct->tim.dtimPeriod;
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 pAddBssParams->updateBss = updateEntry;
3790
3791
Jeff Johnson32d95a32012-09-10 13:15:23 -07003792 pAddBssParams->cfParamSet.cfpCount = pBeaconStruct->cfParamSet.cfpCount;
3793 pAddBssParams->cfParamSet.cfpPeriod = pBeaconStruct->cfParamSet.cfpPeriod;
3794 pAddBssParams->cfParamSet.cfpMaxDuration = pBeaconStruct->cfParamSet.cfpMaxDuration;
3795 pAddBssParams->cfParamSet.cfpDurRemaining = pBeaconStruct->cfParamSet.cfpDurRemaining;
Jeff Johnson295189b2012-06-20 16:38:30 -07003796
3797
Jeff Johnson32d95a32012-09-10 13:15:23 -07003798 pAddBssParams->rateSet.numRates = pBeaconStruct->supportedRates.numRates;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303799 vos_mem_copy(pAddBssParams->rateSet.rate,
3800 pBeaconStruct->supportedRates.rate, pBeaconStruct->supportedRates.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -07003801
3802 pAddBssParams->nwType = bssDescription->nwType;
3803
Jeff Johnson32d95a32012-09-10 13:15:23 -07003804 pAddBssParams->shortSlotTimeSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortSlotTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 pAddBssParams->llaCoexist = (tANI_U8) psessionEntry->beaconParams.llaCoexist;
3806 pAddBssParams->llbCoexist = (tANI_U8) psessionEntry->beaconParams.llbCoexist;
3807 pAddBssParams->llgCoexist = (tANI_U8) psessionEntry->beaconParams.llgCoexist;
3808 pAddBssParams->ht20Coexist = (tANI_U8) psessionEntry->beaconParams.ht20Coexist;
3809
3810 // Use the advertised capabilities from the received beacon/PR
Jeff Johnson32d95a32012-09-10 13:15:23 -07003811 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003813 pAddBssParams->htCapable = pBeaconStruct->HTCaps.present;
Jeff Johnson295189b2012-06-20 16:38:30 -07003814
Jeff Johnson32d95a32012-09-10 13:15:23 -07003815 if ( pBeaconStruct->HTInfo.present )
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003817 pAddBssParams->htOperMode = (tSirMacHTOperatingMode)pBeaconStruct->HTInfo.opMode;
3818 pAddBssParams->dualCTSProtection = ( tANI_U8 ) pBeaconStruct->HTInfo.dualCTSProtection;
Jeff Johnson295189b2012-06-20 16:38:30 -07003819
Jeff Johnson295189b2012-06-20 16:38:30 -07003820 chanWidthSupp = limGetHTCapability( pMac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, psessionEntry);
Jeff Johnson32d95a32012-09-10 13:15:23 -07003821 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 (chanWidthSupp) )
3823 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003824 pAddBssParams->txChannelWidthSet = ( tANI_U8 ) pBeaconStruct->HTInfo.recommendedTxWidthSet;
3825 pAddBssParams->currentExtChannel = pBeaconStruct->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -07003826 }
3827 else
3828 {
3829 pAddBssParams->txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003830 pAddBssParams->currentExtChannel = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07003832 pAddBssParams->llnNonGFCoexist = (tANI_U8)pBeaconStruct->HTInfo.nonGFDevicesPresent;
3833 pAddBssParams->fLsigTXOPProtectionFullSupport = (tANI_U8)pBeaconStruct->HTInfo.lsigTXOPProtectionFullSupport;
3834 pAddBssParams->fRIFSMode = pBeaconStruct->HTInfo.rifsMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 }
3836 }
3837
3838 pAddBssParams->currentOperChannel = bssDescription->channelId;
3839
Jeff Johnsone7245742012-09-05 17:12:55 -07003840#ifdef WLAN_FEATURE_11AC
Jeff Johnson32d95a32012-09-10 13:15:23 -07003841 if (psessionEntry->vhtCapability && ( pBeaconStruct->VHTCaps.present ))
Jeff Johnsone7245742012-09-05 17:12:55 -07003842 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003843 pAddBssParams->vhtCapable = pBeaconStruct->VHTCaps.present;
3844 pAddBssParams->vhtTxChannelWidthSet = pBeaconStruct->VHTOperation.chanWidth;
Madan Mohan Koyyalamudic6226de2012-09-18 16:33:31 -07003845 pAddBssParams->currentExtChannel = limGet11ACPhyCBState ( pMac,
3846 pAddBssParams->currentOperChannel,
3847 pAddBssParams->currentExtChannel,
3848 psessionEntry->apCenterChan,
3849 psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003850 }
3851 else
3852 {
3853 pAddBssParams->vhtCapable = 0;
3854 }
3855#endif
3856
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 // Populate the STA-related parameters here
3858 // Note that the STA here refers to the AP
3859 {
3860 pAddBssParams->staContext.staType = STA_ENTRY_OTHER; // Identifying AP as an STA
3861
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05303862 vos_mem_copy(pAddBssParams->staContext.bssId,
3863 bssDescription->bssId,
3864 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 pAddBssParams->staContext.listenInterval = bssDescription->beaconInterval;
3866
3867 pAddBssParams->staContext.assocId = 0; // Is SMAC OK with this?
3868 pAddBssParams->staContext.uAPSD = 0;
3869 pAddBssParams->staContext.maxSPLen = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003870 pAddBssParams->staContext.shortPreambleSupported = (tANI_U8)pBeaconStruct->capabilityInfo.shortPreamble;
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 pAddBssParams->staContext.updateSta = updateEntry;
3872
Jeff Johnson32d95a32012-09-10 13:15:23 -07003873 if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && ( pBeaconStruct->HTCaps.present ))
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 {
3875 pAddBssParams->staContext.us32MaxAmpduDuration = 0;
3876 pAddBssParams->staContext.htCapable = 1;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003877 pAddBssParams->staContext.greenFieldCapable = ( tANI_U8 ) pBeaconStruct->HTCaps.greenField;
3878 pAddBssParams->staContext.lsigTxopProtection = ( tANI_U8 ) pBeaconStruct->HTCaps.lsigTXOPProtection;
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003879#ifdef WLAN_FEATURE_11AC
3880 if (psessionEntry->vhtCapability && pBeaconStruct->VHTCaps.present)
3881 {
3882 pAddBssParams->staContext.vhtCapable = 1;
3883 if ((pBeaconStruct->VHTCaps.suBeamFormerCap ||
3884 pBeaconStruct->VHTCaps.muBeamformerCap) &&
3885 psessionEntry->txBFIniFeatureEnabled )
3886 {
3887 pAddBssParams->staContext.vhtTxBFCapable = 1;
3888 }
3889 }
3890#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07003891 if( (pBeaconStruct->HTCaps.supportedChannelWidthSet) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 (chanWidthSupp) )
3893 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07003894 pAddBssParams->staContext.txChannelWidthSet = ( tANI_U8 )pBeaconStruct->HTInfo.recommendedTxWidthSet;
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003895#ifdef WLAN_FEATURE_11AC
3896 if (pAddBssParams->staContext.vhtCapable)
Jeff Johnsone7245742012-09-05 17:12:55 -07003897 {
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003898 pAddBssParams->staContext.vhtTxChannelWidthSet =
3899 pBeaconStruct->VHTOperation.chanWidth;
Jeff Johnsone7245742012-09-05 17:12:55 -07003900 }
Kiran Kumar Lokereeb7f2352013-06-18 16:22:55 -07003901#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 }
3903 else
3904 {
3905 pAddBssParams->staContext.txChannelWidthSet = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3906 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07003907 pAddBssParams->staContext.mimoPS = (tSirMacHTMIMOPowerSaveState)pBeaconStruct->HTCaps.mimoPowerSave;
3908 pAddBssParams->staContext.delBASupport = ( tANI_U8 ) pBeaconStruct->HTCaps.delayedBA;
3909 pAddBssParams->staContext.maxAmsduSize = ( tANI_U8 ) pBeaconStruct->HTCaps.maximalAMSDUsize;
3910 pAddBssParams->staContext.maxAmpduDensity = pBeaconStruct->HTCaps.mpduDensity;
3911 pAddBssParams->staContext.fDsssCckMode40Mhz = (tANI_U8)pBeaconStruct->HTCaps.dsssCckMode40MHz;
krunal soni71343fb2013-09-16 16:16:26 -07003912 /*
3913 * We will check gShortGI20Mhz and gShortGI40Mhz from ini file.
3914 * if they are set then we will use what ever Beacon coming from AP
3915 * supports. If these values are set as 0 in ini file then
3916 * we will hardcode this values to 0.
3917 */
3918 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3919 (pMac, WNI_CFG_SHORT_GI_20MHZ,
3920 &shortGi20MhzSupport)))
3921 {
3922 if (VOS_TRUE == shortGi20MhzSupport)
3923 {
3924 pAddBssParams->staContext.fShortGI20Mhz =
3925 (tANI_U8)pBeaconStruct->HTCaps.shortGI20MHz;
3926 }
3927 else
3928 {
3929 pAddBssParams->staContext.fShortGI20Mhz = VOS_FALSE;
3930 }
3931 }
3932 else
3933 {
3934 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 20Mhz"
3935 "CFG,setting value to default"));)
3936 pAddBssParams->staContext.fShortGI20Mhz =
3937 WNI_CFG_SHORT_GI_20MHZ_STADEF;
3938 }
3939
3940 if (HAL_STATUS_SUCCESS(ccmCfgGetInt
3941 (pMac, WNI_CFG_SHORT_GI_40MHZ,
3942 &shortGi40MhzSupport)))
3943 {
3944 if (VOS_TRUE == shortGi40MhzSupport)
3945 {
3946 pAddBssParams->staContext.fShortGI40Mhz =
3947 (tANI_U8)pBeaconStruct->HTCaps.shortGI40MHz;
3948 }
3949 else
3950 {
3951 pAddBssParams->staContext.fShortGI40Mhz = VOS_FALSE;
3952 }
3953 }
3954 else
3955 {
3956 PELOGE(limLog(pMac, LOGE, FL("could not retrieve shortGI 40Mhz"
3957 "CFG,setting value to default"));)
3958 pAddBssParams->staContext.fShortGI40Mhz =
3959 WNI_CFG_SHORT_GI_40MHZ_STADEF;
3960 }
3961
Jeff Johnson32d95a32012-09-10 13:15:23 -07003962 pAddBssParams->staContext.maxAmpduSize= pBeaconStruct->HTCaps.maxRxAMPDUFactor;
Leela V Kiran Kumar Reddy Chiralab1f7d342013-02-11 00:27:02 -08003963 if( pAddBssParams->staContext.vhtTxBFCapable && pMac->lim.disableLDPCWithTxbfAP )
3964 {
3965 pAddBssParams->staContext.htLdpcCapable = 0;
3966 pAddBssParams->staContext.vhtLdpcCapable = 0;
3967 }
3968 else
3969 {
3970 pAddBssParams->staContext.htLdpcCapable = (tANI_U8)pBeaconStruct->HTCaps.advCodingCap;
3971 pAddBssParams->staContext.vhtLdpcCapable = (tANI_U8)pBeaconStruct->VHTCaps.ldpcCodingCap;
3972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003973
Jeff Johnson32d95a32012-09-10 13:15:23 -07003974 if( pBeaconStruct->HTInfo.present )
3975 pAddBssParams->staContext.rifsMode = pBeaconStruct->HTInfo.rifsMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003976 }
3977
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303978 //If WMM IE or 802.11E IE is not present and AP is HT AP then enable WMM
3979 if ((psessionEntry->limWmeEnabled && (pBeaconStruct->wmeEdcaPresent || pAddBssParams->staContext.htCapable)) ||
3980 (psessionEntry->limQosEnabled && (pBeaconStruct->edcaPresent || pAddBssParams->staContext.htCapable)))
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 pAddBssParams->staContext.wmmEnabled = 1;
3982 else
3983 pAddBssParams->staContext.wmmEnabled = 0;
3984
3985 //Update the rates
Jeff Johnsone7245742012-09-05 17:12:55 -07003986#ifdef WLAN_FEATURE_11AC
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,
3989 &pBeaconStruct->VHTCaps);
Jeff Johnsone7245742012-09-05 17:12:55 -07003990#else
Leela Venkata Kiran Kumar Reddy Chirala85c9fb12013-09-05 20:47:36 -07003991 limPopulatePeerRateSet(pMac, &pAddBssParams->staContext.supportedRates,
Jeff Johnson32d95a32012-09-10 13:15:23 -07003992 pBeaconStruct->HTCaps.supportedMCSSet, false,psessionEntry);
Jeff Johnsone7245742012-09-05 17:12:55 -07003993#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 limFillSupportedRatesInfo(pMac, NULL, &pAddBssParams->staContext.supportedRates,psessionEntry);
3995
3996 }
3997
3998
3999 //Disable BA. It will be set as part of ADDBA negotiation.
4000 for( i = 0; i < STACFG_MAX_TC; i++ )
4001 {
4002 pAddBssParams->staContext.staTCParams[i].txUseBA = eBA_DISABLE;
4003 pAddBssParams->staContext.staTCParams[i].rxUseBA = eBA_DISABLE;
4004 pAddBssParams->staContext.staTCParams[i].txBApolicy = eBA_POLICY_IMMEDIATE;
4005 pAddBssParams->staContext.staTCParams[i].rxBApolicy = eBA_POLICY_IMMEDIATE;
4006 }
4007
4008 pAddBssParams->staContext.encryptType = psessionEntry->encryptType;
4009
4010#if defined WLAN_FEATURE_VOWIFI
4011 pAddBssParams->maxTxPower = psessionEntry->maxTxPower;
4012#endif
4013
4014 pAddBssParams->status = eHAL_STATUS_SUCCESS;
4015 pAddBssParams->respReqd = true;
4016
4017 pAddBssParams->staContext.sessionId = psessionEntry->peSessionId;
4018 pAddBssParams->sessionId = psessionEntry->peSessionId;
4019
4020 pAddBssParams->halPersona = (tANI_U8)psessionEntry->pePersona; //update persona
4021
Bansidhar Gopalacharib099ac62013-06-12 19:02:39 -07004022 pAddBssParams->bSpectrumMgtEnabled = psessionEntry->spectrumMgtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07004023
4024#if defined WLAN_FEATURE_VOWIFI_11R
4025 pAddBssParams->extSetStaKeyParamValid = 0;
4026#endif
4027
Chet Lanctot186b5732013-03-18 10:26:30 -07004028#ifdef WLAN_FEATURE_11W
4029 if (psessionEntry->limRmfEnabled)
4030 {
4031 pAddBssParams->rmfEnabled = 1;
4032 pAddBssParams->staContext.rmfEnabled = 1;
4033 }
4034#endif
4035
Jeff Johnson295189b2012-06-20 16:38:30 -07004036 // Set a new state for MLME
4037
4038 //pMac->lim.gLimMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
4039 psessionEntry->limMlmState = eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE;
4040
Jeff Johnsone7245742012-09-05 17:12:55 -07004041 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004042
4043 //we need to defer the message until we get the response back from HAL.
4044 SET_LIM_PROCESS_DEFD_MESGS(pMac, false);
4045
4046 msgQ.type = WDA_ADD_BSS_REQ;
4047 /** @ToDo : Update the Global counter to keeptrack of the PE <--> HAL messages*/
4048 msgQ.reserved = 0;
4049 msgQ.bodyptr = pAddBssParams;
4050 msgQ.bodyval = 0;
4051
4052 limLog( pMac, LOG1, FL( "Sending SIR_HAL_ADD_BSS_REQ..." ));
Jeff Johnsone7245742012-09-05 17:12:55 -07004053 MTRACE(macTraceMsgTx(pMac, psessionEntry->peSessionId, msgQ.type));
Jeff Johnson295189b2012-06-20 16:38:30 -07004054
4055 retCode = wdaPostCtrlMsg( pMac, &msgQ );
4056 if( eSIR_SUCCESS != retCode)
4057 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004058 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304059 vos_mem_free(pAddBssParams);
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004060 limLog( pMac, LOGE, FL("Posting ADD_BSS_REQ to HAL failed, reason=%X"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004061 retCode );
4062 goto returnFailure;
4063
4064 }
4065 else
Jeff Johnson32d95a32012-09-10 13:15:23 -07004066 {
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304067 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 return retCode;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004070
4071 returnFailure:
4072 // Clean-up will be done by the caller...
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304073 vos_mem_free(pBeaconStruct);
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 return retCode;
4075}
4076
4077
4078
4079
4080
Jeff Johnson295189b2012-06-20 16:38:30 -07004081
4082/** -------------------------------------------------------------
4083\fn limPrepareAndSendDelStaCnf
4084\brief deletes DPH entry
4085 changes the MLM mode for station.
4086 calls limSendDelStaCnf
4087\param tpAniSirGlobal pMac
4088\param tpDphHashNode pStaDs
4089\return none
4090 -------------------------------------------------------------*/
4091
4092
4093void
4094limPrepareAndSendDelStaCnf(tpAniSirGlobal pMac, tpDphHashNode pStaDs, tSirResultCodes statusCode,tpPESession psessionEntry)
4095{
4096 tANI_U16 staDsAssocId = 0;
4097 tSirMacAddr staDsAddr;
4098 tLimMlmStaContext mlmStaContext;
4099
4100 if(pStaDs == NULL)
4101 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004102 PELOGW(limLog(pMac, LOGW, FL("pStaDs is NULL"));)
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 return;
4104 }
4105 staDsAssocId = pStaDs->assocId;
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304106 vos_mem_copy((tANI_U8 *)staDsAddr,
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 pStaDs->staAddr,
4108 sizeof(tSirMacAddr));
4109
4110 mlmStaContext = pStaDs->mlmStaContext;
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304111 if ((psessionEntry->limSystemRole == eLIM_AP_ROLE) ||
4112 (psessionEntry->limSystemRole == eLIM_BT_AMP_AP_ROLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004113 {
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304114 limReleasePeerIdx(pMac, pStaDs->assocId, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 }
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304116 limDeleteDphHashEntry(pMac, pStaDs->staAddr, pStaDs->assocId, psessionEntry);
4117
4118 if ( (psessionEntry->limSystemRole == eLIM_STA_ROLE)||
4119 (psessionEntry->limSystemRole == eLIM_BT_AMP_STA_ROLE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 {
4121 psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE;
Madan Mohan Koyyalamudie3830c42013-08-08 20:38:47 +05304122 MTRACE(macTrace(pMac, TRACE_CODE_MLM_STATE,
4123 psessionEntry->peSessionId, psessionEntry->limMlmState));
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 limSendDelStaCnf(pMac, staDsAddr, staDsAssocId, mlmStaContext, statusCode,psessionEntry);
4126}
4127
4128/** -------------------------------------------------------------
4129\fn limGetStaRateMode
4130\brief Gets the Station Rate Mode.
4131\param tANI_U8 dot11Mode
4132\return none
4133 -------------------------------------------------------------*/
4134tStaRateMode limGetStaRateMode(tANI_U8 dot11Mode)
4135{
4136 switch(dot11Mode)
4137 {
4138 case WNI_CFG_DOT11_MODE_11A:
4139 return eSTA_11a;
4140 case WNI_CFG_DOT11_MODE_11B:
4141 return eSTA_11b;
4142 case WNI_CFG_DOT11_MODE_11G:
4143 return eSTA_11bg;
4144 case WNI_CFG_DOT11_MODE_11N:
4145 return eSTA_11n;
Jeff Johnsone7245742012-09-05 17:12:55 -07004146#ifdef WLAN_FEATURE_11AC
4147 case WNI_CFG_DOT11_MODE_11AC:
4148 return eSTA_11ac;
4149#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 case WNI_CFG_DOT11_MODE_ALL:
4151 default:
4152 return eSTA_11n;
4153
4154 }
4155}
4156
4157/** -------------------------------------------------------------
4158\fn limInitPreAuthTimerTable
4159\brief Initialize the Pre Auth Tanle and creates the timer for
4160 each node for the timeout value got from cfg.
4161\param tpAniSirGlobal pMac
4162\param tpLimPreAuthTable pPreAuthTimerTable
4163\return none
4164 -------------------------------------------------------------*/
4165void limInitPreAuthTimerTable(tpAniSirGlobal pMac, tpLimPreAuthTable pPreAuthTimerTable)
4166{
4167 tANI_U32 cfgValue;
4168 tANI_U32 authNodeIdx;
4169 tpLimPreAuthNode pAuthNode = pPreAuthTimerTable->pTable;
4170
4171 // Get AUTH_RSP Timers value
4172
4173 if (wlan_cfgGetInt(pMac, WNI_CFG_AUTHENTICATE_RSP_TIMEOUT,
4174 &cfgValue) != eSIR_SUCCESS)
4175 {
4176 /*
4177 ** Could not get AUTH_RSP timeout value
4178 ** from CFG. Log error.
4179 **/
4180 limLog(pMac, LOGP,
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004181 FL("could not retrieve AUTH_RSP timeout value"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 return;
4183 }
4184
4185 cfgValue = SYS_MS_TO_TICKS(cfgValue);
4186 for(authNodeIdx=0; authNodeIdx<pPreAuthTimerTable->numEntry; authNodeIdx++, pAuthNode++)
4187 {
4188 if (tx_timer_create(&pAuthNode->timer,
4189 "AUTH RESPONSE TIMEOUT",
4190 limAuthResponseTimerHandler,
4191 authNodeIdx,
4192 cfgValue,
4193 0,
4194 TX_NO_ACTIVATE) != TX_SUCCESS)
4195 {
4196 // Cannot create timer. Log error.
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004197 limLog(pMac, LOGP, FL("Cannot create Auth Rsp timer of Index :%d."), authNodeIdx);
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 return;
4199 }
4200 pAuthNode->authNodeIdx = (tANI_U8)authNodeIdx;
4201 pAuthNode->fFree = 1;
4202 }
4203
4204}
4205
4206/** -------------------------------------------------------------
4207\fn limAcquireFreePreAuthNode
4208\brief Retrives a free Pre Auth node from Pre Auth Table.
4209\param tpAniSirGlobal pMac
4210\param tpLimPreAuthTable pPreAuthTimerTable
4211\return none
4212 -------------------------------------------------------------*/
4213tLimPreAuthNode * limAcquireFreePreAuthNode(tpAniSirGlobal pMac, tpLimPreAuthTable pPreAuthTimerTable)
4214{
4215 tANI_U32 i;
4216 tLimPreAuthNode *pTempNode = pPreAuthTimerTable->pTable;
4217 for (i=0; i<pPreAuthTimerTable->numEntry; i++,pTempNode++)
4218 {
4219 if (pTempNode->fFree == 1)
4220 {
4221 pTempNode->fFree = 0;
4222 return pTempNode;
4223 }
4224 }
4225
4226 return NULL;
4227}
4228
4229/** -------------------------------------------------------------
4230\fn limGetPreAuthNodeFromIndex
4231\brief Depending on the Index this retrives the pre auth node.
4232\param tpAniSirGlobal pMac
4233\param tpLimPreAuthTable pAuthTable
4234\param tANI_U32 authNodeIdx
4235\return none
4236 -------------------------------------------------------------*/
4237tLimPreAuthNode * limGetPreAuthNodeFromIndex(tpAniSirGlobal pMac,
4238 tpLimPreAuthTable pAuthTable, tANI_U32 authNodeIdx)
4239{
4240 if ((authNodeIdx >= pAuthTable->numEntry) || (pAuthTable->pTable == NULL))
4241 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004242 limLog(pMac, LOGE, FL("Invalid Auth Timer Index : %d NumEntry : %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004243 authNodeIdx, pAuthTable->numEntry);
4244 return NULL;
4245 }
4246
4247 return pAuthTable->pTable + authNodeIdx;
4248}
4249
4250/* Util API to check if the channels supported by STA is within range */
4251tSirRetStatus limIsDot11hSupportedChannelsValid(tpAniSirGlobal pMac, tSirAssocReq *assoc)
4252{
4253 /*
4254 * Allow all the stations to join with us.
4255 * 802.11h-2003 11.6.1 => An AP may use the supported channels list for associated STAs
4256 * as an input into an algorithm used to select a new channel for the BSS.
4257 * The specification of the algorithm is beyond the scope of this amendment.
4258 */
4259
4260 return (eSIR_SUCCESS);
4261}
4262
4263/* Util API to check if the txpower supported by STA is within range */
4264tSirRetStatus limIsDot11hPowerCapabilitiesInRange(tpAniSirGlobal pMac, tSirAssocReq *assoc,tpPESession psessionEntry)
4265{
4266 tPowerdBm localMaxTxPower;
4267 tANI_U32 localPwrConstraint;
4268
4269 localMaxTxPower = cfgGetRegulatoryMaxTransmitPower(pMac, psessionEntry->currentOperChannel);
4270
4271 if(wlan_cfgGetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, &localPwrConstraint) != eSIR_SUCCESS) {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004272 limLog( pMac, LOGP, FL( "Unable to get Local Power Constraint from cfg" ));
Jeff Johnson295189b2012-06-20 16:38:30 -07004273 return eSIR_FAILURE;
4274 }
4275 localMaxTxPower -= (tPowerdBm)localPwrConstraint;
4276
4277 /**
4278 * The min Tx Power of the associating station should not be greater than (regulatory
4279 * max tx power - local power constraint configured on AP).
4280 */
4281 if(assoc->powerCapability.minTxPower > localMaxTxPower)
4282 {
Kiran Kumar Lokere80007262013-03-18 19:45:50 -07004283 limLog(pMac, LOGW, FL("minTxPower (STA) = %d, localMaxTxPower (AP) = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 assoc->powerCapability.minTxPower, localMaxTxPower);
4285 return (eSIR_FAILURE);
4286 }
4287
4288 return (eSIR_SUCCESS);
4289}
4290
4291/** -------------------------------------------------------------
4292\fn limFillRxHighestSupportedRate
4293\brief Fills in the Rx Highest Supported Data Rate field from
4294\ the 'supported MCS set' field in HT capability element.
4295\param tpAniSirGlobal pMac
4296\param tpSirSupportedRates pRates
4297\param tANI_U8* pSupportedMCSSet
4298\return none
4299 -------------------------------------------------------------*/
4300void limFillRxHighestSupportedRate(tpAniSirGlobal pMac, tANI_U16 *rxHighestRate, tANI_U8* pSupportedMCSSet)
4301{
4302 tSirMacRxHighestSupportRate *pRxHighestRate;
4303 tANI_U8 *pBuf;
4304 tANI_U16 rate=0;
4305
4306 pBuf = pSupportedMCSSet + MCS_RX_HIGHEST_SUPPORTED_RATE_BYTE_OFFSET;
4307 rate = limGetU16(pBuf);
4308
4309 pRxHighestRate = (tSirMacRxHighestSupportRate *) &rate;
4310 *rxHighestRate = pRxHighestRate->rate;
4311
4312 return;
4313}
Chet Lanctot186b5732013-03-18 10:26:30 -07004314
4315#ifdef WLAN_FEATURE_11W
4316/** -------------------------------------------------------------
4317\fn limSendSmeUnprotectedMgmtFrameInd
4318\brief Forwards the unprotected management frame to SME.
4319\param tpAniSirGlobal pMac
4320\param frameType - 802.11 frame type
4321\param frame - frame buffer
4322\param sessionId - id for the current session
4323\param psessionEntry - PE session context
4324\return none
4325 -------------------------------------------------------------*/
4326void limSendSmeUnprotectedMgmtFrameInd(
4327 tpAniSirGlobal pMac, tANI_U8 frameType,
4328 tANI_U8 *frame, tANI_U32 frameLen, tANI_U16 sessionId,
4329 tpPESession psessionEntry)
4330{
4331 tSirMsgQ mmhMsg;
4332 tSirSmeUnprotMgmtFrameInd * pSirSmeMgmtFrame = NULL;
4333 tANI_U16 length;
4334
4335 length = sizeof(tSirSmeUnprotMgmtFrameInd) + frameLen;
4336
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304337 pSirSmeMgmtFrame = vos_mem_malloc(length);
4338 if (NULL == pSirSmeMgmtFrame)
Chet Lanctot186b5732013-03-18 10:26:30 -07004339 {
4340 limLog(pMac, LOGP,
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304341 FL("AllocateMemory failed for tSirSmeUnprotectedMgmtFrameInd"));
Chet Lanctot186b5732013-03-18 10:26:30 -07004342 return;
4343 }
Bansidhar Gopalachari3999e2e2013-07-12 10:57:01 +05304344 vos_mem_set((void*)pSirSmeMgmtFrame, length, 0);
Chet Lanctot186b5732013-03-18 10:26:30 -07004345
4346 pSirSmeMgmtFrame->sessionId = sessionId;
4347 pSirSmeMgmtFrame->frameType = frameType;
4348
4349 vos_mem_copy(pSirSmeMgmtFrame->frameBuf, frame, frameLen);
4350 pSirSmeMgmtFrame->frameLen = frameLen;
4351
4352 mmhMsg.type = eWNI_SME_UNPROT_MGMT_FRM_IND;
4353 mmhMsg.bodyptr = pSirSmeMgmtFrame;
4354 mmhMsg.bodyval = 0;
4355
4356 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4357 return;
4358}
4359#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004360
4361#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
4362/** -------------------------------------------------------------
4363\fn limSendSmeTsmIEInd
4364\brief Forwards the TSM IE information to SME.
4365\param tpAniSirGlobal pMac
4366\param psessionEntry - PE session context
4367\param tid - traffic id
4368\param state - tsm state (enabled/disabled)
4369\param measurementInterval - measurement interval
4370\return none
4371 -------------------------------------------------------------*/
4372void limSendSmeTsmIEInd(tpAniSirGlobal pMac, tpPESession psessionEntry,
4373 tANI_U8 tid, tANI_U8 state, tANI_U16 measInterval)
4374{
4375 tSirMsgQ mmhMsg;
4376 tpSirSmeTsmIEInd pSirSmeTsmIeInd = NULL;
4377
4378 if (!pMac || !psessionEntry)
4379 {
4380 return;
4381 }
4382 pSirSmeTsmIeInd = vos_mem_malloc(sizeof(tSirSmeTsmIEInd));
4383 if (NULL == pSirSmeTsmIeInd)
4384 {
4385 limLog(pMac, LOGP,
4386 FL("AllocateMemory failed for tSirSmeTsmIEInd"));
4387 return;
4388 }
4389 vos_mem_set((void*)pSirSmeTsmIeInd, sizeof(tSirSmeTsmIEInd), 0);
4390
4391 pSirSmeTsmIeInd->sessionId = psessionEntry->smeSessionId;
4392 pSirSmeTsmIeInd->tsmIe.tsid = tid;
4393 pSirSmeTsmIeInd->tsmIe.state= state;
4394 pSirSmeTsmIeInd->tsmIe.msmt_interval= measInterval;
4395
4396 mmhMsg.type = eWNI_SME_TSM_IE_IND;
4397 mmhMsg.bodyptr = pSirSmeTsmIeInd;
4398 mmhMsg.bodyval = 0;
4399
4400 limSysProcessMmhMsgApi(pMac, &mmhMsg, ePROT);
4401 return;
4402}
4403#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
4404
4405